/* ResultWatch design system
   - Tokens on :root, dark theme via prefers-color-scheme or [data-theme].
   - Accent is indigo: deliberately not a colour any major Nigerian party uses.
   - Status is never colour alone: every badge/alert carries an icon and words.
   - Contrast targets WCAG 2.2 AA (body text >= 4.5:1, UI >= 3:1). */

:root {
  color-scheme: light;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e1e5eb;
  --border-strong: #c9cfd8;
  --text: #111827;
  --text-2: #475467;
  --text-3: #5d6676;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --accent-soft-text: #3730a3;
  --on-accent: #ffffff;
  --focus: #4338ca;

  --ok: #067647;      --ok-bg: #ecfdf3;      --ok-border: #abefc6;
  --info: #344054;    --info-bg: #f2f4f7;    --info-border: #d0d5dd;
  --low: #0e6a85;     --low-bg: #ecfbff;     --low-border: #a5e4f3;
  --medium: #8a3a0b;  --medium-bg: #fff8e6;  --medium-border: #fbd88a;
  --high: #b42318;    --high-bg: #fef3f2;    --high-border: #fecdca;

  --shadow-1: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04);
  --shadow-2: 0 8px 24px rgb(16 24 40 / 0.10), 0 2px 6px rgb(16 24 40 / 0.06);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 252px;
  --topbar-h: 60px;
  --gutter: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17; --surface: #121826; --surface-2: #182032; --surface-3: #212a3d;
    --border: #252f43; --border-strong: #35415a;
    --text: #e8ebf1; --text-2: #b1b9c8; --text-3: #959eb0;
    --accent: #a5b4fc; --accent-hover: #c7d2fe; --accent-soft: #1e2244; --accent-soft-text: #c7d2fe;
    --on-accent: #0b0f17; --focus: #a5b4fc;
    --ok: #75e0a7;     --ok-bg: rgb(23 178 106 / .12);   --ok-border: rgb(23 178 106 / .35);
    --info: #c3cad6;   --info-bg: rgb(148 163 184 / .12); --info-border: rgb(148 163 184 / .3);
    --low: #7dd8ef;    --low-bg: rgb(34 180 220 / .12);  --low-border: rgb(34 180 220 / .35);
    --medium: #fdc96b; --medium-bg: rgb(247 144 9 / .12); --medium-border: rgb(247 144 9 / .35);
    --high: #fda29b;   --high-bg: rgb(240 68 56 / .13);  --high-border: rgb(240 68 56 / .38);
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 10px 30px rgb(0 0 0 / .45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17; --surface: #121826; --surface-2: #182032; --surface-3: #212a3d;
  --border: #252f43; --border-strong: #35415a;
  --text: #e8ebf1; --text-2: #b1b9c8; --text-3: #959eb0;
  --accent: #a5b4fc; --accent-hover: #c7d2fe; --accent-soft: #1e2244; --accent-soft-text: #c7d2fe;
  --on-accent: #0b0f17; --focus: #a5b4fc;
  --ok: #75e0a7;     --ok-bg: rgb(23 178 106 / .12);   --ok-border: rgb(23 178 106 / .35);
  --info: #c3cad6;   --info-bg: rgb(148 163 184 / .12); --info-border: rgb(148 163 184 / .3);
  --low: #7dd8ef;    --low-bg: rgb(34 180 220 / .12);  --low-border: rgb(34 180 220 / .35);
  --medium: #fdc96b; --medium-bg: rgb(247 144 9 / .12); --medium-border: rgb(247 144 9 / .35);
  --high: #fda29b;   --high-bg: rgb(240 68 56 / .13);  --high-border: rgb(240 68 56 / .38);
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 10px 30px rgb(0 0 0 / .45);
}

/* ---- base ---------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
a, button, select, summary, input, label { touch-action: manipulation; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.011em; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: .9375rem; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img, svg { display: block; max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .875em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: .8125rem; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 16px; height: 16px; flex: none; }
.icon-lg { width: 22px; height: 22px; flex: none; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--accent-soft-text); }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100; padding: 10px 14px;
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius-sm); font-weight: 600;
  text-decoration: none; transition: top .15s var(--ease);
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

/* ---- app shell ----------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* paint the sidebar column full height, however long the page */
  background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--border) 0 var(--sidebar-w), transparent 0); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px;
  overflow-y: auto;
}
.sidebar-close { display: none; }
.sidebar-head { display: flex; align-items: flex-start; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.brand-tag { display: block; font-size: .75rem; color: var(--text-3); font-weight: 500; }

.nav-section { margin-top: 14px; padding: 0 10px 6px; font-size: .6875rem; font-weight: 650;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 550; font-size: .9375rem; white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-text); }
.nav-link .soon { margin-left: auto; font-size: .6875rem; font-weight: 600; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; }
.nav-link.is-disabled { color: var(--text-3); pointer-events: none; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.user-chip:hover { background: var(--surface-2); color: var(--text); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--text-2); font-weight: 650; font-size: .8125rem; text-transform: uppercase;
}
.user-chip .who { min-width: 0; line-height: 1.3; }
.user-chip .who strong { display: block; font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: .75rem; color: var(--text-3); text-transform: capitalize; }
.foot-actions { display: flex; gap: 6px; justify-content: space-between; align-items: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  align-items: center; gap: 10px; padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 56px; display: grid; gap: 24px; }

.scrim { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(86vw, 300px);
    height: 100vh; height: 100dvh; /* dvh: excludes mobile browser toolbars */
    padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
    overscroll-behavior: contain; visibility: hidden;
    transform: translateX(-102%); transition: transform .22s var(--ease), visibility 0s linear .22s; box-shadow: var(--shadow-2);
  }
  .shell[data-nav-open="true"] .sidebar { visibility: visible; transition: transform .22s var(--ease), visibility 0s; }
  .sidebar-close { display: inline-flex; margin-left: auto; }
  html.nav-locked, html.nav-locked body { overflow: hidden; }
  .shell[data-nav-open="true"] .sidebar { transform: none; }
  .shell[data-nav-open="true"] .scrim {
    display: block; position: fixed; inset: 0; z-index: 40; background: rgb(8 12 20 / .45);
  }
  .content { gap: 18px; padding: 20px max(var(--gutter), env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
  .nav-link { min-height: 44px; }
}

/* ---- page header --------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.page-head .eyebrow { font-size: .8125rem; color: var(--text-3); font-weight: 550; margin-bottom: 4px; }
.page-head p { color: var(--text-2); margin-top: 6px; max-width: 64ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- buttons ------------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-border);
  font: 600 .9375rem/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-1); transition: background .12s var(--ease), border-color .12s var(--ease), transform .06s;
}
.btn:hover { background: var(--surface-2); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-border: transparent; }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { --btn-fg: var(--high); --btn-border: var(--high-border); }
.btn-danger:hover { background: var(--high-bg); color: var(--high); }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: .8125rem; }
.btn-block { width: 100%; }
.icon-btn { min-height: 40px; min-width: 40px; padding: 8px; }
@media (max-width: 960px) { .btn { min-height: 44px; } .btn-sm { min-height: 38px; } .icon-btn { min-width: 44px; } }

/* ---- forms --------------------------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: .875rem; color: var(--text); }
.field .hint { font-size: .8125rem; color: var(--text-3); }
.input, .select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 16px/1.3 var(--font); /* 16px stops iOS zooming on focus */
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--high); }
.field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--high); font-size: .8125rem; font-weight: 550; }
.field-error .icon-sm { margin-top: 1px; }
.select { appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 52px; }
.password-wrap .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-grid { display: grid; gap: 16px; }
.role-guide { margin: 8px 0 0; display: grid; gap: 4px; }
.role-guide div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; }
.role-guide dt { font-weight: 600; color: var(--text-2); }
.role-guide dd { margin: 0; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr; } }

/* ---- cards & panels ------------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head p { color: var(--text-3); font-size: .8125rem; margin-top: 2px; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .grid-kpi { gap: 12px; }
  .grid-kpi .kpi { padding: 14px; gap: 6px; }
  .grid-kpi .kpi-icon { display: none; }
  .grid-kpi .kpi-value { font-size: 1.5rem; }
  .grid-kpi .kpi-foot { font-size: .75rem; line-height: 1.35; }
}

/* KPI tile */
.kpi { padding: 18px 20px; display: grid; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: .8125rem; font-weight: 600; color: var(--text-2); }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-value.is-empty { color: var(--text-3); }
.kpi-foot { font-size: .8125rem; color: var(--text-3); }

/* Meter (coverage bar) */
.meter { display: grid; gap: 6px; }
.meter-row { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; }
.meter-row .num { font-weight: 600; }
.meter-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: var(--accent); min-width: 0; transition: width .4s var(--ease); }
.meter-fill.is-ok { background: var(--ok); }
.stack { display: grid; gap: 18px; }

/* Status list */
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.status-list li:first-child { border-top: 0; }
.status-list .what { flex: 1; min-width: 0; }
.status-list .what strong { display: block; font-size: .875rem; font-weight: 600; }
.status-list .what span { display: block; font-size: .8125rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges: icon + words, never colour alone */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: .75rem; font-weight: 650; line-height: 1.3; border: 1px solid var(--info-border);
  background: var(--info-bg); color: var(--info); white-space: nowrap;
}
.badge .icon-sm { width: 14px; height: 14px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge-low { background: var(--low-bg); color: var(--low); border-color: var(--low-border); }
.badge-medium, .badge-warn { background: var(--medium-bg); color: var(--medium); border-color: var(--medium-border); }
.badge-high { background: var(--high-bg); color: var(--high); border-color: var(--high-border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }
.badge-off { background: transparent; color: var(--text-3); border-color: var(--border-strong); }

/* Alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: .9375rem; }
.alert .icon { margin-top: 2px; }
.alert strong { display: block; font-weight: 650; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.alert-error { background: var(--high-bg); border-color: var(--high-border); color: var(--high); }
.alert-warn { background: var(--medium-bg); border-color: var(--medium-border); color: var(--medium); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.alert p { color: inherit; }

/* Empty state */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 44px 24px; }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-soft-text); margin-bottom: 6px; }
.empty h2 { font-size: 1.125rem; }
.empty p { color: var(--text-2); max-width: 52ch; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; text-align: left; width: min(100%, 560px); }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-strong); font-weight: 700; font-size: .8125rem; color: var(--text-2); }
.steps strong { display: block; font-size: .9375rem; }
.steps span { display: block; font-size: .8125rem; color: var(--text-2); margin-top: 2px; }
.steps code { background: var(--surface); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }

/* Tables: stack into cards on small screens */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .cell-main strong { display: block; font-weight: 600; }
.table .cell-main span { font-size: .8125rem; color: var(--text-3); }
.table .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.table tr.is-inactive td { color: var(--text-3); }
.table .select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .9375rem; max-width: 180px; }
.table .actions { flex-wrap: nowrap; }
.nowrap { white-space: nowrap; }
@media (max-width: 760px) {
  .table .select { max-width: none; min-height: 44px; font-size: 16px; }
  .table .actions { flex-wrap: wrap; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; }
  .table td[data-label]::before { content: attr(data-label); font-size: .8125rem; color: var(--text-3); font-weight: 550; }
  .table td.cell-main { display: block; padding-bottom: 8px; }
  .table .actions { justify-content: flex-start; padding-top: 8px; }
}

/* Election switcher */
.switcher { display: flex; align-items: center; gap: 8px; }
.switcher .select { min-width: 240px; }
@media (max-width: 640px) { .switcher { width: 100%; } .switcher .select { min-width: 0; } }

/* Disclosure / dialog panel */
details.panel > summary { list-style: none; cursor: pointer; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel:not([open]) > summary { border-bottom: 0; }
details.panel[open] summary .btn { display: none; }

/* ---- auth pages ---------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-aside {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background: #151a3a; color: #e6e8ff;
  background-image: radial-gradient(1200px 500px at -10% -20%, #3b3fa8 0%, transparent 55%),
                    radial-gradient(800px 500px at 120% 120%, #252a6b 0%, transparent 60%);
}
.auth-aside .brand { color: #fff; padding: 0; }
.auth-aside .brand-mark { background: #fff; color: #2b2f86; }
.auth-aside .brand-tag { color: #b9bdf0; }
.auth-aside .aside-title { margin: 0; font-weight: 700; font-size: clamp(1.75rem, 2.6vw, 2.375rem); line-height: 1.15; letter-spacing: -0.025em; color: #fff; max-width: 18ch; }
.auth-aside .lede { margin-top: 14px; color: #c9ccf5; font-size: 1rem; max-width: 46ch; }
.principles { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; max-width: 460px; }
.principles li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.principles .p-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgb(255 255 255 / .08); color: #fff; border: 1px solid rgb(255 255 255 / .12); }
.principles strong { color: #fff; font-weight: 650; display: block; }
.principles span { color: #b9bdf0; font-size: .875rem; }
.auth-aside .aside-foot { color: #9ea3e0; font-size: .8125rem; }
.auth-main { display: grid; place-items: center; padding: max(40px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: var(--bg); }
.auth-card { width: min(100%, 400px); display: grid; gap: 22px; }
.auth-card .mobile-brand { display: none; }
.auth-card h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
.auth-card .intro { color: var(--text-2); margin-top: 6px; }
.auth-foot { font-size: .8125rem; color: var(--text-3); text-align: center; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { place-items: start center; padding-top: 48px; }
  .auth-card .mobile-brand { display: flex; }
}

/* Error page */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-page .code { font-size: .8125rem; font-weight: 700; color: var(--accent); letter-spacing: .08em; }
.error-page h1 { margin: 8px 0 10px; }
.error-page p { color: var(--text-2); max-width: 48ch; margin: 0 auto 22px; }

/* HTMX request indicator */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

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

/* ---- touch screens (any width, incl. phones in landscape and tablets) ---------------------- */
@media (pointer: coarse) {
  .btn, .btn-sm { min-height: 44px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .select, .table .select { min-height: 44px; font-size: 16px; } /* 16px stops iOS zooming on focus */
  .nav-link { min-height: 44px; }
}
/* command snippets stay readable on small screens */
.steps code { font-size: 12.5px; }

/* ---- review queue & sheet review (Phase 4) ----------------------------------------------------- */
.nav-link .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--accent-soft); color: var(--accent-soft-text); }
.budget-banner { margin: 0 0 16px; }
.card-foot { padding: 12px 20px 16px; font-size: .875rem; }
.sub { font-size: .875rem; font-weight: 650; margin: 0 0 8px; color: var(--text); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-weight: 600; }
.back-link:hover { color: var(--accent); }
.reason-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.reason-list.subtle { font-size: .875rem; color: var(--text-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-2); text-decoration: none; font-size: .875rem; font-weight: 600; }
.chip .num { color: var(--text-3); font-weight: 600; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-current="true"] { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }

.review-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.review-list li + li { border-top: 1px solid var(--border); }
.review-item { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; gap: 6px 16px; align-items: center;
  padding: 14px 20px; color: inherit; text-decoration: none; }
.review-item:hover { background: var(--surface-2); }
.review-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.ri-main { display: grid; gap: 2px; min-width: 0; }
.ri-main strong { font-size: .9375rem; }
.ri-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-meta { font-size: .8125rem; color: var(--text-3); }
.ri-reasons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ri-go { color: var(--text-3); }
@media (max-width: 760px) {
  .review-item { grid-template-columns: minmax(0, 1fr) 20px; padding: 14px 16px; }
  .ri-reasons { grid-column: 1 / 2; grid-row: 2; justify-content: flex-start; }
  .ri-go { grid-column: 2; grid-row: 1 / span 2; }
  .chips { padding: 0 16px 14px; }
}

.review-head h1 { margin-top: 2px; }
.review-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .review-layout { grid-template-columns: 1fr; } }
.viewer-card { overflow: hidden; position: sticky; top: 16px; }
@media (max-width: 1100px) { .viewer-card { position: static; } }
.viewer-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.viewer-tools a { margin-left: auto; }
.zoom-level { min-width: 48px; text-align: center; font-size: .8125rem; color: var(--text-2); }
.viewer { height: min(78vh, 900px); overflow: auto; background: var(--surface-3); overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; }
.viewer:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.viewer img { display: block; width: 100%; height: auto; max-width: none; transform-origin: top left; }
.viewer[data-zoomed] img { width: var(--zoom-w, 100%); }
@media (max-width: 1100px) { .viewer { height: 62vh; height: 62dvh; } }
.sheet-facts > summary { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-weight: 600; font-size: .875rem; border-top: 1px solid var(--border); }
.facts { margin: 0; padding: 4px 16px 16px; display: grid; gap: 8px; font-size: .875rem; }
.facts div { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: 12px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.form-card .card-head p { max-width: 60ch; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.group > legend { font-weight: 700; font-size: .9375rem; margin-bottom: 10px; padding: 0; }
.group { display: grid; gap: 12px; }
.figure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
@media (max-width: 420px) { .figure-grid { grid-template-columns: 1fr; } }
.input.num, .num .input { text-align: right; font-variant-numeric: tabular-nums; }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.45; }
.is-unsure .input { border-color: var(--medium-border); background: var(--medium-bg); }
.unsure-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--medium); font-weight: 600; }
.party-rows { display: grid; gap: 8px; }
.party-row { display: grid; grid-template-columns: minmax(84px, 120px) minmax(0, 1fr) 22px; gap: 8px; align-items: center; }
.party-row .field-error { grid-column: 1 / -1; }
.party-code { text-transform: uppercase; font-weight: 650; }
.party-row.is-extra .input { border-style: dashed; }
.unsure-dot { color: var(--medium); display: inline-flex; }
.tri { display: grid; gap: 6px; }
.tri > legend { font-weight: 600; font-size: .875rem; margin-bottom: 6px; padding: 0; }
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; max-width: 340px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; font-size: 16px; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 6px 12px; font-size: .875rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.segmented label + label span { border-left: 1px solid var(--border-strong); }
.segmented input:checked + span { background: var(--accent); color: var(--on-accent); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.checks { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.checks ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; font-size: .875rem; }
.checks li { display: flex; gap: 8px; align-items: flex-start; }
.checks li[data-state="ok"] { color: var(--ok); }
.checks li[data-state="bad"] { color: var(--high); font-weight: 600; }
.checks li[data-state="na"] { color: var(--text-3); }
.checks li:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-top: 4px; }
.form-actions .btn-ghost { margin-left: auto; }
@media (max-width: 640px) {
  .form-actions { position: sticky; bottom: 0; margin: 0 -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border); backdrop-filter: blur(6px); }
  .form-actions .btn-primary { flex: 1 1 100%; }
  .segmented { max-width: none; width: 100%; }
}
.table.compact th, .table.compact td { padding: 8px 12px; }
.table .num, .table th.num { text-align: right; }
@media (pointer: coarse) {
  .segmented span { min-height: 44px; }
  .chip { min-height: 44px; }
}
/* review polish */
.figure-grid .field { align-content: start; }
.ri-reasons .badge { white-space: normal; text-align: left; border-radius: 10px; }
@media (max-width: 640px) {
  .card-head { flex-wrap: wrap; }
  .card-head > .btn { width: 100%; justify-content: center; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; flex: 0 0 auto; }
}
/* Wide children (scrolling chip rows, tables) must never widen the page. */
.main, .content, .card, .review-layout > * { min-width: 0; }
.chips { max-width: 100%; }

/* ---- field reports (Phase 5 part 2) --------------------------------------------------------- */
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .action-grid { grid-template-columns: 1fr; gap: 12px; } }
.action-card { display: grid; grid-template-columns: auto minmax(0, 1fr) 20px; gap: 16px; align-items: center; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  color: inherit; text-decoration: none; transition: border-color .12s var(--ease), box-shadow .12s var(--ease); }
.action-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.action-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.action-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-soft-text); }
.action-text { display: grid; gap: 4px; min-width: 0; }
.action-text strong { font-size: 1.0625rem; }
.action-text span { color: var(--text-2); font-size: .875rem; }
.action-go { color: var(--text-3); }
.review-item.static:hover { background: transparent; }
.safety { margin-top: 0; }
.safety p { margin-top: 2px; }

.field-form { max-width: 720px; }
.choice-list { display: grid; gap: 8px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; font-size: 16px; }
.choice span { display: grid; gap: 2px; padding: 12px 14px 12px 44px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); position: relative; }
.choice span::before { content: ""; position: absolute; left: 14px; top: 14px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.choice small { color: var(--text-3); font-size: .8125rem; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.choice input:checked + span::before { border-color: var(--accent); background: radial-gradient(var(--accent) 0 4px, var(--surface) 5px); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.segmented.wide { display: grid; grid-auto-flow: column; max-width: none; width: 100%; }
@media (max-width: 420px) { .segmented.wide span { padding: 6px 8px; font-size: .8125rem; white-space: normal; text-align: center; } }
.place-ok, .place-miss { display: flex; gap: 6px; align-items: flex-start; font-size: .875rem; font-weight: 600; margin: 2px 0 0; }
.place-ok { color: var(--ok); }
.place-miss { color: var(--medium); }
.file-input { width: 100%; padding: 14px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); font-size: 16px; min-height: 64px; cursor: pointer; }
.file-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-input::file-selector-button { margin-right: 12px; min-height: 40px; padding: 8px 14px; border-radius: var(--radius-sm); border: 0; background: var(--accent); color: var(--on-accent); font: 600 .9375rem/1 var(--font); cursor: pointer; }
.photo-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo-preview { margin: 0; display: grid; gap: 4px; }
.photo-preview img, .photo-doc { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-3); }
.photo-doc { display: grid; place-items: center; font-weight: 700; color: var(--text-2); }
.photo-preview figcaption { font-size: .75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.photo-preview.is-bad figcaption { color: var(--high); font-weight: 600; }
/* Native date/time inputs have an intrinsic minimum width; never let them (or any form row) widen the card. */
.field-form > *, .field-form .field, .field-form .group { min-width: 0; }
.input[type="datetime-local"], .input[type="date"], .input[type="time"] { min-width: 0; max-width: 100%; display: block; }
.hint .mono { font-size: 1em; }  /* keep example codes in hints at least as large as the hint */

/* ---- dashboard (Phase 6) ------------------------------------------------------------------- */
/* Chart colours: categorical slots 1-2 of the validated reference palette (CVD dE 24.7 light /
   26.8 dark, all >= 3:1 on our surfaces). Parties never get colours: one neutral bar colour. */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-bar: var(--accent); --viz-band: rgb(42 120 214 / .08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --viz-1: #3987e5; --viz-2: #d95926; --viz-band: rgb(57 135 229 / .12); } }
:root[data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; --viz-band: rgb(57 135 229 / .12); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .875rem; color: var(--text-3); margin-bottom: 4px; }
.crumbs a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text-2); }
.h1-code { font-size: .55em; font-weight: 500; }
.party-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.party-bars li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.pb-party { font-weight: 650; font-size: .875rem; }
.pb-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.pb-fill { display: block; height: 100%; background: var(--viz-bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.pb-value { font-size: .875rem; white-space: nowrap; text-align: right; min-width: 92px; }
.totals-foot { margin: 12px 0 0; font-size: .8125rem; color: var(--text-3); }
.compact-list li { padding: 8px 0; }
.area-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.area-list li + li { border-top: 1px solid var(--border); }
.area-item { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto 20px; gap: 8px 16px; align-items: center; padding: 12px 20px; color: inherit; text-decoration: none; }
.area-item:hover { background: var(--surface-2); }
.area-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.ai-name { display: grid; gap: 1px; min-width: 0; }
.ai-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-name .mono { font-size: .8125rem; }
.ai-meter { display: grid; gap: 4px; font-size: .8125rem; color: var(--text-2); }
.mini-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.mini-fill { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.ai-stats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; font-size: .8125rem; }
@media (max-width: 760px) {
  .area-item { grid-template-columns: minmax(0, 1fr) 20px; padding: 12px 16px; }
  .ai-meter, .ai-stats { grid-column: 1; justify-content: flex-start; }
  .area-item .ri-go { grid-column: 2; grid-row: 1 / span 3; }
  .party-bars li { grid-template-columns: 52px minmax(0, 1fr); }
  .pb-value { grid-column: 2; text-align: left; }
}
.version-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 16px 20px 20px; }
.version-card { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: grid; }
.version-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.version-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--surface-3); }
.version-card figcaption { padding: 10px 12px 12px; display: grid; gap: 6px; font-size: .875rem; }
.facts.tight { padding: 0; gap: 4px; font-size: .8125rem; }
.facts.tight div { grid-template-columns: 96px 1fr; }
.diff-table th[scope="row"] { font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .875rem; color: var(--text); background: transparent; white-space: normal; }
.diff-table tr.is-changed td, .diff-table tr.is-changed th { background: var(--medium-bg); }
.changed-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; color: var(--medium); font-size: .75rem; font-weight: 700; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 20px 12px; }
.filter { display: grid; gap: 4px; font-size: .8125rem; font-weight: 600; color: var(--text-2); min-width: 200px; flex: 1 1 200px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.flag-summary { font-size: .9375rem; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.flag-text { font-size: 1rem; line-height: 1.55; margin: 0; }
.flag-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.evidence > summary { display: flex; gap: 6px; align-items: center; padding: 8px 0; font-weight: 600; font-size: .875rem; }
.evidence[open] > summary .icon-sm { transform: rotate(90deg); }
.evidence-json { margin: 0; padding: 12px; max-height: 320px; overflow: auto; background: var(--surface-2); border-radius: var(--radius-sm); font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.check-row { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: .9375rem; min-height: 44px; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.viz-grid { align-items: start; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 20px 4px; font-size: .8125rem; color: var(--text-2); }
.viz-legend span { display: inline-flex; gap: 6px; align-items: center; }
.viz-svg { display: block; width: 100%; height: auto; padding: 4px 8px 12px; touch-action: manipulation; }
.viz-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.viz-svg .tick, .viz-svg .axis-label { fill: var(--text-3); font: 500 12px var(--font); }
.viz-svg .axis-label { fill: var(--text-2); font-weight: 650; }
.viz-svg .band { fill: var(--viz-band); }
.viz-svg .diag { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.pt { stroke: var(--surface); stroke-width: 2; }
.pt-plain { fill: var(--viz-1); }
.pt-cluster { fill: var(--viz-2); }
.pt.is-hot { stroke: var(--text); stroke-width: 2; }
.viz-tip { position: fixed; z-index: 50; max-width: 280px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); font-size: .8125rem; line-height: 1.35; pointer-events: none; box-shadow: var(--shadow-2); }
.table-view > summary { display: flex; gap: 8px; align-items: center; padding: 14px 20px; font-weight: 600; }
.table-view[open] > summary .icon-sm { transform: rotate(90deg); }
@media (max-width: 1100px) { .flag-layout { grid-template-columns: 1fr; } }
/* The drawer's close button is for phones only; `.btn` (declared later, same specificity) used to win. */
@media (min-width: 961px) { .sidebar .sidebar-close { display: none; } }
.viz-grid { grid-template-columns: 1fr; }
.viz-svg .cluster-label { fill: var(--text); font: 700 13px var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.kpi-link { color: inherit; text-decoration: none; transition: border-color .12s var(--ease), box-shadow .12s var(--ease); }
.kpi-link:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.kpi-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Touch: every link and toggle in the dashboard at least 44px tall. */
@media (pointer: coarse) {
  .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .table td a { display: inline-flex; align-items: center; min-height: 44px; }
  .version-card figcaption a { display: inline-flex; align-items: center; min-height: 44px; }
  .evidence > summary, .table-view > summary, .sheet-facts > summary { min-height: 44px; }
}
/* "Assign to me": the whole row is the control. */
.check-row { position: relative; padding-left: 34px; cursor: pointer; }
.check-row input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; font-size: 16px; }
.check-row span::before { content: ""; position: absolute; left: 0; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border: 2px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.check-row input:checked + span::before { background: var(--accent); border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface); }
.check-row input:focus-visible + span::before { outline: 3px solid var(--focus); outline-offset: 2px; }
.table td a { white-space: nowrap; }  /* PU codes never wrap; the table scrolls inside its card */
@media (pointer: coarse) { .crumbs a { min-width: 44px; justify-content: center; padding: 0 2px; } }
@media (max-width: 640px) { .version-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 16px 16px; } }
