:root {
  --paper: #EEF1F4;
  --surface: #FFFFFF;
  --sunk: #F5F7F9;
  --ink: #142033;
  --muted: #5A6879;
  --line: #D5DCE4;
  --accent: #1F4FD1;
  --accent-ink: #FFFFFF;
  --focus: #1F4FD1;

  --s-indexed: #13795B;
  --s-pending: #B7791F;
  --s-not: #C0392B;
  --s-blocked: #7A4FC4;
  --s-unknown: #8C99A8;
  --s-queued: #C7D0DB;

  --radius-s: 4px;
  --radius-m: 8px;
  --rail: 216px;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1622; --surface: #152030; --sunk: #111B29; --ink: #E6ECF3; --muted: #93A1B3; --line: #26344A;
    --accent: #6E95FF; --accent-ink: #0B1220; --focus: #8EADFF;
    --s-indexed: #3FB68B; --s-pending: #E0A63E; --s-not: #EF6B5D; --s-blocked: #A988EC; --s-unknown: #6C7A8C; --s-queued: #33445C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1622; --surface: #152030; --sunk: #111B29; --ink: #E6ECF3; --muted: #93A1B3; --line: #26344A;
  --accent: #6E95FF; --accent-ink: #0B1220; --focus: #8EADFF;
  --s-indexed: #3FB68B; --s-pending: #E0A63E; --s-not: #EF6B5D; --s-blocked: #A988EC; --s-unknown: #6C7A8C; --s-queued: #33445C;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code, .code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px;
  background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1px 5px;
  word-break: break-all;
}
pre.code { padding: 12px; overflow-x: auto; white-space: pre-wrap; margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; display: flex; flex-direction: column; gap: 24px;
  border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 16px; }
.brand svg { flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-m);
  color: var(--muted); text-decoration: none; font-weight: 550;
}
.nav a:hover { color: var(--ink); background: var(--sunk); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--sunk); box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.rail-foot { margin-top: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 8px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.linkbtn:hover { color: var(--ink); text-decoration: underline; }

main { padding: 28px 36px 64px; min-width: 0; }
.page { max-width: 1180px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .lede { margin-top: 6px; color: var(--muted); max-width: 70ch; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: inline-block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.banner {
  border: 1px solid var(--line); border-left: 4px solid var(--s-pending); background: var(--surface);
  padding: 12px 16px; border-radius: var(--radius-m);
}
.banner.info { border-left-color: var(--accent); }
.banner.bad { border-left-color: var(--s-not); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; flex-wrap: wrap; }
.panel-body { padding: 4px 18px 18px; }
.panel-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ---------- figures ---------- */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.figure { padding: 16px 18px; border-left: 1px solid var(--line); }
.figure:first-child { border-left: 0; }
.figure .num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.figure .lbl { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--s-unknown); display: inline-block; }
.dot.indexed { background: var(--s-indexed); } .dot.not_indexed { background: var(--s-not); }
.dot.blocked { background: var(--s-blocked); } .dot.unknown { background: var(--s-unknown); } .dot.pending { background: var(--s-pending); }

/* ---------- coverage band (signature) ---------- */
.coverage { display: flex; flex-direction: column; }
.cov-row {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr 74px 120px; gap: 18px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--line); text-decoration: none; color: inherit;
}
.cov-row:hover { background: var(--sunk); }
.cov-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-row .name small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.cov-row .pct { font-size: 20px; font-weight: 700; text-align: right; }
.cov-row .quota { font-size: 12.5px; color: var(--muted); text-align: right; }
.band { display: flex; height: 22px; border-radius: var(--radius-s); overflow: hidden; background: var(--s-queued); gap: 2px; }
.band.thin { height: 8px; gap: 1px; border-radius: 2px; }
.band > span { display: block; min-width: 2px; }
.band .indexed { background: var(--s-indexed); } .band .not_indexed { background: var(--s-not); }
.band .blocked { background: var(--s-blocked); } .band .unknown { background: var(--s-unknown); }
.band .pending { background: var(--s-pending); } .band .queued { background: var(--s-queued); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- lists ---------- */
.reasons { list-style: none; margin: 0; padding: 0; }
.reasons li { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.reasons li:first-child { border-top: 0; }
.reasons b { font-weight: 600; }
.reasons .n { font-weight: 700; }
.reasons p { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 78px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); }
.events .warn { color: var(--s-pending); } .events .error { color: var(--s-not); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; }
td.url { min-width: 240px; max-width: 420px; overflow-wrap: anywhere; }
.table-wrap table { min-width: 860px; }
td.url a { color: var(--ink); text-decoration: none; }
td.url a:hover { text-decoration: underline; }
td .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
td.reason { color: var(--muted); font-size: 13px; min-width: 220px; max-width: 380px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid var(--line); background: var(--surface);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--s-unknown); }
.pill.indexed::before { background: var(--s-indexed); } .pill.not_indexed::before { background: var(--s-not); }
.pill.blocked::before, .pill.skipped::before, .pill.error::before { background: var(--s-blocked); }
.pill.pending::before, .pill.submitted::before, .pill.resubmitted::before, .pill.sent::before { background: var(--s-pending); }
.pill.queued::before { background: var(--s-queued); border: 1px solid var(--s-unknown); }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 6px; margin-left: 6px; }

/* pipeline track: checked > submitted > day 2 > day 4 */
.track { display: flex; align-items: center; gap: 0; }
.track i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); flex: none; }
.track b { width: 14px; height: 2px; background: var(--line); flex: none; }
.track i.done { border-color: var(--s-pending); background: var(--s-pending); }
.track b.done { background: var(--s-pending); }
.track.indexed i.done { border-color: var(--s-indexed); background: var(--s-indexed); } .track.indexed b.done { background: var(--s-indexed); }
.track.not_indexed i.end { border-color: var(--s-not); background: var(--s-not); }
.track.skipped i.end, .track.error i.end { border-color: var(--s-blocked); background: var(--s-blocked); }

/* ---------- forms ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 14px; border-radius: var(--radius-m); padding: 8px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px; line-height: 1.3;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--s-not); }
button:disabled { opacity: .55; cursor: progress; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13.5px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=number], input[type=password], input[type=search], textarea, select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 8px 10px; width: 100%;
}
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { margin-top: 3px; }
.check span { display: flex; flex-direction: column; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-left: 1px solid var(--line); font-weight: 550; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 0 18px 14px; }
.filters input[type=search] { max-width: 280px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.steps li::marker { color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.ok { color: var(--s-indexed); font-weight: 600; } .no { color: var(--s-not); font-weight: 600; }

.empty { padding: 36px 18px; text-align: left; display: grid; gap: 10px; justify-items: start; }
.empty p { color: var(--muted); max-width: 60ch; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--surface); padding: 10px 16px;
  border-radius: var(--radius-m); font-size: 14px; max-width: 420px; z-index: 50; box-shadow: 0 6px 24px rgba(10, 20, 40, .25);
}
.toast.bad { background: var(--s-not); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 0; max-width: 560px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 18, 30, .45); }
dialog .panel-body { padding: 18px; }

/* ---------- figures notes, lists ---------- */
.fig-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.grid-2.wide-left { grid-template-columns: 1.6fr 1fr; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li a { color: var(--ink); text-decoration: none; }
.list li a:hover { text-decoration: underline; }
.list li .n { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 700; font-size: 14px; }
.list li .small { grid-column: 1; }
.status-panel h2 { font-size: 19px; }

/* ---------- step tracker: checked > sent > waiting > re-checked ---------- */
.stepper { list-style: none; margin: 0; padding: 14px 0 2px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; counter-reset: s; }
.stepper li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; font-size: 13.5px; }
.stepper li::before { content: ""; position: absolute; top: 14px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px; background: var(--line); }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.now::before { background: var(--s-indexed); }
.step-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  border: 2px solid var(--line); background: var(--surface); color: var(--muted); position: relative; z-index: 1; }
.stepper li.done .step-n { background: var(--s-indexed); border-color: var(--s-indexed); color: #fff; }
.stepper li.now .step-n { border-color: var(--s-pending); color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--s-pending) 22%, transparent); }
.stepper b { font-weight: 600; }
.stepper small { color: var(--muted); font-size: 12px; line-height: 1.35; }
@media (prefers-reduced-motion: no-preference) {
  .stepper li.now .step-n { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--s-pending) 12%, transparent); } }
}
@media (max-width: 960px) { .grid-2.wide-left { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .stepper { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .stepper li:nth-child(3)::before { display: none; }
}

.banner.fw { position: sticky; top: 0; z-index: 40; border-radius: 0; margin: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid-2 { grid-template-columns: 1fr; }
  .cov-row { grid-template-columns: 1fr 64px; gap: 8px 14px; }
  .cov-row .band { grid-column: 1 / -1; grid-row: 2; }
  .cov-row .quota { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 14px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; }
  .nav a { white-space: nowrap; padding: 6px 10px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .nav .count, .rail-foot, .brand span { display: none; }
  main { padding: 20px 16px 48px; }
  .form-row { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
