:root {
  color-scheme: light;
  --paper: #f4f6f4;
  --surface: #ffffff;
  --ink: #1e2525;
  --muted: #657173;
  --line: #d9dfdc;
  --green: #188064;
  --blue: #2f6f96;
  --amber: #b36b1f;
  --red: #b94a48;
  --shadow: 0 16px 40px rgba(30, 37, 37, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar,
.source-band,
.workspace,
.panel-head,
.inline-actions,
.probability-row,
.factor-row,
.status-strip {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.eyebrow,
h1,
h2,
h3,
p {
  margin: 0;
}

.eyebrow {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.icon-button {
  width: 44px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 1.25rem;
  font-weight: 900;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 900;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.secondary-button {
  background: #e8eeeb;
  border-color: var(--line);
  color: var(--ink);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.text-button {
  background: transparent;
  color: var(--red);
  font-weight: 900;
}

.source-band,
.status-strip,
.result-panel,
.side-panel section,
.prediction-card,
.history-item,
.source-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.source-band {
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.field-row {
  display: grid;
  flex: 1 1 220px;
  gap: 6px;
}

label,
.panel-head span,
.source-list span,
.history-meta,
.subtle,
.status-strip span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

label {
  font-weight: 750;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd4d0;
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 0 11px;
}

button:focus-visible,
select:focus {
  outline: 3px solid rgba(24, 128, 100, 0.2);
  outline-offset: 2px;
}

.status-strip {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 12px;
  background: #eef7f2;
}

.status-strip.is-warning {
  background: #fff7e8;
  border-color: #ecd29c;
}

.status-strip.is-error {
  background: #fff0f0;
  border-color: #edc4c4;
}

.workspace {
  align-items: flex-start;
  gap: 14px;
}

.result-panel,
.side-panel section {
  box-shadow: var(--shadow);
}

.result-panel {
  flex: 1 1 680px;
  min-width: 0;
  padding: 14px;
}

.side-panel {
  display: grid;
  flex: 0 0 360px;
  gap: 12px;
  min-width: 0;
}

.side-panel section {
  padding: 12px;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.compact-head {
  margin-bottom: 8px;
}

.inline-actions {
  gap: 8px;
}

.prediction-card {
  min-height: 430px;
  padding: 14px;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-content: center;
  gap: 6px;
  text-align: center;
}

.empty-state span {
  color: var(--muted);
  font-size: 0.9rem;
}

.winner-line {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.winner-line strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.05;
}

.confidence-pill {
  border-radius: 999px;
  padding: 7px 11px;
  background: #e8f1f6;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.probability-grid,
.factor-list,
.insight-list,
.source-list,
.history-list {
  display: grid;
  gap: 9px;
}

.probability-grid {
  margin: 14px 0;
}

.probability-row {
  grid-template-columns: minmax(110px, 1fr) minmax(140px, 2fr) minmax(60px, auto);
  gap: 10px;
  align-items: center;
}

.probability-row span,
.probability-row strong,
.factor-row span,
.factor-row strong {
  font-size: 0.86rem;
}

.probability-row strong,
.factor-row strong {
  text-align: right;
}

.bar,
.factor-bar {
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.bar {
  height: 10px;
}

.bar i,
.factor-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.reason-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfb;
  line-height: 1.45;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.analysis-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfb;
}

.analysis-box h3 {
  margin-bottom: 8px;
}

.factor-row {
  grid-template-columns: minmax(104px, 1fr) minmax(100px, 1.4fr) minmax(48px, auto);
  gap: 8px;
  align-items: center;
}

.factor-bar {
  height: 8px;
}

.factor-bar i {
  background: var(--green);
}

.factor-row.is-away .factor-bar i {
  margin-left: auto;
  background: var(--amber);
}

.insight-list span {
  border-radius: 8px;
  background: #eef7f2;
  color: #174d3e;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 750;
}

.insight-list span.warning {
  background: #fff6e6;
  color: #6c420f;
}

.source-list article,
.history-item {
  padding: 10px;
}

.source-list strong,
.history-item strong {
  display: block;
  margin-bottom: 4px;
}

.history-item {
  cursor: pointer;
}

.history-item:hover {
  border-color: #b9c7c1;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 18px;
  z-index: 10;
  max-width: 720px;
  margin: 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

@media (max-width: 920px) {
  .workspace {
    display: grid;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
    flex-basis: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .source-band,
  .status-strip,
  .winner-line,
  .analysis-grid,
  .side-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .probability-row,
  .factor-row {
    grid-template-columns: minmax(82px, 1fr) minmax(76px, 1.2fr) minmax(48px, auto);
  }
}
