/* GSC Pulse UI — shared by GSC Pulse (/) and the Audit Engine (audit/).
   Source of truth: /ui.css. audit/ui.css is a copy; test/ui-sync.test.mjs fails when they differ. */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/inter-regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/inter-medium.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/inter-semibold.woff") format("woff"); }

:root {
  color-scheme: light;
  --canvas: #f8f8fa;
  --sidebar: #f4f4f7;
  --panel: #ffffff;
  --sunken: #f6f6f9;
  --line: #e6e6ec;
  --line-strong: #d6d6de;
  --ink: #18181d;
  --ink-2: #3c3c46;
  --muted: #636370;
  --faint: #9a9aa6;

  --accent: #5a49d6;
  --accent-hover: #4b3bc4;
  --accent-ink: #3a2c9e;
  --accent-soft: #eeebfd;
  --accent-line: #d9d3fa;

  --up: #24704d;
  --up-bar: #6aa685;
  --up-soft: #e5f2ea;
  --down: #bd3a26;
  --down-bar: #e2735f;
  --down-soft: #fbe9e5;
  --warn: #93560a;
  --warn-soft: #fcf0dc;
  --info: #2c5aa8;
  --info-soft: #e7eefa;
  --bar: #dcdce4;
  --quickwin: #c97f1a; /* query-matrix quick wins; 3.2:1 on white as a mark */

  --sev-critical: #bd3a26; --sev-critical-soft: #fbe9e5;
  --sev-high: #a84a0c;     --sev-high-soft: #fdeedd; /* 5.1:1 on its soft fill */
  --sev-medium: #93560a;   --sev-medium-soft: #fcf3dc;
  --sev-warning: #7a6608;  --sev-warning-soft: #f8f3d2;
  --sev-low: #2c5aa8;      --sev-low-soft: #e7eefa;
  --sev-info: #5d5d6a;     --sev-info-soft: #efeff3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(24, 24, 40, .04), 0 2px 8px rgba(24, 24, 40, .04);
  --shadow-pop: 0 8px 24px rgba(24, 24, 40, .12), 0 2px 6px rgba(24, 24, 40, .06);
  --font: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid var(--canvas); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.012em; text-wrap: balance; }
.num, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.skip { position: fixed; left: 12px; top: -48px; z-index: 50; padding: 8px 14px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 500; text-decoration: none; }
.skip:focus { top: 12px; }
.skip:hover, .skip:focus { color: #fff; }
.page:focus { outline: none; } /* focused by script on view change; the skip link target */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── icons ──────────────────────────────────────────── */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 14px; height: 14px; }

/* ── shell ──────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 14px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: #fff; display: grid; place-items: center; }
.brand-mark .i { width: 16px; height: 16px; stroke-width: 2.2; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.account {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 10px; margin-bottom: 18px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  box-shadow: var(--shadow);
}
.account:hover { border-color: var(--line-strong); }
.account-text { min-width: 0; flex: 1; }
.account-name, .account-sub { display: block; }
.account-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.account-sub { color: var(--muted); font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item .i { color: var(--muted); }
.nav-item:hover { background: rgba(24, 24, 40, .05); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item[aria-current="page"] .i { color: var(--accent); }
.nav-item .ext { margin-left: auto; width: 12px; height: 12px; color: var(--faint); }
.sidebar-foot { margin-top: auto; padding: 10px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(248, 248, 250, .88); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.btn.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--faint); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.search { position: relative; width: min(340px, 36vw); }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 34px; padding: 0 44px 0 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel); font: inherit; font-size: 13px; color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: 500 11px var(--font); color: var(--muted); background: var(--sunken);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 6px; max-height: 320px; overflow-y: auto;
}
.search-results a {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-size: 13px;
}
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.search-results .empty-hit { padding: 8px; color: var(--muted); font-size: 13px; }

.page { padding: 24px 28px 56px; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 22px; line-height: 1.25; }
.page-sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .hint { color: var(--muted); font-size: 12.5px; }
.back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none;
  font-weight: 500; font-size: 13.5px; padding: 6px 4px; margin-right: 6px;
}
.back:hover { color: var(--ink); }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ── buttons & inputs ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font: 500 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--sunken); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(58, 44, 158, .25); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--down); }
.btn-danger:hover { background: var(--down-soft); color: var(--down); border-color: #efc6bd; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(24, 24, 40, .05); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm); }
.btn.is-busy .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select {
  height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); font: 400 13.5px var(--font); min-width: 0;
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636370' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.select-sm { height: 28px; font-size: 12.5px; padding-left: 8px; }
.field { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field .input { flex: 1; min-width: 200px; }

/* filter chips (reference: "Period · Year to date") */
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--muted); white-space: nowrap; position: relative;
}
.chip b { color: var(--ink); font-weight: 600; }
.chip .i { color: var(--muted); }
.chip select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font: inherit; }
.chip.is-control { cursor: pointer; }
/* the comparison window: stated, not a control */
.period { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.period .i { width: 15px; height: 15px; }
.chip.is-control:hover { border-color: var(--line-strong); }
.chip.is-control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font: 500 12.5px var(--font); color: var(--muted);
  padding: 5px 11px; border-radius: 5px; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.seg .count { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.period-seg { flex: none; margin-right: 10px; }

/* ── panels ─────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 4px; }
.panel-title { font-size: 15px; display: flex; align-items: center; gap: 7px; }
.panel-title .i { color: var(--muted); }
.panel-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.panel-body { padding: 14px 20px 20px; }
.panel-body.flush { padding: 8px 0 4px; }
.panel-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* entity header (reference: account header + KPI strip) */
.entity { padding: 20px 20px 18px; }
.entity-top { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.tile {
  width: 52px; height: 52px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 16px; letter-spacing: .02em; flex: none;
}
.tile-sm { width: 30px; height: 30px; border-radius: 7px; font-size: 11.5px; }
.tile-xs { width: 24px; height: 24px; border-radius: 6px; font-size: 10px; }
.entity-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entity-name h1 { font-size: 22px; }
.entity-meta { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.entity-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.kpis {
  display: grid; grid-template-columns: repeat(var(--kpi-cols, 6), minmax(0, 1fr));
  margin-top: 18px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.kpi { padding: 13px 16px 14px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; line-height: 1.2; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.kpi-delta { font-size: 12.5px; margin-top: 3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* a KPI that filters the table below it */
button.kpi { font: inherit; color: inherit; text-align: left; background: transparent; border: 0; border-left: 1px solid var(--line); cursor: pointer; }
button.kpi:hover { background: rgba(24, 24, 40, .04); }
button.kpi[aria-pressed="true"] { background: var(--accent-soft); }
button.kpi[aria-pressed="true"] .kpi-label { color: var(--accent-ink); }
.kpi-filter { vertical-align: -2px; margin-right: 4px; color: var(--muted); }
/* one-line 'why' under a KPI strip */
.kpi-note { display: flex; gap: 8px; align-items: flex-start; margin: 12px 2px 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); max-width: 110ch; }
.kpi-note > .i { flex: none; margin-top: 3px; color: var(--info); }
/* source line under a table; intent label under a query */
.table-note { margin: 0; padding: 10px 20px 14px; font-size: 12px; color: var(--muted); }
.pill.intent { margin-top: 4px; font-size: 11px; }
button.kpi:hover .kpi-filter, button.kpi[aria-pressed="true"] .kpi-filter { color: var(--accent); }

/* attention queue (portfolio): one row per site, its reasons inline */
.att { list-style: none; margin: 0; padding: 0 0 6px; }
.att li + li .att-row { border-top: 1px solid var(--line); }
.att-row { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: inherit; text-decoration: none; }
.att-row:hover { background: rgba(24, 24, 40, .04); color: inherit; }
.att-row .cell-main { flex: 1; }
.att-why { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.att-go { color: var(--muted); transform: rotate(-90deg); flex: none; }
.att-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 4px 20px 14px; font-size: 12.5px; }
.att-more a { margin-left: auto; color: var(--muted); text-decoration: none; }
.att-more a:hover { color: var(--accent); }
.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-warn { color: var(--warn); }
.is-info { color: var(--info); } /* an opportunity, not a warning */
.is-flat { color: var(--muted); }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--sunken); color: var(--ink-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.no-dot::before { display: none; }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill.neutral { background: var(--sunken); color: var(--muted); }
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.sev-critical { color: var(--sev-critical); } .sev-high { color: var(--sev-high); } .sev-medium { color: var(--sev-medium); }
.sev-warning { color: var(--sev-warning); } .sev-low { color: var(--sev-low); } .sev-info { color: var(--sev-info); }
.sevtag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.sevtag.sev-critical { background: var(--sev-critical-soft); } .sevtag.sev-high { background: var(--sev-high-soft); }
.sevtag.sev-medium { background: var(--sev-medium-soft); } .sevtag.sev-warning { background: var(--sev-warning-soft); }
.sevtag.sev-low { background: var(--sev-low-soft); } .sevtag.sev-info { background: var(--sev-info-soft); }
.sevtag::before { display: none; }

/* ── tables ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th {
  position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 500; font-size: 12.5px;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl tbody tr.is-link { cursor: pointer; }
.tbl tbody tr.is-link:hover td { background: #fbfbfd; }
.tbl th button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: inherit;
}
.tbl th button:hover { color: var(--ink); }
.tbl th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.tbl th[aria-sort] button { color: var(--ink); }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-title { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.cell-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.cell-wrap { white-space: normal; max-width: 520px; min-width: 170px; overflow-wrap: break-word; }
.delta { font-size: 12.5px; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.progress { height: 6px; background: var(--sunken); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s var(--ease); }

/* ── states ─────────────────────────────────────────── */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty p { margin: 0 auto 14px; max-width: 460px; }
.loading { display: flex; align-items: center; gap: 10px; padding: 28px 20px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px; border: 1px solid;
}
.alert .i { margin-top: 2px; }
.alert.down { background: var(--down-soft); color: #7f2415; border-color: #f0c9c0; }
.alert.warn { background: var(--warn-soft); color: #6b3f06; border-color: #f1d7ab; }
.alert.info { background: var(--info-soft); color: #1f4280; border-color: #c9d7f2; }
.alert .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 60; max-width: 420px;
  background: var(--ink); color: #fff; border-radius: var(--radius); padding: 11px 14px;
  font-size: 13px; box-shadow: var(--shadow-pop);
  transform: translateY(8px); opacity: 0; transition: transform .35s var(--ease), opacity .35s var(--ease); pointer-events: none;
}
.toast.show { transform: none; opacity: 1; }
.note { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--ink-2); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.dl-total { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.dl-total b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── charts ─────────────────────────────────────────── */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 6px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 500 11px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }
.chart text.marker-lbl { stroke-width: 4px; }
.sort-ind { color: var(--accent); width: 12px; height: 12px; }
.sort-ind.asc { transform: rotate(180deg); }
.chart .grid line { stroke: var(--line); }
.chart .lbl-up { fill: var(--up); font-weight: 600; }
.chart .lbl-down { fill: var(--down); font-weight: 600; }
.chart .marker { stroke: var(--accent); stroke-dasharray: 3 3; }
.chart .marker-lbl { fill: var(--accent-ink); font-weight: 600; }
.chart .bars rect { transform-box: fill-box; transform-origin: bottom; }
@media (prefers-reduced-motion: no-preference) {
  .chart.rise .bars g { animation: rise .7s var(--ease) both; animation-delay: calc(var(--n) * 45ms); }
  @keyframes rise { from { transform: scaleY(.0001); transform-origin: 50% 100%; } }
}
.chart .bars g { transform-box: fill-box; transform-origin: 50% 100%; }

/* ── login / gate ───────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; }
.gate-card .brand { padding: 0 0 22px; }
.gate-card h1 { font-size: 20px; }
.gate-card p { color: var(--muted); margin: 6px 0 22px; }
.gate-card .btn { width: 100%; height: 40px; }
.gate-card .fine { font-size: 12.5px; margin: 16px 0 0; }

/* ── responsive ─────────────────────────────────────── */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n + 1) { border-left: 0; }
  .kpi:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: 280px; transform: translateX(-100%);
    transition: transform .3s var(--ease); box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(24, 24, 40, .3); z-index: 40; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .search { width: auto; flex: 1; }
  .topbar-spacer { display: none; } /* the search takes the free width, so its placeholder isn't cut */
  .kbd { display: none; }
  .crumbs { display: none; }
  .page { padding: 18px 16px 48px; }
  .grid-2-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .seg { max-width: 100%; overflow-x: auto; }
  /* long-text tables become stacked rows on phones */
  .tbl.tbl-stack { min-width: 0; }
  .tbl.tbl-stack thead { display: none; }
  /* a card per row: name and text cells full width, numbers in a labelled 3-column grid */
  .tbl.tbl-stack tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .tbl.tbl-stack td { display: block; grid-column: 1 / -1; padding: 0 !important; border: 0; text-align: left; min-width: 0; }
  .tbl.tbl-stack td.num { grid-column: auto; color: var(--ink); font-weight: 500; }
  .tbl.tbl-stack td.num[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
  /* text cells after the first keep their column name, small, above the value */
  .tbl.tbl-stack td:not(.num):not(:first-child)[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
  .tbl.tbl-stack td:first-child { margin-bottom: 4px; }
  .tbl.tbl-stack td.hide-sm { display: none; } /* secondary on a phone; the domain page has it */
  .tbl.tbl-stack .row-actions { justify-content: flex-start; margin-top: 6px; }
  /* every number keeps its comparison: wrap instead of truncating */
  .kpi-label, .kpi-delta { white-space: normal; overflow: visible; text-overflow: clip; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .kpi:nth-child(2n + 1) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .entity-actions { margin-left: 0; width: 100%; }
}

/* whole-view loading placeholder */
.skel { display: grid; gap: 12px; }
.skel-line, .skel-block { height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--sunken) 0%, var(--line) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; }
.skel-block { border-radius: var(--radius); margin-top: 8px; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-line, .skel-block { animation: none; } }
