/* Palette values come from the dataviz reference palette; categorical slots 1-8
   are validated for CVD separation in both modes. Light mode's aqua/yellow/
   magenta sit below 3:1 on the surface, so the relief rule applies: legend
   swatches, direct end labels and the table view all carry identity without
   ever relying on hue alone. */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f4f4f1;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-soft: rgba(11, 11, 11, 0.06);
  --hover-wash: rgba(11, 11, 11, 0.045);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -16px rgba(11, 11, 11, 0.18);
  --good: #006300;
  --good-wash: rgba(12, 163, 12, 0.10);
  --bad: #d03b3b;
  --bad-wash: rgba(208, 59, 59, 0.10);
  --provisional: rgba(11, 11, 11, 0.035);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-soft: rgba(255, 255, 255, 0.06);
    --hover-wash: rgba(255, 255, 255, 0.06);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -16px rgba(0, 0, 0, 0.8);
    --good: #0ca30c;
    --good-wash: rgba(12, 163, 12, 0.16);
    --bad: #e66767;
    --bad-wash: rgba(230, 103, 103, 0.16);
    --provisional: rgba(255, 255, 255, 0.04);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-soft: rgba(255, 255, 255, 0.06);
  --hover-wash: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -16px rgba(0, 0, 0, 0.8);
  --good: #0ca30c;
  --good-wash: rgba(12, 163, 12, 0.16);
  --bad: #e66767;
  --bad-wash: rgba(230, 103, 103, 0.16);
  --provisional: rgba(255, 255, 255, 0.04);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Shell: fixed sidebar + scrolling main ---------- */
.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: 232px; flex: none; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px 16px;
  background: var(--surface-1);
  border-right: 1px solid var(--border-soft);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px; color: var(--text-primary);
}
.brand-logo {
  height: 46px; width: auto; max-width: 100%; display: block;
}
.login-logo {
  display: block; height: 72px; width: auto; max-width: 100%; margin: 0 auto 18px;
}
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--series-1); color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
  padding: 9px 11px; border-radius: 9px; text-align: left;
  transition: background 120ms, color 120ms;
}
.nav button svg { width: 18px; height: 18px; flex: none; opacity: 0.75; }
.nav button:hover { background: var(--hover-wash); color: var(--text-primary); }
.nav button[aria-current="page"] {
  background: var(--text-primary); color: var(--surface-1); font-weight: 550;
}
.nav button[aria-current="page"] svg { opacity: 1; }

.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 10px;
}
.whoami { display: flex; align-items: center; gap: 10px; padding: 0 4px; min-width: 0; }
.who-avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.who-block { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.who-name {
  font-size: 12.5px; font-weight: 550; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-role {
  font-size: 10.5px; font-weight: 550; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); background: none; border: 0; padding: 0;
}
.foot-actions { display: flex; gap: 6px; }
.foot-actions .ghost-btn {
  flex: 1; padding: 6px 8px; font-size: 12px; text-align: center; box-shadow: none;
}

.main {
  flex: 1; min-width: 0; max-width: 1240px;
  padding: 0 30px 72px; margin: 0 auto;
}

/* ---------- Header ---------- */
header.top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; padding: 30px 0 18px;
}
header.top h1 {
  font-size: 21px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.015em;
}
header.top .meta {
  font-size: 12.5px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
header.top .meta .dot { color: var(--axis); }

/* ---------- Filter row (one row, above everything it scopes) ---------- */
.filters {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 0 14px; margin-bottom: 10px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.segmented {
  display: inline-flex; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 9px; padding: 3px;
  box-shadow: var(--shadow);
}
.segmented button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 450; color: var(--text-secondary);
  padding: 5px 12px; border-radius: 6px; white-space: nowrap;
  transition: background 120ms, color 120ms;
}
.segmented button:hover { background: var(--hover-wash); color: var(--text-primary); }
.segmented button[aria-pressed="true"] {
  background: var(--text-primary); color: var(--surface-1); font-weight: 550;
}
.filters .spacer { flex: 1; }
.brand-select {
  appearance: none; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text-secondary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 30px 7px 13px; box-shadow: var(--shadow); max-width: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: background-color 120ms, color 120ms;
}
.brand-select:hover { color: var(--text-primary); }
.brand-select:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.pbn-status {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface-1); border: 1px solid var(--border-soft);
  font-size: 13px; color: var(--text-secondary);
}
.pbn-status.error { border-color: #e5484d; color: #e5484d; background: transparent; }
.pbn-status a { color: var(--series-1); font-weight: 550; }
.serps-search {
  appearance: none; font: inherit; font-size: 13px; max-width: 200px;
  color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px;
  box-shadow: var(--shadow);
}
.serps-search:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.api-params { margin: 4px 0 10px; padding-left: 18px; }
.api-params li { font-size: 13px; color: var(--text-secondary); margin: 5px 0; line-height: 1.5; }
.serp-mine td { background: color-mix(in srgb, var(--series-1) 16%, transparent); font-weight: 550; }
.serp-row { cursor: pointer; }
.serp-row:hover { background: var(--hover-wash); }
.serp-detail > td { background: var(--surface-1); padding: 6px 10px 12px; }
.serp-kw { margin: 4px 0 2px; }
.serp-kw th, .serp-kw td { font-size: 12.5px; }
#serps-meta.muted, .muted { color: var(--text-muted); }
.ghost-btn {
  appearance: none; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text-secondary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 13px;
  box-shadow: var(--shadow); transition: background 120ms, color 120ms;
}
.ghost-btn:hover { background: var(--hover-wash); color: var(--text-primary); }
.ghost-btn[aria-expanded="true"] {
  background: var(--text-primary); color: var(--surface-1); border-color: transparent;
}
.filters label.field {
  font-size: 11px; font-weight: 550; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted); margin-right: 1px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 22px 24px 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card > h2 {
  font-size: 14px; font-weight: 600; margin: 0 0 3px; letter-spacing: -0.005em;
}
.card > p.sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 18px; }
.card.loading { opacity: 0.45; transition: opacity 140ms; }

/* ---------- Hero ---------- */
/* Three columns that hold one row: the long delta sentence wraps inside its own
   column instead of pushing the sparkline onto a second line. */
.hero { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.hero .hero-main { flex: 0 0 auto; min-width: 190px; }
.hero .figure-label {
  font-size: 11px; font-weight: 550; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px;
}
.hero .figure {
  font-size: 56px; font-weight: 600; line-height: 1; letter-spacing: -0.03em;
  /* proportional figures - tabular would make a number like 121 look loose */
}
.hero .hero-facts {
  flex: 1 1 300px; min-width: 0;
  display: flex; flex-direction: column; gap: 9px; font-size: 13px;
  color: var(--text-secondary);
}
.hero .hero-facts b { font-weight: 600; color: var(--text-primary); }
.hero .hero-trend { flex: 0 0 240px; margin-left: auto; text-align: right; }
.hero .hero-trend .cap {
  font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
}

/* delta chip */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.chip.up { color: var(--good); background: var(--good-wash); }
.chip.down { color: var(--bad); background: var(--bad-wash); }
.chip.flat { color: var(--text-muted); background: var(--hover-wash); }

/* ---------- Stat tiles ---------- */
.tiles {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
}
.tile {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 15px 17px 13px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color 120ms;
}
.tile:hover { border-color: var(--border); }
.tile .tile-label {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  font-weight: 500; color: var(--text-secondary); margin-bottom: 9px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.tile .tile-value {
  font-size: 28px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em;
}
.tile .tile-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 10px; margin-top: 9px;
}
.tile .tile-foot > div:first-child { min-width: 0; }
.tile .tile-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Legend ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none;
}
.legend li { display: flex; }
.legend button {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  appearance: none; border: 1px solid var(--border-soft); background: var(--surface-2);
  padding: 4px 11px 4px 9px; border-radius: 999px; font: inherit; font-size: 12.5px;
  color: var(--text-secondary); transition: opacity 120ms, border-color 120ms;
}
.legend button:hover { border-color: var(--border); color: var(--text-primary); }
.legend button[aria-pressed="false"] { opacity: 0.4; }
.legend .key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.legend .val {
  color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 12px;
}

/* ---------- Chart ---------- */
.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-host svg:focus-visible { outline: 2px solid var(--series-1); outline-offset: 4px; border-radius: 6px; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axisline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.endlabel { fill: var(--text-secondary); font-size: 11.5px; font-weight: 500; }
.endlabel-num { fill: var(--text-primary); font-weight: 600; }
.leader { stroke: var(--axis); stroke-width: 1; fill: none; }
.crosshair { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-area { stroke: none; }
.series-dot { stroke: var(--surface-1); stroke-width: 2; }
.provisional-band { fill: var(--provisional); }
.provisional-cap { fill: var(--text-muted); font-size: 10px; letter-spacing: 0.02em; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 168px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.24);
  font-size: 12px; opacity: 0; transition: opacity 90ms;
}
.tooltip[data-show="1"] { opacity: 1; }
.tooltip .tt-head {
  font-size: 11px; color: var(--text-muted); margin-bottom: 7px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-soft);
}
.tooltip .tt-row { display: flex; align-items: center; gap: 9px; padding: 2.5px 0; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .tt-name {
  color: var(--text-secondary); flex: 1; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tooltip .tt-val {
  font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums;
}

/* ---------- Table view ---------- */
.table-host { overflow-x: auto; max-height: 560px; overflow-y: auto; border-radius: 10px; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td {
  text-align: right; padding: 7px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  color: var(--text-muted); font-weight: 550; font-size: 11px;
  letter-spacing: 0.03em; text-transform: uppercase;
  position: sticky; top: 0; background: var(--surface-1); z-index: 1;
}
table.data tbody tr:hover td { background: var(--hover-wash); }
table.data td { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
table.data td:first-child { color: var(--text-primary); font-weight: 450; }
table.data tfoot td {
  font-weight: 600; color: var(--text-primary); border-bottom: 0;
  position: sticky; bottom: 0; background: var(--surface-1);
  border-top: 1px solid var(--border);
}

/* ---------- Small multiples ---------- */
.multiples { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.multiple {
  border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 13px 15px 9px; background: var(--surface-1);
  transition: border-color 120ms;
}
.multiple:hover { border-color: var(--border); }
.multiple .m-head {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  font-weight: 500; color: var(--text-secondary); margin-bottom: 3px;
}
.multiple .m-val {
  font-size: 20px; font-weight: 600; color: var(--text-primary);
  letter-spacing: -0.015em; margin-bottom: 2px;
}

/* ---------- Site picker ---------- */
.picker {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.picker-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 13px; }
.picker-head input[type="search"] {
  flex: 1; min-width: 190px; font: inherit; font-size: 13px;
  padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
}
.picker-head input[type="search"]:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent;
}
.picker-count { font-size: 12px; color: var(--text-muted); }
.picker-list {
  max-height: 280px; overflow-y: auto; display: grid; gap: 2px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.picker-list label {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--text-secondary);
}
.picker-list label:hover { background: var(--hover-wash); }
.picker-list label.on { color: var(--text-primary); background: var(--surface-2); }
.picker-list label:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.picker-list .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--axis); }
.picker-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list .ct { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.picker-list input { accent-color: var(--series-1); }

.notice {
  border: 1px solid var(--border-soft); border-radius: 12px; padding: 13px 16px;
  background: var(--surface-1); font-size: 13px; color: var(--text-secondary);
  margin-bottom: 18px; box-shadow: var(--shadow);
}
.notice b { color: var(--text-primary); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- Narrow viewports: the sidebar becomes a top rail ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: auto; height: auto; flex-direction: row;
    align-items: center; gap: 10px; padding: 10px 16px;
    border-right: 0; border-bottom: 1px solid var(--border-soft);
    overflow-x: auto;
  }
  .brand { padding: 0 6px 0 0; }
  .brand-text { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav button { white-space: nowrap; padding: 8px 12px; }
  .sidebar-foot {
    margin-top: 0; margin-left: auto; padding-top: 0; border-top: 0;
    flex-direction: row; align-items: center; gap: 10px;
  }
  .who-block { display: none; }
  .main { padding: 0 18px 56px; }
  header.top { padding: 22px 0 14px; }
  .hero { gap: 22px; }
}

@media (max-width: 620px) {
  .nav button span { display: none; }        /* icons only when space is tight */
  .nav button { padding: 8px 10px; }
  .foot-actions .ghost-btn { padding: 6px 9px; }
  .main { padding: 0 14px 48px; }
  .hero .figure { font-size: 44px; }
  .hero .hero-trend { margin-left: 0; text-align: left; width: 100%; }
  .card { padding: 18px 16px 16px; }
  .filters { gap: 8px; }
}

/* ---------- Coverage ---------- */
.coverage-bar {
  display: flex; height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); gap: 2px;   /* the 2px surface gap, not a border */
}
.coverage-bar span { display: block; height: 100%; }
.coverage-key {
  display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 13px; font-size: 12.5px;
  color: var(--text-secondary);
}
.coverage-key .item { display: flex; align-items: center; gap: 8px; }
.coverage-key .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.coverage-key b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
#missing-search {
  width: 100%; font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
  margin-bottom: 10px;
}
.missing-list {
  max-height: 300px; overflow-y: auto; display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  font-size: 12.5px; color: var(--text-secondary);
}
.missing-list div {
  padding: 4px 8px; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.missing-list div:nth-child(odd) { background: var(--hover-wash); }

/* ---------- Keyword bar chart ---------- */
.bar-label {
  fill: var(--text-primary); font-size: 12.5px;
}
.bar-value {
  fill: var(--text-secondary); font-size: 11.5px; font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.kw-coverage {
  font-size: 12.5px; color: var(--text-secondary); margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--border-soft);
}
.kw-coverage b { color: var(--text-primary); font-weight: 600; }

/* ---------- Accounts ---------- */
.accounts {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.accounts h2 { font-size: 14px; font-weight: 600; margin: 0 0 3px; }
.accounts .sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 16px; }
.account-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border-soft);
  border-radius: 11px; margin-bottom: 8px; background: var(--surface-2);
}
.account-row .who { flex: 1; min-width: 220px; }
.account-row .em {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  word-break: break-all;
}
.account-row .pr { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.account-row .count {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.account-row .count span { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.account-row .bad { color: var(--bad); font-size: 12px; }
.btn-danger {
  appearance: none; font: inherit; font-size: 12.5px; cursor: pointer;
  color: var(--text-secondary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px;
}
.btn-danger:hover { color: var(--bad); border-color: var(--bad); }
.btn-danger[data-confirm="1"] { color: var(--surface-1); background: var(--bad); border-color: var(--bad); }

.account-add { margin-top: 16px; }
.add-drop {
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  text-align: center; padding: 22px 18px; cursor: pointer;
  border: 1px dashed var(--axis); border-radius: 12px;
  color: var(--text-secondary); transition: border-color 120ms, background 120ms;
}
.add-drop:hover, .add-drop.over { border-color: var(--series-1); background: var(--hover-wash); }
.add-drop b { color: var(--text-primary); font-size: 13.5px; font-weight: 600; }
.add-drop span { font-size: 12.5px; color: var(--text-muted); }
.add-status { font-size: 12.5px; margin-top: 11px; min-height: 18px; }
.add-status.ok { color: var(--good); }
.add-status.err { color: var(--bad); }
.add-status.busy { color: var(--text-muted); }
.add-help { margin-top: 14px; font-size: 12.5px; color: var(--text-secondary); }
.add-help summary { cursor: pointer; color: var(--text-muted); }
.add-help ol { margin: 10px 0 0; padding-left: 20px; line-height: 1.7; }
.add-help code {
  font-size: 11.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
}

/* ---------- Loading indicator ---------- */
.loading-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--series-1); display: inline-block; margin-right: 3px;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loading-dot { animation: none; opacity: 0.7; } }

/* ---------- Sync status ---------- */
.sync-line {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted); margin-top: 5px;
}
.sync-line .pip {
  width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--good);
}
.sync-line .pip.busy { background: var(--series-1); animation: pulse 1.1s ease-in-out infinite; }
.sync-line .pip.bad { background: var(--bad); }
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--good-wash); color: var(--good);
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 550;
}
.sync-badge.gone { background: var(--hover-wash); color: var(--text-secondary); }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface-1);
  border: 1px solid var(--border-soft); border-radius: 16px;
  padding: 32px 30px; box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.015em;
}
.login-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 24px; }
.login-card label {
  display: block; font-size: 12px; font-weight: 550; color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 12px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--page); color: var(--text-primary); margin-bottom: 16px;
}
.login-card input:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent;
}
.login-btn {
  width: 100%; appearance: none; border: 0; cursor: pointer; font: inherit;
  font-size: 14px; font-weight: 550; padding: 10px 14px; border-radius: 9px;
  background: var(--text-primary); color: var(--surface-1); margin-top: 4px;
}
.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.55; cursor: default; }
.login-error {
  font-size: 12.5px; color: var(--bad); margin: 14px 0 0; min-height: 1em;
  display: none;
}
.login-error.show { display: block; }

/* ---------- View container ---------- */
.view { padding-top: 4px; }

/* ---------- Users ---------- */
.user-form { margin-top: 4px; }
.uf-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.uf-field { flex: 1; min-width: 160px; }
.uf-field.uf-narrow { flex: 0 0 130px; min-width: 130px; }
.uf-field label {
  display: block; font-size: 12px; font-weight: 550;
  color: var(--text-secondary); margin-bottom: 6px;
}
.uf-field input, .uf-field select {
  width: 100%; font: inherit; font-size: 13.5px; padding: 8px 11px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--page); color: var(--text-primary);
}
.uf-submit { width: auto; margin-top: 0; padding: 9px 18px; }
.uf-hint { font-size: 12px; color: var(--text-muted); margin: 12px 0 0; }
.user-row .who { flex: 1; min-width: 200px; }
.user-row .um { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.user-row select {
  font: inherit; font-size: 12.5px; padding: 5px 9px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
.user-row .self {
  font-size: 11px; font-weight: 550; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--series-1);
}

/* ---------- Period picker ---------- */
.range-picker { position: relative; }
.range-trigger { display: flex; align-items: center; gap: 8px; }
.range-trigger svg { width: 14px; height: 14px; opacity: 0.6; }
.range-trigger[aria-expanded="true"] {
  background: var(--text-primary); color: var(--surface-1); border-color: transparent;
}
.range-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 244px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; box-shadow: 0 12px 34px -10px rgba(0, 0, 0, 0.28);
}
.range-menu > button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  font-size: 13px; color: var(--text-secondary); text-align: left;
  padding: 8px 10px; border-radius: 8px;
}
.range-menu > button:hover { background: var(--hover-wash); color: var(--text-primary); }
.range-menu > button::before {
  content: "✓"; width: 16px; flex: none; font-size: 16px; font-weight: 700;
  color: var(--text-primary); opacity: 0;      /* selection, not hover, gets the check */
}
.range-menu > button[aria-checked="true"] { color: var(--text-primary); font-weight: 550; }
.range-menu > button[aria-checked="true"]::before { opacity: 1; }

.range-custom { border-top: 1px solid var(--border-soft); margin-top: 6px; padding: 12px 10px 8px; }
.rc-fields { display: flex; gap: 10px; }
.rc-fields label {
  flex: 1; display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; font-weight: 550; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.rc-fields input {
  font: inherit; font-size: 12.5px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
  text-transform: none; letter-spacing: 0;
}
.rc-apply { width: 100%; margin-top: 10px; padding: 8px 12px; font-size: 13px; }
.rc-note { font-size: 11.5px; color: var(--text-muted); margin: 8px 0 0; }
.rc-note.bad { color: var(--bad); }

/* ---------- Load progress ---------- */
.progress {
  position: sticky; top: 0; z-index: 60; height: 2px;
  background: transparent; overflow: hidden; opacity: 0;
  transition: opacity 140ms;
}
.progress.on { opacity: 1; }
.progress span {
  display: block; height: 100%; width: 34%; border-radius: 2px;
  background: var(--series-1);
  animation: slide 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(390%); }
}
@media (prefers-reduced-motion: reduce) {
  .progress span { animation: none; width: 100%; opacity: 0.5; }
}

/* the period button says what it is doing */
.range-trigger.busy { opacity: 0.65; pointer-events: none; }
.card.loading { position: relative; }

/* ---------- Phishing reporter ---------- */
.segmented .pill {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--hover-wash); color: var(--text-muted);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.segmented button[aria-pressed="true"] .pill {
  background: rgba(255, 255, 255, 0.22); color: inherit;
}

.ph-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; word-break: break-all;
}
.ph-sub { font-size: 11.5px; color: var(--text-muted); }
.ph-err { font-size: 11.5px; color: var(--bad); margin-top: 3px; }
.ph-empty { color: var(--text-muted); text-align: center; padding: 26px 0 !important; }
.ph-actions { white-space: nowrap; display: flex; gap: 6px; }

.ph-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 550; letter-spacing: 0.01em;
  background: var(--hover-wash); color: var(--text-secondary);
}
.ph-badge.processing { background: var(--good-wash); color: var(--good); }
.ph-badge.flagged { background: var(--good-wash); color: var(--good); }

.ph-bar {
  display: block; width: 110px; height: 6px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.ph-bar span { display: block; height: 100%; background: var(--series-1); }
.ph-bar-cap {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.ph-add { margin: 4px 0 0; }
.ph-add textarea {
  width: 100%; font: inherit; font-size: 13.5px; padding: 8px 11px; resize: vertical;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--page); color: var(--text-primary);
}
#ph-queue-host, #ph-reported-host { margin-top: 16px; }

.ph-reason {
  border: 1px solid var(--border-soft); border-radius: 11px;
  background: var(--surface-2); padding: 14px 16px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.ph-reason .uf-field label {
  display: block; font-size: 12px; font-weight: 550;
  color: var(--text-secondary); margin-bottom: 6px;
}
.ph-reason input, .ph-reason textarea {
  width: 100%; font: inherit; font-size: 13.5px; padding: 8px 11px; resize: vertical;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--page); color: var(--text-primary);
}
.ph-reason textarea { line-height: 1.55; }
.ph-reason input:disabled, .ph-reason textarea:disabled {
  opacity: 0.75; cursor: default;
}
.ph-reason-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
#ph-new-reason { margin-top: 4px; }

.ph-log {
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
  padding: 6px 8px; border-radius: 7px; font-size: 12.5px;
  color: var(--text-secondary);
}
.ph-log:nth-child(odd) { background: var(--hover-wash); }
.ph-log.bad .ph-chan { color: var(--bad); }
.ph-chan {
  font-size: 11px; font-weight: 550; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted);
}
.ph-token {
  display: block; margin-top: 6px; padding: 9px 11px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; color: var(--text-primary); word-break: break-all;
  user-select: all;
}
.ph-db { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ph-db code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 8px; padding: 7px 11px;
  word-break: break-all;
}
.ph-db a { text-decoration: none; }
