/* ==========================================================================
   Sightline styles
   Tokens first (light, then dark), then base, shell, components, views, print.
   Contrast ratios for each colour pair are listed in README.md.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f5f7f8;
  --surface-2: #eceff1;
  --ink: #15191c;
  --ink-2: #48525a;
  --ink-3: #646e76;
  --line: #e2e7ea;
  --line-strong: #8c969d;

  /* Accent: deep cyan for text and buttons, mid cyan for graphics and focus,
     bright cyan only as a fill behind dark text. Never used to mean "good". */
  --accent-ink: #0b6b85;
  --accent: #0891b2;
  --accent-bright: #22d3ee;
  --accent-soft: #e4f5f9;
  --on-accent: #ffffff;
  --btn-bg: #0b6b85;
  --btn-bg-hover: #09576c;

  --good: #166534;
  --good-soft: #e7f4eb;
  --warn: #a8520a;
  --warn-soft: #fcf1e3;
  --crit: #b42318;
  --crit-soft: #fcebea;

  --focus: #0891b2;
  --shadow-pop: 0 1px 2px rgb(21 25 28 / 0.06), 0 8px 24px -8px rgb(21 25 28 / 0.14);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 72px;

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 236px;
  --tabbar: 64px;
  --content: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111417;
    --surface: #181c20;
    --surface-2: #20252a;
    --ink: #e6eaed;
    --ink-2: #a9b3ba;
    --ink-3: #89939a;
    --line: #262c31;
    --line-strong: #5b656c;
    --accent-ink: #5fcde4;
    --accent: #3fb8d3;
    --accent-bright: #5fcde4;
    --accent-soft: #10303a;
    --on-accent: #0b1215;
    --btn-bg: #5fcde4;
    --btn-bg-hover: #86dbec;
    --good: #5cc98a;
    --good-soft: #14291d;
    --warn: #e5a54b;
    --warn-soft: #2e2413;
    --crit: #f07c7a;
    --crit-soft: #321a1a;
    --focus: #5fcde4;
    --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px -12px rgb(0 0 0 / 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111417;
  --surface: #181c20;
  --surface-2: #20252a;
  --ink: #e6eaed;
  --ink-2: #a9b3ba;
  --ink-3: #89939a;
  --line: #262c31;
  --line-strong: #5b656c;
  --accent-ink: #5fcde4;
  --accent: #3fb8d3;
  --accent-bright: #5fcde4;
  --accent-soft: #10303a;
  --on-accent: #0b1215;
  --btn-bg: #5fcde4;
  --btn-bg-hover: #86dbec;
  --good: #5cc98a;
  --good-soft: #14291d;
  --warn: #e5a54b;
  --warn-soft: #2e2413;
  --crit: #f07c7a;
  --crit-soft: #321a1a;
  --focus: #5fcde4;
  --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px -12px rgb(0 0 0 / 0.6);
}

/* ---------- base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 650; letter-spacing: -0.015em; line-height: 1.15; overflow-wrap: anywhere; }
h1 { font-size: clamp(26px, 3.2vw, 34px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); font-size: 13px; }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0.01em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.noscript { padding: var(--s6); }

.skip {
  position: absolute; left: var(--s3); top: var(--s3); z-index: 100;
  transform: translateY(-200%);
  background: var(--ink); color: var(--bg); border: 0; border-radius: var(--radius-sm);
  padding: var(--s2) var(--s4); min-height: 44px; cursor: pointer;
}
.skip:focus { transform: none; }

/* ---------- shell ---------- */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s5) var(--s4);
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s2); color: var(--ink); text-decoration: none; min-height: 44px; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }

.nav ul { list-style: none; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 44px; padding: 0 var(--s3);
  border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .nav-label { flex: 1; }
.badge {
  min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--crit); color: var(--bg);
  font: 600 12px/1 var(--font-mono);
}

.sidebar-foot { margin-top: auto; display: grid; gap: var(--s3); padding: 0 var(--s2); }
.agency-name { font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; min-width: 44px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink-2); cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.main {
  margin-left: var(--sidebar);
  min-height: 100vh;
  display: flex; flex-direction: column;
  outline: none;
}
.content {
  width: 100%; max-width: var(--content);
  margin: 0 auto; padding: var(--s6) var(--s6) var(--s7);
  flex: 1;
}
.app-foot {
  width: 100%; max-width: var(--content); margin: 0 auto;
  padding: var(--s4) var(--s6) var(--s5);
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-3);
}

/* Tablet: narrower sidebar */
@media (max-width: 1099px) {
  :root { --sidebar: 208px; }
  .content { padding: var(--s5) var(--s5) var(--s7); }
  .app-foot { padding: var(--s4) var(--s5) var(--s5); }
}

/* Mobile: sidebar becomes a top bar, nav becomes a bottom tab bar */
@media (max-width: 767px) {
  .sidebar {
    position: sticky; top: 0; inset: auto; width: auto; height: auto;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: var(--s2) var(--s4);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar-foot { margin: 0; padding: 0; display: flex; align-items: center; }
  .agency-name { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
  }
  .nav ul { grid-template-columns: repeat(5, 1fr); gap: 0; }
  .nav a {
    flex-direction: column; justify-content: center; gap: 2px;
    min-height: var(--tabbar); padding: var(--s1) 2px;
    border-radius: 0; font-size: 11.5px; font-weight: 500; text-align: center;
    position: relative;
  }
  .nav a[aria-current="page"] { background: transparent; box-shadow: inset 0 2px 0 var(--accent); }
  .nav .nav-label { flex: none; line-height: 1.2; }
  .nav .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; height: 20px; font-size: 11px; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .content { padding: var(--s5) var(--s4) var(--s6); }
  .app-foot { padding: var(--s4); }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 15px; line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--btn-bg); color: var(--on-accent); }
.btn-primary:hover { background: var(--btn-bg-hover); }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--accent-ink); padding: 0 var(--s3); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--crit); color: var(--bg); }
.btn-danger:hover { filter: brightness(0.92); }
.btn-danger-quiet { background: transparent; color: var(--crit); border-color: var(--line); }
.btn-danger-quiet:hover { background: var(--crit-soft); border-color: var(--crit); }
.btn-lg { min-height: 52px; padding: 0 var(--s5); font-size: 16px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 24px; padding: 2px 10px 2px 8px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill-risk, .pill-crit { background: var(--crit-soft); color: var(--crit); }
.pill-watch, .pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-info, .pill-nodata { background: var(--surface-2); color: var(--ink-2); }
.pill-platform { background: transparent; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; padding: 2px 10px; }

/* ---------- banners and flash ---------- */

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4);
  padding: var(--s3) var(--s4); margin-bottom: var(--s5);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-2); font-size: 14px;
}
.banner strong { color: var(--ink); font-weight: 600; }
.banner-warn { background: var(--warn-soft); color: var(--ink); }
.banner-crit { background: var(--crit-soft); color: var(--ink); }
.banner-good { background: var(--good-soft); color: var(--ink); }
.banner-text { flex: 1 1 240px; }
@media (max-width: 767px) { .banner { font-size: 13.5px; padding: var(--s3); gap: var(--s2); margin-bottom: var(--s4); } .banner .btn { font-size: 14px; } }
.banner .close { margin-left: auto; }

/* ---------- page head ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); }
.page-head-text { display: grid; gap: var(--s2); min-width: 0; flex: 1 1 420px; }
.page-head .lede { color: var(--ink-2); max-width: 62ch; }
.crumb { font-size: 14px; }
.crumb a { color: var(--ink-3); text-decoration: none; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }

.section { margin-top: var(--s7); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s4); }
.section-head p { color: var(--ink-3); font-size: 14px; }

/* ---------- KPI row (no cards: separated by thin rules) ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0; }
.kpi { padding: var(--s4) var(--s4) var(--s4) 0; min-width: 0; }
.kpi + .kpi { padding-left: var(--s4); border-left: 1px solid var(--line); }
.kpi dt { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi dd { margin: 0; }
.kpi .value { display: block; font: 500 24px/1.25 var(--font-mono); letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .delta { display: block; font-size: 13px; margin-top: 2px; }
@media (max-width: 1099px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi, .kpi + .kpi { padding: var(--s3) var(--s3) var(--s3) 0; border-left: 0; }
  .kpi:nth-child(even) { padding-left: var(--s3); border-left: 1px solid var(--line); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 767px) { .kpi .value { font-size: 20px; } }

.delta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up-good, .delta.down-good { color: var(--good); }
.delta.up-bad, .delta.down-bad { color: var(--crit); }
.delta.flat, .delta.neutral { color: var(--ink-3); }
.delta .vs { font-family: var(--font-body); color: var(--ink-3); }

/* ---------- health summary ---------- */

.health { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); margin: var(--s5) 0 var(--s5); }
.health-item { display: flex; align-items: baseline; gap: var(--s2); color: inherit; text-decoration: none; min-height: 44px; }
a.health-item:hover .label { color: var(--ink); text-decoration: underline; }
.health-item .n { font: 600 28px/1 var(--font-display); letter-spacing: -0.02em; }
.health-item.risk .n { color: var(--crit); }
.health-item.watch .n { color: var(--warn); }
.health-item.good .n { color: var(--good); }
.health-item.zero .n { color: var(--ink-3); }
.health-item .label { color: var(--ink-2); font-size: 14px; }
.health-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: var(--s5); gap: 2px; }
.health-bar span { display: block; height: 100%; }
.health-bar .risk { background: var(--crit); }
.health-bar .watch { background: var(--warn); }
.health-bar .good { background: var(--good); }

/* ---------- tables ---------- */

.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.table-wrap:focus-visible { outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-full { min-width: 760px; }
.table-mid { min-width: 560px; }
th, td { padding: var(--s3) var(--s4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
tbody tr:last-child > * { border-bottom: 0; }
thead th { font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--surface); white-space: nowrap; }
th.r, td.r { text-align: right; }
th.r .sort-btn { justify-content: flex-end; }
td.r { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr { transition: background-color 120ms ease; }
tbody tr.linkable:hover { background: var(--surface); }
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; min-width: 44px; margin: calc(var(--s3) * -1) 0; padding: 0;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
.sort-btn:hover { color: var(--ink); }
.sort-btn .arrow { width: 10px; opacity: 0.8; }
th[aria-sort] .sort-btn { color: var(--ink); }

/* Long names: clamp to two lines, full name stays in the DOM for screen readers and in title for hover. */
.name-cell { max-width: 300px; min-width: 180px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.name-cell a { color: var(--ink); font-weight: 600; text-decoration: none; }
.name-cell a:hover { color: var(--accent-ink); text-decoration: underline; }
.name-cell .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.issue-cell { max-width: 260px; min-width: 160px; color: var(--ink-2); }

/* ---------- brief ---------- */

.brief { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.brief-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.brief-head h2, .brief-head h3 { font-family: var(--font-display); font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.brief-body { padding: var(--s5); display: grid; gap: var(--s5); }
.brief-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.02em; margin-bottom: var(--s2); }
.changes { list-style: none; display: grid; gap: var(--s2); }
.changes li { display: flex; gap: var(--s3); align-items: baseline; }
.changes li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; transform: translateY(-2px); }
.actions { list-style: none; counter-reset: act; display: grid; gap: var(--s4); }
.action { counter-increment: act; display: grid; grid-template-columns: 32px 1fr; gap: var(--s3); }
.action::before {
  content: counter(act); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink); font: 600 13px/1 var(--font-mono);
}
.action-body { display: grid; gap: var(--s2); min-width: 0; }
.action-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-weight: 600; overflow-wrap: anywhere; }
.action-why { color: var(--ink-2); overflow-wrap: anywhere; }
.action-do { overflow-wrap: anywhere; }
.action-do strong { font-weight: 600; }
.evidence { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--s4); margin: 0; padding: var(--s3) var(--s4); background: var(--surface); border-radius: var(--radius-sm); font-size: 13px; }
.evidence dt { color: var(--ink-3); }
.evidence dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .evidence { grid-template-columns: 1fr; }
  .evidence dd { margin-bottom: var(--s2); }
  .brief-body { padding: var(--s4); }
  .brief-head { padding: var(--s3) var(--s4); }
}
.brief-note { font-size: 13px; color: var(--ink-3); }

/* ---------- top actions list (overview) ---------- */

.top-actions { list-style: none; display: grid; border-top: 1px solid var(--line); }
.top-actions li > .pill { justify-self: start; }
.top-actions li { display: grid; grid-template-columns: 112px 1fr auto; gap: var(--s2) var(--s4); align-items: start; padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.top-actions .ta-main { min-width: 0; display: grid; gap: 2px; }
.top-actions .ta-client { font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.top-actions .ta-title { font-weight: 600; overflow-wrap: anywhere; }
.top-actions .ta-do { color: var(--ink-2); font-size: 14px; overflow-wrap: anywhere; }
.top-actions .ta-impact { text-align: right; font-size: 13px; color: var(--ink-3); }
.top-actions .ta-impact .num { display: block; color: var(--ink); font-size: 14px; }
@media (max-width: 1099px) {
  .top-actions li { grid-template-columns: 1fr; gap: var(--s2); }
  .top-actions .ta-impact { text-align: left; }
  .top-actions .ta-impact .num { display: inline; margin-right: 6px; }
}

/* ---------- charts ---------- */

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s5); }
.chart figure, figure.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; gap: var(--s3); font-size: 14px; font-weight: 600; margin-bottom: var(--s2); }
.chart figcaption .subtle { font-weight: 400; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-3); font: 11px var(--font-mono); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: var(--accent-soft); }
.chart .band-label { fill: var(--accent-ink); font: 600 11px var(--font-body); }
.chart .gap-dot { fill: var(--crit); }
@media (max-width: 520px) { .charts { grid-template-columns: 1fr; } }

/* ---------- welcome ---------- */

.welcome { padding-top: var(--s5); }
.welcome-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: var(--s6); align-items: start; }
.welcome-copy { display: grid; gap: var(--s5); align-content: start; padding-top: var(--s7); }
.welcome h1 {
  font-size: clamp(36px, 5vw, 60px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 700;
  font-variation-settings: "opsz" 96;
}
.welcome h1 .hl { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent-bright); text-decoration-thickness: 0.09em; text-underline-offset: 0.12em; text-decoration-skip-ink: none; }
.welcome .lede { font-size: 17px; color: var(--ink-2); max-width: 44ch; }
.welcome .fine { font-size: 13px; color: var(--ink-3); }

.stage { position: relative; padding: var(--s7) var(--s5); }
.preview {
  position: relative; z-index: 1;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--surface); }
.preview-bar .title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sample-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.preview-body { padding: var(--s4); display: grid; gap: var(--s4); }
.preview .table-wrap { border-radius: var(--radius-sm); }
.preview table { font-size: 13px; }
.preview th, .preview td { padding: var(--s2) var(--s3); }
.preview .name-cell { min-width: 140px; max-width: 220px; }
.preview .brief-head { padding: var(--s3) var(--s4); }
.preview .brief-body { padding: var(--s4); gap: var(--s4); }
.preview .brief { border-radius: var(--radius-sm); }
.preview .evidence { font-size: 12px; }

.chips { list-style: none; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.chip-csv { font-family: var(--font-mono); color: var(--accent-ink); border-color: var(--accent); }
.stage .chips li { position: absolute; z-index: 2; }
.stage .chips li:nth-child(1) { top: 10px; left: 4%; }
.stage .chips li:nth-child(2) { top: 2px; left: 30%; }
.stage .chips li:nth-child(3) { top: 12px; left: 55%; }
.stage .chips li:nth-child(4) { top: 0; right: 4%; }
.stage .chips li:nth-child(5) { bottom: 6px; left: 10%; }
.stage .chips li:nth-child(6) { bottom: 8px; left: 40%; }
.stage .chips li:nth-child(7) { bottom: 4px; right: 12%; }

.steps { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); margin-top: var(--s8); padding-top: var(--s6); border-top: 1px solid var(--line); }
.steps li { counter-increment: step; display: grid; gap: var(--s2); align-content: start; }
.steps li::before { content: counter(step, decimal-leading-zero); font: 500 13px var(--font-mono); color: var(--accent-ink); }
.steps h3 { font-family: var(--font-display); font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.steps p { color: var(--ink-2); font-size: 14px; max-width: 34ch; }

.welcome-note { margin-top: var(--s6); font-size: 14px; color: var(--ink-3); max-width: 70ch; }

@media (max-width: 1199px) {
  .welcome-grid { grid-template-columns: 1fr; gap: var(--s6); }
  .welcome-copy { max-width: 640px; padding-top: 0; }
  .stage { padding: 0; display: grid; gap: var(--s4); }
  .stage .chips { display: flex; flex-wrap: wrap; gap: var(--s2); order: -1; }
  .stage .chips li { position: static; }
}
@media (max-width: 767px) {
  .welcome { padding-top: 0; }
  .welcome .lede { font-size: 16px; }
  .welcome-copy .btn-row .btn { flex: 1 1 100%; }
  .steps { grid-template-columns: 1fr; gap: var(--s4); margin-top: var(--s7); }
  .chip { font-size: 12.5px; padding: 5px 10px; }
}

/* ---------- empty states ---------- */

.empty { display: grid; justify-items: start; gap: var(--s3); padding: var(--s7) 0; max-width: 56ch; }
.empty h2 { font-size: 22px; }
.empty p { color: var(--ink-2); }

/* ---------- alerts ---------- */

.filters { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s5); }
.filter {
  min-height: 44px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink-2); font-weight: 500; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.filter:hover { border-color: var(--line-strong); color: var(--ink); }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter .num { margin-left: 4px; }
.alert-list { list-style: none; display: grid; gap: var(--s4); }
.alert { display: grid; gap: var(--s3); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--radius); }
.alert-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.alert-client { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.alert h2 { font-size: 17px; font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }

/* ---------- client detail ---------- */

.client-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.client-title { font-size: clamp(26px, 3.4vw, 36px); max-width: 28ch; }
.copy-fallback { display: grid; gap: var(--s2); margin-top: var(--s3); }
.copy-fallback textarea { width: 100%; min-height: 160px; padding: var(--s3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); font: 13px/1.5 var(--font-mono); }

/* ---------- forms ---------- */

.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--ink-3); }
.input, .select {
  width: 100%; min-height: 44px; padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink);
  transition: border-color 120ms ease;
}
.select { padding-right: var(--s6); appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover, .select:hover { border-color: var(--ink-3); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--crit); }
.field-error { font-size: 13px; color: var(--crit); font-weight: 500; }
.field-ok { font-size: 13px; color: var(--good); font-weight: 500; }
.radio-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.radio {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
}
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.radio input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.radio:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; }
.form-row .field { flex: 1 1 260px; }

/* ---------- import ---------- */

.drop {
  display: grid; justify-items: center; gap: var(--s3); text-align: center;
  padding: var(--s7) var(--s5);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 120ms ease, background-color 120ms ease;
}
.drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop h3 { font-family: var(--font-display); font-size: 19px; font-weight: 650; }
.drop p { color: var(--ink-2); font-size: 14px; max-width: 52ch; }
.drop .file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:has(.file-input:focus-visible) .btn { outline: 2px solid var(--focus); outline-offset: 2px; }

.pending-list { display: grid; gap: var(--s4); margin-top: var(--s5); }
.pending { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pending.error { border-color: var(--crit); }
.pending-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s3) var(--s4); background: var(--surface); border-bottom: 1px solid var(--line); }
.pending-file { font-weight: 600; overflow-wrap: anywhere; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.pending-body { padding: var(--s4); display: grid; gap: var(--s4); }
.pending-error { display: grid; gap: var(--s1); padding: var(--s3) var(--s4); background: var(--crit-soft); border-radius: var(--radius-sm); }
.pending-error strong { color: var(--crit); }
.pending-warn { padding: var(--s3) var(--s4); background: var(--warn-soft); border-radius: var(--radius-sm); font-size: 14px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s3); }
.map-grid .field label { font-size: 13px; }
.req { color: var(--crit); }
.pending-foot { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; justify-content: space-between; }
.pending-foot .assign { display: flex; flex-wrap: wrap; gap: var(--s3); flex: 1 1 420px; }
.pending-foot .assign .field { flex: 1 1 200px; }
.stats-line { font-size: 13px; color: var(--ink-3); }

.confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding: var(--s3); border-radius: var(--radius-sm); background: var(--crit-soft);
}
.confirm p { font-size: 14px; flex: 1 1 200px; }
td .confirm { min-width: 280px; }

.settings-grid { display: grid; gap: var(--s7); max-width: 760px; }
.settings-section { display: grid; gap: var(--s4); }
.settings-section > p { color: var(--ink-2); }
.danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--line); }
.danger-row:last-child { border-bottom: 1px solid var(--line); }
.danger-row > div:first-child { flex: 1 1 280px; display: grid; gap: 2px; }
.danger-row p { color: var(--ink-2); font-size: 14px; }
.rules-list { list-style: none; display: grid; border-top: 1px solid var(--line); }
.rules-list li { display: grid; grid-template-columns: 110px 1fr; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rules-list li > span:last-child { color: var(--ink-2); }
@media (max-width: 520px) { .rules-list li { grid-template-columns: 1fr; gap: var(--s1); } }

/* ---------- report ---------- */

.report-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.report { max-width: 820px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s7) var(--s7); background: var(--bg); }
.report-head { display: grid; gap: var(--s2); padding-bottom: var(--s5); border-bottom: 2px solid var(--ink); margin-bottom: var(--s5); }
.report-brand { display: flex; justify-content: space-between; gap: var(--s3); font-size: 13px; color: var(--ink-3); }
.report-brand strong { color: var(--ink); font-weight: 600; }
.report h1 { font-size: 30px; }
.report h2 { font-size: 18px; margin: var(--s6) 0 var(--s3); }
.report table { font-size: 14px; }
.report .kpi-table td, .report .kpi-table th { padding: var(--s2) var(--s3); }
.report-foot { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); display: grid; gap: var(--s1); }
@media (max-width: 767px) { .report { padding: var(--s5) var(--s4); } }

.report-list { list-style: none; display: grid; border-top: 1px solid var(--line); }
.report-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.report-list .rl-name { flex: 1 1 260px; min-width: 0; display: grid; gap: 2px; }
.report-list .rl-name strong { overflow-wrap: anywhere; }

/* ---------- round 2: periods, pacing, channels, drivers, notes, health, branding ---------- */

.head-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.period-field { display: grid; gap: 4px; }
.period-field label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.select-sm { width: auto; min-width: 170px; }

.data-note { display: flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s5); padding: var(--s3) var(--s4); border-radius: var(--radius-sm); background: var(--warn-soft); font-size: 14px; }
.data-note svg { width: 18px; height: 18px; flex: none; color: var(--warn); }

.table-wide { min-width: 960px; }

.pace { font-size: 13px; white-space: nowrap; font-weight: 500; }
.pace .num { font-weight: 600; }
.pace-bad { color: var(--crit); }
.pace-warn { color: var(--warn); }
.pace-good { color: var(--good); }
.pace-muted { color: var(--ink-3); }

.pacing { display: grid; gap: var(--s3); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--radius); }
.pacing-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2) var(--s4); align-items: baseline; }
.pacing-label { font-weight: 600; }
.pacing-bar { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); margin: var(--s2) 0; }
.pacing-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.pacing-bar.is-over .fill { background: var(--crit); }
.pacing-bar .even { position: absolute; top: -4px; width: 2px; height: 18px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.pacing-key { margin: 0; }
.pacing-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin: 0; }
.pacing-stats dt { font-size: 12.5px; color: var(--ink-3); }
.pacing-stats dd { margin: 0; font-size: 16px; }
@media (max-width: 640px) { .pacing-stats { grid-template-columns: 1fr 1fr; } .pacing { padding: var(--s4); } }

.targets { list-style: none; display: grid; margin-top: var(--s4); border-top: 1px solid var(--line); }
.target { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s5); padding: var(--s3) 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.target-label { font-weight: 600; min-width: 160px; }

.budget-form { display: grid; gap: var(--s4); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--radius); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s4); }
.form-grid .field label { font-size: 13.5px; }
.unit-input { display: flex; align-items: stretch; }
.unit-input .input { border-radius: 0; flex: 1; min-width: 0; }
.unit-input .input:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.unit-input .input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.unit { display: grid; place-items: center; padding: 0 var(--s3); min-width: 44px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2); font-size: 13.5px; }
.unit:not(.unit-pre) { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.unit-pre { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.custom-rules { border-top: 1px solid var(--line); padding-top: var(--s3); }
.custom-rules summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.custom-rules[open] summary { margin-bottom: var(--s2); }

.share { display: inline-flex; align-items: center; gap: var(--s2); }
.share-bar { position: relative; width: 90px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.share-bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
tbody th[scope="row"] { font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; }

.channels-compact th, .channels-compact td { padding-left: var(--s3); padding-right: var(--s3); }
.channels-compact .share-bar { width: 56px; }
.filters-inline { margin: 0; }
.drivers-summary { margin-bottom: var(--s4); max-width: 70ch; }

.chart .note-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .note-dot { fill: var(--ink); }
.chart .note-num { fill: var(--bg); font: 600 10px var(--font-mono); }
.chart-notes { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s4); font-size: 14px; }
.chart-notes li { display: flex; gap: var(--s2); align-items: baseline; }
.note-badge { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 600; }

.note-form { display: grid; grid-template-columns: 190px 1fr auto; gap: var(--s3); align-items: start; margin-bottom: var(--s4); }
.note-form .btn { margin-top: 26px; }
@media (max-width: 767px) { .note-form { grid-template-columns: 1fr; } .note-form .btn { margin-top: 0; justify-self: start; } }
.notes-list { list-style: none; display: grid; border-top: 1px solid var(--line); }
.notes-list li { display: grid; grid-template-columns: 130px 1fr auto; gap: var(--s2) var(--s4); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.note-when { font-size: 13px; color: var(--ink-3); }
.note-body { overflow-wrap: anywhere; }
@media (max-width: 640px) { .notes-list li { grid-template-columns: 1fr; } .notes-list .btn { justify-self: start; } }

.health-list { list-style: none; display: grid; border-top: 1px solid var(--line); }
.health-list li { display: grid; gap: var(--s1); padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.health-title { font-weight: 600; overflow-wrap: anywhere; }
#health-title:focus { outline: none; }

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.btn-row:has(.file-input:focus-visible) label.btn, .field:has(.file-input:focus-visible) label.btn { outline: 2px solid var(--focus); outline-offset: 2px; }
.brand-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s5); }
.logo-box { width: 180px; height: 80px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #ffffff; padding: var(--s2); }
.logo-box .subtle { color: #646e76; }
.logo-preview { max-width: 160px; max-height: 60px; object-fit: contain; }
.color-input { width: 56px; height: 44px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }

.report-head { border-bottom: 3px solid var(--brand, var(--ink)); }
.report-brand { align-items: center; flex-wrap: wrap; }
.report-logo { max-height: 40px; max-width: 160px; object-fit: contain; margin-right: var(--s2); }
.report .pacing, .report .targets { margin-top: var(--s2); }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- print (client report) ---------- */

@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #ffffff; --surface: #f5f7f8; --surface-2: #eceff1; --ink: #000000; --ink-2: #333a40; --ink-3: #555e66;
    --line: #d5dbdf; --line-strong: #8c969d; --accent: #0891b2; --accent-ink: #0b6b85; --accent-soft: #e4f5f9;
    --good: #166534; --good-soft: #e7f4eb; --warn: #a8520a; --warn-soft: #fcf1e3; --crit: #b42318; --crit-soft: #fcebea;
  }
  @page { margin: 16mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .nav, .skip, .banner, .app-foot, .report-toolbar, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  .content { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; max-width: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pacing, .targets { break-inside: avoid; }
  .report h2 { break-after: avoid; }
  .action, .kpi-table, .chart, .evidence { break-inside: avoid; }
  .table-wrap { overflow: visible; border-color: #d5dbdf; }
  a { color: inherit; text-decoration: none; }
}
