/* Sightline by Nextwebi — one stylesheet, no framework, no build step.
   ============================================================================

   Organised as tokens → reset → layout → components → responsive. Everything is
   driven by the custom properties at the top, so a colour or a radius changes in
   one place.

   Two constraints shape the whole file:

   1. No webfont. The project is built to run offline with no toolchain, and a
      Google Fonts link makes first paint depend on the network — it would either
      block or flash a fallback on exactly the machines this is meant to work on.
      The system stack below resolves to Segoe UI Variable on Windows 11, SF on
      macOS and Roboto on Android: all three are modern and already installed.

   2. The class names are a contract with the view code (public/views-*.js builds
      the DOM by hand). Selectors are kept and restyled rather than renamed.
*/

/* ================================================================== tokens */

:root {
  color-scheme: light dark;

  /* Nextwebi: white and blue. Brand navy #223C81 and sky #149BD7, taken from
     the logo. Navy carries text, buttons and active states (it passes AA on
     white with room to spare); sky blue is the highlight — focus rings, the
     active marker on the rail, charts — because as text on white it only
     reaches ~3:1. Neutrals lean slightly blue so they sit with both. */
  --bg: #f4f7fc;
  --panel: #ffffff;
  --panel-2: #f5f8fd;
  --panel-3: #e9eff8;
  --border: #e1e8f2;
  --border-strong: #c7d3e5;
  --text: #0f1d3d;
  --text-2: #34466e;
  --muted: #5f7096;

  --brand-navy: #223c81;
  --brand-sky: #149bd7;

  --accent: #223c81;
  --accent-hover: #1a2f68;
  --accent-soft: #e7f2fb;
  --accent-ring: rgb(20 155 215 / 0.28);
  --on-accent: #ffffff;

  /* Status colours stay green / amber / red: a "good" or "bad" signal must
     not look like the brand. Tuned cool so they sit with the blues. */
  --ok: #12804f;
  --ok-soft: #e3f4ea;
  --warn: #b26a00;
  --warn-soft: #fdf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;

  /* A five-step sequential ramp (one hue, dark-to-light), for a magnitude or
     rank encoding — e.g. "how much of this site's traffic lands in each
     position band" — where the *order* is the point. Brand navy to sky to
     pale, kept separate from the status colours. */
  --rank-1: #1b3170;
  --rank-2: #2459a8;
  --rank-3: #149bd7;
  --rank-4: #6dbfe7;
  --rank-5: #b5ddf2;

  /* Four categorical hues for series that are different things (the pages
     compared on one chart), in this fixed order. Checked with the palette
     validator for colour-blind separation and contrast on each surface. */
  --cat-1: #2459a8;
  --cat-2: #c4610f;
  --cat-3: #008f80;
  --cat-4: #8a4fc2;

  /* The rail is brand navy — the same blue as the logo tile — and stays a
     dark surface in both themes, which is what frames the content area. Its
     active marker is the brand sky blue. */
  --sidebar: #223c81;
  --sidebar-border: #2d4a93;
  --sidebar-text: #ffffff;
  --sidebar-text-2: #d6e0f3;
  --sidebar-muted: #a6b8de;
  --sidebar-hover: #2a4892;
  --sidebar-accent: #149bd7;
  --sidebar-accent-soft: #1d5a9e;

  /* Cool, navy-tinted shadows: a near one for the edge, a far one for lift. */
  --shadow-xs: 0 1px 2px rgb(15 29 61 / 0.06);
  --shadow-sm: 0 1px 2px rgb(15 29 61 / 0.07), 0 1px 3px rgb(15 29 61 / 0.05);
  --shadow-md: 0 2px 4px rgb(15 29 61 / 0.06), 0 6px 16px rgb(15 29 61 / 0.09);
  --shadow-lg: 0 4px 10px rgb(15 29 61 / 0.08), 0 20px 44px rgb(15 29 61 / 0.16);

  /* A notch tighter than a typical SaaS dashboard's bubbly radii — crisper
     corners read as tailored rather than playful. */
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* A 4px rhythm. Named by size so a value is chosen, not invented. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  --fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --med: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-w: 244px;
  --content-max: 1280px;
}

/* Dark values are written twice on purpose: once for the system preference and
   once for an explicit choice from the theme toggle. Without a build step there
   is no way to share one block between a media query and a selector, and the
   alternative — one list of overrides per property — is far harder to read.
   The rail stays a dark navy surface in both themes; dark mode only deepens it
   so it frames the page instead of glowing beside it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1225;
    --panel: #111a31;
    --panel-2: #152039;
    --panel-3: #1b2846;
    --border: #22314f;
    --border-strong: #2f4268;
    --text: #e8eefb;
    --text-2: #c2cde4;
    --muted: #8d9cbc;

    --accent: #4cb3e6;
    --accent-hover: #74c6ef;
    --accent-soft: #12304a;
    --accent-ring: rgb(76 179 230 / 0.3);
    --on-accent: #06142b;

    --ok: #3fbf8a;
    --ok-soft: #12301f;
    --warn: #e0a03a;
    --warn-soft: #33260f;
    --bad: #f07a72;
    --bad-soft: #3a1a1c;

    --rank-1: #8fd0f2;
    --rank-2: #4cb3e6;
    --rank-3: #2f86c4;
    --rank-4: #2a5f9e;
    --rank-5: #233f73;

    --cat-1: #4a88dc;
    --cat-2: #d9752a;
    --cat-3: #16a68e;
    --cat-4: #a874dc;

    /* A deeper navy rail, so it frames the dark page instead of glowing. */
    --sidebar: #0e1834;
    --sidebar-border: #1d2a4c;
    --sidebar-hover: #172447;
    --sidebar-accent-soft: #16345e;

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.32);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.38), 0 1px 3px rgb(0 0 0 / 0.32);
    --shadow-md: 0 2px 4px rgb(0 0 0 / 0.38), 0 6px 18px rgb(0 0 0 / 0.42);
    --shadow-lg: 0 6px 14px rgb(0 0 0 / 0.44), 0 22px 48px rgb(0 0 0 / 0.58);
  }
}

:root[data-theme='dark'] {
  --bg: #0b1225;
  --panel: #111a31;
  --panel-2: #152039;
  --panel-3: #1b2846;
  --border: #22314f;
  --border-strong: #2f4268;
  --text: #e8eefb;
  --text-2: #c2cde4;
  --muted: #8d9cbc;

  --accent: #4cb3e6;
  --accent-hover: #74c6ef;
  --accent-soft: #12304a;
  --accent-ring: rgb(76 179 230 / 0.3);
  --on-accent: #06142b;

  --ok: #3fbf8a;
  --ok-soft: #12301f;
  --warn: #e0a03a;
  --warn-soft: #33260f;
  --bad: #f07a72;
  --bad-soft: #3a1a1c;

  --rank-1: #8fd0f2;
  --rank-2: #4cb3e6;
  --rank-3: #2f86c4;
  --rank-4: #2a5f9e;
  --rank-5: #233f73;

  --cat-1: #4a88dc;
  --cat-2: #d9752a;
  --cat-3: #16a68e;
  --cat-4: #a874dc;

  /* A deeper navy rail, so it frames the dark page instead of glowing. */
  --sidebar: #0e1834;
  --sidebar-border: #1d2a4c;
  --sidebar-hover: #172447;
  --sidebar-accent-soft: #16345e;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.32);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.38), 0 1px 3px rgb(0 0 0 / 0.32);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.38), 0 6px 18px rgb(0 0 0 / 0.42);
  --shadow-lg: 0 6px 14px rgb(0 0 0 / 0.44), 0 22px 48px rgb(0 0 0 / 0.58);
}

/* =================================================================== reset */

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Numbers line up in every table and card without each one asking. */
  font-variant-numeric: tabular-nums;
}

/* The view code toggles the `hidden` attribute to show and hide things. Any
   author `display` rule outranks the browser's own `[hidden] { display: none }`,
   whatever the specificity, because author styles win over the user-agent
   origin. Several components below set `display`, so without this the selection
   bar would never hide — it would sit on screen showing a stale count. */
[hidden] { display: none !important; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 2px;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.011em; }

::selection { background: var(--accent-soft); color: var(--text); }

/* A focus ring that is always visible against any background: a solid accent
   outline plus a soft halo. Applied once, here, rather than per component. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbars, so a tall table does not punch a grey slab through the design. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ================================================================== layout */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

#sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* The Nextwebi mark (inline SVG in index.html, so it stays crisp and needs no
   request) beside the product name. */
.brand {
  padding: var(--s5) var(--s4) var(--s4);
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark { width: 34px; height: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand .name {
  color: var(--sidebar-text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.brand .sub { font-size: 11.5px; font-weight: 550; color: var(--sidebar-muted); letter-spacing: 0.01em; }

#site-picker {
  padding: 0 var(--s3) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}
#site-picker select {
  width: 100%;
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  border-color: var(--sidebar-border);
}
#site-picker select:hover { border-color: var(--sidebar-accent); }
#site-picker select:focus-visible { border-color: var(--sidebar-accent); box-shadow: 0 0 0 3px var(--sidebar-accent-soft); }
#site-picker .through { font-size: 11.5px; color: var(--sidebar-muted); padding-left: 2px; }

#nav { padding: var(--s2); flex: 1 1 auto; }

#nav button {
  appearance: none;
  position: relative;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-2);
  font: inherit;
  font-size: 13.8px;
  padding: 8px 10px;
  margin-bottom: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  transition: background var(--fast), color var(--fast);
}
.nav-icon { display: inline-grid; place-items: center; width: 20px; flex: none; color: var(--sidebar-muted); transition: color var(--fast); }
.nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav button:hover .nav-icon { color: var(--sidebar-text); }
#nav button[aria-current='true'] .nav-icon { color: var(--sidebar-accent); }
#nav button:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* White text on a white tint: the rail is blue, so sky-blue text on it would
   be blue-on-blue. The sky accent lives in the bar below instead. */
#nav button[aria-current='true'] {
  background: rgb(255 255 255 / 0.13);
  color: var(--sidebar-text);
  font-weight: 600;
}
/* A bar on the active item, so the current section is findable without relying
   on the background tint alone — which is nearly invisible in bright sunlight
   and absent entirely in forced-colours mode. */
#nav button[aria-current='true']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-accent);
}

#nav .group {
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sidebar-muted);
  padding: var(--s4) 10px var(--s1);
}
#nav .group:first-child { padding-top: var(--s1); }

#nav .count {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--sidebar-hover);
  color: var(--sidebar-muted);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
  line-height: 1.6;
}
#nav button[aria-current='true'] .count { background: var(--sidebar-accent); color: #06142b; }
#nav .count.red { background: var(--bad); color: #fff; }
#nav .count.amber { background: var(--warn); color: #fff; }

#sidebar-foot {
  padding: var(--s3);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  gap: var(--s1);
  flex-wrap: wrap;
}
#sidebar-foot .btn {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-2);
  border-color: var(--sidebar-border);
  box-shadow: none;
}
#sidebar-foot .btn:hover:not(:disabled) {
  background: var(--sidebar-accent-soft);
  color: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
}

#content { min-width: 0; display: flex; flex-direction: column; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  /* Opaque first, so a browser without color-mix() still gets a readable bar. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.title-block { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.25;
}
.page-context { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; font-size: 12.5px; color: var(--muted); }
.page-context:empty { display: none; }
.ctx-site { color: var(--text-2); font-weight: 600; }
.ctx-sep { opacity: 0.55; }

.ai-chip {
  appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 12px 5px 10px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast), color var(--fast);
}
.ai-chip:hover { border-color: var(--border-strong); color: var(--text); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--panel-3); }
.ai-chip.live .ai-dot { background: var(--brand-sky, #149bd7); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-sky, #149bd7) 22%, transparent); }

/* The dashboard-wide date range. Shaped like the AI chip beside it. */
#range-picker:empty { display: none; }
.range-chip {
  appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 11px 5px 10px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  transition: border-color var(--fast), background var(--fast);
}
.range-chip:hover, .range-chip[aria-expanded='true'] { border-color: var(--border-strong); background: var(--panel-2); }
.range-icon { display: inline-grid; color: var(--accent); }
.range-dates { font-weight: 500; color: var(--muted); }
.range-dates::before { content: '·'; margin-right: 7px; opacity: 0.6; }
.range-caret { color: var(--muted); font-size: 10px; }
.range-vs { font-weight: 500; color: var(--text-2); }
.range-vs::before { content: '·'; margin-right: 7px; opacity: 0.6; color: var(--muted); }
.range-compare { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.range-compare select { width: 100%; }
.range-fields select { width: 100%; }
.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.range-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.range-fields input { width: 100%; }
@media (max-width: 860px) {
  .range-dates { display: none; }
  .range-fields { grid-template-columns: 1fr; }
}

/* Site audit: one collapsible block per issue. */
.audit-issue { border: 1px solid var(--border); border-radius: var(--radius, 10px); padding: 10px 12px; margin-bottom: 8px; background: var(--panel); }
.audit-issue > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; list-style: none; }
.audit-issue > summary::-webkit-details-marker { display: none; }
.audit-issue > summary::before { content: '▸'; color: var(--muted); width: 12px; }
.audit-issue[open] > summary::before { content: '▾'; }
.audit-count { margin-left: auto; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* A desktop Google result at Google's own type sizes, for judging truncation. */
.serp { background: #fff; color: #202124; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; max-width: 652px; font-family: Arial, sans-serif; overflow: hidden; }
.serp-url { font-size: 14px; color: #202124; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serp-crumbs { color: #4d5156; }
.serp-title { font-size: 20px; line-height: 1.3; color: #1a0dab; margin: 4px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.serp-desc { font-size: 14px; line-height: 1.58; color: #4d5156; }
.serp-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-family: inherit; }
.chip-row { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.meta-opt { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.meta-opt.failed { opacity: 0.7; border-style: dashed; }

.user-btn {
  appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast), background var(--fast);
}
.user-btn:hover, .user-btn[aria-expanded='true'] { border-color: var(--border-strong); background: var(--panel-2); }
.user-name { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-caret { display: inline-grid; color: var(--muted); }
#topbar .icon-btn { width: 34px; height: 34px; }
#topbar .spacer { flex: 1 1 auto; }
#topbar .meta { font-size: 12.5px; color: var(--muted); }

main {
  padding: 24px 28px 96px;
  max-width: var(--content-max);
  width: 100%;
}

/* The sign-in and password screens replace the whole shell. */
body.signed-out #app { display: block; }
#signin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s6);
  padding: var(--s6) var(--s4);
  /* A quiet wash of the brand blues behind the card. */
  background:
    radial-gradient(900px 480px at 50% -10%, color-mix(in srgb, var(--brand-sky, #149bd7) 14%, transparent), transparent 70%),
    var(--bg);
}
#signin .panel { width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }

.signin-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.signin-brand img { width: 240px; height: auto; }
.signin-product { font-size: 13px; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* Navy lettering on light backgrounds, white lettering on dark ones. Both the
   system preference and the theme toggle decide, like the colour tokens. */
.logo-on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .logo-on-light { display: none; }
  :root:not([data-theme='light']) .logo-on-dark { display: block; }
}
:root[data-theme='dark'] .logo-on-light { display: none; }
:root[data-theme='dark'] .logo-on-dark { display: block; }

/* ================================================================== panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--s5);
  overflow: hidden;
}

/* Sentence case at a readable size, not tiny uppercase. A panel heading is a
   label people read, and all-caps costs legibility for no gain in hierarchy
   once the weight and colour already carry it. */
.panel > h2 {
  margin: 0;
  padding: 14px 20px;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.012em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  min-height: 52px;
}
.panel > h2 .spacer { flex: 1 1 auto; }
.panel-body { padding: 18px 20px 20px; }
.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- metric cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: var(--s3);
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 15px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.card .k {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.card .v {
  font-size: 28px;
  font-weight: 680;
  letter-spacing: -0.035em;
  margin-top: 6px;
  line-height: 1.1;
  color: var(--text);
}
.card .d {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.8px;
  color: var(--muted);
  margin-top: 9px;
}
.card .d.up, .card .d.down { padding: 2px 9px 2px 7px; border-radius: var(--radius-pill); font-weight: 650; }
.card .d.up { color: var(--ok); background: var(--ok-soft); }
.card .d.down { color: var(--bad); background: var(--bad-soft); }
.card .trend { display: inline-grid; place-items: center; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }

/* ================================================================== tables */

table { width: 100%; border-collapse: collapse; font-size: 13.8px; }

th, td {
  text-align: left;
  padding: 9px var(--s3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  /* The sticky header needs its own bottom edge: a border on a sticky cell
     scrolls away with the row box in several engines. */
  box-shadow: inset 0 -1px 0 var(--border);
  border-bottom: 0;
}

td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--fast); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
tbody tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.table-wrap {
  overflow-x: auto;
  max-height: 620px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* A checkbox column takes exactly its own width, not a share of the table. */
td:has(> input[type='checkbox']),
th:has(> input[type='checkbox']) { width: 1%; white-space: nowrap; }

/* ================================================================ controls */

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  border: 1px solid transparent;
  vertical-align: baseline;
  letter-spacing: 0.005em;
}
.chip.grey { background: var(--panel-3); color: var(--muted); border-color: var(--border); }
.chip.blue { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.chip.green { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.chip.amber { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.chip.red { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.chip.tiny { font-size: 10px; padding: 1px 6px; vertical-align: middle; }

button.btn {
  appearance: none;
  font: inherit;
  font-size: 13.8px;
  font-weight: 550;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px var(--s3);
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--fast), transform var(--fast);
}
button.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
/* A press that moves. Without it a click on a fast machine gives no feedback at
   all, because the result arrives before the eye registers a colour change. */
button.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }

button.btn.primary {
  background: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, white) 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgb(15 29 61 / 0.18), inset 0 1px 0 rgb(255 255 255 / 0.14);
}
button.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}
button.btn.danger:hover:not(:disabled) {
  border-color: var(--bad);
  color: var(--bad);
  background: var(--bad-soft);
}
button.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
button.btn.sm { font-size: 12.8px; padding: 4px 10px; min-height: 28px; }

select,
input[type='text'],
input[type='number'],
input[type='url'],
input[type='search'],
input[type='password'],
input[type='email'],
textarea {
  font: inherit;
  font-size: 13.8px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 34px;
  max-width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast);
}
select:hover, input:hover, textarea:hover { border-color: var(--muted); }

/* Focus on a text field gets the halo instead of the outline: the ring sits on
   the border so the field reads as active, and an outline offset from a wide
   input looks like a selection box. */
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

select {
  /* Room for the native arrow, which otherwise sits on top of the text. */
  padding-right: var(--s6);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentcolor 50%),
    linear-gradient(135deg, currentcolor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea { width: 100%; resize: vertical; line-height: 1.55; }

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

label.field { display: block; margin-bottom: var(--s3); font-size: 12.8px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 5px; font-weight: 550; color: var(--text-2); }
label.field input, label.field select, label.field textarea { width: 100%; }
label.inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13.8px; color: var(--text); cursor: pointer; }

input[type='radio'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 2px 0 0;
  flex: none;
}

/* A labelled group that is not a single input (Users & keys > Add a user). */
.field-block { margin-bottom: var(--s3); }
.field-label { display: block; margin-bottom: 6px; font-size: 12.8px; font-weight: 550; color: var(--text-2); }

/* Radio options as cards: the description is what someone choosing needs. */
.choice-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s2); }
.choice {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.choice:focus-within { outline: 2px solid var(--accent-ring); outline-offset: 1px; }
.choice-title { display: block; font-weight: 600; font-size: 13.8px; color: var(--text); }
.choice-desc { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.site-picks { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }

pre.signin-details {
  margin: 0 0 var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  user-select: all;
}

.row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 var(--s4); }

/* ==================================================================== text */

.muted { color: var(--muted); }
.small { font-size: 12.8px; }
.strong { font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code {
  background: var(--panel-3);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.url { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* Inside a table cell, break-all backfires: a long URL squeezed into a narrow
   auto-layout column wraps one character per line, which inflates the row to
   the URL's height while leaving the rest of the row looking empty. A table
   row needs to stay compact and scannable, so the cell truncates instead —
   `.table-wrap`'s own horizontal scroll is what full-URL contexts (a note, a
   detail panel) rely on; nothing here removes that for them, since this only
   targets a `.url` that is itself inside a `<td>`. */
td .url {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  word-break: normal;
}

.note {
  font-size: 12.8px;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  padding: var(--s2) var(--s3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: var(--s3) 0;
}
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.note.bad { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.note.good { border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }

pre {
  font-family: var(--mono);
  font-size: 12.3px;
  line-height: 1.5;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.8px;
  padding: var(--s1) 0;
  font-weight: 550;
  transition: color var(--fast);
}
details > summary:hover { color: var(--accent); }
details[open] > summary { margin-bottom: var(--s2); }

dl.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s1) var(--s4); font-size: 13.8px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

ol.steps { margin: var(--s2) 0 0; padding-left: var(--s5); font-size: 12.8px; }
ol.steps li { margin: 3px 0; }

/* Used inside a button that is working — the one place a skeleton cannot go,
   because the button must keep its position and size. Everywhere else loads
   with a skeleton. */
.spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp 0.65s linear infinite;
  flex: 0 0 auto;
  vertical-align: -2px;
}
/* On a filled button the accent ring would be invisible against the accent
   background, so it borrows the button's own text colour instead. */
button.btn.primary .spin {
  border-color: color-mix(in srgb, var(--on-accent) 35%, transparent);
  border-top-color: var(--on-accent);
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ================================================================== toasts */

#toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: var(--s3);
  font-size: 13.2px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--med) both;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
/* Partial success — "3 added, 1 already on the watchlist" — is neither. */
.toast.warn { border-left-color: var(--warn); }
.toast .t { font-weight: 650; margin-bottom: 1px; }
.toast pre { margin-top: var(--s2); max-height: 170px; overflow: auto; }

/* ================================================================== alerts */

.alert {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s2);
  background: var(--panel);
  transition: box-shadow var(--fast), opacity var(--fast);
}
.alert:hover { box-shadow: var(--shadow-xs); }
.alert.critical { border-left-color: var(--bad); }
.alert.warning { border-left-color: var(--warn); }
.alert.info { border-left-color: var(--accent); }
.alert.good { border-left-color: var(--ok); }
.alert.is-read { opacity: 0.6; }
.alert .head { display: flex; gap: var(--s2); align-items: baseline; flex-wrap: wrap; margin-bottom: 3px; }
.alert .title { font-weight: 620; font-size: 14.2px; }
.alert .body { font-size: 13.2px; color: var(--text-2); }
.alert .foot { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s2); font-size: 12.2px; color: var(--muted); }
.alert table { font-size: 12.8px; margin-top: var(--s2); }

/* =============================================================== assistant */

#chat-wrap { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: var(--s4); align-items: start; }

.thread-list button {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font: inherit;
  font-size: 12.8px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--fast), color var(--fast);
}
.thread-list button:hover { background: var(--panel-3); color: var(--text); }
.thread-list button[aria-current='true'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

#chat-log { display: flex; flex-direction: column; gap: var(--s3); min-height: 220px; }

.msg { display: flex; flex-direction: column; gap: var(--s1); max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.msg .bubble {
  border-radius: var(--radius-lg);
  padding: var(--s3) var(--s4);
  font-size: 14.2px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}
/* The user's own turn is the one tail-less corner, which is what makes a thread
   scannable without reading the labels. */
.msg.user .bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  border-bottom-right-radius: var(--radius-sm);
}
.msg.assistant .bubble { background: var(--panel); border-bottom-left-radius: var(--radius-sm); }
.msg .bubble > :first-child { margin-top: 0; }
.msg .bubble > :last-child { margin-bottom: 0; }
.msg .bubble p { margin: 0 0 var(--s2); }
.msg .bubble ul, .msg .bubble ol { margin: 0 0 var(--s2); padding-left: var(--s5); }
.msg .bubble li { margin-bottom: var(--s1); }
.msg .bubble h4 { margin: var(--s3) 0 var(--s1); font-size: 13.8px; }
.msg.user .bubble code { background: rgb(255 255 255 / 0.2); color: inherit; }
.msg .tools { font-size: 11.5px; color: var(--muted); }

#composer { display: flex; gap: var(--s2); align-items: flex-end; margin-top: var(--s4); }
#composer textarea { flex: 1 1 auto; min-height: 44px; max-height: 180px; font-size: 14.2px; }

.suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s3); }
.suggestions button {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 5px var(--s3);
  font: inherit;
  font-size: 12.8px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.suggestions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* =============================================================== watchlist

   The Monitor toggle is quiet when off and solid when on, because it is read
   down a column of 200 rows: "is this one on?" has to be answerable by colour
   alone, without reading the label. */

.monitor-btn {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.monitor-btn.compact { font-size: 11px; padding: 5px 9px; }
.monitor-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.monitor-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.monitor-btn.on:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.monitor-btn:disabled { opacity: 0.55; cursor: default; }

/* The watchlist is the shared table; only the page cell and the expanded row
   need anything of their own. */
table.watchlist td:first-child { max-width: 420px; }
.wl-page { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wl-page .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-chev { color: var(--muted); font-size: 10px; flex: 0 0 auto; transition: transform var(--fast); }

/* The detail row spans every column, so it must not inherit the cell padding
   that keeps the table rows compact. */
.wl-detail-row > td { padding: var(--s1) var(--s4) var(--s5); background: var(--panel-2); }
.wl-detail-row > td > .wl-stack { max-width: 980px; }

/* ---- the verdict */

.verdict {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  margin: var(--s3) 0;
  border: 1px solid var(--border);
}
.verdict-icon { font-size: 13px; line-height: 1.5; }
.verdict-label { font-weight: 650; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.verdict.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.verdict.good .verdict-icon, .verdict.good .verdict-label { color: var(--ok); }
.verdict.mixed { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.verdict.mixed .verdict-icon, .verdict.mixed .verdict-label { color: var(--warn); }
.verdict.attention { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.verdict.attention .verdict-icon, .verdict.attention .verdict-label { color: var(--bad); }

.obs-count {
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--muted);
}

.obs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.obs {
  padding: var(--s3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--panel);
}
.obs.bad { border-left-color: var(--bad); }
.obs.warn { border-left-color: var(--warn); }
.obs.good { border-left-color: var(--ok); }
.obs-title { font-weight: 620; font-size: 13.5px; }
.obs-evidence { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
/* The action is the part someone acts on, so it is the part that stands out. */
.obs-action { font-size: 12.5px; margin-top: var(--s2); padding-top: var(--s2); border-top: 1px dashed var(--border); }

/* ---- sections inside an expanded row
   One stack, read top to bottom. A heading and a hairline rule are enough to
   separate them; nesting bordered cards inside an already-bordered row is what
   made this read as a dashboard. */

.wl-stack { display: flex; flex-direction: column; }
.wl-sec { margin: var(--s4) 0 0; }
.wl-sec > h4,
.pick-group > h4 {
  margin: 0 0 var(--s2);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.wl-sec > h4 > span:first-child { flex: 0 0 auto; }

.mini-list { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.mini-list > li {
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.mini-list .steps { margin: var(--s2) 0 0; padding-left: var(--s5); font-size: 12.5px; }
.mini-list .steps li { margin: 3px 0; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px var(--s4); margin: var(--s3) 0 0; font-size: 13.2px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.kw-filter { width: 100%; margin: var(--s2) 0; }
/* The full keyword set can be hundreds of rows, so it scrolls inside the panel
   rather than pushing the next page off screen. */
.kw-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ============================================================ bulk select

   The bar is sticky at the bottom of the viewport. Ticking rows happens while
   scrolling, and a button that scrolled away with the top of the table would
   leave people hunting for it. */

.sel-bar {
  position: sticky;
  bottom: var(--s3);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s3) 0 0;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: bar-in var(--med) both;
}
@keyframes bar-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.sel-bar .grow { flex: 1 1 auto; }

/* ============================================================== AI picker */

.picker-row { display: flex; gap: var(--s2); align-items: center; }
.picker-input { flex: 1 1 auto; min-width: 0; font-size: 14px; }

.picker-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--s3) 0 0; }
.chip-btn {
  font: inherit;
  font-size: 12px;
  padding: 5px var(--s3);
  cursor: pointer;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  transition: color var(--fast), border-color var(--fast), background var(--fast);
}
.chip-btn:hover { color: var(--accent); border-color: var(--accent); border-style: solid; background: var(--accent-soft); }

.picker-results { margin: var(--s4) 0 0; }
.picker-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-interp { margin: var(--s2) 0 0; font-size: 13.2px; }

.pick-group { margin: var(--s4) 0 0; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
/* A label, so the whole row is a hit target for its checkbox. */
.pick {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
}
.pick:hover { border-color: var(--accent); background: var(--accent-soft); }
.pick:has(> input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pick > input { margin-top: 3px; flex: 0 0 auto; }
.pick-body { min-width: 0; }
.pick-url { display: flex; align-items: center; gap: 7px; font-weight: 620; font-size: 13.5px; word-break: break-word; }
.pick-why { margin-top: 2px; color: var(--text-2); }
.pick-nums { margin-top: 2px; }

/* ============================================================ agent panels

   One per subject, collapsed until asked for. The trigger is deliberately quiet:
   these appear on six screens, and six boxes competing with the content would
   make the data harder to read, which is the opposite of the point. */

.ag { margin: var(--s3) 0 0; }

.ag-trigger {
  appearance: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.2px;
  font-weight: 550;
  padding: 9px var(--s3);
  cursor: pointer;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.ag-trigger:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ag-trigger.on {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.ag-spark { font-size: 12px; color: var(--accent); flex: 0 0 auto; }
.ag-hint { margin-left: auto; font-weight: 400; }
.ag-trigger.on .ag-hint { display: none; }

.ag-body {
  border: 1px solid var(--accent);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: var(--s3);
  background: var(--panel);
}
.ag-duty { margin: 0 0 var(--s3); }

.ag-log { display: flex; flex-direction: column; gap: var(--s3); }
.ag-log:empty { display: none; }

.ag-turn { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.ag-who { font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ag-user > div {
  align-self: flex-start;
  background: var(--panel-3);
  border-radius: var(--radius-sm);
  padding: 7px var(--s3);
}
.ag-agent > div { min-width: 0; }

/* A refusal is a boundary, not an error: amber, and labelled. */
.ag-scope-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  margin-bottom: 5px;
}

.ag-md > :first-child { margin-top: 0; }
.ag-md > :last-child { margin-bottom: 0; }
.ag-md p { margin: 0 0 var(--s2); }
.ag-md ul, .ag-md ol { margin: 0 0 var(--s2); padding-left: var(--s5); }
.ag-md li { margin-bottom: 3px; }
.ag-md h4 { margin: var(--s3) 0 var(--s1); font-size: 13.5px; }

.ag-served { margin: var(--s2) 0 0; font-size: 11px; }

.ag-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: var(--s3) 0 0; }
.ag-chips:empty { display: none; }

.ag-compose { display: flex; gap: var(--s2); margin: var(--s3) 0 0; }
.ag-input { flex: 1 1 auto; min-width: 0; }

/* =============================================================== skeletons

   A sweeping highlight over a neutral block. The sweep runs across the whole
   page rather than per element (`background-attachment: fixed`), so a column of
   twelve placeholders reads as one surface catching the light instead of twelve
   independent flashing boxes.

   Nothing here uses opacity on a parent: fading a whole skeleton in and out
   makes the page look like it is failing rather than working. */

.sk {
  display: block;
  border-radius: 5px;
  background-color: var(--panel-3);
  background-image: linear-gradient(
    100deg,
    transparent 20%,
    color-mix(in srgb, var(--panel) 85%, transparent) 42%,
    color-mix(in srgb, var(--panel) 85%, transparent) 58%,
    transparent 80%
  );
  background-size: 900px 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  animation: sk-sweep 1.5s linear infinite;
  flex: 0 0 auto;
}

@keyframes sk-sweep {
  from { background-position: -40vw 0; }
  to { background-position: 140vw 0; }
}

.sk-lines { display: flex; flex-direction: column; }
.sk-wrap { display: block; }

/* The panel chrome stays solid; only its contents are pending. */
.sk-panel > h2 { min-height: 44px; }

.sk-rowlist { display: flex; flex-direction: column; gap: var(--s2); }
.sk-row {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

/* A chart-shaped placeholder: axis stubs on the left, bars across the plot. */
.sk-chart { display: flex; gap: var(--s3); align-items: stretch; }
.sk-chart-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 2px 0 22px;
  flex: 0 0 auto;
}
.sk-chart-plot {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  gap: 2.5%;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.sk-chart-plot > .sk { border-radius: 4px 4px 0 0; min-width: 0; }

/* Visible to a screen reader, not on screen. The skeleton itself is
   aria-hidden, so this sentence is the only thing announced. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ================================================================== charts */

.chart { display: flex; flex-direction: column; gap: var(--s2); }

.chart-svg { position: relative; }
/* The crosshair is a DOM element rather than an SVG line so it can be moved by
   percentage without recomputing the viewBox on every pointer move. */
.chart-cross {
  position: absolute;
  top: 0;
  bottom: 22px;
  width: 1px;
  background: var(--accent);
  opacity: 0.5;
  pointer-events: none;
}

.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s3); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.chart-key > i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.chart-key > i.dash {
  width: 14px;
  height: 0;
  border-radius: 0;
  border-top: 2px dashed var(--muted);
  background: none;
}

.chart-readout {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: baseline;
  font-size: 12.5px;
  min-height: 20px;
}
.chart-val { display: inline-flex; align-items: center; gap: 5px; }
.chart-val > i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.chart-readout .up { color: var(--ok); font-weight: 600; }
.chart-readout .down { color: var(--bad); font-weight: 600; }

/* ---- horizontal bars */

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: center;
  font-size: 12.5px;
}
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--panel-3); border-radius: var(--radius-pill); height: 9px; overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--med);
}
.bar-value { color: var(--muted); white-space: nowrap; font-size: 12px; }

/* ---- one stacked bar of shares */

.share {
  display: flex;
  height: 14px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--panel-3);
}
.share-seg { display: block; height: 100%; }
.share-seg:not(:last-child) { border-right: 1px solid var(--panel); }
.share-keys { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s2); }

/* ---- insights */

.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.insight {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.insight.good { border-left-color: var(--ok); }
.insight.bad { border-left-color: var(--bad); }
.insight.neutral { border-left-color: var(--accent); }
.insight-icon { font-size: 11px; line-height: 1.6; flex: 0 0 auto; }
.insight.good .insight-icon { color: var(--ok); }
.insight.bad .insight-icon { color: var(--bad); }
.insight.neutral .insight-icon { color: var(--accent); }
.insight-text { font-weight: 600; font-size: 13.5px; }
.insight-detail { margin-top: 2px; }

/* ============================================================== responsive */

@media (max-width: 1040px) {
  .two-col { grid-template-columns: 1fr; }
  #chat-wrap { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  :root { --content-max: 100%; }

  #app { grid-template-columns: 1fr; }
  #sidebar { position: sticky; top: 0; z-index: 20; height: auto; border-right: 0; border-bottom: 1px solid var(--sidebar-border); }
  .brand { padding: var(--s3) var(--s4) var(--s2); }
  #site-picker { padding: 0 var(--s4) var(--s3); }

  /* The nav becomes one scrolling row of pills. Wrapping it into four rows of
     buttons pushed the actual content below the fold on a phone. With eight or
     more sections it never fits one screen width, so the trailing edge fades
     instead of hard-clipping — otherwise "Dashboard · Alerts · Rankings" reads
     as the whole list and nothing says Settings is one swipe further. */
  #nav {
    display: flex;
    gap: var(--s1);
    padding: 0 var(--s4) var(--s3);
    overflow-x: auto;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  }
  #nav::-webkit-scrollbar { display: none; }
  #nav button {
    width: auto;
    flex: 0 0 auto;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-pill);
    padding: 7px var(--s3);
    margin: 0;
  }
  #nav button[aria-current='true']::before { display: none; }
  #nav .group { display: none; }
  #sidebar-foot { padding: var(--s2) var(--s4); border-top: 0; }

  #topbar { padding: var(--s3) var(--s4); }
  #topbar h1 { font-size: 16.5px; }
  main { padding: var(--s4) var(--s4) 88px; }

  .wl-detail-row > td { padding: var(--s1) var(--s2) var(--s4); }
  table.watchlist td:first-child { max-width: 220px; }
  td .url { max-width: 160px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: var(--s2); }
  .picker-row { flex-wrap: wrap; }
  .picker-row > .btn { width: 100%; }
  .sel-bar { flex-wrap: wrap; }
  .msg { max-width: 100%; }
  #toasts { right: var(--s2); left: var(--s2); bottom: var(--s2); max-width: none; }
  /* The label column has to give way first, or a long URL squeezes the bar to
     nothing and the chart stops being a chart. */
  .bar-row { grid-template-columns: minmax(60px, 90px) minmax(0, 1fr) auto; }
  .chart-readout { font-size: 12px; gap: var(--s2); }

  /* Comfortable targets on a touch screen without inflating the desktop UI. */
  button.btn { min-height: 38px; }
  .monitor-btn { padding: 8px 12px; }
  input[type='checkbox'] { width: 18px; height: 18px; }
}

/* Honour a stated preference for less motion: keep the state changes, drop the
   movement. The spinner keeps turning, slowly — a frozen spinner reads as a
   hang, which is worse than the animation it was meant to avoid. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spin { animation: sp 1.4s linear infinite !important; animation-duration: 1.4s !important; }

  /* Skeletons still need to say "pending", so the sweep becomes a slow pulse in
     opacity rather than a travelling highlight. Stopping dead would leave a
     screenful of grey blocks that look like the real, empty content. */
  .sk {
    background-image: none !important;
    animation: sk-pulse 2s ease-in-out infinite !important;
    animation-duration: 2s !important;
    animation-iteration-count: infinite !important;
  }
}

@keyframes sk-pulse {
  0%, 100% { background-color: var(--panel-3); }
  50% { background-color: var(--panel-2); }
}

/* Forced colours (Windows high contrast): let the system palette through and
   keep the structural borders, which are the only thing left to read by. */
@media (forced-colors: active) {
  .panel, .card, .alert, .obs, .pick, .mini-list > li, .toast, .sel-bar { border: 1px solid CanvasText; }
  #nav button[aria-current='true'] { outline: 2px solid Highlight; }
  .chip { border: 1px solid CanvasText; }
}

/* ============================================================ team members
   Users & keys > Team members. Built to be scanned: who someone is, what they
   can do and whether they can sign in, at a glance; everything consequential
   one deliberate step away (the row menu, with confirmation). */

.panel-count { margin-left: auto; font-size: 12.5px; font-weight: 550; color: var(--muted); }

.team-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s3);
}

/* Segmented role filter */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.segmented .seg {
  appearance: none;
  font: inherit;
  font-size: 12.8px;
  font-weight: 550;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 3px);
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.segmented .seg:hover { color: var(--text); }
.segmented .seg[aria-pressed='true'] { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-count {
  font-size: 11px;
  font-weight: 650;
  min-width: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--panel-3);
  color: var(--muted);
  text-align: center;
}
.seg[aria-pressed='true'] .seg-count { background: var(--accent-soft); color: var(--accent); }

/* Search with its icon inside the field */
.team-search-wrap { position: relative; display: inline-flex; align-items: center; flex: 0 1 280px; color: var(--muted); }
.team-search-wrap > svg { position: absolute; left: 10px; pointer-events: none; }
.team-search-wrap .team-search { width: 100%; padding-left: 32px; }

/* The table */
table.team { border-collapse: separate; border-spacing: 0; }
table.team th { position: static; background: transparent; box-shadow: none; border-bottom: 1px solid var(--border); padding: 0 var(--s3) var(--s2); }
table.team td { vertical-align: middle; padding: 14px var(--s3); }
table.team tbody tr { transition: background var(--fast); }
table.team tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
table.team tbody tr.is-disabled .member,
table.team tbody tr.is-disabled .access { opacity: 0.55; }
table.team tr[hidden] { display: none !important; }
table.team .c-actions { width: 1%; text-align: right; padding-right: var(--s2); }
table.team .c-role { width: 1%; white-space: nowrap; }
table.team .c-member { width: 30%; }
table.team .c-status, table.team .c-last { white-space: nowrap; }

/* Member: avatar, name, email */
.member { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.member-text { min-width: 0; }
.member-name { display: flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.member-email { font-size: 12.8px; color: var(--muted); overflow-wrap: anywhere; }
.you-badge {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
}
.avatar {
  --tone: #223c81;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--tone) 16%, var(--panel));
  color: color-mix(in srgb, var(--tone) 78%, var(--text));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 22%, transparent);
}
.avatar.tone-0 { --tone: #223c81; }
.avatar.tone-1 { --tone: #149bd7; }
.avatar.tone-2 { --tone: #2a7f9e; }
.avatar.tone-3 { --tone: #4f5fb8; }
.avatar.tone-4 { --tone: #3b6f8f; }
.avatar.tone-5 { --tone: #5a6fa1; }

/* Role: a pill-shaped select, tinted by role (the word carries the meaning;
   the tint only speeds up scanning). */
.role-select, .role-pill {
  font-size: 12.8px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  min-height: 30px;
  padding: 4px 28px 4px 12px;
  border: 1px solid var(--border-strong);
  background-color: var(--panel);
  color: var(--text-2);
  cursor: pointer;
}
.role-pill { display: inline-flex; align-items: center; padding-right: 12px; cursor: default; }
.role-admin { background-color: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.role-editor { background-color: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.role-viewer { background-color: var(--panel-2); color: var(--text-2); }
.role-select:hover { border-color: currentcolor; }

/* Website access */
.access { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.access-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12.8px; color: var(--muted); }
.access-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 4px 2px 10px;
  min-height: 26px;
}
.access-role { font-size: 11px; font-weight: 650; color: var(--muted); padding-left: 6px; border-left: 1px solid var(--border); }
.access-x {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.access-x:hover { background: var(--bad-soft); color: var(--bad); }
.access-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.access-x svg { width: 12px; height: 12px; }
.access-none { font-size: 12.8px; color: var(--warn); }
.access-add .chip-btn { display: inline-flex; align-items: center; gap: 5px; }
.access-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.access-form select { min-height: 30px; padding-top: 4px; padding-bottom: 4px; font-size: 12.8px; min-width: 120px; }

/* Status */
.status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 7px; font-size: 13px; color: var(--text-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.active { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.locked { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.status-dot.disabled { background: var(--muted); box-shadow: 0 0 0 3px var(--panel-3); }
.status-sub { flex-basis: 100%; font-size: 11.5px; color: var(--warn); margin-top: 2px; }
.last-seen { font-size: 13px; color: var(--text-2); }
.last-seen.never { color: var(--muted); font-style: italic; }

.team-empty { display: grid; gap: 4px; justify-items: center; padding: var(--s6) var(--s4); color: var(--muted); font-size: 13px; text-align: center; }
.team-empty[hidden] { display: none; }
.team-empty strong { color: var(--text-2); font-size: 14px; }

/* Icon-only button (row menu, dialog close) */
.icon-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.icon-btn:hover:not(:disabled), .icon-btn[aria-expanded='true'] { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn:disabled { opacity: 0.6; cursor: progress; }

/* Row menu */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: menu-in var(--fast);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-3px); } }
.menu-item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--bad-soft); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }

/* Destructive confirm button */
button.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
button.btn.danger-solid:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 86%, #000); border-color: color-mix(in srgb, var(--bad) 86%, #000); color: #fff; }

/* Dialog */
dialog.dialog {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
}
dialog.dialog::backdrop { background: rgb(8 16 38 / 0.5); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: dialog-in var(--med); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
.dialog-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s4) 0 var(--s5); }
.dialog-head h3 { margin: 0; flex: 1; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.dialog-body { padding: var(--s3) var(--s5) var(--s4); font-size: 13.8px; color: var(--text-2); line-height: 1.55; }
.dialog-body > p { margin: 0 0 var(--s3); }
.dialog-body > :last-child { margin-bottom: 0; }
.dialog-body .choice-list { margin-bottom: var(--s3); }
.choice-list.stack { grid-template-columns: 1fr; }
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}
.dialog-foot:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .menu, dialog.dialog[open] { animation: none; }
}

/* Narrow screens: each person becomes a card. */
@media (max-width: 860px) {
  table.team thead { display: none; }
  table.team, table.team tbody { display: block; }
  table.team tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: 'member actions' 'role status' 'access access' 'last last';
    gap: 10px var(--s3);
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--border);
  }
  table.team td,
  table.team .c-member,
  table.team .c-role,
  table.team .c-actions { display: block; padding: 0; border: 0; width: auto; }
  table.team .c-member { grid-area: member; }
  table.team .c-actions { grid-area: actions; }
  table.team .c-role { grid-area: role; }
  table.team .c-status { grid-area: status; justify-self: end; }
  table.team .c-access { grid-area: access; }
  table.team .c-last { grid-area: last; font-size: 12px; }
  table.team .c-last::before { content: 'Last sign-in: '; color: var(--muted); }
  .team-search-wrap { flex: 1 1 100%; }
  /* The filter scrolls sideways rather than being cut off. */
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .segmented .seg { flex: none; }
}

/* =========================================================== refinements */

/* A view eases in rather than snapping, so switching sections feels calm. */
#view > * { animation: view-in 180ms ease-out both; }
@keyframes view-in { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { #view > * { animation: none; } }

/* Menu header (the account menu's name and email). */
.menu-head { padding: 8px 10px 7px; }
.menu-head-title { font-weight: 650; font-size: 13.5px; color: var(--text); }
.menu-head-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Small avatar for the top bar. */
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }

/* Toasts: a faint tint of their kind, so success and failure read at a glance. */
.toast.ok { background: color-mix(in srgb, var(--ok-soft) 45%, var(--panel)); }
.toast.err { background: color-mix(in srgb, var(--bad-soft) 45%, var(--panel)); }
.toast.warn { background: color-mix(in srgb, var(--warn-soft) 45%, var(--panel)); }

/* Phones: keep the top bar on one tidy line. */
@media (max-width: 860px) {
  #topbar { padding: 10px 16px; min-height: 0; }
  #topbar h1 { font-size: 17px; }
  .page-context { display: none; }
  .user-name { display: none; }
  .ai-chip span:last-child { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 16px 16px 80px; }
  /* Narrow cards: a wrapped change badge reads better as a soft rectangle. */
  .card .v { font-size: 24px; }
  .card .d { font-size: 11.2px; align-items: flex-start; line-height: 1.35; }
  .card .d.up, .card .d.down { border-radius: var(--radius-sm); padding: 3px 8px 3px 6px; }
  .card .trend { margin-top: 1px; }
}

/* ================================================== cards, tiles, insights */

/* Tone colours, shared by card icons, tiles, badges and meters. */
.tone-accent { --tone: var(--accent); --tone-soft: var(--accent-soft); }
.tone-ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.tone-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.tone-bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.tone-muted { --tone: var(--muted); --tone-soft: var(--panel-3); }
.tone-text-ok { color: var(--ok) !important; }
.tone-text-warn { color: var(--warn) !important; }
.tone-text-bad { color: var(--bad) !important; }
.tone-text-accent { color: var(--accent) !important; }

/* Metric card anatomy: icon tile + label (+ hint, + arrow), value, change, trend. */
.card { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; text-align: left; }
.card-head { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 20px; }
.card-head .k { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--tone, var(--accent));
  background: var(--tone-soft, var(--accent-soft));
}
.card.has-icon .v { margin-top: 12px; }
.card-hint { display: inline-grid; color: var(--muted); opacity: 0.6; cursor: help; position: relative; transition: opacity var(--fast); }
.card:hover .card-hint { opacity: 1; }
.card-hint::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: -8px;
  width: max-content;
  max-width: 230px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--panel);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity var(--fast), transform var(--fast);
}
.card-hint:hover::after, .card.is-link:focus-visible .card-hint::after { opacity: 1; transform: none; }
.card-go { display: inline-grid; color: var(--muted); opacity: 0; transform: translateX(-3px); transition: opacity var(--fast), transform var(--fast); }

button.card.is-link { appearance: none; font: inherit; color: inherit; cursor: pointer; width: 100%; }
.card.is-link:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card.is-link:hover .card-go, .card.is-link:focus-visible .card-go { opacity: 1; transform: none; color: var(--accent); }
.card.is-link:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.card.is-link:active { transform: none; box-shadow: var(--shadow-xs); }

.card-spark { width: 100%; margin-top: 12px; color: var(--brand-sky, var(--accent)); line-height: 0; }
.card-spark svg { display: block; overflow: visible; }
.card-meter { width: 100%; height: 6px; margin-top: 14px; border-radius: var(--radius-pill); background: var(--panel-3); overflow: hidden; }
.card-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--tone, var(--accent)); transition: width 400ms ease; }

/* Quick actions: the next places to go, with live counts. */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.qa {
  appearance: none;
  font: inherit;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.qa:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.qa:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.qa .card-icon { width: 38px; height: 38px; border-radius: 10px; }
.qa-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.qa-title { font-weight: 650; font-size: 13.8px; letter-spacing: -0.01em; }
.qa-sub { font-size: 12.3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-badge {
  flex: none;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--tone);
  background: var(--tone-soft);
}

/* "What changed" beside the visibility snapshot. */
.two-col.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.two-col > .panel { margin-bottom: 0; }
.two-col { margin-bottom: var(--s5); }

.snapshot { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; flex: none; width: 112px; height: 112px; }
.ring-svg, .ring-svg svg { display: block; }
.ring-svg circle:last-child { transition: stroke-dasharray 600ms ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-text strong { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.ring-text span { font-size: 11px; color: var(--muted); }
.snap-stats { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.snap-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); cursor: default; }
.snap-stat:last-child { border-bottom: 0; }
.snap-label { font-size: 12.8px; color: var(--text-2); }
.snap-stat strong { font-size: 14px; font-weight: 680; white-space: nowrap; }

/* Opportunities: three tabs that double as summary tiles. */
.opp-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.opp-tab {
  appearance: none;
  font: inherit;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
}
.opp-tab:hover { border-color: var(--border-strong); background: var(--panel); }
.opp-tab[aria-pressed='true'] { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.opp-tab:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.opp-tab-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.opp-tab-title { font-weight: 650; font-size: 13.8px; }
.opp-tab-count { font-size: 12.3px; color: var(--muted); }
.opp-tab-gain { font-size: 12px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.opp-blurb { margin: 16px 0 10px; font-size: 13px; color: var(--text-2); }

/* Table cells used by the opportunity lists. */
.cell-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-stack strong { font-weight: 600; }
.cell-sub { font-size: 11.8px; color: var(--muted); }
.gain { font-weight: 700; color: var(--ok); }
.ctr-vs { display: inline-flex; flex-direction: column; align-items: flex-end; }
.rank-badge { display: inline-block; min-width: 40px; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 650; font-size: 12.5px; text-align: center; }
.rank-badge.r1 { background: var(--ok-soft); color: var(--ok); }
.rank-badge.r2 { background: var(--accent-soft); color: var(--accent); }
.rank-badge.r3 { background: var(--warn-soft); color: var(--warn); }
.rank-badge.r4 { background: var(--panel-3); color: var(--muted); }
.share-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; font-size: 12.5px; color: var(--text-2); }
.share-track { flex: 1 1 auto; height: 6px; border-radius: var(--radius-pill); background: var(--panel-3); overflow: hidden; }
.share-track > span { display: block; height: 100%; background: var(--brand-sky, var(--accent)); border-radius: inherit; }
.ask-btn { white-space: nowrap; color: var(--accent); }
.ask-btn svg { color: var(--brand-sky, var(--accent)); }

/* Insights: icon in a soft disc, a touch more air. */
.insight { background: var(--panel); padding: 12px 14px; }
.insight-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 9px; line-height: 1; }
.insight.good .insight-icon { background: var(--ok-soft); }
.insight.bad .insight-icon { background: var(--bad-soft); }
.insight.neutral .insight-icon { background: var(--accent-soft); }

@media (max-width: 1040px) {
  .two-col.wide-left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .opp-tabs { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .qa { padding: 11px 12px; gap: 10px; }
  .qa .card-icon { width: 32px; height: 32px; }
  .qa-sub { white-space: normal; }
  .qa-badge { display: none; }
  .snapshot { flex-direction: column; align-items: stretch; }
  .ring { align-self: center; }
  .card-icon { width: 28px; height: 28px; border-radius: 8px; }
  .card-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card.is-link:hover, .qa:hover { transform: none; }
}

/* A long card label wraps to a second line rather than losing its end. */
.card-head .k { white-space: normal; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 860px) {
  .card-go { display: none; }
  .card-head { gap: 7px; }
  .card-head .k { letter-spacing: 0.03em; }
}

/* ---------------------------------------------------------------- watchlist plan */
/* A button that reads as a link: page paths that open the page report. */
.link-btn {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: var(--accent); cursor: pointer; text-align: left;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-radius: 3px; }

ol.steps.plan-actions > li { margin: 0 0 12px; }
.plan-action-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 4px 0 2px; }

.plan-overlaps { display: grid; gap: 10px; }
.plan-overlap { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--panel-2); }
.plan-overlap-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.plan-overlap-pages { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
.plan-overlap-pages > li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

/* Pages compared: a colour swatch ties each column to its line in the charts. */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
/* Page paths as column heads: as written, wrapping, so four fit side by side. */
.compare-table th:not(:first-child) {
  text-transform: none; letter-spacing: 0; font-weight: 600; white-space: normal;
  min-width: 140px; max-width: 260px;
}
.compare-table th .url { vertical-align: middle; font-size: 11.5px; color: var(--text-2); }
.compare-table td:first-child { white-space: nowrap; }
.compare-table td.best { font-weight: 600; color: var(--ok); }
#plan-compare:empty { display: none; }
/* The action filters scroll sideways on a phone rather than being cut off. */
#plan-actions .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
#plan-actions .segmented .seg { flex: 0 0 auto; }
