/* Operations UI stylesheet. Vendored, no CDN — the CSP allows only 'self' for
   scripts and styles, so every rule lives here and no template may carry an
   inline style= attribute (tests/web/test_security_headers.py).

   Layout of this file: tokens → base → controls → app shell → page furniture
   → tables → per-surface rules. Colours are tokens only; a literal hex below
   the token blocks is a bug unless it is a chart series (Okabe-Ito, fixed
   across themes on purpose). */

/* --- Font ---------------------------------------------------------------- */
/* Inter, vendored (static/fonts, OFL — licence beside it): a variable font,
   Latin subset, 48 KB. Built for dense UI; its tabular figures keep the price
   columns aligned. `swap` so text never waits on it. */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --- Tokens --------------------------------------------------------------- */
/* Light is the default; dark is opt-in per browser (the top-bar toggle, a
   cookie rendered onto <html data-theme>, app/web/prefs.py). Deliberately not
   prefers-color-scheme: light is the house default whatever the OS says. */
:root {
  color-scheme: light;

  /* Surfaces: page < raised (cards, tables) < sunken-but-light (table head,
     toolbars, group headers). Inputs sit on the raised surface, not the page,
     so a field in a card reads as a field, not a hole. */
  --bg: #f3f4f6;
  --card: #ffffff;
  --surface-2: #f7f8fa;
  --input-bg: #ffffff;
  --border: #dde1e6;
  --border-strong: #c3c9d1;
  --fg: #1b1e23;
  --muted: #5d6470;
  --accent: #2b6cb0;
  --accent-fill: #2b6cb0;
  --on-accent: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);

  /* Status vocabulary — one meaning each, everywhere: ok (fine), warn (worth a
     look), danger (refused, broken, rejected). Text colours clear 4.5:1 on
     their own 10 % tint in both themes. */
  --ok: #17703a;
  --warn: #855600;
  --danger: #b00020;
  --ok-bg: color-mix(in srgb, var(--ok) 10%, transparent);
  --warn-bg: color-mix(in srgb, var(--warn) 11%, transparent);
  --danger-bg: color-mix(in srgb, var(--danger) 9%, transparent);
  --ok-border: color-mix(in srgb, var(--ok) 32%, transparent);
  --warn-border: color-mix(in srgb, var(--warn) 36%, transparent);
  --danger-border: color-mix(in srgb, var(--danger) 32%, transparent);

  /* Competitor vs us (F3.1): deep red = they are cheaper, dark teal = dearer.
     A red/cyan pair rather than red/green for colour-blind readers; the teal is
     dark because bright cyan text fails contrast on white. */
  --cheaper: #a3001e;
  --dearer: #0e7490;

  --radius: 6px;
  --radius-lg: 8px;
  --shadow-pop: 0 6px 18px rgba(15, 20, 30, 0.16);

  /* One height and one padding for every form control on every page. Filter
     labels shrink their control's font to 0.82rem, so padding alone does not
     line a search box up with a dropdown — the min-height is what does. */
  --control-h: 2.1rem;
  --control-pad: 0.4rem 0.6rem;

  /* Height of the page chrome above a frozen table (top bar, sub-nav, page
     heading, filter bar, results bar). The frozen wrapper subtracts it so the
     table and the page do not both scroll. */
  --chrome-h: 15.5rem;
}
/* Dark: neutral, slightly cool greys with real steps between page, surface
   and raised layers — the first dark palette's page and card were 1.12:1. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1114;
    --card: #191c21;
    --surface-2: #20242a;
    --input-bg: #22262d;
    --border: #2e333b;
    --border-strong: #444b56;
    --fg: #e7e9ec;
    --muted: #9ea5b0;
    --accent: #7db4f0;
    /* A filled control keeps white text, so its fill is a darker blue than
       the link colour: white on #7db4f0 would be 2.3:1. */
    --accent-fill: #2f6db5;
    --on-accent: #ffffff;
    --ok: #74d896;
    --warn: #e8b64c;
    --danger: #ff8d9c;
    --ok-bg: color-mix(in srgb, var(--ok) 13%, transparent);
    --warn-bg: color-mix(in srgb, var(--warn) 13%, transparent);
    --danger-bg: color-mix(in srgb, var(--danger) 13%, transparent);
    --cheaper: #ff8d9c;
    --dearer: #5fd3ea;
    --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.55);
}

/* --- Base ----------------------------------------------------------------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Inter's large x-height reads a size up from the system face. */
  font-size: 14px;
  line-height: 1.45;
  /* Inter's alternates: an l with a tail and a serifed I, so codes and
     names (LB10420.6, Ventilator Il-…) cannot be misread. */
  font-feature-settings: "cv05", "cv08";
  color: var(--fg);
  background: var(--bg);
  accent-color: var(--accent-fill);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: var(--accent); text-underline-offset: 0.15em; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.6rem; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* One focus ring for everything a keyboard can reach. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link {
  position: absolute; left: 0.75rem; top: -3rem; z-index: 50;
  padding: 0.4rem 0.75rem; border-radius: var(--radius);
  background: var(--accent-fill); color: var(--on-accent); text-decoration: none;
}
.skip-link:focus { top: 0.5rem; }
main:focus { outline: none; }

/* --- Controls ------------------------------------------------------------- */
/* Every form control, everywhere. This rule used to read
   `.stack input, select, button`, where the `.stack` scope bound only to the
   first selector, so text fields in filter bars rendered as bare UA widgets
   beside styled dropdowns. Controls that are deliberately compact (the inline
   row write-backs) reset --control-h explicitly below; nothing else should
   re-declare padding. */
input[type="text"], input[type="search"], input[type="date"],
input[type="number"], input[type="password"], input[type="email"],
select, button {
  font: inherit;
  min-height: var(--control-h);
  padding: var(--control-pad);
  line-height: 1.25;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--fg);
}
input::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover { border-color: var(--muted); }

/* Buttons: three looks, nothing else.
     default  — bordered, raised surface (the base rule above + this)
     primary  — accent fill: the one action a form exists for
     ghost    — no border, muted: navigation-like actions (sign out, reset)
   plus a compact size for controls that live inside a table row. */
button { cursor: pointer; background: var(--card); }
button:hover { border-color: var(--accent); color: var(--accent); }
button:active { transform: translateY(1px); }
button[disabled], button[disabled]:hover {
  cursor: not-allowed; opacity: 0.5; transform: none;
  border-color: var(--border-strong); color: var(--fg);
}

.stack button, .stack-form button[type="submit"], .settings-form button[type="submit"],
.user-create-form button[type="submit"], .bulk-bar button[type="submit"],
.filters button[type="submit"] {
  background: var(--accent-fill); color: var(--on-accent); border-color: transparent;
  font-weight: 600;
}
.stack button:hover, .stack-form button[type="submit"]:hover,
.settings-form button[type="submit"]:hover, .user-create-form button[type="submit"]:hover,
.bulk-bar button[type="submit"]:hover, .filters button[type="submit"]:hover {
  color: var(--on-accent); background: color-mix(in srgb, var(--accent-fill) 86%, #000);
}
.bulk-bar button[type="submit"][disabled]:hover { background: var(--accent-fill); }
.stack button { margin-top: 0.5rem; }

/* Link-shaped buttons. An <a> ignores min-height until it is a flex box, so
   these would otherwise sit shorter than the fields beside them. */
.btn-reset {
  display: inline-flex; align-items: center;
  min-height: var(--control-h); padding: var(--control-pad);
  border: 1px solid transparent; border-radius: var(--radius);
  text-decoration: none; color: var(--muted); background: transparent;
}
.btn-reset:hover { color: var(--accent); background: var(--accent-soft); }
.btn-export {
  display: inline-flex; align-items: center;
  min-height: var(--control-h); padding: var(--control-pad);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  text-decoration: none; color: var(--fg); background: var(--card);
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }

/* Compact row controls: the write-backs that sit in a table row. The forms
   inside a row's popover menu keep the full control size — they float above
   the table and have the room. */
.inline-toggle button, .inline-resolve button, .row-actions button,
td > .inline-decide button {
  font-size: 0.8rem; padding: 0.15rem 0.5rem; min-height: 1.75rem;
}
td > .inline-decide select, td > .inline-decide input[type="text"],
.inline-resolve input[type="text"] {
  font-size: 0.82rem; padding: 0.15rem 0.35rem; min-height: 1.75rem;
}
/* A row's decision form on two lines — the choice and its button, then the
   note — so the column is as wide as a select, not select + note + button. */
td > .inline-decide.stacked {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem; width: 15rem;
}
td > .inline-decide.stacked input[type="text"] { grid-column: 1 / -1; order: 1; width: 100%; }
td > .inline-decide.stacked select { min-width: 0; width: 100%; }
/* Several one-button forms in one cell (accept / reject): stacked, not a row. */
td.decide-cell { white-space: normal; }
td.decide-cell > .inline-decide { display: flex; margin: 0 0 0.3rem; }
td.decide-cell > .inline-decide:last-child { margin-bottom: 0; }
.inline-resolve input[type="text"] { width: 9rem; }

/* Messages */
.form-error, .form-ok {
  border-radius: var(--radius); padding: 0.5rem 0.75rem;
  border: 1px solid; margin: 0 0 1rem;
}
.form-error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.form-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.stack .form-error { margin: 0; }

/* --- App shell ------------------------------------------------------------ */
/* One bar: brand, the four sections, then theme, language and account. A
   section's own pages are tabs under the page title (.section-tabs), not a
   second bar here. */
.topbar {
  display: flex; align-items: center; gap: 1.75rem;
  padding: 0 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  min-height: 3.25rem; font-weight: 650; white-space: nowrap; letter-spacing: -0.01em;
}
/* The caterpillar. Body in the accent, segments separated by the bar's own
   colour, so it reads as a row of beads at 20 px. */
.brand-mark { width: 1.75rem; height: 1.3rem; flex: none; overflow: visible; }
.brand-body circle { fill: var(--accent); stroke: var(--card); stroke-width: 1.1; }
.brand-eye { fill: var(--card); }
.brand-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; }

.navgroups { display: flex; gap: 0.15rem; align-self: stretch; }
.navgroups a {
  display: inline-flex; align-items: center; padding: 0 0.65rem;
  color: var(--muted); text-decoration: none; font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.navgroups a:hover { color: var(--fg); }
.navgroups a.active { color: var(--fg); border-bottom-color: var(--accent); }
.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.75rem;
}
.topbar-right .nav-user {
  color: var(--muted); font-size: 0.88rem; text-decoration: none;
  max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right .nav-user:hover { color: var(--fg); text-decoration: underline; }
.lang-form, .logout-form, .theme-form { display: flex; align-items: center; margin: 0; }
/* Language toggle: two immediate-apply buttons, current one highlighted. */
.lang-form { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.lang-btn {
  cursor: pointer; border: 0; border-radius: 0; min-height: 1.85rem; padding: 0.2rem 0.55rem;
  background: transparent; color: var(--muted); font-size: 0.8rem; font-weight: 600;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border-strong); }
.lang-btn:hover { color: var(--fg); }
.lang-btn.active { background: var(--surface-2); color: var(--fg); }
/* Theme toggle: an icon button the height of the language switch beside it. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.95rem; min-height: 1.95rem; padding: 0;
  background: transparent; border-color: var(--border-strong); color: var(--muted);
}
.icon-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--fg); border-color: var(--muted); background: var(--surface-2); }
/* Sign out is a way out, not the page's main action. */
.logout-form button {
  min-height: 1.85rem; padding: 0.2rem 0.55rem; font-size: 0.85rem;
  background: transparent; border-color: transparent; color: var(--muted);
}
.logout-form button:hover { color: var(--fg); background: var(--surface-2); border-color: transparent; }

/* A section's pages, as tabs directly under the page title: they switch
   between views of this section, so they sit with the content they switch.
   Underline tabs, the same accent mark as the active section above. */
.section-tabs {
  display: flex; flex-wrap: wrap; gap: 0 1.5rem;
  margin: -0.35rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.section-tabs a {
  padding: 0.55rem 0.05rem; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-weight: 550;
  border-bottom: 2px solid transparent;
}
.section-tabs a:hover { color: var(--fg); border-bottom-color: var(--border-strong); }
.section-tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }

/* Width: data pages use the screen; forms and reading pages stay narrow so a
   label and its field are not a screen apart. */
.container { max-width: 1440px; margin: 1.5rem auto 3rem; padding: 0 1.25rem; }
.container.container-wide { max-width: none; --chrome-h: 22rem; }
.container.container-narrow { max-width: 62rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
}
.card-narrow { max-width: 24rem; margin: 3rem auto 0; }
.card h1 { margin-top: 0; font-size: 1.35rem; }
.card p { color: var(--muted); margin-bottom: 0; }

/* --- Page furniture ------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 0.5rem; }
.stack label { font-size: 0.9rem; font-weight: 600; }
.panel { margin-bottom: 2.25rem; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; max-width: 75ch; }
/* An empty state says what is empty and, where a filter caused it, offers the
   way back. */
.empty {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.75rem;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 2rem 1.5rem; text-align: center; margin: 0;
}

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 0.75rem;
  margin-bottom: 1rem;
}
.filters label, .filters .filter-field {
  display: flex; flex-direction: column; gap: 0.2rem;
  font-size: 0.8rem; color: var(--muted); font-weight: 500;
}
/* Not the checkboxes in the category panel: a 10rem-wide tick box pushes its
   own label half a panel away. */
.filters input:not([type="checkbox"]), .filters select { min-width: 10rem; font-size: 0.88rem; color: var(--fg); }
/* A filter bar's own controls inherit the body size; keep them level with the
   fields beside them. */
.filters button, .btn-reset, .btn-export { font-size: 0.88rem; }

/* The category picker: a <details> disclosure over a checkbox list. It replaces
   a `<select multiple size="4">`, which was four rows tall and needed
   ctrl-click. A real combobox is not available here: the CSP is script-src
   'self' and base.html is pinned to exactly two scripts. The panel is
   absolutely positioned so opening it does not reflow the filter row, and
   `:has(:checked)` tells you the filter is active while it is shut. */
.multi-picker { position: relative; }
.multi-picker > summary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: var(--control-h); padding: var(--control-pad); min-width: 12rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--input-bg); color: var(--fg); font-size: 0.88rem;
  cursor: pointer; list-style: none; white-space: nowrap;
}
.multi-picker > summary::-webkit-details-marker { display: none; }
.multi-picker > summary::after { content: "\25BE"; margin-left: auto; color: var(--muted); }
.multi-picker[open] > summary::after { content: "\25B4"; }
.multi-picker[open] > summary,
.multi-picker:has(input:checked) > summary { border-color: var(--accent); color: var(--accent); }
.multi-panel {
  position: absolute; z-index: 5; margin-top: 0.25rem;
  min-width: 22rem; max-height: 17rem; overflow-y: auto;
  padding: 0.35rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
/* Row-wise, not the column the .filters label rule above imposes. */
.filters .multi-panel label {
  flex-direction: row; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.4rem; border-radius: 4px;
  font-size: 0.85rem; color: var(--fg); white-space: nowrap; cursor: pointer; font-weight: 400;
}
.filters .multi-panel label:hover { background: var(--surface-2); }
.multi-panel input[type="checkbox"] { margin: 0; flex: none; }
/* The domain picker's include/exclude switch, at the top of its panel. */
.multi-panel select[name="domain_mode"] { width: 100%; margin-bottom: 0.3rem; }

/* "More filters" on /grid: the secondary filters behind one button whose panel
   is a native popover (inside the same form, so its fields still submit). The
   popover is what closes it on a click outside or Esc — no script. The button
   carries the accent while any of them is set, and the set ones show as
   chips beside it (_grid_active_filters.html). */
.more-filters { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; min-width: 0; }
.more-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: var(--control-h); padding: var(--control-pad);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--card); color: var(--fg); font-size: 0.88rem; font-weight: 400;
  cursor: pointer; white-space: nowrap;
}
.more-toggle::after { content: "\25BE"; color: var(--muted); }
.more-filters:has(.more-panel:popover-open) .more-toggle::after { content: "\25B4"; }
.more-filters:has(.more-panel input:checked) .more-toggle,
.more-filters:has(.more-panel input[type="text"]:not(:placeholder-shown)) .more-toggle,
.more-filters:has(.more-panel select:not([name="day_scope"]) option:checked:not([value=""])) .more-toggle,
.more-filters:has(select[name="day_scope"] option:checked:not([value="latest"])) .more-toggle {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.active-filters { display: contents; }
.filter-chip {
  display: inline-flex; align-items: baseline; gap: 0.3rem; max-width: 100%;
  min-height: 0; padding: 0.2rem 0.55rem;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent-soft); color: var(--fg); font-size: 0.8rem; font-weight: 400;
  cursor: pointer; white-space: nowrap;
}
.filter-chip-label, .filter-chip-more { color: var(--muted); flex: none; }
.filter-chip-value { min-width: 0; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; }
/* Without anchor positioning a popover sits centred on screen, which is
   always visible. With it, it opens below the button, rightwards, and flips
   or falls back to the page gutter when that would leave the viewport. A
   popover is position: fixed, so the viewport is what it is checked against.
   overflow stays visible so the category and manufacturer lists can hang
   below the panel. */
.more-panel {
  margin: auto; overflow: visible;
  flex-wrap: wrap; align-items: end; gap: 0.75rem;
  width: max-content; max-width: min(48rem, calc(100vw - 2rem));
  padding: 0.85rem; background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.more-panel:popover-open { display: flex; }
@supports (anchor-name: --a) {
  .more-toggle { anchor-name: --more-filters; }
  .more-panel {
    position-anchor: --more-filters; inset: auto; margin: 0.35rem 0 0;
    top: anchor(bottom); left: anchor(left);
    position-try-fallbacks: flip-inline, --more-panel-gutter;
  }
}
/* Neither side of the button has room: start at the page gutter. */
@position-try --more-panel-gutter { left: 1rem; right: auto; top: anchor(bottom); }
/* Phone width: span the gutters. */
@media (max-width: 40rem) {
  .more-panel { left: 1rem; right: 1rem; width: auto; position-try-fallbacks: none; }
}
.filters-end { display: flex; gap: 0.5rem; align-items: end; margin-left: auto; }

/* Live filters (/grid, /competitors, /domains, /review/errors): htmx sets
   .htmx-request on the hx-indicator element for the request's duration;
   dimming the results is enough feedback at ~350 ms. */
#grid-results.htmx-request,
#competitor-results.htmx-request,
#domain-results.htmx-request,
#error-results.htmx-request { opacity: 0.55; transition: opacity 0.12s ease-out; }
#outlier-results.htmx-request { opacity: 0.55; transition: opacity 0.12s ease-out; }

/* The band between filters and table: bulk action on the left, the result
   count and export on the right — one toolbar, not two. */
.results-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1rem; margin: 0 0 0.6rem;
}
.results-bar .hint { margin: 0; }
.results-meta { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.results-bar .export-bar { margin: 0; }

/* Bulk decisions (routes/bulk.py, static/bulk.js). */
.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin: 0 0 0.6rem; padding: 0.35rem 0.5rem 0.35rem 0.7rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card);
  font-size: 0.88rem;
}
.results-bar .bulk-bar { margin: 0; }
.bulk-bar select, .bulk-bar input[type="text"], .bulk-bar button {
  min-height: 1.9rem; padding: 0.2rem 0.5rem; font-size: 0.85rem;
}
.bulk-bar .bulk-count { color: var(--muted); min-width: 6.5rem; }
.bulk-bar [data-bulk-count] { font-weight: 650; color: var(--fg); font-variant-numeric: tabular-nums; }
.bulk-bar .bulk-summary { color: var(--muted); }
.bulk-bar .bulk-summary:not(:empty) { color: var(--fg); }

/* Export (Step 8) — exports the filtered selection rather than the page. */
.export-bar { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 1rem; }
.export-bar .hint { margin: 0; }

/* Pager */
.pager { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; }
.pager a, .pager .disabled {
  padding: 0.3rem 0.7rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  text-decoration: none; font-size: 0.88rem; background: var(--card);
}
.pager a:hover { border-color: var(--accent); }
.pager .disabled { color: var(--muted); border-color: var(--border); background: transparent; }
.pager-status { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }

/* --- Tables --------------------------------------------------------------- */
/* Always horizontally scrollable inside their own wrapper so the page body
   never scrolls sideways. */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card);
}

/* Frozen header row, opt-in per table. `overflow-x: auto` already makes the
   wrapper a scroll container on BOTH axes, so a sticky `thead th` resolves
   against the wrapper, never the viewport. Capping the height is the whole
   trick: the table box becomes the vertical scroll region and row 1 pins to
   its top. The cap subtracts the real chrome height (--chrome-h), so the page
   and the table do not both scroll. */
.table-wrap.freeze-head { max-height: calc(100dvh - var(--chrome-h)); overscroll-behavior: contain; }
.freeze-head table.grid thead th {
  position: sticky;
  top: 0;
  /* Above tr.group-header below: both are sticky, and the group header —
     sticky on the *left* — would otherwise slide over the pinned column
     headers when the table is scrolled both right and down. */
  z-index: 2;
  /* An inset shadow, not a border: under border-collapse the border belongs to
     the table grid, not the cell, so it does not travel with the sticky box. */
  box-shadow: inset 0 -1px 0 var(--border-strong);
}
.freeze-head tr.group-header th { z-index: 1; }

/* Single-table pages (main.page-fill): no height estimate at all. The page is
   exactly one screen tall, the chrome above the table takes what it needs, and
   the table box takes the rest — shrinking to its rows when there are few,
   scrolling inside when there are many — with the pager always on screen
   below it. A fixed `100dvh - chrome` cap could only be right for one page:
   on the review queue it overshot the screen by ~150 px (two scrollbars, pager
   out of sight), elsewhere it stopped short, and either way the visible rows
   ended at an arbitrary point that read as "only a few items".
   `:has()` marks every element between <main> and the table box, so the
   swapped results wrappers (#grid-results, …) take part without markup. */
/* At least 40rem, so a short window scrolls the page rather than squeezing
   the table to nothing. */
body:has(> main.page-fill) { display: flex; flex-direction: column; height: max(100dvh, 40rem); }
body:has(> main.page-fill) > .topbar { flex: none; }
main.page-fill {
  flex: 1 1 0; min-height: 0; width: 100%;
  display: flex; flex-direction: column;
  margin-bottom: 0; padding-bottom: 1rem;
}
.page-fill > *, .page-fill :has(.table-wrap.freeze-head) > * { flex: none; }
.page-fill :has(.table-wrap.freeze-head) {
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
}
.page-fill .table-wrap.freeze-head { flex: 0 1 auto; min-height: 0; max-height: none; }
.page-fill .pager { margin-bottom: 0; }
@media (max-width: 900px) {
  /* Small screens scroll the page as usual; the box keeps its own cap. */
  body:has(> main.page-fill) { display: block; height: auto; }
  main.page-fill { display: block; }
  .page-fill .table-wrap.freeze-head { max-height: calc(100dvh - 8rem); }
}
/* A capped, scrolling box prints as a clipped box. */
@media print {
  .table-wrap.freeze-head { max-height: none; overflow: visible; }
}
table.grid { border-collapse: collapse; width: 100%; font-size: 0.875rem; background: var(--card); }
table.grid th, table.grid td { padding: 0.45rem 0.55rem; text-align: left; white-space: nowrap; vertical-align: middle; }
table.grid thead th {
  background: var(--surface-2); border-bottom: 1px solid var(--border-strong);
  font-weight: 600; font-size: 0.8rem; color: var(--muted);
  /* Headers may wrap: "Preis Wettbewerber" on two lines is cheaper than a
     column the price data never needs. */
  white-space: normal; line-height: 1.25; vertical-align: bottom;
}
table.grid thead th .sort-link { white-space: normal; }
table.grid thead th .sort-ind { white-space: nowrap; }
table.grid thead th a.sort-link { color: var(--muted); }
table.grid tbody tr { border-top: 1px solid var(--border); }
table.grid tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Column roles. Every table is sized to its box (no sideways scroll at
   1440 px); these decide where the width goes.
     .col-text   the free-text column a row is read for (a reason, an error):
                 wraps, and takes the spare width — 30 % as a share, never
                 below 18rem
     td.notes    secondary free text (a human note): wraps, stays narrow
     .col-name   a product name: wraps, but wide enough to read in two lines
     .trunc      an identity value (a domain): one line, capped, full on hover
     .stack-cell two short values on two lines instead of two columns */
table.grid th.col-text { width: 30%; }
table.grid td.col-text { white-space: normal; min-width: 18rem; line-height: 1.4; }
table.grid td.notes { white-space: normal; max-width: 24rem; min-width: 8rem; color: var(--muted); }
table.grid td.col-name { white-space: normal; min-width: 13rem; }
.trunc, .domain-table td:first-child > a {
  display: inline-block; max-width: 10rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom;
}
table.grid td.stack-cell { line-height: 1.5; }
.th-sub { display: block; font-weight: 500; }

/* Long free text (a health reason, an error message): two lines, the rest on
   hover via the cell's title. */
.clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}
.url-cell {
  display: inline-block; max-width: 9rem; overflow: hidden; text-overflow: ellipsis;
  vertical-align: bottom; white-space: nowrap;
}
table.grid td.day { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-warn td { background: var(--danger-bg); }

/* Sort links — inactive columns show a muted ⇅ so they read as clickable; the
   one active column shows ▲/▼ in the accent colour. Exactly one is ever active. */
.sort-link { text-decoration: none; color: var(--fg); white-space: nowrap; cursor: pointer; }
.sort-link:hover { color: var(--fg); text-decoration: underline; }
.sort-link .sort-ind { color: var(--muted); font-size: 0.8em; opacity: 0.7; }
table.grid thead th a.sort-link.active, .sort-link.active { color: var(--accent); }
.sort-link.active .sort-ind { color: var(--accent); opacity: 1; }

/* Product grouping in the grid: the product row is the heading of its
   competitor rows, so it reads as one — stronger rule above, its own surface,
   the name in full colour. */
tbody.product-group { border-top: 2px solid var(--border-strong); }
tr.group-header th {
  background: var(--surface-2); text-align: left; font-weight: 600;
  position: sticky; left: 0; padding-top: 0.55rem; padding-bottom: 0.55rem;
  font-size: 0.875rem; color: var(--fg);
}
tr.group-header .lb { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92em; }
tr.group-header .pname { color: var(--fg); margin-left: 0.6rem; font-weight: 600; }
/* The header's content box is zero-width to the table's sizing: `width: 0`
   gives it no intrinsic size and `min-width: 100%` (ignored while sizing)
   then fills the cell. Without it the colspan cell's one-line width — name,
   categories, five facts — became the table's minimum and pushed every
   grid to ~1950 px. Now it wraps to whatever the columns need. */
tr.group-header th { white-space: normal; }
tr.group-header .ph { width: 0; min-width: 100%; }
tr.group-header .ph-sub {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.9rem;
  margin-top: 0.2rem; font-weight: 400; font-size: 0.82rem;
}
/* Manufacturer and shop link on the first line (d2f4a6c8e019). */
tr.group-header .pmeta { color: var(--muted); margin-left: 0.6rem; font-weight: 400; font-size: 0.88em; white-space: nowrap; }
tr.group-header .pmeta::before { content: "·"; margin-right: 0.6rem; }
tr.group-header .pcats { color: var(--muted); }
/* Our own storefront page, on the product header. */
tr.group-header a.shop-link { color: var(--accent); text-decoration: none; }
tr.group-header a.shop-link:hover { text-decoration: underline; }

/* Price deviation: direction is a mark and a word in the title, not colour. */
.diff { white-space: nowrap; font-variant-numeric: tabular-nums; }
.diff-mark { display: inline-block; width: 1.1em; margin-right: 0.15em; text-align: center; font-size: 0.72em; color: var(--muted); }
.diff-cheaper, .diff-cheaper .diff-mark { color: var(--cheaper); font-weight: 600; }
.diff-dearer, .diff-dearer .diff-mark { color: var(--dearer); }
.price-cheaper { color: var(--cheaper); font-weight: 700; }

/* Product facts on the group header: HAN, EAN, Shopware prices, units sold. */
tr.group-header .pfacts { display: inline-flex; flex-wrap: wrap; gap: 0.15rem 0.9rem; color: var(--fg); }
tr.group-header .pfact { white-space: nowrap; }
tr.group-header .pfact-k { color: var(--muted); }
/* The "+" on a product header (F3.3): a disclosure holding the add form. */
.add-url { display: inline-block; margin-left: 0.9rem; font-weight: 400; }
.add-url > summary { display: inline-block; cursor: pointer; padding: 0 0.45rem; border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--accent); list-style: none; }
.add-url > summary::-webkit-details-marker { display: none; }
.add-url form { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.35rem; }
.add-url input[type="url"] { min-width: 22rem; }
.add-url-msg { font-weight: 400; margin-left: 0.5rem; }
.add-url-msg.ok { color: var(--ok); }
.add-url-msg.err { color: var(--danger); }
.range-pair { display: inline-flex; gap: 0.3rem; }
.range-pair input { width: 5rem; }
.last-attempt { color: var(--muted); font-size: 0.8em; }

/* Badges */
.badge {
  display: inline-block; padding: 0.08rem 0.5rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 550; line-height: 1.45;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--fg);
  white-space: nowrap;
}
.badge-ok, .status-ok, .health-ok {
  color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg);
}
.badge-warn, .status-not_found, .health-no_price, .health-outage, .health-degraded {
  color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg);
}
.status-error, .status-implausible, .health-blocked, .health-unreachable, .target-badge-broken {
  color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg);
}
.badge-muted, .health-idle { color: var(--muted); background: transparent; }
/* Competitor decision states (/competitors, /domains). */
.status-relevant { color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg); }
.status-pending { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }
.status-irrelevant_permanent, .status-irrelevant_recheck { color: var(--muted); background: transparent; }
/* Shop status (/domains, plan §C5): a person's statement, so calmer than the
   health badge beside it. "Temporary" keeps the neutral badge. */
.shop-status-checking { color: var(--warn); border-color: var(--warn-border); background: var(--warn-bg); }
.shop-status-workaround { color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg); }
.shop-status-not_trackable { color: var(--muted); background: transparent; }
.shop-status-cell .clamp { display: block; }
.shop-status-cell .since { white-space: nowrap; }
/* Anything carrying an explanation in its title: the cursor says so, and the
   dotted rule is the only visual cue there is something to hover. */
.has-help { cursor: help; }
.badge.has-help { border-bottom-style: dotted; }
th .has-help, .approx.has-help { border-bottom: 1px dotted var(--muted); }
/* Own price shown from the live catalogue for a row with no snapshot. */
.approx { color: var(--muted); }
.help { cursor: help; color: var(--muted); font-size: 0.85em; border-bottom: 1px dotted var(--muted); }

/* Crawl target state (f4a8c2e6b913). Red is "our crawling of this URL is
   failing" (broken), grey is "deliberately out of the crawl" (retired). The
   row tint says it before the badge is read, because a stale row otherwise
   looks exactly like a current one; the left edge carries it where a faint
   tint vanishes. */
.target-badge-retired { color: var(--muted); border-style: dashed; background: transparent; }
.target-reason { display: block; max-width: 9rem; color: var(--muted); font-size: 0.76rem; line-height: 1.3; white-space: normal; margin-top: 0.15rem; }
tr.target-broken td { background: var(--danger-bg); }
tr.target-retired td { color: var(--muted); background: var(--surface-2); }
tr.target-broken td:first-child { box-shadow: inset 3px 0 var(--danger); }
tr.target-retired td:first-child { box-shadow: inset 3px 0 var(--muted); }
tr.target-retired td a { color: var(--muted); }
/* D3: an active link whose newest attempt found no price — shown, not hidden,
   but quieter than a price. Muted text only: no error colour, it is often just
   an out-of-stock page. */
tr[data-no-price] td { color: var(--muted); }
.no-price-note { font-style: italic; }
/* One line where the window has room (D2's 1500 px); below it the note wraps
   rather than widening the grid past the window (grid cells are nowrap). */
table.grid td.no-price-cell { white-space: normal; }
@media (min-width: 1500px) { table.grid td.no-price-cell { white-space: nowrap; } }

/* C4: a product with no (active) crawl target, listed on request. A neutral
   statement in the accent tint — not muted like D3's no-price rows, never a
   status or error colour. */
tr.coverage-row td { background: var(--accent-soft); white-space: normal; }
tr.coverage-row td:first-child { box-shadow: inset 3px 0 var(--accent); }
.coverage-note { font-weight: 600; color: var(--fg); }
.coverage-add { color: var(--muted); margin-left: 0.6rem; }
.filters label.check-filter { flex-direction: row; align-items: center; gap: 0.4rem; align-self: end; padding-bottom: 0.45rem; }

table.grid th.pick, table.grid td.pick { width: 1.5rem; padding-right: 0.2rem; }

/* --- Row write-backs ------------------------------------------------------ */
/* Inline forms sit tight to the value they act on; the htmx post swaps just
   the row (or the cell) in place. */
.inline-decide, .inline-toggle, .inline-resolve {
  display: inline-flex; align-items: center; gap: 0.3rem; margin: 0;
}
.pricing-cell { white-space: nowrap; }
.pricing-toggle { display: inline-flex; margin: 0; }
.htmx-request.pricing-toggle, .htmx-request .inline-decide button { opacity: 0.5; }
.status-cell { white-space: nowrap; }
/* Cells holding several badges may wrap them, but only between pieces: the
   Crawl cell (state, tier, last attempt, stock, "replace link") reads on one
   line when the window has room (D2, Lukas's mock-up) and wraps piece by piece
   rather than widening the grid when it has not (1c086d0). The price check's
   pill may sit under the status badge for the same reason. */
table.grid td.target-cell, table.grid td.status-cell, table.grid td.method-cell { white-space: normal; }
table.grid td.target-cell { min-width: 6.5rem; }
table.grid td.status-cell { min-width: 6.5rem; }
table.grid td.target-cell .badge, table.grid td.status-cell .badge { margin: 0.1rem 0; }
td.target-cell .crawl-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.4rem; }
td.target-cell .crawl-when { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
td.target-cell .replace-url { margin: 0; }
td.target-cell .replace-url > summary { white-space: nowrap; }
/* With room to spare, Method and Status keep to one line too, so an ordinary
   row is one line (~1650 px and up). Below 1500 px their minimum widths would
   no longer fit the grid's box, so they wrap again as above. */
@media (min-width: 1500px) {
  table.grid td.method-cell, table.grid td.status-cell { white-space: nowrap; }
}
/* The two discovery review tables were a little over their box at ~1430 px.
   The identity columns give way first — a domain and a URL are read on hover
   anyway — then the free-text reason, which still wraps to two or three
   lines. The sample product name wraps rather than setting the column. */
.review-table .trunc { max-width: 8.5rem; }
.review-table .url-cell, .candidate-table .url-cell { max-width: 7.5rem; }
table.grid.review-table td.stack-cell { white-space: normal; min-width: 8rem; }
table.grid.candidate-table td.col-text { min-width: 14rem; }

/* Row menus — the price check, Feeds pricing, a competitor's Decide — are
   native popovers (popovertarget, no script). A popover lives in the top
   layer: it floats over the table instead of stretching the row, is never
   clipped by the table's scroll box, and closes on Esc or a click outside.

   Where the browser supports anchor positioning (Chrome/Edge 125+, Safari
   26+) the menu opens just under the pill that opened it — a popover's invoker
   is its implicit anchor — and flips up or left when there is no room.
   Elsewhere it keeps the browser's default placement, centred on screen. */
.pill-menu {
  min-height: 0; cursor: pointer; font: inherit; font-size: 0.76rem; font-weight: 550;
  line-height: 1.45; padding: 0.08rem 0.5rem;
}
.pill-menu::after { content: "\25BE"; margin-left: 0.3em; font-size: 0.85em; opacity: 0.75; }
.pill-menu:hover { color: inherit; border-color: var(--accent); }
.pill-menu.badge-ok:hover { color: var(--ok); }
.pill-menu.badge-warn:hover { color: var(--warn); }
.pill-menu.badge-muted { border-style: dashed; }
.row-menu-btn {
  min-height: 0; font-size: 0.8rem; padding: 0.1rem 0.45rem;
  color: var(--muted); background: transparent; border-color: transparent;
}
.row-menu-btn::after { content: "\25BE"; margin-left: 0.3em; font-size: 0.85em; }
.row-menu-btn:hover { color: var(--accent); border-color: var(--border-strong); background: var(--card); }

.row-pop {
  margin: auto; padding: 0.6rem; max-width: min(22rem, 92vw);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--card); color: var(--fg); box-shadow: var(--shadow-pop);
  font-size: 0.875rem; white-space: normal;
}
@supports (position-area: bottom) {
  .row-pop {
    inset: auto; margin: 0.3rem 0;
    position-area: bottom span-right;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
  }
}
.row-pop .hint { margin: 0 0 0.5rem; font-size: 0.8rem; }
.row-pop > button { width: 100%; }
.row-pop .inline-decide { display: flex; flex-direction: column; align-items: stretch; gap: 0.4rem; min-width: 15rem; }
.check-form { display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; min-width: 14rem; }
.check-form .hint { margin: 0; font-size: 0.78rem; }
.htmx-request .check-form button { opacity: 0.5; }

/* --- Runs ----------------------------------------------------------------- */
/* The latest run, answered before the table: did last night work? */
.run-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1px;
  margin: 0 0 1.25rem; overflow: hidden;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.run-strip > div { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem 1rem; background: var(--card); }
.run-strip dt { color: var(--muted); font-size: 0.78rem; }
.run-strip dd { margin: 0; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-strip dd .muted { font-size: 0.8rem; font-weight: 400; }
.run-strip .run-strip-head dd { font-size: 1rem; }
/* Method split: a proportional bar beside the numbers. Attribute-only SVG
   (widths are presentation attributes, which style-src does not govern);
   colours are Okabe-Ito from classes, as on the cost chart. */
.methods { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.mbar { display: inline-block; width: 4.5rem; height: 0.5rem; vertical-align: middle; margin-right: 0.45rem; border-radius: 2px; overflow: hidden; background: var(--surface-2); }
.m-jsonld { fill: #0072b2; }
.m-cache { fill: #009e73; }
.m-llm { fill: #e69f00; }
.m-api { fill: #cc79a7; }

/* --- Threshold editor (Step 6) -------------------------------------------- */
.settings-section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 0.25rem; margin-bottom: 1.25rem;
}
.settings-section > h2 { margin-bottom: 0.25rem; }
/* Autosave status. Sticky because the form is much taller than the viewport;
   `:empty` keeps it out of the flow between saves. */
.settings-status {
  position: sticky; top: 0.5rem; z-index: 6;
  margin: 0 0 0.5rem; font-size: 0.9rem;
}
.settings-status:empty { display: none; }
.settings-status.htmx-request { opacity: 0.5; transition: opacity 0.1s; }
.settings-status-text {
  display: inline-block; padding: 0.4rem 0.75rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-pop);
}
.settings-status-text.is-ok { color: var(--ok); border-color: var(--ok-border); }
.settings-status-text.is-error { color: var(--danger); border-color: var(--danger-border); }
.settings-autosave-note { margin-top: 0; }
/* One feedback slot per threshold — the only thing an autosave swaps. */
.setting-msg { display: flex; flex-direction: column; gap: 0.35rem; }
.setting-msg:empty { display: none; }
.setting-msg .form-error, .setting-msg .form-ok, .setting-value .form-error { margin: 0; font-size: 0.85rem; padding: 0.3rem 0.5rem; }
.setting-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 0.5rem 2rem;
  padding: 0.8rem 0; border-top: 1px solid var(--border);
}
.settings-section > h2 + .setting-row, .settings-section > .hint + .setting-row { border-top: 0; }
.setting-label label { display: block; font-weight: 600; }
.setting-label .hint { display: block; margin: 0.2rem 0 0; }
.setting-value { display: flex; flex-direction: column; gap: 0.35rem; }
.setting-input { display: flex; align-items: center; gap: 0.5rem; }
.setting-value input[type="number"] { width: 8rem; font-variant-numeric: tabular-nums; }
.setting-value input[type="text"] { width: 100%; }
.setting-unit { color: var(--muted); font-size: 0.85rem; }
.setting-static { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.setting-updated { color: var(--muted); font-size: 0.8rem; }
/* Two selectors for one state, on purpose. `.has-error` is set by the classic
   POST re-render; an autosave swaps only the message span and can never add a
   class to its ancestor, so `:has()` reads the state off the error span. */
.setting-row.has-error input[type="number"],
.setting-row:has(.form-error) input[type="number"] { border-color: var(--danger); }
.settings-form > button[type="submit"] { margin: 0.5rem 0 1rem; }
@media (max-width: 720px) {
  .setting-row { grid-template-columns: 1fr; }
}

/* --- User management (Step 7) --------------------------------------------- */
.user-create-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.user-create-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.row-actions form { display: inline; }
.row-inactive td { opacity: 0.55; }
/* The one-time credential. Loud on purpose: it is shown exactly once. */
.credential {
  border: 1px solid var(--warn-border); background: var(--warn-bg);
  border-radius: var(--radius); padding: 0.75rem 1rem;
}
.credential h2 { margin-top: 0; }
.credential-pair { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.credential-pair dt { color: var(--muted); }
.credential-pair dd { margin: 0; }
.credential-value { font-size: 1.15rem; user-select: all; }
/* A plain vertical form (own-account password change). */
.stack-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 22rem; }
.stack-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.stack-form button[type="submit"] { align-self: flex-start; margin-top: 0.25rem; }

/* --- Cost analytics ------------------------------------------------------- */
/* Range presets as one segmented control; the active range is marked. */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.segmented a {
  display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 0.75rem;
  font-size: 0.85rem; color: var(--muted); text-decoration: none; background: var(--card);
}
.segmented a + a { border-left: 1px solid var(--border-strong); }
.segmented a:hover { color: var(--fg); background: var(--surface-2); }
.segmented a[aria-current="true"] { color: var(--fg); background: var(--accent-soft); font-weight: 600; }
/* Headline tiles: the total holds the left column at double height, the six
   supporting figures fill a 3 × 2 block beside it — no orphan tile. */
.kpi-grid {
  display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1rem;
}
.kpi {
  display: flex; flex-direction: column; gap: 0.2rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem;
}
.kpi-hero { grid-row: span 2; justify-content: center; }
.kpi-label { color: var(--muted); font-size: 0.82rem; }
.kpi-value { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-hero .kpi-value { font-size: 2.2rem; letter-spacing: -0.02em; }
.kpi-hint { color: var(--muted); font-size: 0.78rem; }
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-hero { grid-row: auto; grid-column: 1 / -1; }
}

/* The chart: inline SVG scaled to the panel width. Series colours are the
   Okabe-Ito palette (blue, orange, purple), distinguishable under every common
   colour-vision deficiency and with no red/green pair; the fixed subscription
   is a neutral grey because it is the floor, not a series. Same hues in dark
   mode — all four clear 3:1 against both surfaces. */
.chart { margin: 0; padding: 0.75rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gridlines line { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .seg { shape-rendering: crispEdges; }
.s-fixed { fill: #8c8c8c; }
.s-llm-daily { fill: #0072b2; }
.s-llm-weekly { fill: #e69f00; }
.s-discovery { fill: #cc79a7; }
.s-unpriced { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .bar.partial .seg { opacity: 0.6; }
.chart .bar:hover .seg { opacity: 0.85; }
.hatch-line { stroke: #1a1a1a; stroke-width: 1; }
/* Texture is the backup channel for print and forced-colours, not a default. */
@media print, (forced-colors: active) {
  .s-llm-weekly { fill: url(#hatch); }
}
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; padding: 0; margin: 0.6rem 0 0; font-size: 0.85rem; }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 3px; }
.swatch.s-fixed { background: #8c8c8c; }
.swatch.s-llm-daily { background: #0072b2; }
.swatch.s-llm-weekly { background: #e69f00; }
.swatch.s-discovery { background: #cc79a7; }

/* --- Narrow screens ------------------------------------------------------- */
/* Desktop-first; below this the sections move to their own row under the
   brand rather than wrapping raggedly. */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 0 1rem; padding: 0 1rem; }
  .topbar .brand { min-height: 3rem; }
  .navgroups { order: 3; width: 100%; overflow-x: auto; margin-left: -0.65rem; }
  .navgroups a { padding: 0.55rem 0.65rem; }
  .topbar-right .nav-user { display: none; }
  .container { padding: 0 1rem; margin-top: 1rem; }
  .filters-end { margin-left: 0; }
}

/* The narrow end of the laptop range (1280 px): tighter cells and caps, so the
   widest tables still fit their box without a sideways scroll. Last in the
   file so it overrides the base rules it tightens. */
@media (max-width: 1400px) {
  table.grid th, table.grid td { padding-left: 0.45rem; padding-right: 0.45rem; }
  .url-cell { max-width: 7.5rem; }
  .trunc { max-width: 8.5rem; }
  .review-table .trunc { max-width: 7.5rem; }
  .review-table .url-cell, .candidate-table .url-cell { max-width: 6.5rem; }
  table.grid.candidate-table td.col-text { min-width: 12rem; }
  table.grid td.col-text { min-width: 14rem; }
  td > .inline-decide.stacked { width: 13rem; }
  .target-reason { max-width: 7rem; }
  td.target-cell .crawl-when { flex-wrap: wrap; }
  .inline-resolve input[type="text"] { width: 7rem; }
  table.grid td.day { font-size: 0.8rem; }
  table.grid td.col-name { min-width: 10rem; }
}
/* Product name under its number on the crawl-error list (F2.5). */
.pname-sub { display: block; font-size: 0.8em; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Crawl tier (F2.3a). Neutral: it says how often, not whether anything is wrong. */
.badge.tier-weekly { color: var(--muted); }
