/* pod — shared app styles. Visual identity: design/brand/brand-guidelines.md
   (Dolphin Analytics brand guide). The token values below mirror that file AND the inlined
   :root in templates/report.html — keep all three in sync. */

/* Brand fonts — self-hosted (OFL). Linked by URL here; embedded as base64 in
   templates/partials/_report_fonts.css for the PDF renderer (which has no base URL). */
@font-face {
  font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/static/fonts/HankenGrotesk-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/SpaceMono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/SpaceMono-700.woff2') format('woff2');
}

:root {
  /* neutrals */
  --ink: #0a0a0a; --muted: #4b4b57; --muted-2: #66666f; --line: #d9dcf5;
  --bg: #f7f4f4; --panel: #ffffff; --soft: #f7f4f4; --soft-line: #ececf8;
  /* brand — cobalt is the one working colour (buttons, links, focus, active nav, logo) */
  --cobalt: #4042e2; --cobalt-hover: #3335c6; --cobalt-soft: #e8e8fc; --vivid-blue: #032cfc;
  --accent: var(--cobalt); --accent-soft: var(--cobalt-soft);
  /* slight accents — never the main story */
  --amber: #fbd23c; --coral: #ea6952;
  /* signature gradient — hero backdrops & key accents only, never inside the logo.
     Matches sister-app Sonar exactly (18deg, blue→magenta→amber). */
  --signature-gradient: linear-gradient(18deg, #2a1ff5 0%, #531ec6 22%, #832da8 45%, #b94169 63%, #ea6952 80%, #fbd23c 100%);
  /* semantic states */
  --flag-bg: #fdefc4; --flag-ink: #5c4300;     /* needs-review (amber) */
  --ok-bg: #e7f6ec; --ok-ink: #166534;         /* figures validated (functional green) */
  --warn: #b26a00;                             /* verifying / caution */
  --ok-dot: #16a34a;                           /* data-fresh status dot (functional green, not a brand colour) */
  /* type — Hanken Grotesk (display + body), Space Mono (numbers, metrics, code) */
  --font-display: 'Hanken Grotesk', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Hanken Grotesk', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: var(--font-body); --serif: var(--font-display);   /* back-compat aliases */
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2.serif, .serif { font-family: var(--font-display); font-weight: 700; }
/* on-brand keyboard focus ring (cobalt) — visible for all interactive elements */
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }

/* ---- top bar ---- */
.topbar {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 14px 24px;
}
/* the one signature-gradient moment — a hairline of the brand spectrum across the top */
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--signature-gradient);
}
/* the wordmark doubles as the home link (back to /clients from anywhere, incl. admin) */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display);
  text-decoration: none; }
.brand[href] { cursor: pointer; }
.brand[href]:hover .wordmark b { color: var(--cobalt); }
.brand .logo { width: 26px; height: 26px; display: inline-block; }
.brand .accent { color: var(--cobalt); }
/* "Surface by Dolphin Analytics" lockup — mirrors sister-app Sonar's masthead wordmark */
.wordmark { font-size: 17px; letter-spacing: -.01em; color: var(--ink); font-weight: 500; }
.wordmark b { font-weight: 700; }
.wordmark-by { color: var(--muted-2); font-weight: 400; }
.workspace {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px;
}
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.topbar .admin {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 4px 10px;
}
.topbar .right a { color: var(--muted); }
.topbar .admin-link { font-weight: 600; }
.topbar .admin-link:hover { color: var(--accent); }
.topbar .user-email { color: var(--muted); }
.topbar .logout-form { margin: 0; }
.topbar .logout-btn { background: none; border: none; padding: 0; font: inherit;
  color: var(--muted); cursor: pointer; }
.topbar .logout-btn:hover { color: var(--accent); }

/* ---- shell: optional sidebar + main ---- */
/* Children stretch (no align-items: flex-start): the sidebar must run the full
   height of a long page, not stop at one viewport of background. */
.shell { display: flex; }
.sidebar {
  width: 200px; flex: 0 0 200px; padding: 24px 16px; border-right: 1px solid var(--line);
  min-height: calc(100vh - 57px); background: var(--panel);
}
.sidebar a, .sidebar .navitem {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 2px;
}
.sidebar a.active, .sidebar .navitem.active { background: var(--accent-soft); color: var(--accent); }
.sidebar a:hover { background: var(--soft); }
.sidebar .stage { margin-top: 18px; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; padding: 0 12px; }
/* Auto inline margins center the content column in the space left of the
   sidebar — on any viewport, instead of hugging the sidebar's edge. */
main { flex: 1 1 auto; padding: 40px 36px; max-width: 980px; margin-inline: auto; }
/* Explore opts into the full width for the chart canvas; every other screen
   keeps the readable 980px column. */
main.main-wide { max-width: 1720px; }

/* ---- page header ---- */
.page-head { margin-bottom: 24px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
h1 { font-size: 30px; margin: 6px 0 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 15px; }

/* ---- client cards (Clients screen) ---- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 12px; display: flex; align-items: center; gap: 16px;
}
.card .who { flex: 1 1 auto; }
.card .name { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.chip {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); display: inline-block; }
.dot.verifying { background: var(--warn); }
.card .freshness { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.actions { display: flex; gap: 8px; }
/* font-family/line-height are set explicitly because <button> does NOT inherit
   page typography from the UA stylesheet while <a class="btn"> does: without
   this, buttons rendered in the browser's default face (against the brand
   guide) and sat 5px shorter than the anchors beside them. */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-block;
  font-family: inherit; line-height: 1.25; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--cobalt-hover); border-color: var(--cobalt-hover); color: #fff; }

/* ---- client header (inside a client) ---- */
.client-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 24px; }
.client-head .name { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.view-row { display: flex; align-items: center; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.view-pill {
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; font-size: 13px;
  font-weight: 600; color: var(--ink); background: var(--panel);
}
.view-pill .label { color: var(--muted); font-weight: 600; margin-right: 6px; font-size: 12px; }
.view-pill { display: inline-flex; align-items: center; }
/* `hidden` must beat `.view-pill { display: inline-flex }` — the UA [hidden] rule
   (specificity 0,0,1) loses to the class (0,1,0), so the custom-range fields would
   stay visible on a preset. Scoped id+attr (1,1,0) wins without a global !important. */
#ex-date-fields[hidden] { display: none; }
.view-pill select {
  border: 0; background: transparent; font: inherit; font-weight: 700;
  color: var(--cobalt); cursor: pointer; padding: 0 2px; outline: none;
}
.account-menu { position: relative; display: inline-block; padding: 0; }
.account-menu > summary {
  display: inline-flex; align-items: center; padding: 5px 12px;
  list-style: none; cursor: pointer;
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-summary { color: var(--cobalt); font-weight: 700; }
.account-panel {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 12;
  width: max-content; min-width: 230px; max-width: min(360px, calc(100vw - 36px));
  padding: 7px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(64, 66, 226, .10);
}
.account-option {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 7px; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.account-option:hover { background: var(--cobalt-soft); }
.account-option input { accent-color: var(--cobalt); }
/* Table metric picker: checkboxes reusing the account-menu pattern — a plain
   click on a native <select multiple> REPLACES the selection (2026-08-05). */
.metric-menu .account-panel { left: 0; right: auto; }
.metric-menu .account-option:has(input:disabled) { color: var(--muted); cursor: default; }
.metric-menu-hint { font-size: 11px; color: var(--muted); margin: 4px 8px 2px; }
.acct-chip { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.freshline { font-size: 12px; color: var(--muted); margin-top: 8px; }
/* .banner.warn carries an 18px bottom margin sized for the report header; inside the
   app masthead it sits above the page content, so flip the spacing. */
.client-head .banner.warn { margin-top: 10px; margin-bottom: 0; }

/* ---- ask form ---- */
.askbar { display: flex; gap: 10px; margin: 8px 0 12px; }
.askbar input[type=text] {
  flex: 1 1 auto; border: 1px solid var(--line); border-radius: 10px; padding: 13px 16px;
  font-size: 15px; font-family: var(--sans); color: var(--ink); background: var(--panel);
}
.askbar input[type=text]:focus { outline: none; border-color: var(--accent); }
.suggested { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.suggested .label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); align-self: center; margin-right: 4px; }
.suggested button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; color: var(--ink); cursor: pointer;
}
.suggested button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- answer ---- */
.answer { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; }
.answer-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--soft-line); }
.answer-permalink { font-size: 13px; color: var(--muted); }
/* ---- Ask: conversation layout (chat + a per-client thread rail) ---- */
.ask-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .ask-layout { grid-template-columns: 1fr; } }
.ask-main { min-width: 0; }
/* Ask as a chat: the thread scrolls, the ask bar stays pinned at the bottom.
   The real height is set by sizeChat() in ask.html (viewport minus the measured
   header stack + main's bottom padding); this calc is only the JS-off fallback. */
.ask-main.chat { display: flex; flex-direction: column; height: calc(100vh - 283px); min-height: 420px; }
.ask-main.chat .thread { flex: 1 1 auto; overflow-y: auto; padding-right: 6px; margin-top: 0; }
.ask-main.chat .chat-foot { flex: 0 0 auto; padding-top: 10px; }
.ask-main.chat .askbar { margin: 6px 0 0; }
/* the conversation: each answered turn is appended here */
.thread { display: flex; flex-direction: column; gap: 18px; margin-top: 6px; }
.turn { display: flex; flex-direction: column; gap: 10px; }
.turn-q { align-self: flex-end; max-width: 82%; background: var(--accent); color: #fff;
  border-radius: 12px 12px 4px 12px; padding: 10px 15px; font-size: 15px; font-weight: 500; }

/* the conversations rail */
.conversations { position: sticky; top: 18px; }
.conv-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.conv-head .label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.btn.small { padding: 4px 11px; font-size: 12px; }
.conv-link { display: block; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.conv-link:hover { border-color: var(--accent); }
.conv-link.active { border-color: var(--accent); background: rgba(64, 66, 226, .06); }
.conv-title { display: block; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.conv-empty { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.flag { background: var(--flag-bg); color: var(--flag-ink); }
/* neutral — validation didn't run (assistant unavailable); never green */
.badge.unverified { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
/* informational cobalt — a run_sql answer's provenance ("computed from live rows");
   not success-green (not a registry-formula match), not a warning */
.badge.info { background: rgba(64, 66, 226, .10); color: var(--accent); border: 1px solid rgba(64, 66, 226, .25); }
/* neutral — a degrade notice (outage / an engine bug), distinct from Unverified */
.badge.muted { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.answer .sources { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-left: 8px; }
/* the resolved reporting window ("Showing 21 May – 18 Jun 2026") — so a figure is
   never shown without a visible date range. Space Mono to match the metric numerals. */
.answer .window-line { display: inline-block; margin-left: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.answer .prose p { font-size: 16px; margin: 12px 0; }
.facts { display: flex; flex-wrap: wrap; gap: 18px 28px; margin: 16px 0; padding: 14px 0; border-top: 1px solid var(--soft-line); border-bottom: 1px solid var(--soft-line); }
.fact .label { font-size: 12px; color: var(--muted); }
.fact .value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.fact .fact-window { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.insight { background: var(--soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; margin: 8px 0; font-size: 14px; }
.insight .tag { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; display: block; margin-bottom: 2px; }
.insight em { font-style: italic; }
/* Honesty notes for the story KPI strip — sit between the figures they explain
   and the executive summary. Mirrored in story_pdf.html's inlined <style>. */
.kpi-caveats { margin: 0 0 22px; }
/* Grouped notes (Explore table): several caveats share one box + one tag. */
.insight .note { display: block; }
.insight .note + .note { margin-top: 4px; }
/* Ask charts (#109): the same panel treatment as an Explore block, so a promoted
   figure reads as a first-class object rather than a loose SVG floating in prose.
   Tokens only — no new colours. The figcaption carries the figure's full scope
   disclosure, so it must stay legible, not decorative. */
figure.ask-chart {
  margin: 16px 0 0; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(10, 10, 34, .05), 0 6px 20px rgba(64, 66, 226, .06);
}
figure.ask-chart + details.evidence { margin-top: 10px; }
figure.ask-chart figcaption { margin-top: 8px; font-size: 12px; color: var(--muted); }
figure.ask-chart .chart-caveat {
  margin: 6px 0 0; font-size: 12px; font-style: italic; color: var(--muted);
}
/* The refusal note (v10 §4). Quieter than a figcaption on purpose: it reports an
   absence, so it must be findable without competing with the answer it sits under. */
.answer .chart-refused { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
details.evidence { margin-top: 14px; font-size: 13px; color: var(--muted); }
details.evidence summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.evidence pre { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12px; font-family: var(--font-mono); }
details.evidence pre.sql { white-space: pre-wrap; word-break: break-word; }
.sql-rows-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
table.sql-rows { border-collapse: collapse; width: 100%; font-size: 12px; }
table.sql-rows th, table.sql-rows td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--soft-line); white-space: nowrap; }
table.sql-rows th { position: sticky; top: 0; background: var(--soft); font-weight: 600; color: var(--ink); }
table.sql-rows td { font-family: var(--font-mono); color: var(--ink); }
.htmx-indicator { opacity: 0; transition: opacity .2s; color: var(--muted); font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px; }
.htmx-request .htmx-indicator { opacity: 1; }

/* Inline spinner — inherits the text colour (currentColor) so it reads on a primary
   button (white) or next to muted indicator text. Used by js-busy submits + the htmx
   indicators. Honours reduced-motion. */
.spin {
  display: inline-block; width: 1em; height: 1em; flex: 0 0 auto;
  vertical-align: -0.15em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 1.4s; } }
/* A disabled busy button keeps its primary colour (don't grey it out — it's working). */
.btn[aria-busy="true"] { opacity: .85; cursor: progress; }

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { width: auto; min-height: 0; border-right: none; border-bottom: 1px solid var(--line); display: flex; gap: 4px; overflow-x: auto; }
  main { padding: 24px 18px; }
  .card { flex-wrap: wrap; }
}

/* ---- Explore: query-builder controls ---- */
.explore-controls {
  display: flex; flex-direction: column; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 20px;
}
.control { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.control-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  font-weight: 700; flex: 0 0 70px;
}
/* segmented group-by control (radios styled as a pill bar; :has keeps state live, no JS) */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span { display: block; padding: 7px 15px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg + .seg span { border-left: 1px solid var(--line); }
.seg:has(input:checked) span { background: var(--accent); color: #fff; }
.seg:has(input:focus-visible) span { outline: 2px solid var(--cobalt); outline-offset: -2px; }
/* metric multi-select chips */
.metric-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mchip input { position: absolute; opacity: 0; width: 0; height: 0; }
.mchip span {
  display: inline-block; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; color: var(--ink); cursor: pointer;
}
.mchip:has(input:checked) span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
/* Unavailable metric (e.g. Leads outside Meta scope). It must LOOK inert: the
   disabled chip was pixel-identical to a selectable-but-unselected one, so it
   read as a broken control rather than an explained one (Andras, 2026-07-28).
   Muted, not faint — the label carries the REASON ("— Meta only"), and greying
   that into illegibility would hide the explanation that makes it not a bug.
   muted-2 on soft holds ~5.7:1, past the AA floor. */
.mchip:has(input:disabled) span {
  background: var(--soft); border-color: var(--soft-line);
  color: var(--muted-2); cursor: not-allowed;
}
.mchip:has(input:focus-visible) span { outline: 2px solid var(--cobalt); outline-offset: 2px; }

/* ---- Explore: shared result primitives ---- */
.explore-ctx { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.explore-ctx .ctx-line { font-size: 13px; color: var(--muted); }
.explore-chart { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.explore-chart .chart-head { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.bar-label { flex: 0 0 180px; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1 1 auto; background: var(--soft); border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; min-width: 2px; }
.bar-value { flex: 0 0 120px; text-align: right; font-family: var(--font-mono); font-size: 14px; font-weight: 700; }

/* ---- SVG charts (pod/core/charts.py geometry; .bar-* above stays for Story CSS bars) ---- */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .c-track { fill: var(--soft); }
.chart-svg .c-fill { fill: var(--accent); }
/* Bar/pie labels are HTML inside a foreignObject so the RENDERER fits them
   (ellipsis at the end — a char budget can't be exact across fonts/scripts).
   `color`, not `fill`: SVG fill is inert on HTML text. Heights mirror the row
   grids in charts.py (BAR_ROW_H / PIE_LEGEND_ROW_H); the pair of copies
   (style.css + _chart_svg.css) is enforced by tests/test_charts_render.py. */
.chart-svg .c-fo-label { box-sizing: border-box; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--font-body); font-size: 14px; color: var(--ink); }
.chart-bar .c-fo-label { height: 30px; line-height: 30px; text-align: right; }
/* Pie legend row: the value keeps its intrinsic width, the label takes the
   remainder and ellipsises (min-width:0 is what lets a flex child shrink) —
   overlap is impossible at any value length, in any font. */
.chart-pie .c-leg-row { display: flex; align-items: center; gap: 10px; height: 26px; box-sizing: border-box; }
.chart-pie .c-leg-label { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--font-body); font-size: 14px; color: var(--ink); }
.chart-pie .c-leg-value { flex: none; white-space: nowrap; font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--ink); }
.chart-svg .c-value { font-family: var(--font-mono); font-size: 14px; font-weight: 700; fill: var(--ink); }
.chart-svg .c-grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .c-tick { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.chart-svg .c-line { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .c-dot { fill: var(--accent); }
/* Categorical palette drawn from the signature gradient's own stops — the
   brand colors live IN the data as fixed hues (color never varies along an
   axis, so it never implies a measurement). "All others" stays neutral. */
.chart-svg .c-slice-0 { fill: var(--cobalt); }
.chart-svg .c-slice-1 { fill: #531ec6; }   /* gradient indigo */
.chart-svg .c-slice-2 { fill: #832da8; }   /* gradient purple */
.chart-svg .c-slice-3 { fill: #b94169; }   /* gradient magenta */
.chart-svg .c-slice-4 { fill: var(--coral); }
.chart-svg .c-slice-5 { fill: var(--amber); }
.chart-svg .c-slice-6 { fill: #23255f; }
.chart-svg .c-slice-others { fill: #d6d7dd; }
/* Ordinal ramp for bar rows: gradient-blue at rank 0 down to light tints.
   Deliberately NOT the categorical palette — rank-rotating hues would fake
   identity; a monotone ramp reads as what it is, an ordering. */
.chart-svg .c-rank-0 { fill: #2a1ff5; }    /* gradient blue */
.chart-svg .c-rank-1 { fill: var(--cobalt); }
.chart-svg .c-rank-2 { fill: #5c5ee8; }
.chart-svg .c-rank-3 { fill: #7b7dec; }
.chart-svg .c-rank-4 { fill: #a5a6f3; }
.chart-svg .c-rank-5 { fill: #c6c7f7; }
/* Multi-series line strokes: cobalt / purple / magenta (gradient stops with
   real hue distance — indigo reads as cobalt at 2.5px). Dots match strokes. */
.chart-svg .c-line.c-slice-0 { stroke: var(--cobalt); fill: none; }
.chart-svg .c-line.c-slice-1 { stroke: #832da8; fill: none; }
.chart-svg .c-line.c-slice-2 { stroke: #b94169; fill: none; }
.chart-svg .c-dot.c-slice-1 { fill: #832da8; }
.chart-svg .c-dot.c-slice-2 { fill: #b94169; }
/* Area-fill gradient stops (cobalt fading out) — single-series lines only. */
.chart-svg .c-area-a { stop-color: var(--cobalt); stop-opacity: .16; }
.chart-svg .c-area-b { stop-color: var(--cobalt); stop-opacity: 0; }
/* Comparison overlay: always muted, always secondary — context, not rival. */
.chart-svg .c-bar-prev { fill: var(--muted-2); opacity: .38; }
.chart-svg .c-line.c-cmp { stroke: var(--muted-2); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
.chart-svg .c-dot.c-cmp { fill: var(--muted-2); }

/* Hover: server-rendered, hidden by default (PNG export never shows it). */
.chart-bar .c-row:hover .c-track { fill: var(--cobalt-soft); }
.chart-bar .c-row:hover .c-bar { opacity: .85; }
.chart-pie .c-slice:hover { opacity: .82; }
.chart-svg .c-hit { fill: transparent; }
.chart-svg .c-hv { display: none; pointer-events: none; }
.chart-svg .c-hot:hover .c-hv { display: block; }
.chart-svg .c-guide { stroke: var(--muted-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .c-tip-box { fill: var(--panel); stroke: var(--line); }
.chart-svg .c-tip-title { font-family: var(--font-mono); font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart-svg .c-tip-text { font-family: var(--font-mono); font-size: 12px; fill: var(--ink); }

/* ---- Explore: chart canvas (round 3) ----
   The wrapper is a CSS size container AND the visual canvas: a soft dot-grid
   panel with the signature-gradient hairline; charts sit on it as white cards.
   Grid columns key to the CANVAS width (not the viewport), 12 columns wide, so
   the sidebar/window can never squeeze chart text illegible. Browsers without
   container queries fall back to one column — degraded but honest. */
.canvas-head { display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; }
.canvas-title {
  font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0;
  background: var(--signature-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.canvas-heading { min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.canvas-kicker {
  flex-basis: 100%; color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; line-height: 1; text-transform: uppercase;
}
.canvas-title.dashboard-view-title {
  max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; color: var(--ink); font-size: 18px; letter-spacing: -.01em;
  text-transform: none;
}
.dashboard-saved.notice { margin: 0; padding: 4px 9px; font-size: 12px; }
.canvas-tools {
  margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  justify-content: flex-end;
}
.canvas-tools form { display: inline-flex; margin: 0; }
.canvas-honesty {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: var(--panel); margin-bottom: 12px;
}
.canvas-honesty .explore-ctx { margin-bottom: 0; }
.canvas-honesty .evidence { margin-top: 8px; }
.canvas-honesty .evidence p { margin-bottom: 0; }
.dashboard-menu, .dashboard-save, .dashboard-rename { position: relative; }
.dashboard-menu > summary, .dashboard-save > summary, .dashboard-rename > summary {
  list-style: none;
}
.dashboard-menu > summary::-webkit-details-marker,
.dashboard-save > summary::-webkit-details-marker,
.dashboard-rename > summary::-webkit-details-marker { display: none; }
.dashboard-panel, .dashboard-name-form, .dashboard-rename-form {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 12;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(64, 66, 226, .10);
}
.dashboard-panel { width: min(360px, calc(100vw - 36px)); padding: 7px; }
.dashboard-row {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-width: 0; padding: 8px; border-radius: 7px;
}
.dashboard-row + .dashboard-row { border-top: 1px solid var(--soft-line); }
.dashboard-link {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--ink); font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.dashboard-link:hover, .dashboard-link[aria-current="page"] { color: var(--cobalt); }
.dashboard-link[aria-current="page"] { background: var(--cobalt-soft); border-radius: 5px; padding: 3px 5px; }
.dashboard-row-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.dashboard-action {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 12px; padding: 2px 0;
}
.dashboard-action:hover { color: var(--cobalt); }
.dashboard-name-form, .dashboard-rename-form {
  width: min(340px, calc(100vw - 36px)); padding: 10px; gap: 7px; flex-wrap: wrap;
}
.dashboard-name-input {
  min-width: 0; flex: 1 1 180px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 13px;
  padding: 7px 9px;
}
.dashboard-name-input:focus { outline: 2px solid var(--cobalt); border-color: var(--cobalt); }
.dashboard-row-error {
  flex-basis: 100%; padding: 6px 8px; border-radius: 6px;
  background: var(--flag-bg); color: var(--flag-ink); font-size: 12px;
}
.dashboard-empty { color: var(--muted); font-size: 13px; margin: 5px 7px; }
.canvas-tools .btn:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 900px) {
  .canvas-head { align-items: flex-start; flex-wrap: wrap; }
  .canvas-tools { width: 100%; margin-left: 0; justify-content: flex-start; }
  .dashboard-panel, .dashboard-name-form { right: auto; left: 0; }
}
.canvas-wrap {
  container-type: inline-size; position: relative;
  background: radial-gradient(var(--line) 1px, transparent 1px) 0 0 / 22px 22px, var(--soft);
  border: 1px solid var(--soft-line); border-radius: 14px; padding: 18px;
  margin-bottom: 26px;
}
.canvas-wrap::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 14px 14px 0 0; background: var(--signature-gradient);
}
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.chart-block { grid-column: span 1; }
.add-tile { grid-column: span 1; }
@container (min-width: 680px) {
  .chart-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  /* Medium band renders min(span, 6): never below the 320px geometry floor. */
  .chart-block.span-3 { grid-column: span 3; }
  .chart-block.span-4 { grid-column: span 4; }
  .chart-block.span-5 { grid-column: span 5; }
  .chart-block.span-6, .chart-block.span-7, .chart-block.span-8,
  .chart-block.span-9, .chart-block.span-10, .chart-block.span-11,
  .chart-block.span-12 { grid-column: span 6; }
  .add-tile { grid-column: span 3; }
}
@container (min-width: 1360px) {
  .chart-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .chart-block.span-3 { grid-column: span 3; }
  .chart-block.span-4 { grid-column: span 4; }
  .chart-block.span-5 { grid-column: span 5; }
  .chart-block.span-6 { grid-column: span 6; }
  .chart-block.span-7 { grid-column: span 7; }
  .chart-block.span-8 { grid-column: span 8; }
  .chart-block.span-9 { grid-column: span 9; }
  .chart-block.span-10 { grid-column: span 10; }
  .chart-block.span-11 { grid-column: span 11; }
  .chart-block.span-12 { grid-column: span 12; }
  .add-tile { grid-column: span 3; }
}
@container (max-width: 679px) {
  .drag-handle, .resize-handle { display: none; }
}
.grid-note { font-size: 13px; color: var(--warn); background: var(--flag-bg); border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; }
.chart-block {
  position: relative; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; background: var(--panel); min-width: 0;
  box-shadow: 0 1px 2px rgba(10, 10, 34, .05), 0 6px 20px rgba(64, 66, 226, .06);
}
.chart-block:hover {
  box-shadow: 0 2px 4px rgba(10, 10, 34, .06), 0 10px 28px rgba(64, 66, 226, .10);
}
.chart-block.dragging {
  box-shadow: 0 6px 12px rgba(10, 10, 34, .12), 0 18px 44px rgba(64, 66, 226, .18);
  opacity: .92;
}
.chart-block .chart-head { margin-top: 10px; }
.block-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.block-bar select {
  -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 12px; padding: 4px 22px 4px 8px; max-width: 150px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%2366666f'/%3E%3C/svg%3E") no-repeat right 8px center;
  cursor: pointer;
}
.block-bar select:hover { border-color: var(--cobalt); }
.block-bar select:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 1px; }
.block-bar select[disabled] { color: var(--muted-2); cursor: default; }
.block-bar select[multiple] {
  min-height: 72px; padding-right: 8px; background-image: none;
}
.block-bar input[type="search"] {
  font: inherit; font-size: 12px; padding: 4px 8px; width: 150px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  background: var(--panel);
}
.block-bar input[type="search"]:hover { border-color: var(--cobalt); }
.block-bar input[type="search"]:focus-visible {
  outline: 2px solid var(--cobalt); outline-offset: 1px;
}
.block-tools { margin-left: auto; display: flex; gap: 4px; }
.block-btn { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; min-width: 26px; height: 26px; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1; }
.block-btn:hover { color: var(--ink); border-color: var(--muted-2); }
.cmp-toggle { font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 0 7px; }
.cmp-toggle[aria-pressed="true"] { background: var(--cobalt-soft); color: var(--cobalt); border-color: var(--cobalt); }
.drag-handle { cursor: grab; }
.resize-handle {
  position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px;
  cursor: nwse-resize; touch-action: none;
  border-right: 3px solid var(--line); border-bottom: 3px solid var(--line);
  border-radius: 0 0 8px 0;
}
.resize-handle:hover { border-color: var(--muted-2); }
/* Ghost add-tile: part of the grid, invitation not chrome. */
.add-tile {
  min-height: 130px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--line); border-radius: 12px; background: transparent;
  color: var(--muted-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.add-tile:hover { color: var(--cobalt); border-color: var(--cobalt); background: rgba(255, 255, 255, .55); }
.add-tile-plus { font-size: 18px; line-height: 1; }
.chart-legend { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-legend .swatch.c-slice-0 { background: var(--cobalt); }
.chart-legend .swatch.c-slice-1 { background: #832da8; }
.chart-legend .swatch.c-slice-2 { background: #b94169; }
.chart-legend .swatch.c-cmp { background: transparent; height: 0; border-top: 2px dashed var(--muted-2); vertical-align: 2px; }
.block-caption { font-size: 12px; color: var(--muted); margin-top: 10px; }
.block-coverage {
  margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700;
}
/* One tagged box per block; the tag is its own line (like .insight) and each
   note is a separate block element, so dedup can hide an exact duplicate
   without touching a distinct note or orphaning the tag. */
.block-caveats { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }
.block-caveats .tag { display: block; font-style: normal; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); margin-bottom: 2px; }
.block-caveats .note { display: block; }
/* The display rules above beat the UA's [hidden]{display:none} — without this,
   app.js's dedup "hides" a duplicate note that keeps rendering. Screen-only:
   the PNG dedups server-side and never sets hidden. */
.block-caveats[hidden],
.block-caveats .note[hidden] { display: none !important; }
/* Motion: hover lift, entrance, and the loading shimmer — all gated. */
@media (prefers-reduced-motion: no-preference) {
  .chart-block { transition: box-shadow .18s ease, transform .18s ease; }
  .chart-block:hover { transform: translateY(-1px); }
  .chart-block.dragging { transform: rotate(.4deg) scale(1.01); }
  .add-tile { transition: color .15s ease, border-color .15s ease, background-color .15s ease; }
  .chart-block.htmx-added { animation: block-in .22s ease-out; }
  @keyframes block-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
  .chart-block.htmx-request svg { opacity: .45; transition: opacity .15s ease; }
  .chart-block.htmx-request::after {
    content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
    background-size: 220% 100%;
    animation: block-shimmer 1.1s ease-in-out infinite;
  }
  @keyframes block-shimmer {
    from { background-position: 130% 0; }
    to { background-position: -70% 0; }
  }
}

.table-wrap { overflow-x: auto; }
.block-table-wrap { max-height: 560px; }
.block-table-actions { margin-top: 12px; }
.explore-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.explore-table th {
  text-align: right; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.explore-table th.dim, .explore-table td.dim { text-align: left; }
.explore-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.explore-table td.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.explore-table td.dim { font-weight: 600; }
.explore-table .plat { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-left: 8px; }
.explore-table .val { font-weight: 700; }
.explore-table .delta { font-size: 11px; margin-left: 6px; font-weight: 700; }
.filter-input {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 220px;
  background: var(--panel);
  color: var(--ink);
}
.filter-input:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
  border-color: var(--cobalt);
}
.date-input { min-width: 0; width: 140px; }
.table-caption {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
/* Δ% colour follows metric polarity (good/bad), not raw direction — status affordance */
.delta.good { color: var(--ok-ink); }
.delta.bad { color: #b4231a; }
.delta.neutral { color: var(--muted); }
/* Lighter than .total-row (1px vs its 2px top border): a subtotal, subordinate
   to the Total, which stays the anchor. Mirrors .total-row's dim-cell treatment. */
.matching-row td { border-top: 1px solid var(--line); border-bottom: none;
                   font-weight: 700; padding-top: 11px; }
.matching-row td.dim { text-transform: uppercase; font-size: 12px;
                       letter-spacing: .06em; color: var(--muted); }
.total-row td { border-top: 2px solid var(--line); border-bottom: none; font-weight: 700; padding-top: 11px; }
.total-row td.dim { text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.explore-actions { display: flex; gap: 8px; margin-top: 18px; }
.explore-empty { padding: 30px; text-align: center; color: var(--muted); background: var(--soft); border-radius: 10px; }
.explore-error {
  padding: 18px 20px; color: var(--ink); background: var(--soft);
  border: 1px solid var(--line); border-left: 4px solid var(--cobalt); border-radius: 8px;
}
.explore-error strong { display: block; margin-bottom: 4px; }

/* --- Connections (onboarding hub) --- */
.conn-intro { color: var(--muted); font-size: 15px; max-width: 72ch; margin: 0 0 22px; }
.conn-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.conn-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.conn-meta { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 8px; }
.grant-card { background: var(--soft); border: 1px solid var(--soft-line); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.grant-card summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--cobalt); }
.grant-subject { font-size: 13px; font-weight: 600; color: var(--ink); margin: 10px 0 6px; }
.grant-body { font-family: var(--font-mono); font-size: 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; white-space: pre-wrap; margin: 0; }
.conn-accounts { display: flex; flex-direction: column; }
.conn-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 0; border-top: 1px solid var(--soft-line); }
.conn-account:first-child { border-top: none; }
.acct-main { display: flex; flex-direction: column; gap: 2px; }
.acct-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.acct-id { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.acct-status { display: flex; align-items: center; gap: 12px; }
.acct-fresh { font-size: 12px; color: var(--muted); }
.acct-error { flex-basis: 100%; font-size: 13px; color: var(--flag-ink); background: var(--flag-bg); border-radius: 6px; padding: 6px 10px; margin-top: 4px; }
.badge.verified { background: var(--cobalt-soft); color: var(--cobalt); }
.conn-stage2 { display: flex; gap: 16px; margin-top: 26px; flex-wrap: wrap; }
.stage2-card { flex: 1 1 280px; opacity: .72; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.stage2-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 6px 0; }
.stage2-card p { color: var(--muted); font-size: 14px; margin: 0; }

/* --- Direct connections (OAuth card, #261) --- */
.oauth-heading { font-size: 15px; font-weight: 700; color: var(--ink); margin: 26px 0 12px;
  display: flex; align-items: center; gap: 10px; }
.oauth-card { border-color: var(--cobalt-soft); }
.oauth-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Limitation + consequence, stated up front rather than in a footnote nobody reads. */
.oauth-beta { font-size: 13px; color: var(--muted); margin: 0 0 10px; max-width: 72ch; }
.oauth-state { font-size: 13px; color: var(--ink); margin: 0 0 8px; }
.oauth-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.oauth-message { margin: 0 0 10px; }
.oauth-accounts { border-top: 1px solid var(--soft-line); padding-top: 12px; margin-top: 4px; }
.oauth-account-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.oauth-account-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.oauth-account-form select { font: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.oauth-probe { border-top: 1px solid var(--soft-line); padding-top: 12px; margin-top: 12px; }
/* The window is part of the figure, so it sits with it and never gets separated. */
.oauth-window { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.oauth-figures { display: flex; gap: 28px; flex-wrap: wrap; }
.oauth-figure-value { font-family: var(--font-mono); font-size: 22px; color: var(--ink); }
.oauth-figure-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.oauth-nodata { font-size: 13px; color: var(--muted); margin: 0; }

/* --- Stories: list --- */
.stories-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.story-card { text-decoration: none; color: inherit; transition: border-color .15s; }
.story-card:hover { border-color: var(--accent); }
.story-card .story-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* --- Stories: shared body (detail + PDF use the same class names) --- */
.story-top { margin-bottom: 8px; }
.crumb { font-size: 13px; font-weight: 600; color: var(--muted); }
.crumb:hover { color: var(--accent); }
.story-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 22px; }
.story-head h1 { margin: 4px 0 2px; }
.story-head .period { font-family: var(--font-mono); color: var(--muted); font-size: 14px; }
.story-head .genat { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
.story-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }
.banner.warn { margin-bottom: 18px; padding: 10px 14px; border-radius: 8px; background: var(--flag-bg); color: var(--flag-ink); font-size: 13px; }
.banner.warn div + div { margin-top: 4px; }
.notice { margin-bottom: 18px; padding: 10px 14px; border-radius: 8px; background: var(--cobalt-soft); color: var(--cobalt); font-size: 13px; }
/* Destructive (delete-client) — a readable deep red, not the soft brand coral. */
.banner.danger { margin-bottom: 18px; padding: 12px 14px; border-radius: 8px; background: #fdecea; color: #8a1f12; font-size: 13px; }
.banner.danger div + div { margin-top: 6px; }
.btn.danger { background: #c0392b; border-color: #c0392b; color: #fff; }
.btn.danger:hover { background: #a83224; border-color: #a83224; color: #fff; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 32px; padding: 16px; border: 1px solid #f1c7c0; border-radius: 12px; background: #fdf6f5; }
.danger-zone .dz-title { font-weight: 600; color: #8a1f12; }
.prose p { font-size: 16px; margin: 12px 0; }

.kpi-strip { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 26px; }
.kpi { flex: 1 1 160px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi-delta { font-family: var(--font-mono); font-size: 13px; font-weight: 700; margin-top: 2px; }
.kpi-delta.good { color: var(--ok-ink); } .kpi-delta.bad { color: #b4231a; } .kpi-delta.neutral { color: var(--muted); }

.section-eyebrow { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 30px 0 10px; }
.story-section { margin-top: 30px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--soft-line); padding-bottom: 6px; }
.sec-num { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.sec-title { font-family: var(--font-display); font-size: 19px; letter-spacing: -.01em; margin: 0; }
.sec-type { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sec-recon { margin-left: auto; font-size: 12px; color: var(--ok-ink); font-weight: 700; }
.sec-recon.needs { color: var(--muted); }   /* a clarify/degrade brief section — never a green tick */
.sec-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.story-section .window-line { display: block; margin: 8px 0 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.story-chart { margin: 16px 0; }

/* --- Stories: validation panel + appendix --- */
.val-panel { margin-top: 32px; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; background: var(--soft); }
.val-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.val-recon { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.val-layers { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.val-layer { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-ink); }
.val-layer.fail { background: var(--flag-bg); color: var(--flag-ink); }
.val-sections { margin: 6px 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.val-method { font-size: 12px; color: var(--muted); margin: 8px 0 0; max-width: 80ch; }
.appendix { margin-top: 26px; font-size: 13px; }
.appendix > summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.appendix-title { font-weight: 700; margin: 16px 0 4px; }
.appendix-empty { color: var(--muted); }

/* --- Stories: New form --- */
.story-form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.story-form .field { display: flex; flex-direction: column; gap: 8px; }
.story-form input[type=text] { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: var(--sans); color: var(--ink); background: var(--panel); }
.story-form input[type=text]:focus { outline: none; border-color: var(--accent); }
.story-form textarea { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: var(--sans); color: var(--ink); background: var(--panel); resize: vertical; min-height: 96px; line-height: 1.5; }
.story-form textarea:focus { outline: none; border-color: var(--accent); }
.story-form-actions { display: flex; gap: 8px; align-items: center; }
.btn-link { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
.btn-link:hover { color: #b4231a; }

/* --- Login (P2 auth) — standalone page, signature gradient as the hero accent --- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--signature-gradient); padding: 24px; }
.login-card { background: var(--panel); border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(10,10,30,.28); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.login-h { font-size: 24px; margin: 0 0 4px; }
/* anti-hallucination tagline (mirrors sister-app Sonar's masthead tag) */
.login-tag { font-family: var(--font-mono); font-size: 12px; color: var(--muted-2);
  letter-spacing: .01em; margin: 0 0 22px; }
.login-diamond { color: var(--amber); font-size: 10px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.login-field input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: 15px; font-family: var(--font-body); color: var(--ink); background: var(--panel); }
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-submit { margin-top: 4px; padding: 12px; font-size: 15px; cursor: pointer; }
.login-error { background: var(--flag-bg); color: var(--flag-ink); border-radius: 10px;
  padding: 10px 13px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }

/* --- Account: change password --- */
.account-form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; max-width: 420px; }
.account-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.account-field input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: 15px; font-family: var(--font-body); color: var(--ink); background: var(--panel); }
.account-field input:focus { outline: none; border-color: var(--accent); }
.account-actions { margin-top: 4px; }
.account-ok { background: var(--ok-bg); color: var(--ok-ink); border-radius: 10px;
  padding: 10px 13px; font-size: 13px; font-weight: 600; margin-bottom: 16px; max-width: 420px; }
.account-error { background: var(--flag-bg); color: var(--flag-ink); border-radius: 10px;
  padding: 10px 13px; font-size: 13px; font-weight: 600; margin-bottom: 16px; max-width: 420px; }
.story-delete { margin-top: 28px; }

/* ---- admin UI (Dolphin-admin-only client + user management) ---- */
.admin-nav { display: flex; align-items: center; gap: 16px; margin-top: 10px; font-size: 14px; }
.admin-nav a { color: var(--muted); text-decoration: none; }
.admin-nav a.active { color: var(--ink); font-weight: 600; }
.admin-nav a.btn.primary { color: #fff; margin-left: auto; }
.admin-form { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin-top: 8px; }
.admin-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink); }
.admin-form input, .admin-form select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); }
.admin-form input:focus, .admin-form select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.admin-form .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.admin-form-section { margin-top: 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; border-top: 1px solid var(--line); padding-top: 14px; }
.admin-form-actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.admin-table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th.num, .admin-table td.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.admin-table tfoot td { border-top: 2px solid var(--line); border-bottom: none; }
.section-h { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 700; margin: 28px 0 4px; }
.status-ok { color: var(--ok-ink); font-weight: 700; font-size: 13px; }
.status-bad { color: #b4231a; font-weight: 700; font-size: 13px; }
.admin-created { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.admin-created .pw { font-size: 15px; background: var(--accent-soft); color: var(--accent);
  padding: 3px 8px; border-radius: 6px; }
.muted-tag { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--font-mono, "Space Mono", monospace); }
.inline-add { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.inline-add input { font: inherit; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel); color: var(--ink); }
.inline-x { display: inline; margin: 0; }
.inline-x button { background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 0 0 0 4px; }
.inline-x button:hover { color: var(--flag-ink); }

/* ---- self-serve setup wizard (client role) ---- */
.wsec { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.wsec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.wsec-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.wsec-status { color: var(--muted); font-size: 13px; }
.wstep { display: flex; gap: 14px; padding: 12px 0; border-top: 1px dashed var(--line); }
.wstep:first-of-type { border-top: none; }
.wstep-n { flex: none; width: 26px; height: 26px; border-radius: 999px; background: var(--cobalt-soft);
  color: var(--cobalt); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.wstep-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.wstep-label { font-weight: 600; }
.wstep-hint { color: var(--muted); font-size: 13px; }
.wacct { display: flex; align-items: center; gap: 8px; }
.wacct .conn-account { flex: 1; }
