/* Design tokens — dataviz reference palette (light mode primary). */
:root {
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --accent: #2a78d6;
  --accent-deep: #1c5cab;
  --good: #0ca30c;
  --good-deep: #006300;
  --critical: #d03b3b;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.55;
  font-size: 16px;
}
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent-deep); }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0.6em 0 0.4em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 0.4em 0; }
.lede { font-size: 1.08rem; color: var(--ink-2); max-width: 46em; }
.hint, .meta, small { color: var(--muted); font-size: 0.88rem; }

/* Header / nav */
.site-header { background: var(--surface); border-bottom: 1px solid var(--hairline); }
.site-header .wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-header nav a { color: var(--ink-2); text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--ink); }

/* Hero + stat tiles */
.hero { padding-top: 1.2rem; }
.stat-row, .fact-strip { display: flex; gap: 12px; flex-wrap: wrap; margin: 1.2rem 0; }
.tile {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 12px 18px; min-width: 130px; flex: 1;
}
.tile .num { font-size: 1.7rem; font-weight: 700; }
.tile .lbl { color: var(--muted); font-size: 0.85rem; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--baseline); }
.card p { color: var(--ink-2); font-size: 0.92rem; margin: 0.3em 0; }
.card-top { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

/* Pills */
.pill {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 9px;
  border-radius: 99px; background: var(--hairline); color: var(--ink-2);
}
.pill-good { background: #e2f4e2; color: var(--good-deep); }
.pill-urgent { background: #fbe4e4; color: var(--critical); }

/* Tables */
.settle-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.settle-table th, .settle-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; font-size: 0.93rem; }
.settle-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.settle-table tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }
table.kv { border-collapse: collapse; margin: 0.6rem 0; }
table.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 16px 5px 0; vertical-align: top; white-space: nowrap; }
table.kv td { padding: 5px 0; }

/* Filters */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0.8rem 0; }
.filter {
  border: 1px solid var(--hairline); background: var(--surface); border-radius: 99px;
  padding: 5px 14px; font-size: 0.88rem; cursor: pointer; color: var(--ink-2);
}
.filter.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Buttons / CTA */
.btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: 10px 18px; border-radius: var(--radius); font-weight: 600;
}
.btn:hover { background: var(--accent-deep); }
.btn-sm { padding: 5px 12px; font-size: 0.85rem; }
.cta-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Charts */
.chart { margin: 1rem 0; position: relative; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  font-size: 0.8rem; padding: 4px 8px; border-radius: 5px; transform: translate(-50%, -130%);
  white-space: nowrap;
}
.presence { margin: 0.6rem 0; }
.presence svg { width: 100%; height: auto; display: block; }
.presence figcaption { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; }

/* Newsletter */
.newsletter { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 20px 24px; margin: 2.5rem auto; }
.newsletter-form { display: flex; gap: 8px; flex-wrap: wrap; }
.newsletter-form input { flex: 1; min-width: 220px; padding: 10px 12px; border: 1px solid var(--baseline); border-radius: var(--radius); font-size: 1rem; }
.newsletter-form button { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); padding: 10px 18px; font-weight: 600; cursor: pointer; }

/* Notes, sources, misc */
.note { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 6px 20px 14px; margin: 1.6rem 0; }
.sources { font-size: 0.9rem; word-break: break-all; }
.crumbs { color: var(--muted); font-size: 0.88rem; margin-top: 1rem; }
.crumbs a { color: var(--muted); }
.status-line { font-size: 1.02rem; }
.more { font-weight: 600; }
.aud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.aud-grid > div { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 4px 16px 10px; }

/* Footer */
.site-footer { border-top: 1px solid var(--hairline); margin-top: 3rem; padding: 18px 0 30px; color: var(--muted); font-size: 0.85rem; background: var(--surface); }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .hide-sm { display: none; }
}

/* Database explorer controls */
.db-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 1rem 0 0.4rem; }
.db-controls input[type="search"] {
  flex: 1; min-width: 260px; padding: 10px 14px; font-size: 1rem;
  border: 1px solid var(--baseline); border-radius: var(--radius); background: var(--surface);
}
.db-controls select {
  padding: 9px 10px; border: 1px solid var(--baseline); border-radius: var(--radius);
  background: var(--surface); font-size: 0.92rem; color: var(--ink-2);
}
.db-controls .filter-row { margin: 0; }
.filter .cnt { font-weight: 400; opacity: 0.75; }

.cat-links { font-size: 0.92rem; line-height: 1.9; }
.cat-links a { white-space: nowrap; }

/* Sortable table headers */
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--ink); }
.th-sortable::after { content: " ↕"; opacity: 0.35; font-size: 0.9em; }
.th-sortable[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; }
.th-sortable[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }

/* Closed-settlement notice */
.closed-banner {
  background: #fbf3e4; border: 1px solid #e6d9b8; border-left: 4px solid #b8860b;
  border-radius: var(--radius); padding: 12px 16px; margin: 1rem 0; font-size: 0.95rem;
}
