/* ============================================================================
   AgentHC — Premium design system
   Dark fintech terminal aesthetic (Bloomberg × Linear × Stripe).
   Self-hosted only (strict CSP). One accent. Inter variable font.
   This file is the shared shell: every route inherits this vocabulary.
   ========================================================================== */

/* ----- Font (self-hosted variable woff2; wght 100–900, opsz 14–32) -------- */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  font-named-instance: "Regular";
}

/* ----- Design tokens ------------------------------------------------------- */
:root {
  /* Surfaces — layered, near-black, cool */
  --bg: #0a0c10;
  --bg-elev: #0e1117;
  --surface: #14181f;
  --surface-2: #1a1f28;
  --surface-hover: #1d232d;
  --border: #232a35;
  --border-soft: #1b212b;
  --border-strong: #2e3744;

  /* Text */
  --text: #e8edf4;
  --text-dim: #aab3c0;
  --muted: #7d8694;
  --faint: #565f6c;

  /* Accent — a single confident electric blue */
  --accent: #4d8dff;
  --accent-hover: #6fa3ff;
  --accent-press: #3d79e6;
  --accent-soft: rgba(77, 141, 255, 0.14);
  --accent-glow: rgba(77, 141, 255, 0.35);
  --on-accent: #ffffff;

  /* Semantic */
  --green: #3ecf8e;
  --green-soft: rgba(62, 207, 142, 0.14);
  --red: #ff5d6c;
  --red-soft: rgba(255, 93, 108, 0.14);
  --yellow: #e3b341;
  --yellow-soft: rgba(227, 179, 65, 0.14);
  --orange: #f08c3c;
  --orange-soft: rgba(240, 140, 60, 0.16);
  --purple: #b48cff;
  --pink: #f778ba;

  /* Type scale */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Inter", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Radii */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Spacing rhythm (8px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 8px 30px rgba(77, 141, 255, 0.18);

  --nav-h: 60px;
  --maxw: 1140px;
}

/* ----- Reset --------------------------------------------------------------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Ambient terminal backdrop: faint accent glow + grid, fixed so it doesn't scroll */
  background-image:
    radial-gradient(900px 500px at 78% -10%, rgba(77, 141, 255, 0.10), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(180, 140, 255, 0.05), transparent 55%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img, svg { display: inline-block; vertical-align: middle; max-width: 100%; }
svg { fill: currentColor; }

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

/* Custom scrollbar — subtle, terminal-y */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ----- Focus (accessibility) ---------------------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----- Layout primitives --------------------------------------------------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-5); }
.page { padding: var(--sp-6) var(--sp-5) var(--sp-8); }
.narrow { max-width: 540px; }
main.page { animation: fadeUp 0.4s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- Type helpers -------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; line-height: 1.5; }
.pos { color: var(--green); }
.neg { color: var(--red); }

h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 33px; font-weight: 800; margin-bottom: var(--sp-3); }
h2 { font-size: 23px; font-weight: 700; margin-bottom: var(--sp-3); }
h3 { font-size: 15px; font-weight: 700; margin-bottom: var(--sp-2); letter-spacing: -0.01em; }
h4 { font-size: 14px; font-weight: 700; margin-bottom: var(--sp-2); }
p { margin: 0 0 0.4em; }
strong, b { font-weight: 700; color: var(--text); }
code, pre, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================================================================
   ADMIN PREVIEW ribbon
   ========================================================================== */
.ribbon {
  background: linear-gradient(90deg, var(--orange), #ffaa55);
  color: #1a0f00;
  text-align: center;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
}

/* ============================================================================
   NAV — sticky, frosted, terminal header
   ========================================================================== */
.nav {
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 var(--sp-5);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.nav-brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0;   /* NO gap: 'Agent' (span) + 'HC' (text node) are separate flex items;
               any gap renders BETWEEN them as "Agent HC". Dot spacing is on ::before. */
}
.nav-brand:hover { text-decoration: none; color: var(--text); }
.nav-brand span { color: var(--accent); }
/* Brand mark dot */
.nav-brand::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 12px var(--accent-glow);
  flex: 0 0 auto;
  margin-right: 8px;   /* space between the brand dot and "AgentHC" */
}

.nav-links { display: flex; gap: 2px; margin-left: var(--sp-4); }
.nav-links a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-links a[aria-current="page"], .nav-links a.active { color: var(--text); background: var(--surface-2); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.nav-user { font-size: 12.5px; color: var(--muted); }

/* CSS-only mobile-nav toggle (CSP-safe — strict script-src 'self' forbids inline
   JS). The checkbox IS the hamburger button: appearance:none strips the native
   box, a ::before draws the glyph, and `:checked ~ .nav-links` opens the menu.
   It stays keyboard-operable (Space toggles) so the mobile nav works with no JS. */
.hamburger {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  width: 38px;
  height: 36px;
  margin: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.hamburger::before { content: "\2630"; display: block; } /* ☰ */
.hamburger:checked::before { content: "\2715"; } /* ✕ when open */
.hamburger:hover { background: var(--surface); }
.hamburger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================================
   BADGES — pill, semantic
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  line-height: 1.4;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-admin { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.badge-plan  { background: var(--accent-soft); color: var(--accent-hover); border-color: transparent; }
.badge-win   { background: var(--green-soft);  color: var(--green);  border-color: transparent; }
.badge-loss  { background: var(--red-soft);    color: var(--red);    border-color: transparent; }
.badge-hypo  { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
.badge-flat  { background: rgba(255,255,255,.05); color: var(--text-dim, #9aa6b6); border-color: var(--border-soft, #232834); }
.badge-ok    { background: var(--green-soft);  color: var(--green);  border-color: transparent; }
.badge-warn  { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }

/* ============================================================================
   BUTTONS
   ========================================================================== */
.btn-cta, .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: 0.005em;
  padding: 9px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease, color 0.16s ease;
  user-select: none;
}
.btn-cta {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-accent);
}
.btn-cta:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: var(--on-accent); }
.btn-cta:active { background: var(--accent-press); transform: translateY(1px); box-shadow: var(--shadow-sm); }

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface); border-color: var(--accent); color: var(--text); text-decoration: none; }
.btn-outline:active { transform: translateY(1px); }
.btn-outline.disabled, .btn-cta.disabled,
.btn-outline[disabled], .btn-cta[disabled] {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}

.block { display: flex; width: 100%; text-align: center; margin-bottom: var(--sp-3); }

/* ============================================================================
   DISCLAIMERS / compliance surfaces
   ========================================================================== */
.disclaimer-banner {
  background: linear-gradient(180deg, var(--yellow-soft), transparent);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 9px var(--sp-5);
  text-align: center;
}
.disclaimer-banner strong { color: var(--yellow); }
.disclaimer-banner a { color: var(--accent); white-space: nowrap; }

.disc-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin: var(--sp-3) 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}
.disc-hypothetical { border-left-color: var(--yellow); }
.disc-position { border-left-color: var(--orange); }
.disc-label {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-right: 8px;
}
.disc-position .disc-label { color: var(--orange); }

/* Legal document scroll-boxes (advisory terms / OPRA doc) */
.legal-doc {
  background: var(--bg-elev);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  color: var(--text-dim);
}
.legal-doc h1, .legal-doc h2, .legal-doc h3 { color: var(--text); }

.ok-banner { color: var(--green); font-weight: 650; }

/* ============================================================================
   HERO — tasteful gradient + grid wash
   ========================================================================== */
.hero {
  position: relative;
  padding: var(--sp-8) 0 var(--sp-6);
  isolation: isolate;
  /* Clip the decorative ::before/::after glow+grid horizontally: they bleed
     -40px past the hero's right edge, and on narrow (mobile) viewports that
     pushes the page scrollWidth ~24px past the viewport, causing a horizontal
     scroll. `overflow-x: clip` confines only the horizontal bleed (keeping the
     top glow) without creating a scroll container — no content overflows. */
  overflow-x: clip;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40px -40px auto -40px;
  height: 360px;
  z-index: -1;
  background:
    linear-gradient(transparent, transparent),
    radial-gradient(600px 280px at 18% 10%, var(--accent-soft), transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 320px;
  z-index: -2;
  opacity: 0.5;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(700px 300px at 30% 0%, #000, transparent 75%);
  mask-image: radial-gradient(700px 300px at 30% 0%, #000, transparent 75%);
}
.hero h1 {
  font-size: clamp(34px, 5.2vw, 52px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-4);
  background: linear-gradient(180deg, #ffffff, #c4cdda);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .subtitle {
  font-size: clamp(16px, 2.2vw, 19px);
  color: var(--text-dim);
  max-width: 660px;
  line-height: 1.55;
  margin-bottom: var(--sp-5);
}
.hero-ctas { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ============================================================================
   SECTIONS / GRID / CARDS
   ========================================================================== */
.section { padding: var(--sp-5) 0; }
.section + .section { border-top: 1px solid var(--border-soft); }

.grid { display: grid; gap: var(--sp-4); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 120px),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
/* Cards that link/interact get a lift; static cards stay calm. */
a.card:hover,
.card.win:hover,
.alert-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
a.card:hover { transform: translateY(-2px); text-decoration: none; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.card.win { border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }

fieldset.card { padding: var(--sp-5); }
fieldset.card legend {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ----- Stat blocks --------------------------------------------------------- */
.stat { text-align: center; }
.stat-val {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ----- Key/value lists ----------------------------------------------------- */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.kv li:last-child { border-bottom: none; }
.kv li > span { color: var(--muted); }

.subinfo { font-size: 12.5px; color: var(--muted); line-height: 1.55; }

/* ============================================================================
   PRICING
   ========================================================================== */
.price-card { display: flex; flex-direction: column; gap: var(--sp-3); position: relative; }
.price-card.featured,
.price-card.featured.featured {
  border-color: var(--accent);
  box-shadow: var(--shadow-accent), var(--shadow-md);
}
.price-card.featured::before,
.featured > .price-tier::after { /* no-op safety, real ribbon below */ }
.price-card.featured::after {
  content: "POPULAR";
  position: absolute;
  top: -10px;
  right: var(--sp-4);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-accent);
}
.price-tier {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

/* ============================================================================
   TABLES
   ========================================================================== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: var(--sp-3);
}
.tbl th, .tbl td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.tbl th {
  color: var(--muted);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--bg-elev);
  /* Static, NOT sticky: the table cards live inside overflow containers and
     under a sticky nav, where `position: sticky; top: nav-h` detached the
     header and floated it down over the data rows. A static header sits cleanly
     atop the table and scrolls with it. */
  position: static;
}
.tbl thead th:first-child { border-top-left-radius: var(--r-sm); }
.tbl thead th:last-child { border-top-right-radius: var(--r-sm); }
.tbl td { font-variant-numeric: tabular-nums; color: var(--text-dim); }
.tbl tbody tr { transition: background 0.12s ease; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ============================================================================
   FORMS
   ========================================================================== */
.form { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 440px; margin: var(--sp-3) 0; }
.form label, label {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 550;
}
.form input, .form textarea, .form select,
input[type="text"], input[type="email"], input[type="password"],
textarea, select, .wl-input {
  padding: 10px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form input::placeholder, textarea::placeholder, .wl-input::placeholder { color: var(--faint); }
.form input:focus, .form textarea:focus, .form select:focus,
input:focus, textarea:focus, select:focus, .wl-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.wl-input { width: 100%; box-sizing: border-box; }

.inline-form { display: inline; margin: 0; }

/* Checkbox / toggle rows (clickwrap, settings) */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: var(--sp-2);
  line-height: 1.45;
  font-size: 14px;
  color: var(--text-dim);
}
.check input[type="checkbox"],
.toggle-row input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-meta { display: flex; flex-direction: column; gap: 2px; }
.toggle-meta strong { font-size: 14px; }
.toggle-disabled { opacity: 0.55; }

/* Field wrapper used by several pages */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--sp-3); }
.field > label { margin-bottom: 0; }

/* ============================================================================
   JOURNAL CARD
   ========================================================================== */
.journal-card { display: flex; flex-direction: column; }
.journal-card .grid-3 { gap: var(--sp-3); }
.journal-card .stat {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 10px;
}
.journal-card .stat-val { font-size: 22px; }
.journal-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 10px 14px;
}
.journal-status .disc-label { margin-right: 2px; }

/* ============================================================================
   ALERT CARD  (shared base; alerts/_styles.html layers page specifics on top)
   ========================================================================== */
.alert-card { margin-bottom: var(--sp-4); }
.alert-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.alert-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.alert-strategy {
  margin: 6px 0 2px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.alert-pnl {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: var(--sp-3) 0;
}
.alert-pnl .stat-val { font-size: 24px; }
.alert-modeled, .alert-opra, .alert-opra-locked {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
}
.alert-modeled h4, .alert-opra h4, .alert-opra-locked h4 { margin: 0 0 6px; font-size: 14px; }
.alert-opra-locked {
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-top: var(--sp-4);
}
.alert-fields {
  list-style: none;
  margin: var(--sp-2) 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 22px;
}
.alert-fields li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dotted var(--border);
  padding: 4px 0;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.alert-fields li span { color: var(--muted); }
.alert-fields li b { color: var(--text); }
.alert-card-foot {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
}
.alert-card-foot p { margin: 4px 0; }

/* ============================================================================
   PAGER
   ========================================================================== */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

/* ============================================================================
   FOOTER
   ========================================================================== */
.footer {
  padding: var(--sp-7) 0 var(--sp-6);
  border-top: 1px solid var(--border-soft);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: var(--sp-7);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.25));
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--sp-5);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.footer-links a { color: var(--text-dim); font-weight: 550; }
.footer-links a:hover { color: var(--text); }
.footer-addr { font-size: 12.5px; margin-bottom: var(--sp-2); color: var(--muted); }
.footer-disclaimer {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--faint);
  max-width: 760px;
  margin: 0 auto;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 920px) {
  .grid-3 { grid-template-columns: 1fr; }
  .nav { gap: var(--sp-3); }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: var(--sp-3) var(--sp-5);
    gap: 4px;
    margin-left: 0;
    z-index: 99;
    box-shadow: var(--shadow-lg);
  }
  .hamburger:checked ~ .nav-links,
  .nav-links.open { display: flex; animation: fadeUp 0.2s ease both; }
  .nav-links a { padding: 11px 12px; font-size: 15px; }
  /* Order the in-flow row: brand · (auto gap) · right cluster · hamburger.
     The checkbox sits before .nav-links in the DOM, so order keeps it far-right. */
  .nav-right { order: 2; margin-left: auto; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; order: 3; margin-left: 0; }
  .nav-user { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .container { padding: 0 var(--sp-4); }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .hero { padding: var(--sp-6) 0 var(--sp-5); }
  .card { padding: var(--sp-4); }
  .stat-val { font-size: 26px; }
  .footer-links { gap: var(--sp-4); }
}

/* ============================================================================
   MOTION PREFERENCES
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * , *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   CHART FOUNDATION — server-rendered inline-SVG charts (webapp/charts.py) +
   layout helpers the shared foundation introduces. No JS; CSP-safe.
   ========================================================================== */
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.ahc-chart { margin: 0; width: 100%; }
.ahc-chart svg { max-width: 100%; }

/* donut + bars legend */
.ahc-legend {
  list-style: none;
  margin: var(--sp-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
}
.ahc-legend li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12.5px;
  color: var(--text-dim);
}
.ahc-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.ahc-lg-lbl { flex: 1 1 auto; }
.ahc-lg-val {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

/* horizontally scrollable table wrapper (mobile-safe) */
.ahc-tbl-scroll { overflow-x: auto; padding: 0; }
.ahc-tbl-scroll .tbl { margin: 0; }

@media (max-width: 880px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================================
   PRO WIDGETS — premium UI layer (CSP-safe: CSS + a self-hosted /static/app.js
   progressive-enhancement script; no third-party JS). Everything degrades
   gracefully with JS off and respects prefers-reduced-motion (block above).
   ========================================================================== */

/* ---- reveal-on-scroll: [data-reveal] fades/slides in via app.js (.is-in) --- */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s cubic-bezier(.22,.61,.36,1), transform 0.6s cubic-bezier(.22,.61,.36,1);
  will-change: opacity, transform;
}
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal][data-reveal="fade"] { transform: none; }
[data-reveal][data-reveal="left"] { transform: translateX(-22px); }
[data-reveal][data-reveal="right"] { transform: translateX(22px); }
[data-reveal][data-reveal="scale"] { transform: scale(.96); }
/* JS-off fallback: never hide content if the script never runs */
.no-js [data-reveal] { opacity: 1; transform: none; }

/* ---- glass card variant: subtle frosted, layered depth -------------------- */
.glass {
  background: linear-gradient(160deg,
              color-mix(in srgb, var(--bg-elev) 88%, transparent),
              color-mix(in srgb, var(--surface) 70%, transparent));
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--accent) 8%);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 4%, transparent) inset,
              var(--shadow-lg, 0 18px 40px -24px rgba(0,0,0,.7));
}

/* ---- hover lift / interactive elevation ----------------------------------- */
.lift { transition: transform .18s cubic-bezier(.22,.61,.36,1), box-shadow .18s ease, border-color .18s ease; }
.lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg, 0 20px 44px -22px rgba(0,0,0,.75));
  border-color: color-mix(in srgb, var(--border) 60%, var(--accent) 30%);
}

/* ---- micro-interactions: buttons + links ---------------------------------- */
.btn-cta, .btn-outline { transition: transform .08s ease, background .16s ease, box-shadow .16s ease, border-color .16s ease, color .16s ease; }
.btn-cta:active, .btn-outline:active { transform: translateY(1px) scale(.99); }
.btn-cta:hover { box-shadow: 0 8px 24px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; }
.link-arrow > .arw { transition: transform .18s ease; }
.link-arrow:hover > .arw { transform: translateX(4px); }

/* ---- tooltip: CSS-only, [data-tip] ---------------------------------------- */
.tip { position: relative; cursor: help; border-bottom: 1px dotted var(--muted); }
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 10px; width: max-content; max-width: 240px;
  font-size: 12px; font-weight: 500; line-height: 1.4; white-space: normal;
  box-shadow: var(--shadow-lg, 0 14px 30px -16px rgba(0,0,0,.7));
  opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease; z-index: 50;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- CSS-only tabs: radio inputs + sibling panels (.ahc-tabs) ------------- */
.ahc-tabs { margin-top: var(--sp-3); }
.ahc-tabs > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ahc-tablist { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border-soft); margin-bottom: var(--sp-4); }
.ahc-tablist label {
  padding: 9px 15px; font-size: 13px; font-weight: 650; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.ahc-tablist label:hover { color: var(--text-dim); }
.ahc-tabpanel { display: none; animation: fadeUp .3s ease both; }
/* up to 5 tabs: checked radio reveals its panel + active label */
.ahc-tabs > input:nth-of-type(1):checked ~ .ahc-tabpanels > .ahc-tabpanel:nth-of-type(1),
.ahc-tabs > input:nth-of-type(2):checked ~ .ahc-tabpanels > .ahc-tabpanel:nth-of-type(2),
.ahc-tabs > input:nth-of-type(3):checked ~ .ahc-tabpanels > .ahc-tabpanel:nth-of-type(3),
.ahc-tabs > input:nth-of-type(4):checked ~ .ahc-tabpanels > .ahc-tabpanel:nth-of-type(4),
.ahc-tabs > input:nth-of-type(5):checked ~ .ahc-tabpanels > .ahc-tabpanel:nth-of-type(5) { display: block; }
.ahc-tabs > input:nth-of-type(1):checked ~ .ahc-tablist label:nth-of-type(1),
.ahc-tabs > input:nth-of-type(2):checked ~ .ahc-tablist label:nth-of-type(2),
.ahc-tabs > input:nth-of-type(3):checked ~ .ahc-tablist label:nth-of-type(3),
.ahc-tabs > input:nth-of-type(4):checked ~ .ahc-tablist label:nth-of-type(4),
.ahc-tabs > input:nth-of-type(5):checked ~ .ahc-tablist label:nth-of-type(5) { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- live market ticker (top strip; populated by app.js from /ticker.json)  */
.ahc-ticker-bar {
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  overflow: hidden; position: relative; height: 34px;
}
.ahc-ticker-bar.is-empty { display: none; }
.ahc-ticker-bar::before, .ahc-ticker-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 48px; z-index: 2; pointer-events: none;
}
.ahc-ticker-bar::before { left: 0; background: linear-gradient(90deg, var(--bg) , transparent); }
.ahc-ticker-bar::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
.ahc-ticker {
  display: flex; align-items: center; gap: var(--sp-5); height: 100%;
  white-space: nowrap; width: max-content;
  animation: ahc-marquee 48s linear infinite;
}
.ahc-ticker-bar:hover .ahc-ticker { animation-play-state: paused; }
.ahc-tick { display: inline-flex; align-items: baseline; gap: 7px; font-size: 12.5px; }
.ahc-tick-k { color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.ahc-tick-v { font-weight: 650; font-variant-numeric: tabular-nums; }
.ahc-tick-v.up { color: var(--green); }
.ahc-tick-v.down { color: var(--red); }
.ahc-tick-v.flat { color: var(--text-dim); }
@keyframes ahc-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ahc-ticker { animation: none; } }

/* ---- skeleton shimmer (loading placeholder) ------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--bg-elev) 37%, var(--surface) 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: ahc-shimmer 1.4s ease infinite; color: transparent !important;
}
@keyframes ahc-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
