/*
 * CB Exchange design system. One file, served at /brand.css, loaded by every
 * page (index.html, login.html, subscribe.html, the auth result pages).
 *
 * Tokens first, then the shared components (top bar, page header, cards,
 * buttons, forms, badges, empty/skeleton states, toasts). Page-specific CSS
 * stays in each page.
 *
 * Color roles
 *   --accent      brand teal, the Caribbean sea. Links, primary buttons, focus ring,
 *                 the proof badge. Text-safe on both surfaces (≥ 4.5:1).
 *   --accent-2    coral, used sparingly for warmth: the wordmark dot, highlights.
 *   --series-*    data-viz colors (validated colorblind-safe pairs, see README).
 *                 Never used for UI chrome, never for text.
 *   --good/--warning/--critical   status colors; always paired with an icon or label.
 */

:root {
  color-scheme: light;

  /* surfaces + ink: warm sand, so the teal and coral have something to sit on */
  --page: #f3efe6;
  --surface: #fffdf8;
  --surface-2: #ece7da;
  --ink: #10201f;
  --ink-2: #48595a;
  --muted: #5b6c6d;
  --border: rgba(20, 60, 66, .12);
  --border-strong: rgba(20, 60, 66, .24);
  --grid: #e2dccd;
  --axis: #c6bfae;

  /* brand gradients + atmosphere (per mode) */
  --grad-band: linear-gradient(120deg, #0f766e 0%, #0d3b44 55%, #12232a 100%);
  --grad-brand: linear-gradient(135deg, #0f766e, #c2461f);
  --grad-ink: #ffffff;
  --grad-edge: linear-gradient(135deg, rgba(15, 118, 110, .6), rgba(232, 96, 60, .4) 60%, rgba(15, 118, 110, .1));
  --glow: radial-gradient(55% 38% at 15% -5%, rgba(15, 118, 110, .14), transparent 70%), radial-gradient(40% 30% at 92% 0%, rgba(232, 96, 60, .12), transparent 70%);
  --section-h: #0f766e;

  /* brand */
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-ink: #ffffff;
  --accent-wash: rgba(15, 118, 110, .10);
  --accent-wash-2: rgba(15, 118, 110, .18);
  --accent-2: #e8603c;
  --accent-2-text: #b23a1b;
  --accent-2-wash: rgba(232, 96, 60, .12);

  /* status */
  --good: #0b7a3b;
  --good-wash: rgba(11, 122, 59, .10);
  --warning: #fab219;
  --warning-text: #7a4b00;
  --warning-wash: rgba(250, 178, 25, .16);
  --critical: #c43a3a;
  --critical-wash: rgba(196, 58, 58, .10);
  --up-text: #0b7a3b;
  --down-text: #c43a3a;

  /* data-viz (unchanged from the validated reference palette) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --pos: #2a78d6;
  --neg: #e34948;
  --mid: #ece7da;
  --wash: rgba(42, 120, 214, .10);

  /* type scale (px) */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 32px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --gutter: 16px;
  --measure: 1120px;

  /* radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(17, 18, 16, .06), 0 1px 1px rgba(17, 18, 16, .03);
  --shadow-2: 0 6px 20px rgba(17, 18, 16, .10), 0 1px 2px rgba(17, 18, 16, .06);
  --shadow-3: 0 16px 40px rgba(17, 18, 16, .16), 0 2px 6px rgba(17, 18, 16, .08);

  /* focus ring: visible on every surface, two-tone so it works on the accent too */
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --topbar-h: 56px;
}

/* Dark mode: deep sea. The same hues stepped for the dark surface, declared under both
   the OS preference and the explicit toggle so the toggle wins either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b161a;
    --surface: #12232a;
    --surface-2: #19303a;
    --ink: #eef5f5;
    --ink-2: #bfd0d2;
    --muted: #8ea6ab;
    --border: rgba(120, 200, 210, .14);
    --border-strong: rgba(120, 200, 210, .28);
    --grid: #1f343c;
    --axis: #2c4650;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-ink: #0b161a;
    --accent-wash: rgba(45, 212, 191, .12);
    --accent-wash-2: rgba(45, 212, 191, .22);
    --accent-2: #ff8f6b;
    --accent-2-text: #ff8f6b;
    --accent-2-wash: rgba(255, 143, 107, .14);
    --good: #4ade80;
    --good-wash: rgba(74, 222, 128, .12);
    --warning: #fab219;
    --warning-text: #fcd27a;
    --warning-wash: rgba(250, 178, 25, .14);
    --critical: #f87171;
    --critical-wash: rgba(248, 113, 113, .12);
    --up-text: #4ade80;
    --down-text: #f87171;
    --series-1: #3987e5;
    --series-2: #d95926;
    --pos: #3987e5;
    --neg: #e66767;
    --mid: #2c4650;
    --wash: rgba(57, 135, 229, .12);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 6px 20px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-3: 0 16px 40px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
    --grad-band: linear-gradient(120deg, #0f766e 0%, #0d3b44 55%, #12232a 100%);
    --grad-brand: linear-gradient(135deg, #2dd4bf, #ff8f6b);
    --grad-ink: #0b161a;
    --grad-edge: linear-gradient(135deg, rgba(45, 212, 191, .55), rgba(255, 143, 107, .35) 60%, rgba(45, 212, 191, .1));
    --glow: radial-gradient(55% 38% at 15% -5%, rgba(45, 212, 191, .18), transparent 70%), radial-gradient(40% 30% at 92% 0%, rgba(255, 143, 107, .12), transparent 70%);
    --section-h: #7fd6cb;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b161a;
  --surface: #12232a;
  --surface-2: #19303a;
  --ink: #eef5f5;
  --ink-2: #bfd0d2;
  --muted: #8ea6ab;
  --border: rgba(120, 200, 210, .14);
  --border-strong: rgba(120, 200, 210, .28);
  --grid: #1f343c;
  --axis: #2c4650;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-ink: #0b161a;
  --accent-wash: rgba(45, 212, 191, .12);
  --accent-wash-2: rgba(45, 212, 191, .22);
  --accent-2: #ff8f6b;
  --accent-2-text: #ff8f6b;
  --accent-2-wash: rgba(255, 143, 107, .14);
  --good: #4ade80;
  --good-wash: rgba(74, 222, 128, .12);
  --warning: #fab219;
  --warning-text: #fcd27a;
  --warning-wash: rgba(250, 178, 25, .14);
  --critical: #f87171;
  --critical-wash: rgba(248, 113, 113, .12);
  --up-text: #4ade80;
  --down-text: #f87171;
  --series-1: #3987e5;
  --series-2: #d95926;
  --pos: #3987e5;
  --neg: #e66767;
  --mid: #2c4650;
  --wash: rgba(57, 135, 229, .12);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 20px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
  --grad-band: linear-gradient(120deg, #0f766e 0%, #0d3b44 55%, #12232a 100%);
  --grad-brand: linear-gradient(135deg, #2dd4bf, #ff8f6b);
  --grad-ink: #0b161a;
  --grad-edge: linear-gradient(135deg, rgba(45, 212, 191, .55), rgba(255, 143, 107, .35) 60%, rgba(45, 212, 191, .1));
  --glow: radial-gradient(55% 38% at 15% -5%, rgba(45, 212, 191, .18), transparent 70%), radial-gradient(40% 30% at 92% 0%, rgba(255, 143, 107, .12), transparent 70%);
  --section-h: #7fd6cb;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: var(--fs-base)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Atmosphere: a soft teal + coral glow at the top of every page. Chrome only; charts and status colors are untouched. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--glow), var(--page); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s-3); }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--accent-wash-2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.up { color: var(--up-text); }
.down { color: var(--down-text); }
.small { font-size: var(--fs-sm); }

/* ---------- layout ---------- */
.wrap { max-width: var(--measure); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
main.page { padding-top: var(--s-5); padding-bottom: var(--s-10); }
.stack { display: grid; gap: var(--s-3); }
.stack-lg { display: grid; gap: var(--s-4); }
.cols-2 { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--fs-md); letter-spacing: -.01em; white-space: nowrap; }
.wordmark:hover { color: var(--ink); }
.wordmark .mark { width: 26px; height: 26px; flex: none; display: block; }
.wordmark .mark .tile { fill: var(--accent); }
.wordmark .mark .wave { stroke: var(--accent-ink); }
.wordmark .mark .dot { fill: var(--accent-2); }
.wordmark .name { display: inline-flex; align-items: baseline; gap: 5px; }
.wordmark .name .cb { font-weight: 800; }
.wordmark .name .ex { font-weight: 500; color: var(--ink-2); }
.wordmark.lg { font-size: var(--fs-xl); gap: 12px; }
.wordmark.lg .mark { width: 36px; height: 36px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .bar { height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-3); }
.topbar nav.primary { display: none; align-items: center; gap: 2px; margin-left: var(--s-3); }
.topbar nav.primary a { display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: var(--r-md); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: var(--fs-base); }
.topbar nav.primary a:hover { color: var(--ink); background: var(--surface-2); }
.topbar nav.primary a[aria-current="page"] { color: var(--ink); background: var(--accent-wash); position: relative; }
.topbar nav.primary a[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -11px; height: 2px; border-radius: 2px; background: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .menu { position: relative; }
.topbar .menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 6px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-weight: 500; font-size: var(--fs-sm); max-width: 220px; }
.topbar .menu > summary::-webkit-details-marker { display: none; }
.topbar .menu > summary:hover { background: var(--surface-2); }
.topbar .menu > summary .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu > summary .chev { width: 14px; height: 14px; flex: none; color: var(--muted); }
.topbar .menu[open] > summary .chev { transform: rotate(180deg); }
.topbar .menu .panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 6px; z-index: 30; }
.topbar .menu .panel .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.topbar .menu .panel .head .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu .panel .head .e { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu .panel a, .topbar .menu .panel button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--r-md); color: var(--ink); text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer; }
.topbar .menu .panel a:hover, .topbar .menu .panel button:hover { background: var(--surface-2); }
.topbar .menu .panel .ico { width: 16px; height: 16px; color: var(--muted); flex: none; }
.topbar .burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; margin-left: -4px; }
.topbar .burger svg { width: 20px; height: 20px; }
.topbar .burger:hover { background: var(--surface-2); }
.topbar nav.mobile { display: none; padding: 6px 0 10px; border-top: 1px solid var(--border); }
.topbar nav.mobile a { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px; border-radius: var(--r-md); color: var(--ink); text-decoration: none; font-weight: 500; font-size: var(--fs-md); }
.topbar nav.mobile a:hover { background: var(--surface-2); }
.topbar nav.mobile a[aria-current="page"] { background: var(--accent-wash); }
.topbar nav.mobile a .ico { width: 18px; height: 18px; color: var(--muted); }
.topbar.menu-open nav.mobile { display: grid; gap: 2px; }
@media (min-width: 760px) {
  .topbar nav.primary { display: inline-flex; }
  .topbar .burger { display: none; }
  .topbar.menu-open nav.mobile { display: none; }
}
.signin-link { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border); color: var(--ink); text-decoration: none; font-weight: 500; font-size: var(--fs-sm); white-space: nowrap; flex: none; }
.signin-link:hover { background: var(--surface-2); color: var(--ink); }

/* theme toggle (System / Light / Dark), lives in the account menu and the mobile menu */
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; font-size: var(--fs-sm); color: var(--muted); }
.theme-row .seg button { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }

/* ---------- banners, notes, onboarding ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--warning-wash); border: 1px solid var(--warning); color: var(--ink); padding: 10px 12px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.45; }
.banner .ico { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--warning-text); }
.banner b { font-weight: 600; }
.note { font-size: var(--fs-sm); padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); line-height: 1.45; }
.note.ok { border-color: var(--good); background: var(--good-wash); }
.note.err { border-color: var(--critical); background: var(--critical-wash); }
.note.info { border-color: var(--accent); background: var(--accent-wash); }
.note code { font-size: var(--fs-xs); }
.onboard { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--accent-wash); border: 1px solid var(--accent); border-radius: var(--r-lg); padding: 12px 14px; font-size: var(--fs-base); }
.onboard .ico { width: 22px; height: 22px; flex: none; color: var(--accent); }
.onboard .t { flex: 1; min-width: 200px; }
.onboard .t b { display: block; font-weight: 600; }
.onboard .t span { color: var(--ink-2); font-size: var(--fs-sm); }

/* ---------- page header: the brand band ---------- */
.page-head { position: relative; overflow: hidden; display: grid; gap: var(--s-2); margin-bottom: var(--s-4); padding: var(--s-4); border-radius: var(--r-lg); background: var(--grad-band); color: #fff; border: 1px solid rgba(45, 212, 191, .35); box-shadow: var(--shadow-2); }
.page-head::after { content: ""; position: absolute; right: -24px; top: -16px; width: 220px; height: 140px; pointer-events: none; opacity: .13; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M6 21.5c3 0 3-7 6-7s3 7 6 7 3-10 6-10' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }
.page-head > * { position: relative; z-index: 1; }
.page-head .crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: rgba(255, 255, 255, .72); flex-wrap: wrap; }
.page-head .crumbs a { color: rgba(255, 255, 255, .88); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.page-head .crumbs a:hover { color: #fff; text-decoration: underline; }
.page-head .crumbs .sep { color: rgba(255, 255, 255, .4); }
.page-head .crumbs svg { width: 14px; height: 14px; }
.page-head .row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-2xl); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: #fff; }
.page-head .sub { color: rgba(255, 255, 255, .82); margin: 0; font-size: var(--fs-md); max-width: 60ch; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .pill { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .28); color: #fff; }
.page-head .btn { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .32); color: #fff; }
.page-head .btn:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); color: #fff; }
.page-head .btn.primary { background: #fff; border-color: #fff; color: #0f766e; }
.page-head .btn.primary:hover { background: #e6fffa; border-color: #e6fffa; color: #0f766e; }
.page-head a:focus-visible, .page-head button:focus-visible { box-shadow: 0 0 0 2px #0d3b44, 0 0 0 4px #fff; }
@media (min-width: 760px) { .page-head { padding: var(--s-6) var(--s-6) var(--s-5); } .page-head h1 { font-size: var(--fs-3xl); } .page-head::after { width: 320px; height: 200px; right: -40px; top: -30px; } }

/* The same band, free-standing, for the login and subscribe pages. */
.band { position: relative; overflow: hidden; padding: var(--s-5); border-radius: var(--r-lg); background: var(--grad-band); color: #fff; border: 1px solid rgba(45, 212, 191, .35); box-shadow: var(--shadow-2); }
.band::after { content: ""; position: absolute; right: -30px; top: -20px; width: 240px; height: 160px; pointer-events: none; opacity: .13; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M6 21.5c3 0 3-7 6-7s3 7 6 7 3-10 6-10' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }
.band > * { position: relative; z-index: 1; }
.band h1 { color: #fff; }
.band p { color: rgba(255, 255, 255, .82); }
.band .wordmark, .band .wordmark:hover { color: #fff; }
.band .wordmark .ex { color: rgba(255, 255, 255, .8); }
.band .wordmark .mark .tile { fill: rgba(255, 255, 255, .18); }
.band .wordmark .mark .wave { stroke: #fff; }
.band .kicker { display: inline-flex; align-items: center; gap: 6px; color: #9ff0e4; font-weight: 600; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; }
@media (min-width: 760px) { .band { padding: var(--s-8) var(--s-6); } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-2); flex-wrap: wrap; }
.section-head h2 { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--section-h); }
.section-head .more { font-size: var(--fs-sm); text-decoration: none; font-weight: 500; }
.section-head .more:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4); box-shadow: var(--shadow-1); min-width: 0; }
.card > h2:first-child, .card .card-head h2 { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card > h2:first-child { margin-bottom: var(--s-3); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
a.card { text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
@media (min-width: 760px) { .card { padding: var(--s-5); } }

/* ---------- buttons ---------- */
.btn { font: inherit; font-weight: 500; font-size: var(--fs-base); display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--ink); }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn.lg { height: 44px; padding: 0 20px; font-size: var(--fs-md); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--ink-2); height: 34px; padding: 0 12px; cursor: pointer; font: inherit; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--surface-2); }
.seg button:focus-visible { box-shadow: inset var(--ring); border-radius: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--accent); }

/* ---------- forms ---------- */
.field { display: grid; gap: 5px; min-width: 0; }
.field > span.lbl, .field > label.lbl { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .err { font-size: var(--fs-xs); color: var(--critical); display: none; }
.field.invalid .err { display: block; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--critical); }
input, textarea, select { font: inherit; color: var(--ink); }
input[type=text], input[type=email], input[type=url], input[type=number], input:not([type]), textarea, select {
  width: 100%; padding: 9px 11px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); line-height: 1.4; min-height: 40px;
}
textarea { min-height: 72px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash-2); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--critical); }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
select.compact { min-height: 34px; padding-top: 5px; padding-bottom: 5px; width: auto; }
.form { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }
@media (min-width: 560px) { .form { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .form { grid-template-columns: repeat(4, 1fr); } }
.form .wide { grid-column: 1 / -1; }
.form .half { grid-column: span 1; }
@media (min-width: 560px) { .form .half { grid-column: span 2; } }
.form .actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form .actions .muted { font-size: var(--fs-sm); }

/* ---------- badges, pills, chips, avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 500; line-height: 1; padding: 5px 9px; border-radius: var(--r-pill); border: 1px solid var(--border); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
.pill svg { width: 12px; height: 12px; flex: none; }
.pill.proof { background: var(--accent-wash); border-color: transparent; color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--accent-wash-2), 0 4px 14px var(--accent-wash); }
.pill.warn { background: var(--warning-wash); border-color: var(--warning); color: var(--warning-text); }
.pill.good { background: var(--good-wash); border-color: transparent; color: var(--good); }
.pill.bad { background: var(--critical-wash); border-color: transparent; color: var(--critical); }
.pill.open { background: var(--surface-2); border-color: transparent; }
.pill.lg { font-size: var(--fs-sm); padding: 7px 12px; }
.pill.lg svg { width: 14px; height: 14px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.live, .dot.ok { background: var(--good); }
.dot.statement, .dot.none { background: var(--muted); }
.dot.mismatch, .dot.error { background: var(--critical); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); font-size: var(--fs-sm); max-width: 100%; }
.chip .lbl { font-weight: 600; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar.init { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); background: var(--accent-wash); font-size: var(--fs-sm); }

/* ---------- empty + loading states ---------- */
.empty { color: var(--muted); padding: var(--s-6) var(--s-2); text-align: center; }
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: var(--s-8) var(--s-4); }
.empty-state .ico { width: 40px; height: 40px; color: var(--accent); background: var(--accent-wash); border-radius: 50%; display: grid; place-items: center; margin-bottom: 4px; }
.empty-state .ico svg { width: 20px; height: 20px; }
.empty-state h3 { font-size: var(--fs-md); }
.empty-state p { color: var(--ink-2); max-width: 44ch; margin: 0; font-size: var(--fs-base); }
.empty-state .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); min-height: 12px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); } }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel.line { height: 12px; }
.skel.title { height: 20px; width: 40%; }
.skel.block { height: 120px; border-radius: var(--r-md); }
.fade { opacity: .55; transition: opacity .15s; pointer-events: none; }
.loading-row { display: grid; gap: 10px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 50; pointer-events: none; }
@media (min-width: 560px) { .toasts { left: auto; width: 360px; } }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--ink); color: var(--page); padding: 12px 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-3); font-size: var(--fs-base); animation: toast-in .18s ease-out; }
.toast .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok .ico { color: var(--good); }
.toast.err .ico { color: var(--critical); }
.toast .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .t b { display: block; font-weight: 600; }
.toast .x { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; width: 20px; height: 20px; flex: none; font: inherit; }
.toast .x:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.tscroll { overflow-x: auto; margin: 0 calc(var(--s-4) * -1); padding: 0 var(--s-4); -webkit-overflow-scrolling: touch; }
@media (min-width: 760px) { .tscroll { margin: 0 calc(var(--s-5) * -1); padding: 0 var(--s-5); } }
