:root {
  color-scheme: light;
  --surface-0: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --success: #006300;

  --series-div-A: #2a78d6;
  --series-div-B: #eb6834;
  --series-div-C: #1baf7a;
  --series-div-D: #eda100;
  --series-div-E: #e87ba4;
  --series-primary: #1C6B54;
  --series-primary-soft: #EAF3EF;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --brand-pine: #1C6B54;
  --brand-gold: #B5771F;
}
/* This dashboard is intentionally light-only (no dark-mode auto-switch) —
   a fixed, predictable look for the placement cell regardless of the
   viewer's OS theme setting. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
.muted { color: var(--text-muted); font-size: 12.5px; }
.app { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark-img {
  width: 52px; height: 52px; border-radius: 14px; object-fit: contain; background: #ffffff;
  border: 1px solid var(--border); padding: 6px; flex-shrink: 0;
}
.brand-text h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.brand-text p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.topbar-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.badge-demo { background: #FDF3E3; color: var(--brand-gold); border: 1px solid #F0DDB8; }

/* ---------- page nav (multi-page site) ---------- */
.pagenav {
  display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--border); padding-bottom: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.pagenav a {
  display: inline-block; padding: 10px 16px; font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.pagenav a:hover { color: var(--text-primary); }
.pagenav a.on { color: var(--brand-pine); border-bottom-color: var(--brand-pine); }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 18px; margin-bottom: 22px;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.filter-group select, .filter-group input {
  font: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-0); color: var(--text-primary); min-width: 220px;
}
.filter-group input:focus, .filter-group select:focus { outline: none; border-color: var(--brand-pine); }
.filter-summary { margin-left: auto; }
.btn-ghost {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: transparent; color: var(--text-primary); cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn-ghost:hover { background: var(--surface-0); }

/* ---------- KPI tiles ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi-row-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-row-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
}
.kpi-tile .kpi-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.kpi-tile .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-tile .kpi-sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }
.kpi-tile.kpi-risk .kpi-value { color: var(--status-serious); }

/* ---------- cards / grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px;
  margin-bottom: 16px;
}
.grid-2 > .card { margin-bottom: 0; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head p { margin: 3px 0 14px; }
/* Charts are drawn in a fixed logical SVG coordinate system (viewBox) that
   stretches to fill whatever width it's given - great for normal screens,
   but stretched all the way down to a narrow phone it makes every label
   illegibly small. Below `min-width` the chart scrolls horizontally inside
   its card instead of continuing to shrink, keeping labels readable. */
.chart-body, .chart-body-tall, .chart-body-auto { position: relative; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.chart-body { height: 220px; }
.chart-body-tall { height: 300px; }
.chart-body svg, .chart-body-tall svg, .chart-body-auto svg { min-width: 460px; }

/* ---------- specialization accordion (overview page) ---------- */
.spec-list { display: flex; flex-direction: column; }
.spec-row { border-bottom: 1px solid var(--gridline); }
.spec-row:last-child { border-bottom: none; }
.spec-row-head {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 4px; background: none; border: none;
  cursor: pointer; font: inherit; color: var(--text-primary); text-align: left;
}
.spec-row-head:hover { background: var(--surface-0); }
.spec-row-chevron { flex-shrink: 0; width: 14px; color: var(--text-muted); transition: transform .15s; font-size: 12px; }
.spec-row-head[aria-expanded="true"] .spec-row-chevron { transform: rotate(90deg); color: var(--brand-pine); }
.spec-row-name { flex: 0 0 auto; width: 230px; max-width: 38%; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-row-bar { flex: 1; height: 9px; border-radius: 5px; background: var(--gridline); overflow: hidden; min-width: 40px; }
.spec-row-bar.small { height: 7px; }
.spec-row-fill { display: block; height: 100%; border-radius: 5px; }
.spec-row-value { flex: 0 0 auto; width: 52px; text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.spec-row-count { flex: 0 0 auto; width: 92px; text-align: right; font-size: 11.5px; color: var(--text-muted); }
.spec-row-body { padding: 4px 4px 16px 30px; display: flex; flex-direction: column; gap: 9px; }
.spec-subrow { display: flex; align-items: center; gap: 12px; }
.spec-subrow .spec-row-name { width: auto; flex: 0 0 auto; font-weight: 500; font-size: 12.5px; color: var(--text-secondary); }
.spec-more-link { font-size: 12px; font-weight: 700; color: var(--brand-pine); text-decoration: none; margin-top: 4px; }
.spec-more-link:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .spec-row-name { width: auto; max-width: none; flex: 1 1 40%; }
  .spec-row-count { display: none; }
  .spec-row-body { padding-left: 20px; }
}

/* ---------- weak-spot callout cards (student analytics) ---------- */
.weak-list { display: flex; gap: 12px; flex-wrap: wrap; }
.weak-item {
  flex: 1; min-width: 180px; background: var(--surface-0); border: 1px solid var(--border);
  border-left: 3px solid var(--status-serious); border-radius: 10px; padding: 12px 14px;
}
.weak-item-topic { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.weak-item-pct { font-size: 24px; font-weight: 800; color: var(--status-serious); font-variant-numeric: tabular-nums; }
.weak-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
     color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--gridline); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--gridline); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
.rank-cell { font-weight: 700; color: var(--text-muted); }
.div-chip {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px;
  font-weight: 700; font-size: 11.5px; color: #fff;
}
.status-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------- dumbbell / gap chart (HTML, not SVG - see common.js) ---------- */
.dumbbell-chart { display: flex; flex-direction: column; }
.dumbbell-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--gridline); }
.dumbbell-row:last-child { border-bottom: none; }
.dumbbell-topic { flex: 0 0 180px; max-width: 40%; font-size: 12.5px; color: var(--text-secondary); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dumbbell-track { flex: 1; position: relative; height: 6px; border-radius: 4px; background: var(--gridline); min-width: 60px; }
.dumbbell-connector { position: absolute; top: 50%; height: 2px; transform: translateY(-50%); background: var(--baseline); border-radius: 2px; }
.dumbbell-dot {
  position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%;
  transform: translate(-50%, -50%); border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--border);
}
.dumbbell-dot.avg { background: var(--text-muted); width: 11px; height: 11px; }
.dumbbell-readout { flex: 0 0 76px; text-align: right; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dumbbell-readout .muted { font-weight: 400; font-size: 11px; }

@media (max-width: 560px) {
  .dumbbell-row { flex-wrap: wrap; gap: 4px 10px; padding: 10px 0; }
  .dumbbell-topic { flex: 1 1 100%; max-width: none; text-align: left; font-weight: 600; }
  .dumbbell-track { flex: 1 1 auto; order: 1; }
  .dumbbell-readout { flex: 0 0 auto; order: 2; }
}

/* ---------- exports ---------- */
.export-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- footer ---------- */
.footer { padding-top: 10px; border-top: 1px solid var(--border); }
.footer p { font-size: 12px; color: var(--text-muted); max-width: 900px; line-height: 1.6; }

/* ---------- SVG chart chrome ---------- */
.viz-tooltip {
  position: absolute; pointer-events: none; background: var(--text-primary); color: var(--surface-1);
  font-size: 11.5px; padding: 6px 9px; border-radius: 8px; transform: translate(-50%, -110%);
  white-space: nowrap; opacity: 0; transition: opacity .1s; z-index: 5;
}
.viz-tooltip.show { opacity: 1; }
.bar-label { font-size: 11px; font-weight: 700; fill: var(--text-primary); }
.axis-label { font-size: 10.5px; fill: var(--text-muted); }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 980px) {
  .app { padding: 16px 18px 50px; }
  .kpi-row, .kpi-row-5, .kpi-row-4 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .filter-group select { min-width: 160px; }
}
@media (max-width: 600px) {
  .app { padding: 14px 14px 44px; }
  .kpi-row, .kpi-row-5, .kpi-row-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; }
  .topbar-meta { align-items: flex-start; }
  .brand-text h1 { font-size: 17px; }
  .card { padding: 15px 16px; }
  .filter-group { width: 100%; }
  .filter-group select, .filter-group input { min-width: 0; width: 100%; }
  .filter-summary { margin-left: 0; }
  th, td { font-size: 12px; padding: 7px 8px; }
}
@media (max-width: 400px) {
  .kpi-row, .kpi-row-5, .kpi-row-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-tile .kpi-value { font-size: 21px; }
}
