/*
 * Klever Trading design system (TrueCost, Chain League, Phone Bot Lab).
 * Tokens, base styles and shared components. Page-specific styles live in style.css.
 * Documented in design/DESIGN.md. Reuse these classes on new pages before adding new ones.
 */

/* ---------- font (self-hosted Inter, SIL Open Font Licence: fonts/Inter-OFL.txt) ---------- */
@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e9edf2;
  --border: #e1e5eb;
  --border-strong: #c9d1db;
  --text: #0e1621;
  --text-muted: #4a5667;
  --text-faint: #5f6b7b;
  --accent: #0b7268;
  --accent-hover: #095e56;
  --accent-ink: #ffffff;
  --accent-soft: #e5f4f1;
  --accent-text: #0a665d;
  --warn: #9a4a07;
  --warn-soft: #fdf3e6;
  --warn-border: #f0cf9f;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --good: #067647;
  --good-soft: #e7f6ee;
  --info-soft: #eaf1fd;
  --chart-1: #0f766e; --chart-2: #0369a1; --chart-3: #c2410c; --chart-4: #4d7c0f; --chart-5: #57534e; --chart-6: #a16207;
  --chart-muted: #8792a2;
  --chart-grid: #e6eaef;
  --chart-axis: #c4ccd6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);
  --ring: 0 0 0 3px rgba(11, 114, 104, .35);
  --header-bg: rgba(255, 255, 255, .82);
  --skeleton: #e8ecf1;
  --skeleton-shine: #f5f7fa;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --text-xs: .75rem; --text-sm: .875rem; --text-base: 1rem; --text-lg: 1.125rem; --text-xl: 1.375rem;
  --text-2xl: 1.75rem; --text-3xl: 2.25rem; --text-hero: clamp(2.1rem, 1.3rem + 3.6vw, 3.4rem);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --container: 1120px; --container-narrow: 780px;
  --header-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;
}

/* ---------- tokens: dark (system preference, unless light was chosen) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e13; --surface: #10161d; --surface-2: #151c25; --surface-3: #1c2531;
    --border: #212a36; --border-strong: #2e3a49;
    --text: #e7ecf2; --text-muted: #a3afbe; --text-faint: #8c98a8;
    --accent: #2dd4bf; --accent-hover: #5eead4; --accent-ink: #032420; --accent-soft: rgba(45, 212, 191, .12); --accent-text: #5eead4;
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .1); --warn-border: rgba(251, 191, 36, .35);
    --bad: #f87171; --bad-soft: rgba(248, 113, 113, .1); --good: #34d399; --good-soft: rgba(52, 211, 153, .1); --info-soft: rgba(96, 165, 250, .1);
    --chart-1: #2dd4bf; --chart-2: #38bdf8; --chart-3: #fb923c; --chart-4: #a3e635; --chart-5: #d6d3d1; --chart-6: #facc15;
    --chart-muted: #7c8899; --chart-grid: #1d2632; --chart-axis: #344152;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 10px 32px rgba(0, 0, 0, .5);
    --ring: 0 0 0 3px rgba(45, 212, 191, .4);
    --header-bg: rgba(10, 14, 19, .78);
    --skeleton: #18202a; --skeleton-shine: #222c38;
  }
}
/* the same dark tokens when chosen with the toggle */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e13; --surface: #10161d; --surface-2: #151c25; --surface-3: #1c2531;
  --border: #212a36; --border-strong: #2e3a49;
  --text: #e7ecf2; --text-muted: #a3afbe; --text-faint: #8c98a8;
  --accent: #2dd4bf; --accent-hover: #5eead4; --accent-ink: #032420; --accent-soft: rgba(45, 212, 191, .12); --accent-text: #5eead4;
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .1); --warn-border: rgba(251, 191, 36, .35);
  --bad: #f87171; --bad-soft: rgba(248, 113, 113, .1); --good: #34d399; --good-soft: rgba(52, 211, 153, .1); --info-soft: rgba(96, 165, 250, .1);
  --chart-1: #2dd4bf; --chart-2: #38bdf8; --chart-3: #fb923c; --chart-4: #a3e635; --chart-5: #d6d3d1; --chart-6: #facc15;
  --chart-muted: #7c8899; --chart-grid: #1d2632; --chart-axis: #344152;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 10px 32px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(45, 212, 191, .4);
  --header-bg: rgba(10, 14, 19, .78);
  --skeleton: #18202a; --skeleton-shine: #222c38;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--text-base); line-height: 1.55;
  font-feature-settings: "cv05", "cv08", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 var(--space-3); letter-spacing: -.015em; font-weight: 650; }
h1 { font-size: var(--text-2xl); letter-spacing: -.025em; font-weight: 700; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); margin-top: var(--space-5); }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
strong { font-weight: 650; }
small, .small { font-size: var(--text-sm); }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
::selection { background: var(--accent-soft); color: var(--text); }
img, svg { max-width: 100%; }
.num, .big, table, .kpi .v, .stat-value { font-variant-numeric: tabular-nums; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.skip-link { position: absolute; left: var(--space-3); top: -48px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: var(--space-3); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.container, .wrap { width: 100%; max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--space-4); }
.container.wide, .wrap.wide, .container-wide { max-width: var(--container); }
main { padding-bottom: var(--space-7); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid-2, .grid-3 { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 640px) { .container, .wrap { padding: 0 var(--space-5); } }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  transition: box-shadow var(--dur) var(--ease);
}
.site-header.is-scrolled { box-shadow: var(--shadow-md); }
.header-inner { max-width: var(--container); display: flex; align-items: center; flex-wrap: wrap; gap: 0 var(--space-4); min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; margin-right: auto; padding: var(--space-2) 0; }
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .bm-body { fill: var(--accent); }
.brand-mark .bm-glyph { fill: var(--accent-ink); stroke: var(--accent-ink); }
.brand-mark .bm-glyph rect { stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 1.02rem; }
.brand-sub { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; letter-spacing: .01em; }
.brand-sub b { color: var(--accent-text); font-weight: 650; letter-spacing: .02em; }
.site-nav { display: flex; gap: 2px; order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--space-2)); padding: 0 0 var(--space-2); }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: none; color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 550;
  padding: 7px 10px; border-radius: var(--radius-sm); transition: color var(--dur), background-color var(--dur);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-3); }
.icon-button {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: var(--radius);
  cursor: pointer; transition: color var(--dur), border-color var(--dur), background-color var(--dur);
}
.icon-button:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-button svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
@media (min-width: 860px) {
  .site-nav { order: 0; width: auto; overflow: visible; margin: 0; padding: 0; }
}

/* ---------- page heading & hero ---------- */
.page-head { padding: var(--space-7) 0 var(--space-4); }
.page-head h1 { font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.4rem); margin-bottom: var(--space-3); }
.page-head .lede { font-size: var(--text-lg); color: var(--text-muted); max-width: 64ch; margin: 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--space-3);
  font-size: var(--text-xs); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text);
}
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lede { color: var(--text-muted); }
.hero { padding: var(--space-8) 0 var(--space-6); position: relative; }
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 420px; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 70% at 15% 0%, var(--accent-soft), transparent 70%);
}
.hero-grid { display: grid; gap: var(--space-6); align-items: center; grid-template-columns: 1fr; }
.hero h1 { font-size: var(--text-hero); letter-spacing: -.035em; line-height: 1.05; margin-bottom: var(--space-4); max-width: 16ch; }
.hero .lede { font-size: 1.15rem; max-width: 52ch; margin-bottom: var(--space-5); }
.hero-points { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); list-style: none; padding: 0; margin: var(--space-5) 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.hero-points li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 6px; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.15fr .85fr; } }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4); margin: var(--space-4) 0; box-shadow: var(--shadow-sm);
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-head h2 { margin: 0; }
.card h2 { font-size: var(--text-lg); }
.card-sub { color: var(--text-muted); font-size: var(--text-sm); margin: 4px 0 0; }
.card.elevated { box-shadow: var(--shadow-md); }
.card.flat { box-shadow: none; background: var(--surface-2); }
a.card-link { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur); }
a.card-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); color: inherit; }
.card-link .arrow { color: var(--accent-text); font-weight: 600; font-size: var(--text-sm); }
@media (min-width: 640px) { .card { padding: var(--space-5) var(--space-5); } }

/* ---------- buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 10px 18px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background-color var(--dur), border-color var(--dur), color var(--dur), transform var(--dur) var(--ease);
}
.button:hover { background: var(--accent-hover); color: var(--accent-ink); }
.button:active { transform: translateY(1px); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button.secondary:hover { background: var(--surface-2); color: var(--text); }
.button.ghost { background: transparent; color: var(--accent-text); box-shadow: none; }
.button.ghost:hover { background: var(--accent-soft); }
.button.small, .small-btn { min-height: 34px; padding: 6px 12px; font-size: var(--text-sm); }
.button:disabled, .button[aria-busy="true"] { opacity: .65; cursor: progress; }
.button[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.link-btn { background: none; border: 0; color: var(--accent-text); font: inherit; font-size: var(--text-sm); font-weight: 550; cursor: pointer; padding: 8px 0; }
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }
.cta-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ---------- forms ---------- */
.field { margin: var(--space-3) 0 0; flex: 1; min-width: 0; }
.field label, .label-text { display: block; font-size: var(--text-sm); font-weight: 550; color: var(--text-muted); margin-bottom: 6px; }
input[type="number"], input[type="text"], input[type="email"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem; font-variant-numeric: tabular-nums;
  transition: border-color var(--dur), box-shadow var(--dur), background-color var(--dur);
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238792a2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: var(--space-4) 0 0; padding: var(--space-3) var(--space-4) var(--space-4); min-width: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: var(--text-sm); color: var(--text); }
.row { display: flex; flex-direction: column; gap: 0 var(--space-3); }
@media (min-width: 600px) { .row { flex-direction: row; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-sm); cursor: pointer; }
.check input { margin-top: 3px; }
.hint { font-size: var(--text-sm); color: var(--text-muted); margin: 6px 0 0; }
.seg { display: flex; gap: var(--space-4); font-size: var(--text-sm); margin-top: 4px; }
.seg label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
/* segmented control */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-4); }
.tabs button {
  flex: 1; min-height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted);
  font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: color var(--dur), background-color var(--dur), box-shadow var(--dur);
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
/* chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chips button {
  font: inherit; font-size: var(--text-sm); font-weight: 550; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); border-radius: var(--radius-pill);
  cursor: pointer; transition: color var(--dur), border-color var(--dur), background-color var(--dur);
}
.chips button:hover { color: var(--text); border-color: var(--text-faint); }
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(-45deg); transition: transform var(--dur); }
details[open] > summary::before { transform: rotate(45deg); }

/* ---------- badges, callouts, states ---------- */
.badge, .pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border);
}
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); animation: pulse 2s ease-in-out infinite; }
.notice, .callout {
  border: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--text);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-weight: 500;
}
.notice strong, .callout strong { color: var(--warn); }
.callout.info { background: var(--info-soft); border-color: var(--border); }
.error, .callout.bad { background: var(--bad-soft); border: 1px solid transparent; color: var(--bad); border-radius: var(--radius); padding: var(--space-2) var(--space-3); font-weight: 550; }
.flag { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 6px 10px; font-size: var(--text-sm); font-weight: 550; margin: var(--space-2) 0; }
.state { text-align: center; padding: var(--space-6) var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted); }
.state-icon { width: 36px; height: 36px; margin: 0 auto var(--space-2); display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font-weight: 700; }
.state.error-state .state-icon { background: var(--bad-soft); color: var(--bad); }
.state-title { color: var(--text); font-weight: 600; margin: 0 0 4px; }
.state p { margin: 0 auto; max-width: 48ch; font-size: var(--text-sm); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* ---------- skeletons ---------- */
.skeleton { display: block; border-radius: var(--radius-sm); background: var(--skeleton); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line.lg { height: 22px; width: 40%; }
.skeleton-line.short { width: 55%; }
.skeleton-card { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-3); }

/* ---------- KPIs and big numbers ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin: var(--space-3) 0; }
@media (min-width: 640px) { .kpis.four { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.kpi .v, .stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.kpi .l, .stat-label { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.big { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; margin: 0; line-height: 1.15; }
.label { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.num-flash { animation: flash .7s var(--ease); }

/* ---------- tables ---------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap.tall { max-height: 72vh; overflow: auto; }
.table-wrap.is-scrollable { background:
  linear-gradient(to right, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
  linear-gradient(to left, var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
  radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .16), transparent) left / 10px 100% no-repeat scroll,
  radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .16), transparent) right / 10px 100% no-repeat scroll,
  var(--surface); }
.table-hint { display: none; font-size: var(--text-xs); color: var(--text-muted); margin: 6px 0 0; }
.table-hint::before { content: "↔ "; }
.table-wrap.is-scrollable + .table-hint { display: block; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
th, td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { text-align: left; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-muted);
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
tbody tr { transition: background-color var(--dur); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 550; }
table.zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.zebra tbody tr:hover { background: var(--surface-2); }
td.text, th.text { text-align: left; }
tfoot td, tr.total td, tr.total th { font-weight: 700; background: var(--surface-2); }
.pos { color: var(--good); } .neg { color: var(--bad); }
table.wrap-cells th, table.wrap-cells td { white-space: normal; text-align: left; vertical-align: top; min-width: 7rem; }
/* stacked rows on phones: add .stack-sm to the table and data-label to cells */
@media (max-width: 599px) {
  table.stack-sm thead { display: none; }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td, table.stack-sm th { display: block; width: 100%; }
  table.stack-sm tr { border-bottom: 1px solid var(--border); padding: var(--space-2) 0; }
  table.stack-sm td, table.stack-sm th { border: 0; padding: 4px 12px; text-align: right; white-space: normal; }
  table.stack-sm td::before { content: attr(data-label); float: left; color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; font-weight: 500; }
  .table-wrap.tall { max-height: none; }
  table.stack-sm tbody tr:last-child { border-bottom: 0; }
}

/* ---------- charts ---------- */
.chart { margin: var(--space-4) 0 0; position: relative; }
.chart figcaption { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-2); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart .tick { fill: var(--text-faint); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; font-weight: 550; }
.chart .series { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .series.dashed { stroke-dasharray: 5 4; stroke-width: 1.75; }
.chart .area { stroke: none; opacity: .08; }
.series-1 { stroke: var(--chart-1); --c: var(--chart-1); } .series-2 { stroke: var(--chart-2); --c: var(--chart-2); }
.series-3 { stroke: var(--chart-3); --c: var(--chart-3); } .series-4 { stroke: var(--chart-4); --c: var(--chart-4); }
.series-5 { stroke: var(--chart-5); --c: var(--chart-5); } .series-6 { stroke: var(--chart-6); --c: var(--chart-6); }
.series-muted { stroke: var(--chart-muted); --c: var(--chart-muted); }
.area.series-1 { fill: var(--chart-1); }
.chart .crosshair { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart .marker-label { fill: var(--text); font-size: 12px; font-weight: 650; }
.chart-scroll { overflow-x: auto; }
.chart-scroll svg { min-width: 560px; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 260px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px 10px; font-size: var(--text-xs); line-height: 1.45; opacity: 0; transform: translateY(4px);
  transition: opacity var(--dur), transform var(--dur) var(--ease);
}
.chart-tooltip.is-visible { opacity: 1; transform: none; }
.chart-tooltip .tt-title { font-weight: 650; color: var(--text); margin-bottom: 4px; font-size: var(--text-sm); }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; color: var(--text-muted); }
.chart-tooltip .tt-row b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tooltip .tt-key::before { content: ""; width: 10px; height: 3px; border-radius: 2px; background: var(--c, var(--accent)); flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--text-xs); color: var(--text-muted); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--c, var(--accent)); border-radius: 2px; }
.legend .swatch.dashed { border-top-style: dashed; border-top-width: 2px; }
.chart-hint { font-size: var(--text-xs); color: var(--text-muted); margin: 0 0 6px; }
@media (min-width: 640px) { .chart-hint { display: none; } }

/* ---------- prose ---------- */
.prose p, .prose li { max-width: 70ch; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin: .35rem 0; }
.prose li::marker { color: var(--text-faint); }
.prose h3 { font-size: var(--text-base); margin: var(--space-5) 0 var(--space-2); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: var(--space-6); padding: var(--space-6) 0 var(--space-5); font-size: var(--text-sm); color: var(--text-muted); }
.footer-grid { display: grid; gap: var(--space-5); grid-template-columns: 1fr; max-width: var(--container); }
.footer-brand .brand { margin-bottom: var(--space-3); }
.disclaimer { color: var(--text); font-weight: 600; margin-bottom: var(--space-2); }
.footer-note { max-width: 70ch; }
.footer-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (min-width: 640px) { .footer-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.independence { font-size: var(--text-xs); color: var(--text-muted); max-width: 70ch; }
.independence-bar { background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-muted); }
.independence-bar p { margin: 0; padding: 7px 0; }
.footer-cols h2 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 0 0 var(--space-2); font-weight: 650; }
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a, .footer-bottom a { color: var(--text-muted); text-decoration: none; }
.footer-cols a:hover, .footer-bottom a:hover { color: var(--text); text-decoration: underline; }
.footer-cols a[aria-current="page"] { color: var(--text); font-weight: 600; }
.footer-bottom { max-width: var(--container); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4); border-top: 1px solid var(--border); margin-top: var(--space-5); padding-top: var(--space-4); font-size: var(--text-xs); }
.footer-bottom .link-btn { font-size: var(--text-xs); padding: 0; color: var(--text-muted); }
@media (min-width: 860px) { .footer-grid { grid-template-columns: 1.3fr 1fr; } }

/* ---------- motion ---------- */
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes flash { from { background-color: var(--accent-soft); } to { background-color: transparent; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .35s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}

/* ---------- print: always light, no chrome ---------- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f4f6f8; --surface-3: #eef1f4; --border: #d5dbe2; --border-strong: #c3ccd6;
    --text: #111; --text-muted: #444; --text-faint: #555; --accent: #0b7268; --accent-text: #0b7268; --accent-soft: #eef7f6;
    --warn: #9a4a07; --warn-soft: #fff6ea; --warn-border: #e8c48f; --bad: #b42318; --bad-soft: #fdecea;
    --chart-1: #0f766e; --chart-2: #0369a1; --chart-3: #c2410c; --chart-4: #4d7c0f; --chart-5: #57534e; --chart-6: #a16207; --chart-grid: #e3e7ec; --chart-axis: #b8c1cc;
  }
  body { font-size: 10.5pt; background: #fff; }
  .site-header, .site-footer, .no-print, .skip-link, .theme-toggle, .chart-tooltip, .table-hint, .chart-hint { display: none !important; }
  .card { border: 0; box-shadow: none; padding: 0; margin: 10px 0; break-inside: auto; }
  .card h2, h3 { break-after: avoid; }
  table, figure, .kpis { break-inside: avoid; }
  .table-wrap { overflow: visible; border: 0; background: none !important; }
  thead th { position: static; }
  table { font-size: 8.5pt; }
  th, td { white-space: normal; padding: 4px 5px; }
  a { color: inherit; text-decoration: none; }
  .container, .wrap { max-width: none; padding: 0; }
  .page-head { padding: 0 0 8px; }
  .chart-scroll svg { min-width: 0; }
}
