:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #14213d;
  --text-muted: #5a6478;
  --border: #dfe3ee;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 10px 30px rgba(20, 33, 61, 0.08);
  --radius: 16px;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --info: #0369a1;
  --critical: #9f1239;
  --muted: #64748b;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #131c31;
  --surface-2: #1b2742;
  --text: #e8edf7;
  --text-muted: #9aa6bf;
  --border: #26324e;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #38bdf8;
  --critical: #fb7185;
  --muted: #94a3b8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(1080px, 100% - 2.5rem);
  margin-inline: auto;
}

a {
  color: var(--accent);
}

code {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  flex-wrap: wrap;
  padding-block: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  margin-inline-start: auto;
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Layout ------------------------------------------------------------------ */

.main-content {
  padding-block: 2rem 3rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.lead {
  color: var(--text-muted);
  max-width: 62ch;
}

.section-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

/* Hero -------------------------------------------------------------------- */

.hero {
  --state-color: var(--muted);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--state-color);
  border-radius: var(--radius);
  padding: 1.75rem 1.9rem;
  box-shadow: var(--shadow);
}

.hero-title {
  margin: 0.2rem 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--state-color);
  line-height: 1.1;
}

.hero-confidence {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.hero-reasons {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.hero-reasons li {
  color: var(--text);
}

.state-danger { --state-color: var(--danger); }
.state-warn { --state-color: var(--warn); }
.state-ok { --state-color: var(--ok); }
.state-info { --state-color: var(--info); }
.state-critical { --state-color: var(--critical); }
.state-muted { --state-color: var(--muted); }

/* Banners ----------------------------------------------------------------- */

.banner {
  margin-top: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.banner-warn {
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}

.banner-info {
  border-color: color-mix(in srgb, var(--info) 40%, var(--border));
  background: color-mix(in srgb, var(--info) 10%, var(--surface));
}

/* Cards ------------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.indicator-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.indicator-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.indicator-card.is-empty {
  opacity: 0.65;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.card-value {
  margin-top: 0.6rem;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 0.15rem;
}

.card-date {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-change {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.change-label {
  color: var(--text-muted);
}

.change-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dir-up .change-value,
.dir-up.stat-value { color: var(--warn); }
.dir-down .change-value,
.dir-down.stat-value { color: var(--info); }

/* Advice ------------------------------------------------------------------ */

.advice {
  margin-top: 1.5rem;
}

.advice-headline {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.advice-message {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.advice-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.column-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.action-list,
.example-list,
.advice-notes {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.4rem;
}

.example-list li {
  color: var(--text-muted);
}

.advice-notes {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.disclaimer {
  margin: 1.25rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Detail page ------------------------------------------------------------- */

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--accent);
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head h1 {
  margin: 0.1rem 0 0.5rem;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Chart ------------------------------------------------------------------- */

.chart-card {
  margin-top: 1.5rem;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.chart-head .section-title {
  margin: 0;
}

.window-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.window-option {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-muted);
}

.window-option.is-active {
  background: var(--accent);
  color: #fff;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.empty-state {
  color: var(--text-muted);
  margin: 0;
}

/* Freshness badge --------------------------------------------------------- */

.freshness {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.freshness.is-fresh {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

.freshness.is-stale {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
}

/* Empty / 404 ------------------------------------------------------------- */

.empty-page {
  text-align: center;
  padding: 3rem 1.5rem;
}

.button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0.25rem 0;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 720px) {
  .header-inner {
    gap: 0.5rem;
  }

  .site-nav {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
    overflow-x: auto;
  }

  .theme-toggle {
    margin-inline-start: auto;
  }
}
