:root {
  --bg: #0a0f1c;
  --ink: #0e1424;
  --panel: rgba(20, 28, 46, 0.72);
  --panel-solid: #141c2e;
  --panel-2: #1b2540;
  --border: rgba(120, 140, 180, 0.16);
  --border-strong: rgba(140, 165, 210, 0.34);
  --text: #eef2fb;
  --muted: #93a2c0;
  --faint: #5f6f90;
  --teal: #2dd4bf;
  --sky: #38bdf8;
  --amber: #f5b544;
  --rose: #fb7185;
  --violet: #a78bfa;
  --lime: #a3e635;
  --good: #34d399;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60rem 42rem at 8% -8%, rgba(45, 212, 191, 0.14), transparent 60%),
    radial-gradient(54rem 40rem at 102% 4%, rgba(167, 139, 250, 0.16), transparent 58%),
    radial-gradient(48rem 44rem at 50% 116%, rgba(245, 181, 68, 0.1), transparent 60%),
    var(--bg);
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.4px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 92%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 92%);
}

a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: rgba(10, 15, 28, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

header.topbar .brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  color: var(--text);
}
header.topbar .brand span { color: var(--teal); font-weight: 500; }

header.topbar nav { display: flex; gap: 0.4rem; margin-left: auto; }
header.topbar nav a {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  transition: color 0.18s, background 0.18s;
}
header.topbar nav a.active { color: var(--text); background: var(--panel-2); }
header.topbar nav a:hover { text-decoration: none; color: var(--text); }

main { max-width: 1240px; margin: 0 auto; padding: 2rem 1.5rem 1rem; position: relative; z-index: 1; }

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0.4rem 0 0.6rem;
}
h1 em { font-style: italic; font-weight: 500; color: var(--sky); }
.subtitle { color: var(--muted); margin: 0; font-size: 0.95rem; max-width: 46ch; }

.masthead {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 2rem;
  align-items: end;
  padding-bottom: 1.4rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--faint);
  margin: 0;
}
.mh-right { text-align: right; }
.hl-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  color: var(--faint);
}
.headline {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(2.4rem, 6.2vw, 4.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 0 38px rgba(56, 189, 248, 0.22);
  margin: 0.1rem 0 0.2rem;
}
.headsub { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; min-height: 2rem; }
.chips .hint { color: var(--faint); font-size: 0.84rem; font-style: italic; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 0.32rem 0.5rem 0.32rem 0.62rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.chip:hover { transform: translateY(-1px); border-color: var(--sky); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip-dim {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
  color: var(--muted);
}
.chip-val { max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { color: var(--faint); font-size: 0.72rem; line-height: 1; }
.chip:hover .chip-x { color: var(--rose); }
.clear {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.3rem 0.2rem;
}
.clear:hover { color: var(--text); }

.viewlink {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--teal);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 6px 20px rgba(45, 212, 191, 0.28);
}
.viewlink:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(45, 212, 191, 0.4); }
.viewlink .vl-n { font-weight: 600; }
.viewlink .vl-arrow { transition: transform 0.15s; }
.viewlink:hover .vl-arrow { transform: translateX(3px); }
.viewlink.dim { opacity: 0.45; pointer-events: none; }

.statline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0;
  margin-bottom: 1.5rem;
}
.stat { padding: 0 1.5rem; }
.stat:first-child { padding-left: 0; }
.stat + .stat::before {
  content: '·';
  color: var(--faint);
  margin-right: 1.5rem;
  font-size: 1.2rem;
  line-height: 1;
}
.stat .label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
  color: var(--faint);
}
.stat .value { font-family: var(--font-mono); font-weight: 500; font-size: 1.3rem; color: var(--text); }

.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.1rem;
  align-items: stretch;
}
.bento .s8 { grid-column: span 8; }
.bento .s7 { grid-column: span 7; }
.bento .s5 { grid-column: span 5; }
.bento .s4 { grid-column: span 4; }
.bento .s12 { grid-column: span 12; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.2rem 1.3rem 1.3rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.bento .card { min-height: 0; }
.bento .card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.bento .card .chart-wrap { flex: 1 1 auto; position: relative; min-height: 0; }
.bento .h-lg .chart-wrap { flex-basis: 360px; }
.bento .h-md .chart-wrap { flex-basis: 300px; }

.card h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.08rem;
  margin: 0 0 0.9rem;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.card h2 .ct {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-weight: 400;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.reveal { opacity: 0; animation: rise 0.62s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.masthead.reveal { animation-delay: 0.02s; }
.rail.reveal { animation-delay: 0.1s; }
.statline.reveal { animation-delay: 0.16s; }
.bento > .card:nth-child(1) { animation-delay: 0.2s; }
.bento > .card:nth-child(2) { animation-delay: 0.27s; }
.bento > .card:nth-child(3) { animation-delay: 0.34s; }
.bento > .card:nth-child(4) { animation-delay: 0.41s; }
.bento > .card:nth-child(5) { animation-delay: 0.48s; }
.bento > .card:nth-child(6) { animation-delay: 0.55s; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}
.card.wide { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.tall { height: 380px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.kpi .label, .detail-item .label, .filters label { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; margin-top: 0.25rem; }
.kpi .value.small { font-size: 1.05rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.filters .field { display: flex; flex-direction: column; gap: 0.25rem; }
.filters input, .filters select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  min-width: 160px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18); }
.filters .grow { flex: 1; min-width: 220px; }
.filters .grow input { width: 100%; }

button.btn {
  background: var(--teal);
  color: var(--ink);
  border: none;
  border-radius: 9px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
button.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
button.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.btn.ghost:hover { border-color: var(--border-strong); }
button.btn:disabled { opacity: 0.45; cursor: default; transform: none; filter: none; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
thead th.num, tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th:hover { color: var(--text); }
tbody td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(56, 189, 248, 0.06); }
tbody td .title-link { color: var(--text); font-weight: 500; }
tbody td .title-link:hover { color: var(--sky); }

.badge {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
}
.badge.accent { color: var(--violet); border-color: rgba(167, 139, 250, 0.5); }

.pagination { display: flex; align-items: center; gap: 0.75rem; justify-content: center; margin-top: 1.25rem; }
.pagination .info { color: var(--muted); font-size: 0.85rem; font-family: var(--font-mono); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.detail-item .val { font-size: 1.05rem; margin-top: 0.2rem; }
.detail-item .val.big { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; color: var(--good); }

.muted { color: var(--muted); }
.loading { color: var(--muted); padding: 2rem; text-align: center; }
.note { font-size: 0.8rem; color: var(--faint); margin: 1.4rem 0 0; font-family: var(--font-mono); }

footer { text-align: center; color: var(--faint); font-size: 0.78rem; padding: 2.2rem 1rem; position: relative; z-index: 1; }

@media (max-width: 980px) {
  .bento { grid-template-columns: 1fr; }
  .bento .card { grid-column: 1 / -1; }
  .masthead { grid-template-columns: 1fr; gap: 1.2rem; }
  .mh-right { text-align: left; }
}

@media (max-width: 560px) {
  main { padding: 1.3rem 1rem 1rem; }
  .stat { padding: 0 0.9rem; }
  .stat + .stat::before { margin-right: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; animation: none; }
  .card, .chip, .viewlink, button.btn, tbody tr { transition: none; }
}
