/* ---------- Design tokens (dataviz reference palette) ---------- */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good: #006300;
  --bad: #d03b3b;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);

  /* categorical slots — fixed order, color follows the category */
  --series-1: #2a78d6; /* blue    — General */
  --series-2: #008300; /* green   — PNP */
  --series-3: #e87ba4; /* magenta — CEC */
  --series-4: #eda100; /* yellow  — French */
  --series-5: #1baf7a; /* aqua    — Occupation-targeted */
  --series-6: #eb6834; /* orange  — FSW / FST */

  /* ordinal blue ramp for CRS score bands (low → high score) */
  --ramp-1: #86b6ef;
  --ramp-2: #5598e7;
  --ramp-3: #2a78d6;
  --ramp-4: #1c5cab;
  --ramp-5: #104281;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --good: #0ca30c;
    --bad: #d03b3b;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --series-1: #3987e5;
    --series-2: #008300;
    --series-3: #d55181;
    --series-4: #c98500;
    --series-5: #199e70;
    --series-6: #d95926;
    /* ramp anchor flips on dark: higher score = lighter */
    --ramp-1: #1c5cab;
    --ramp-2: #2a78d6;
    --ramp-3: #5598e7;
    --ramp-4: #86b6ef;
    --ramp-5: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --good: #0ca30c;
  --bad: #d03b3b;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.14);
  --series-1: #3987e5;
  --series-2: #008300;
  --series-3: #d55181;
  --series-4: #c98500;
  --series-5: #199e70;
  --series-6: #d95926;
  --ramp-1: #1c5cab;
  --ramp-2: #2a78d6;
  --ramp-3: #5598e7;
  --ramp-4: #86b6ef;
  --ramp-5: #b7d3f6;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-leaf { font-size: 28px; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.tagline { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.data-status { font-size: 12.5px; color: var(--text-secondary); text-align: right; }
.data-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot-live { background: #0ca30c; }
.dot-snapshot { background: #fab219; }
.icon-btn {
  font-size: 17px; line-height: 1; padding: 7px 10px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-wash); }

/* ---------- Banner ---------- */
.banner {
  margin: 16px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid #fab219;
  border-radius: 8px;
  background: var(--surface-1);
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* ---------- Latest draw ---------- */
.latest-card { margin-top: 16px; }
.latest-card .card-sub { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-secondary); }
.mi-link { font-size: 13px; white-space: nowrap; }
.latest-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 36px;
  align-items: start;
}
@media (max-width: 760px) { .latest-grid { grid-template-columns: 1fr; } }
.latest-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
  margin-top: 10px;
}
.lstat-label { font-size: 12.5px; color: var(--text-secondary); }
.lstat-value { font-size: 20px; font-weight: 600; line-height: 1.25; }
.lstat-value.big { font-size: 28px; }
.lstat-delta { font-size: 12.5px; color: var(--text-secondary); }
.lstat-delta.up-good, .lstat-delta.down-good { color: var(--good); }
.lstat-delta.up-bad, .lstat-delta.down-bad { color: var(--bad); }
.lstat-note { font-size: 12px; color: var(--text-muted); }
.latest-pool { margin-top: 10px; }
.latest-pool-title { margin: 0 0 6px; font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.latest-pool-note { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); max-width: 360px; }

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0 4px;
}

/* ---------- Filters ---------- */
.filter-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  margin: 20px 0 16px;
}
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.range-btn {
  font: inherit; font-size: 13px; padding: 5px 12px;
  background: var(--surface-1); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.range-btn:hover { color: var(--text-primary); }
.range-btn.is-active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; padding: 5px 12px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip[aria-pressed="false"] .swatch { background: var(--text-muted) !important; }
.chip:hover { background: var(--accent-wash); }

/* ---------- KPI tiles ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 12.5px; color: var(--text-secondary); }
.stat-value { font-size: 30px; font-weight: 600; line-height: 1.15; }
.stat-delta { font-size: 12.5px; min-height: 1.2em; color: var(--text-secondary); }
.stat-delta.up-good, .stat-delta.down-good { color: var(--good); }
.stat-delta.up-bad, .stat-delta.down-bad { color: var(--bad); }
.stat-note { font-size: 12px; color: var(--text-muted); }

/* ---------- Cards & charts ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 12px;
  margin-bottom: 14px;
}
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.card-grid .card { margin-bottom: 0; }
@media (max-width: 860px) { .card-grid { grid-template-columns: 1fr; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 16px; }
.card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.chart { position: relative; margin-top: 10px; min-height: 120px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--text-muted); font-size: 13px; padding: 30px 0; text-align: center; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 12.5px; color: var(--text-secondary); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key-line { width: 14px; height: 2px; border-radius: 1px; position: relative; }
.legend .key-line::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: inherit;
}
.legend .key-rect { width: 10px; height: 10px; border-radius: 3px; }

/* SVG chart pieces */
.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--baseline); stroke-width: 1; }
.tick-label { fill: var(--text-muted); font-size: 11px; }
.direct-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.crosshair { stroke: var(--baseline); stroke-width: 1; pointer-events: none; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  padding: 8px 11px;
  font-size: 12.5px;
  max-width: 280px;
}
.tooltip .tt-title { color: var(--text-muted); font-size: 11.5px; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: baseline; gap: 7px; }
.tooltip .tt-key { display: inline-block; width: 10px; height: 2px; border-radius: 1px; flex: none; vertical-align: middle; }
.tooltip .tt-val { font-weight: 600; color: var(--text-primary); }
.tooltip .tt-label { color: var(--text-secondary); }
.tooltip .tt-cap { color: var(--text-muted); font-size: 11px; margin: 7px 0 3px; }
.tooltip .tt-mini { display: block; }
.tooltip .tt-mini-label { fill: var(--text-muted); font-size: 7.5px; }
.tooltip .tt-mini-val { fill: var(--text-secondary); font-size: 7.5px; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
.data-table td.name-cell { white-space: normal; min-width: 220px; }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th button {
  font: inherit; font-weight: 600; color: var(--text-secondary);
  background: none; border: none; padding: 0; cursor: pointer;
}
.data-table th button:hover { color: var(--text-primary); }
.data-table tbody tr:hover { background: var(--accent-wash); }
.sort-ind { font-size: 10px; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.table-foot { font-size: 12.5px; color: var(--text-muted); margin: 8px 0 2px; }
.select-input {
  font: inherit; font-size: 13px;
  padding: 5px 8px;
  background: var(--page); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  max-width: 220px;
}
.search-input {
  font: inherit; font-size: 13px;
  padding: 6px 12px; min-width: 210px;
  background: var(--page); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
}
.table-details { margin: 10px 0 4px; font-size: 13px; }
.table-details summary { cursor: pointer; color: var(--text-secondary); }
.mini-table { border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.mini-table th, .mini-table td { padding: 4px 14px 4px 0; border-bottom: 1px solid var(--grid); text-align: left; }
.mini-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table th.num, .mini-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- SEO content (About + FAQ) ---------- */
.noscript-note { padding: 12px 0; color: var(--text-secondary); font-size: 14px; }
.seo-content > h2 { font-size: 16px; margin: 22px 0 8px; }
.seo-content > h2:first-child { margin-top: 0; }
.seo-content p { font-size: 13.5px; color: var(--text-secondary); max-width: 72ch; }
.seo-content .faq h3 { font-size: 14px; margin: 16px 0 4px; color: var(--text-primary); }
.seo-content .faq p { margin: 0; }
.seo-source { font-size: 12px; color: var(--text-muted); margin-top: 18px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 28px; padding: 20px 0 32px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-muted);
}
.site-footer p { margin: 4px 0; }

@media (max-width: 640px) {
  .stat-value { font-size: 24px; }
  .header-row { flex-wrap: wrap; }
}
