@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/schibsted-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font-sans: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sheet: 16px;
  --radius-panel: 10px;
  --radius-control: 6px;
  --radius-pill: 999px;
  --rail: 240px;
  --maxw: 1320px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #e9ede8;
  --sheet: #fbfcfa;
  --surface: #ffffff;
  --surface-2: #f3f6f2;
  --surface-3: #eaf0ea;
  --ink: #17201c;
  --ink-2: #3f4b45;
  --muted: #68746e;
  --line: #dce3dd;
  --line-strong: #c6d1c9;
  --accent: #c8402c;
  --accent-strong: #9f2c1b;
  --accent-soft: #f7e2dd;
  --accent-line: #e7b9af;
  --stay: #176b55;
  --stay-strong: #0f5442;
  --stay-soft: #dff0e9;
  --data-neutral: #6f8590;
  --data-neutral-soft: #e4ebee;
  --focus: #2d5b8a;
  --field: #ffffff;
  --field-border: #c9d2cc;
  --track: #e5ebe6;
  --chart-grid: #e2e8e2;
  --table-head: #f6f8f5;
  --on-accent: #ffffff;
  --selection: #f7e2dd;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%233f4b45' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0d1210;
  --sheet: #141a17;
  --surface: #1a221e;
  --surface-2: #202a25;
  --surface-3: #27332c;
  --ink: #eef3ef;
  --ink-2: #c7d1ca;
  --muted: #98a59d;
  --line: #2a352f;
  --line-strong: #3e4b43;
  --accent: #ff8a5c;
  --accent-strong: #ffb08d;
  --accent-soft: #3a211c;
  --accent-line: #5c3127;
  --stay: #63d6ae;
  --stay-strong: #8be8c5;
  --stay-soft: #162f28;
  --data-neutral: #6b8b9c;
  --data-neutral-soft: #1c2a31;
  --focus: #8ab8ff;
  --field: #101613;
  --field-border: #39463e;
  --track: #2a352f;
  --chart-grid: #27312b;
  --table-head: #1d2621;
  --on-accent: #1b120e;
  --selection: #3a211c;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23c7d1ca' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }
fieldset { min-width: 0; }
code { font-family: var(--font-mono); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  top: 10px; left: 12px;
  z-index: 100;
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--sheet);
  font-size: 13px;
  transform: translateY(-160%);
  transition: transform .15s var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 24px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.workspace { min-width: 0; padding: 8px; }
.sheet {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 16px);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-sheet);
}
.sheet-inner {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 40px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}
.brand-mark { width: 30px; height: 30px; flex: none; color: var(--ink); }
.brand-text { display: grid; gap: 1px; line-height: 1.1; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.brand-text span { font-size: 12px; color: var(--muted); }

.rail-nav { display: grid; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  text-decoration: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav-icon { width: 17px; height: 17px; flex: none; color: var(--muted); }
.nav-item[aria-current="page"] .nav-icon { color: var(--ink-2); }
.nav-short { display: none; }

.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.status { display: flex; align-items: center; gap: 8px; min-height: 18px; font-size: 12px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--muted); }
.status[data-state="ok"] .status-dot { background: var(--stay); }
.status[data-state="bad"] .status-dot { background: var(--accent); }
.status[data-state="checking"] .status-dot { animation: status-pulse 1.4s ease-in-out infinite; }
@keyframes status-pulse { 50% { opacity: .35; } }
.model-line { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.model-line span { color: var(--ink-2); }
.theme-switch { display: grid; justify-items: start; gap: 6px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.theme-label { font-size: 11px; color: var(--ink-2); }

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}
.segmented button {
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  padding: 5px 10px;
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }
.segmented-small button { min-height: 24px; padding: 4px 8px; font-size: 11px; }
:root[data-theme="light"] .theme-switch [data-theme-choice="light"],
:root[data-theme="dark"] .theme-switch [data-theme-choice="dark"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}
:root[data-theme="dark"] .theme-switch [data-theme-choice="dark"] { background: var(--surface-3); }

.text-button {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--ink); text-decoration-color: currentColor; }

.view { flex: 1 0 auto; padding-bottom: 28px; }
.view[hidden] { display: none; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 36px 0 24px;
  border-bottom: 1px solid var(--line);
}
.page-head-copy { max-width: 70ch; }
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -.025em; }
.page-head p { margin-top: 6px; max-width: 68ch; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: auto;
  padding: 18px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.panel-head h2,
.panel > h2 { font-size: 16px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
.panel-head p,
.panel > p { margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.panel h3 { font-size: 14px; line-height: 1.3; font-weight: 600; }

.content-stack { display: grid; gap: 20px; padding-top: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-7-5 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; }
.grid-5-7 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.button.secondary:hover { background: var(--surface-2); }
.button.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.button.quiet:hover { background: var(--surface-2); color: var(--ink); }
.button:disabled { opacity: .55; }
.button:active:not(:disabled) { transform: translateY(1px); }

.preset-group { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-button {
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
}
.preset-button:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }

.form-panel { display: flex; flex-direction: column; }
.form-section { margin: 0; padding: 20px 0 0; border: 0; }
.form-section:first-of-type { padding-top: 0; }
.form-section legend { padding: 0 0 10px; color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: .02em; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 6px; color: var(--ink-2); font-size: 12.5px; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-note { color: var(--muted); font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; }
input,
select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  caret-color: var(--accent);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
input:hover,
select:hover { border-color: var(--line-strong); }
input:focus,
select:focus { border-color: var(--focus); outline-offset: 1px; }
select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.form-hint { color: var(--muted); font-size: 11.5px; }
.form-hint.is-error { color: var(--accent-strong); }

.score-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 24px;
  align-items: stretch;
  padding-top: 24px;
}
.result-panel { display: flex; flex-direction: column; }
.result-panel.is-filled { align-self: start; }
.empty-state { max-width: 40ch; margin: auto; padding: 34px 2px; }
.empty-state h2 { font-size: 16px; font-weight: 600; }
.empty-state p { margin-top: 6px; color: var(--muted); font-size: 13px; }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.result-label { color: var(--muted); font-size: 11.5px; }
.result-profile { margin-top: 2px; color: var(--ink); font-size: 13px; }
.result-profile span { color: var(--muted); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.tag-risk { background: var(--accent-soft); color: var(--accent-strong); }
.tag-stay { background: var(--stay-soft); color: var(--stay-strong); }

.result-score { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 24px 0 16px; }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.big-number { display: block; margin-top: 2px; font-size: 64px; font-weight: 600; line-height: .95; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.big-number.risk { color: var(--accent-strong); }
.big-number.stay { color: var(--stay-strong); }
.threshold-copy { color: var(--muted); font-size: 11.5px; text-align: right; }
.threshold-copy strong { display: block; margin-top: 2px; color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }

.prob-rail { margin: 2px 0 8px; }
.prob-track { position: relative; height: 10px; border-radius: var(--radius-pill); background: var(--track); }
.prob-band { position: absolute; top: 0; bottom: 0; }
.prob-band-stay { left: 0; border-radius: var(--radius-pill) 0 0 var(--radius-pill); background: var(--stay-soft); }
.prob-band-risk { right: 0; border-radius: 0 var(--radius-pill) var(--radius-pill) 0; background: var(--accent-soft); }
.prob-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: var(--radius-pill); background: var(--stay); transition: width .5s var(--ease), background-color .2s var(--ease); }
.prob-fill.risk { background: var(--accent); }
.prob-threshold { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); transform: translateX(-1px); }
.prob-pin { position: absolute; top: 50%; left: 0; width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; outline: 1px solid var(--line-strong); background: var(--stay); transform: translate(-50%, -50%); transition: left .5s var(--ease), background-color .2s var(--ease); }
.prob-pin.risk { background: var(--accent); }
.prob-labels { position: relative; display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.prob-threshold-label { position: absolute; transform: translateX(-50%); color: var(--ink-2); white-space: nowrap; }
.result-decision { margin-top: 14px; color: var(--muted); font-size: 12.5px; }

.driver-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.driver-note { margin-top: 4px; max-width: 65ch; color: var(--muted); font-size: 12px; }
.driver-legend { display: flex; justify-content: space-between; margin: 14px 0 8px; color: var(--muted); font-size: 10.5px; }
.driver-list { display: grid; gap: 7px; }
.driver-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) 64px; gap: 10px; align-items: center; }
.driver-name { overflow: hidden; color: var(--ink-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.driver-track { position: relative; height: 10px; border-radius: var(--radius-pill); background: var(--surface-2); }
.driver-track::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 50%; width: 1px; background: var(--line-strong); }
.driver-bar { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-pill); }
.driver-bar.up { left: 50%; background: var(--accent); }
.driver-bar.down { right: 50%; background: var(--stay); }
.driver-value { text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.driver-value.up { color: var(--accent-strong); }
.driver-value.down { color: var(--stay-strong); }
.result-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.result-note { margin-top: 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-2); color: var(--muted); font-size: 11.5px; }
.stale-note { margin-bottom: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-2); color: var(--muted); font-size: 11.5px; }

.summary-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}
.summary-item { display: grid; align-content: start; gap: 3px; padding: 17px 22px; }
.summary-item + .summary-item { border-left: 1px solid var(--line); }
.summary-label { color: var(--muted); font-size: 12px; }
.summary-value { color: var(--ink); font-size: 30px; font-weight: 600; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary-note { color: var(--muted); font-size: 11px; }

.table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-color: var(--line-strong) transparent; }
.table-wrap table { min-width: 0; }
.table-wrap[data-wide="true"] table { min-width: 720px; }
.table-scroll-hint { display: none; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
caption { text-align: left; }
th {
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th.n, td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
.segment-name { color: var(--ink); white-space: nowrap; }
.bar-cell { width: 36%; min-width: 120px; }
.bar-track { height: 7px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent); }
.bar-fill.cool { background: var(--data-neutral); }
.selected-row { background: var(--surface-2); }
.selected-row:hover { background: var(--surface-2); }
.cell-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 10.5px; }
.row-tag { display: inline-flex; margin-left: 8px; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--stay-soft); color: var(--stay-strong); font-size: 10.5px; font-weight: 600; vertical-align: 1px; }

.chart-panel { display: flex; flex-direction: column; }
.chart-host { min-width: 0; }
.chart-panel .chart-host { min-height: 220px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); }
.chart-label { fill: var(--muted); font-size: 11px; }
.chart-label-strong { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-baseline { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-threshold { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-identity { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-bar-hot { fill: var(--accent); }
.chart-bar-cool { fill: var(--data-neutral); }
.chart-dot { fill: var(--accent); }
.chart-note { margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.chart-swatch.cool { background: var(--data-neutral); }
.chart-swatch.line { width: 14px; height: 0; border-top: 1px dashed var(--ink-2); border-radius: 0; background: none; }
.table-toggle { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.table-toggle summary { color: var(--muted); cursor: pointer; font-size: 11.5px; }
.table-toggle summary:hover { color: var(--ink); }
.table-toggle table { margin-top: 8px; }
.table-toggle th { font-size: 10.5px; }
.table-toggle td { padding-top: 6px; padding-bottom: 6px; font-size: 11.5px; }

.upload-panel { margin-top: 24px; }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 190px;
  padding: 28px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.dropzone:hover,
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-title { font-size: 14px; font-weight: 600; }
.dropzone-meta { color: var(--muted); font-size: 12px; }
.upload-icon { width: 28px; height: 28px; margin-bottom: 2px; color: var(--muted); }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-2);
}
.file-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .02em; }
.file-copy { display: grid; gap: 1px; min-width: 0; }
.file-copy strong { overflow: hidden; font-size: 12.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-copy span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.file-actions { display: flex; align-items: center; flex-wrap: wrap; margin-left: auto; }
.file-actions .text-button { white-space: nowrap; }
.file-actions .text-button + .text-button { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line-strong); }
.upload-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.columns-help { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.columns-help summary { color: var(--ink-2); cursor: pointer; }
.columns-help summary:hover { color: var(--ink); }
.columns-help p { margin-top: 8px; max-width: 72ch; }
.columns-help code { display: block; margin-top: 8px; padding: 9px 10px; border-radius: var(--radius-control); background: var(--surface-2); color: var(--ink-2); font-size: 10.5px; line-height: 1.5; overflow-wrap: anywhere; }
#batchOut { display: grid; gap: 20px; margin-top: 20px; }
.batch-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.histogram-wrap { margin-top: 4px; }
.batch-table { table-layout: fixed; }
.batch-table th:nth-child(1),
.batch-table td:nth-child(1) { width: 82px; }
.batch-table th:nth-child(3),
.batch-table td:nth-child(3) { width: 126px; }
.prob-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.prob-cell .mini-bar { flex: 0 0 160px; margin: 0; }
.prob-value { min-width: 48px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.mini-bar { position: relative; display: inline-block; width: 83px; height: 6px; margin-right: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.mini-bar span { position: absolute; inset: 0 auto 0 0; border-radius: var(--radius-pill); background: var(--accent); }
.batch-note { color: var(--muted); font-size: 11.5px; }
.batch-empty { padding: 18px 0; color: var(--muted); font-size: 13px; }

.matrix { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 12px; }
.matrix th { padding: 4px 6px; border: 0; color: var(--muted); font-size: 10.5px; font-weight: 500; text-align: center; }
.matrix th:first-child { text-align: left; }
.matrix tbody th { padding: 16px 6px; border: 0; color: var(--muted); font-size: 10.5px; font-weight: 500; text-align: left; vertical-align: middle; }
.matrix td { padding: 16px 10px; border: 0; border-radius: 6px; text-align: center; }
.matrix td:first-child { background: transparent; color: var(--muted); font-size: 10.5px; text-align: left; }
.matrix .matrix-good { background: var(--stay-soft); color: var(--stay-strong); }
.matrix .matrix-bad { background: var(--accent-soft); color: var(--accent-strong); }
.matrix .matrix-count { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.matrix .matrix-share { display: block; margin-top: 2px; font-size: 10.5px; opacity: .8; }

.feature-list { display: grid; gap: 9px; }
.feature-row { display: grid; grid-template-columns: 122px minmax(0, 1fr) 54px; gap: 10px; align-items: center; }
.feature-name { overflow: hidden; color: var(--ink-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.feature-track { height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-2); }
.feature-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent); }
.feature-value { color: var(--ink-2); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; }
.model-meta { color: var(--muted); font-size: 11.5px; }

.subgroup-table { font-size: 12px; }
.subgroup-table th { padding-right: 7px; padding-left: 7px; font-size: 10.5px; }
.subgroup-table td { padding: 9px 7px; }
.subgroup-table th:first-child,
.subgroup-table td:first-child { padding-left: 0; }
.subgroup-table th:last-child,
.subgroup-table td:last-child { padding-right: 0; }
.subgroup-viz { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.subgroup-viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.subgroup-viz h3 { font-size: 12.5px; }
.subgroup-viz-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 10.5px; }
.subgroup-viz-legend span { display: inline-flex; align-items: center; gap: 5px; }
.subgroup-viz-list { display: grid; gap: 9px; margin-top: 11px; }
.subgroup-viz-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 104px; gap: 10px; align-items: center; }
.subgroup-viz-name { overflow: hidden; color: var(--ink-2); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.subgroup-viz-bars { display: grid; gap: 3px; }
.subgroup-viz-track { height: 5px; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-2); }
.subgroup-viz-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--accent); }
.subgroup-viz-fill.predicted { background: var(--data-neutral); }
.subgroup-viz-values { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.loading-state { display: grid; gap: 20px; padding-top: 24px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.skeleton { border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface-2); animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-strip { height: 90px; }
.skeleton-panel { height: 300px; }
.skeleton-tall { height: 420px; }
.score-skeleton { display: grid; gap: 10px; }
.skeleton-line { height: 11px; border: 0; border-radius: 3px; background: var(--surface-2); animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-line.short { width: 56%; }
.skeleton-score { width: 48%; height: 58px; border: 0; border-radius: 6px; background: var(--surface-2); animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-rail { height: 10px; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); animation: skeleton-pulse 1.5s ease-in-out infinite; }
@keyframes skeleton-pulse { 50% { opacity: .55; } }
.error-state { padding: 18px; border: 1px solid var(--accent-line); border-radius: var(--radius-panel); background: var(--accent-soft); color: var(--ink); }
.error-state h2 { font-size: 14px; font-weight: 600; }
.error-state p { margin-top: 5px; max-width: 72ch; font-size: 12.5px; }
.error-state .error-message { white-space: pre-line; }
.error-state ul { margin: 10px 0 0; padding-left: 18px; font-size: 12px; }
.error-state li + li { margin-top: 3px; }
.error-state .button { margin-top: 14px; }
.inline-error { margin-top: 16px; }
.empty-panel { padding: 26px 2px; max-width: 50ch; }
.empty-panel h2 { font-size: 16px; font-weight: 600; }
.empty-panel p { margin-top: 6px; color: var(--muted); font-size: 13px; }
.empty-panel .button { margin-top: 14px; }

.history-table td { padding-top: 12px; padding-bottom: 12px; }
.history-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-source { color: var(--muted); }
.history-profile { color: var(--ink-2); }
.history-result { display: flex; align-items: center; gap: 8px; }
.history-action { text-align: right; }
.history-action .text-button { white-space: nowrap; }

:root[data-theme="dark"] .segmented button[aria-pressed="true"] { background: var(--surface-3); }

@media (max-width: 1120px) {
  .score-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .result-panel { min-height: 300px; }
  .grid-2,
  .grid-7-5,
  .grid-5-7 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 920px) {
  .shell { display: block; }
  .rail {
    position: static;
    height: auto;
    padding: 18px 18px 12px;
    gap: 16px;
  }
  .rail-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .rail-nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; min-height: 33px; padding: 7px 10px; font-size: 13px; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .rail-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 0;
    padding-top: 10px;
  }
  .theme-switch { display: flex; align-items: center; gap: 8px; margin-top: 0; margin-left: auto; padding-top: 0; border-top: 0; }
  .theme-label { white-space: nowrap; }
  .workspace { padding: 0; }
  .sheet { min-height: calc(100dvh - 110px); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 16px 16px 0 0; }
  .sheet-inner { padding: 0 22px; }
  .page-head { padding-top: 28px; }
  .summary-strip { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item + .summary-item { border-top: 0; border-left: 0; }
  .summary-item:nth-child(even) { border-left: 1px solid var(--line); }
  .summary-item:nth-child(n+3) { border-top: 1px solid var(--line); }
  .summary-item:nth-child(3):last-child { grid-column: 1 / -1; }
  .summary-value { font-size: 26px; }
  .skeleton-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .history-table thead { display: none; }
  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table td { display: block; width: 100%; }
  .history-table tr { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .history-table tbody tr:last-child { border-bottom: 0; }
  .history-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 0;
    border: 0;
    text-align: right;
  }
  .history-table td:first-child,
  .history-table td:last-child { padding-left: 0; padding-right: 0; }
  .history-table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 11px;
    text-align: left;
  }
  .history-table .history-result { justify-content: flex-end; }
  .history-table .history-action:empty { display: none; }
}

@media (max-width: 640px) {
  .rail { padding: 14px 14px 10px; }
  .brand-mark { width: 26px; height: 26px; }
  .rail-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
  }
  .nav-item { justify-content: center; min-width: 0; padding: 8px 2px; font-size: 12px; }
  .nav-icon { display: none; }
  .sheet-inner { padding: 0 16px; }
  .page-head { display: block; padding: 24px 0 18px; }
  .page-head h1 { font-size: 24px; }
  .page-head p { font-size: 13px; }
  .page-actions { margin-top: 12px; }
  .panel { padding: 16px; }
  .panel-head { display: block; }
  .preset-group { margin-top: 12px; }
  .field-grid { grid-template-columns: 1fr; }
  .score-grid { gap: 16px; padding-top: 16px; }
  .result-score { margin: 18px 0 14px; }
  .big-number { font-size: 48px; }
  .threshold-copy { font-size: 11px; }
  .driver-row { grid-template-columns: 104px minmax(0, 1fr) 56px; gap: 8px; }
  .driver-name { font-size: 12px; }
  .summary-item { padding: 14px 16px; }
  .summary-value { font-size: 25px; }
  .content-stack { gap: 14px; padding-top: 16px; }
  .grid-2, .grid-7-5, .grid-5-7 { gap: 14px; }
  .upload-panel { margin-top: 16px; }
  .dropzone { min-height: 160px; padding: 22px 16px; }
  .file-row { flex-wrap: wrap; }
  .file-actions { width: 100%; margin-left: 0; padding-left: 46px; }
  .upload-actions { align-items: flex-start; }
  .batch-tools { margin-top: 10px; }
  .table-wrap[data-wide="true"] { margin-right: -16px; padding-right: 16px; }
  .table-scroll-hint { display: block; }
  .batch-table th:nth-child(1),
  .batch-table td:nth-child(1) { width: 58px; }
  .batch-table th:nth-child(3),
  .batch-table td:nth-child(3) { width: 98px; }
  .prob-cell { gap: 8px; }
  .prob-cell .mini-bar { flex-basis: 70px; }
  .prob-value { min-width: 42px; }
  .subgroup-viz-row { grid-template-columns: 82px minmax(0, 1fr) 92px; gap: 8px; }
  .subgroup-viz-values { font-size: 9.5px; }
  .history-when { white-space: normal; }
  .page-foot { margin-top: auto; padding-bottom: 22px; }
  .matrix .matrix-count { font-size: 20px; }
  .matrix td { padding: 12px 6px; }
}

@media (max-width: 480px) {
  .rail-foot .model-line { display: none; }
  .theme-switch { margin-left: 0; }
  .result-head { display: block; }
  .result-head .tag { margin-top: 10px; }
  .threshold-copy { text-align: left; }
  .result-score { align-items: flex-start; flex-direction: column; gap: 8px; }
  .segmented-small button { padding: 4px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  .rail, .page-actions, .theme-switch, .skip-link, .button { display: none !important; }
  .shell { display: block; }
  .workspace { padding: 0; }
  .sheet { border: 0; }
  .sheet-inner { padding: 0; }
}
