@font-face { font-family: "Fraunces"; src: url("assets/fonts/fraunces.woff2") format("woff2"); font-weight: 300 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("assets/fonts/fraunces-italic.woff2") format("woff2"); font-weight: 300 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("assets/fonts/inter.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("assets/fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }

:root {
  --red: #8c0d13;
  --red-deep: #65090e;
  --red-soft: rgba(140, 13, 19, 0.09);
  --gold: #ffc93d;
  --gold-deep: #e7ad11;
  --gold-soft: rgba(255, 201, 61, 0.18);
  --paper: #faf6ef;
  --surface: #f3efe7;
  --white: #fffdf9;
  --ink: #1b1512;
  --muted: #5f5750;
  --ash: #d8d0c4;
  --line: rgba(27, 21, 18, 0.12);
  --teal: #1f6f78;
  --blue: #3b5b92;
  --rust: #b5523b;
  --green: #5c7a38;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --shadow: 0 12px 34px rgba(70, 35, 18, 0.08);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse 60% 38% at 92% -8%, rgba(255, 201, 61, 0.2), transparent 64%),
    radial-gradient(ellipse 55% 40% at 0% 18%, rgba(140, 13, 19, 0.06), transparent 68%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px clamp(18px, 4vw, 48px);
  background: linear-gradient(120deg, var(--red-deep), var(--red) 62%, #a3151c);
  color: var(--paper);
  border-bottom: 4px solid var(--gold);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 260px; }
.brand-mark {
  width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--gold);
  color: var(--red-deep);
  font-family: var(--serif);
  font-size: 1.15rem; font-weight: 600; letter-spacing: -0.03em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.brand-name { font-family: var(--serif); font-size: 1.28rem; line-height: 1.1; font-weight: 500; }
.brand-sub {
  margin-top: 4px;
  font-family: var(--mono); font-size: 0.57rem; letter-spacing: 0.13em;
  text-transform: uppercase; color: rgba(250, 246, 239, 0.7);
}
.view-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.16); }
.view-tab {
  border: 0; background: transparent; color: rgba(250, 246, 239, 0.76);
  padding: 9px 16px; border-radius: 999px;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase;
  transition: background 0.18s ease, color 0.18s ease;
}
.view-tab:hover { color: var(--paper); }
.view-tab.active { background: var(--gold); color: var(--red-deep); font-weight: 600; }
.demo-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border: 1px solid rgba(255, 201, 61, 0.5); border-radius: 999px;
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold);
}
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }

/* Filter bar */
.filterbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px clamp(18px, 4vw, 48px);
  background: rgba(250, 246, 239, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ash);
  box-shadow: 0 6px 18px rgba(70, 35, 18, 0.04);
}
.filter { display: flex; flex-direction: column; gap: 5px; min-width: 138px; }
.filter.search-filter { min-width: 210px; flex: 1 1 210px; max-width: 300px; }
.filter label {
  font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.filter select, .filter input {
  height: 38px; padding: 0 11px;
  border: 1px solid var(--ash); border-radius: 9px;
  background: var(--white); color: var(--ink);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.filter select:focus, .filter input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(140, 13, 19, 0.1);
}
.filter select:disabled { opacity: 0.55; cursor: not-allowed; }
.ghost-btn {
  height: 38px; padding: 0 14px;
  border: 1px solid var(--ash); border-radius: 9px;
  background: transparent; color: var(--red);
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.ghost-btn:hover { background: var(--red-soft); border-color: var(--red); }
.filter-meta {
  margin-left: auto; align-self: center;
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.04em; color: var(--muted);
  white-space: nowrap;
}

/* Layout */
main { padding: 24px clamp(18px, 4vw, 48px) 40px; max-width: 1680px; margin: 0 auto; }
.view { animation: fade-up 0.28s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--red); font-weight: 600;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; }
h1 { margin: 0 0 8px; font-size: clamp(2rem, 3.2vw, 2.85rem); line-height: 1.04; color: var(--red-deep); }
.lede { margin: 0; max-width: 760px; color: var(--muted); font-size: 0.98rem; line-height: 1.55; }
.term-chip {
  padding: 9px 13px; border-radius: 999px;
  background: var(--gold-soft); border: 1px solid rgba(231, 173, 17, 0.4);
  color: #6b4a00; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
}

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.student-kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi {
  position: relative; overflow: hidden;
  padding: 16px 17px;
  border: 1px solid var(--ash); border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gold); }
.kpi.red::before { background: var(--red); }
.kpi.teal::before { background: var(--teal); }
.kpi .kpi-label {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.11em; text-transform: uppercase; color: var(--muted);
}
.kpi .kpi-value { margin-top: 8px; font-family: var(--serif); font-size: 1.85rem; line-height: 1; color: var(--red-deep); }
.kpi .kpi-delta { margin-top: 7px; font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.kpi .kpi-delta.good { color: var(--teal); }
.kpi .kpi-delta.bad { color: var(--red); }

/* Alerts */
.alert-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.alert {
  display: flex; flex-direction: column; gap: 8px;
  padding: 15px 16px; border: 1px solid var(--ash); border-left: 4px solid var(--gold);
  border-radius: 12px; background: var(--white); box-shadow: var(--shadow);
}
.alert.warning { border-left-color: var(--red); }
.alert.positive { border-left-color: var(--teal); }
.alert .alert-kicker { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.alert .alert-title { font-family: var(--serif); font-size: 1.04rem; line-height: 1.22; color: var(--ink); }
.alert .alert-body { margin: 0; font-size: 0.78rem; line-height: 1.45; color: var(--muted); }
.alert .alert-metric { font-family: var(--mono); font-size: 0.66rem; color: var(--red); font-weight: 600; }

/* Panels + charts */
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.panel {
  min-width: 0; padding: 15px 16px 10px;
  border: 1px solid var(--ash); border-radius: var(--radius);
  background: var(--white); box-shadow: var(--shadow);
}
.panel.span-2 { grid-column: span 2; }
.panel header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.panel h2 { margin: 0; font-size: 1.08rem; color: var(--ink); }
.panel header span {
  font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.chart { width: 100%; height: 300px; }
.panel.span-2 .chart { height: 320px; }
.scenario { display: flex; flex-direction: column; padding-bottom: 16px; }
.scenario .scenario-body { flex: 1; }
.scenario .chart { height: auto; }
.scenario-body { display: grid; grid-template-columns: 1fr 1.15fr; gap: 22px; align-items: center; padding: 8px 2px 4px; }
.scenario-body > * { min-width: 0; }
.scenario-control label { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.scenario-control label b { color: var(--red); }
.scenario-control input[type="range"] { width: 100%; margin: 16px 0 8px; accent-color: var(--red); }
.hint { margin: 0; font-size: 0.74rem; line-height: 1.45; color: var(--muted); }
.scenario-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.scenario-metric { min-width: 0; padding: 13px; border: 1px solid var(--ash); border-radius: 10px; background: var(--surface); }
.scenario-metric .k { font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); white-space: normal; line-height: 1.3; }
.scenario-metric .v { margin-top: 7px; font-family: var(--serif); font-size: 1.35rem; color: var(--red-deep); }

/* Tables */
.table-panel { padding-bottom: 14px; }
.table-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; }
.table-wrap { overflow: auto; max-height: 440px; border: 1px solid var(--ash); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 10px; text-align: left;
  background: var(--surface); color: var(--muted);
  font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.1em; text-transform: uppercase;
  border-bottom: 1px solid var(--ash); white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid rgba(216, 208, 196, 0.55); vertical-align: middle; }
tbody tr { transition: background 0.14s ease; }
tbody tr:hover { background: rgba(255, 201, 61, 0.08); }
tbody tr.selected { background: rgba(255, 201, 61, 0.18); }
tbody tr.clickable { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
.student-name { font-weight: 600; color: var(--ink); }
.student-id { display: block; margin-top: 2px; font-family: var(--mono); font-size: 0.58rem; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; padding: 3px 7px; border-radius: 999px;
  font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600;
}
.badge.high { color: var(--red); background: rgba(140, 13, 19, 0.1); }
.badge.medium { color: #7a5600; background: rgba(255, 201, 61, 0.25); }
.badge.low { color: var(--teal); background: rgba(31, 111, 120, 0.1); }
.badge.neutral { color: var(--muted); background: rgba(95, 87, 80, 0.1); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.pager button {
  border: 1px solid var(--ash); background: var(--white); color: var(--ink);
  border-radius: 7px; padding: 5px 9px; font-size: 0.62rem;
}
.pager button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.table-empty { padding: 18px 10px; color: var(--muted); text-align: center; }

/* Footer */
footer {
  display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 18px clamp(18px, 4vw, 48px) 24px;
  border-top: 1px solid var(--ash);
  font-size: 0.72rem; line-height: 1.5; color: var(--muted);
}
footer strong { color: var(--ink); }
.footer-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.footer-actions a { color: var(--red); }
.link-btn { border: 0; background: none; padding: 0; color: var(--red); font-size: 0.72rem; text-decoration: underline; text-underline-offset: 3px; }

/* Backdrop, drawer, modal */
.backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(27, 21, 18, 0.36); backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: min(470px, 94vw); overflow-y: auto;
  background: var(--paper); border-left: 1px solid var(--ash);
  box-shadow: -20px 0 60px rgba(27, 21, 18, 0.22);
  animation: slide-in 0.24s ease both;
}
@keyframes slide-in { from { transform: translateX(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head, .modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px;
  background: linear-gradient(120deg, var(--red-deep), var(--red));
  color: var(--paper); border-bottom: 3px solid var(--gold);
}
.drawer-head h2, .modal-head h2 { margin: 0; color: var(--paper); font-size: 1.5rem; }
.drawer-head .eyebrow, .modal-head .eyebrow { color: var(--gold); margin-bottom: 6px; }
.icon-btn { border: 1px solid rgba(250, 246, 239, 0.35); background: transparent; color: var(--paper); width: 32px; height: 32px; border-radius: 50%; font-size: 1.15rem; line-height: 1; }
.icon-btn:hover { background: rgba(250, 246, 239, 0.12); }
.drawer-body { padding: 18px 22px 30px; }
.modal {
  position: fixed; top: 50%; left: 50%; z-index: 90; transform: translate(-50%, -50%);
  width: min(760px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--paper); border-radius: 16px; box-shadow: 0 30px 90px rgba(27, 21, 18, 0.35);
}
.modal-body { padding: 18px 24px 26px; font-size: 0.88rem; line-height: 1.6; color: var(--muted); }
.modal-body h3 { margin: 20px 0 6px; font-size: 1.05rem; color: var(--ink); }
.modal-body ul { margin: 6px 0 0; padding-left: 20px; }
.modal-body li { margin-bottom: 5px; }
.modal-note { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--ash); font-size: 0.78rem; }

/* Drawer content */
.student-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.student-avatar { width: 58px; height: 58px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: var(--gold); font-family: var(--serif); font-size: 1.2rem; }
.student-meta h3 { margin: 0 0 3px; font-size: 1.25rem; color: var(--ink); }
.student-meta p { margin: 0; font-size: 0.78rem; color: var(--muted); }
.gauge { width: 100%; height: 150px; margin: 4px 0 6px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 12px 0 18px; }
.detail-item { padding: 10px 11px; border: 1px solid var(--ash); border-radius: 9px; background: var(--white); }
.detail-item .k { font-family: var(--mono); font-size: 0.52rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.detail-item .v { margin-top: 4px; font-weight: 600; font-size: 0.88rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.chip { padding: 5px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--ash); font-size: 0.7rem; color: var(--muted); }
.drawer-section { margin-top: 18px; }
.drawer-section h4 { margin: 0 0 8px; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.drawer-section ul { margin: 0; padding-left: 18px; font-size: 0.8rem; line-height: 1.55; color: var(--muted); }
.course-mini { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(216, 208, 196, 0.7); font-size: 0.78rem; }
.course-mini:last-child { border-bottom: 0; }
.course-mini .code { font-family: var(--mono); font-size: 0.62rem; color: var(--red); }
.course-mini .grade { font-family: var(--mono); font-size: 0.66rem; color: var(--muted); }

/* Responsive */
@media (max-width: 1500px) {
  .student-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel.span-2 { grid-column: span 2; }
  .alert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 12px 16px; }
  .brand { min-width: 0; flex: 1 1 100%; }
  .brand-sub { display: none; }
  .view-tabs { order: 2; flex: 1 1 100%; overflow-x: auto; }
  .view-tab { flex: 1; text-align: center; }
  .demo-badge { display: none; }
  .filterbar { padding: 8px 16px; flex-wrap: nowrap; overflow-x: auto; align-items: flex-end; gap: 8px; }
  .filter { flex: 0 0 132px; min-width: 0; }
  .filter.search-filter { flex: 0 0 210px; max-width: none; }
  .filter-meta { display: none; }
  .ghost-btn { flex: 0 0 auto; }
  main { padding: 16px 16px 32px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .panel.span-2 { grid-column: span 1; }
  .alert-grid { grid-template-columns: 1fr; }
  .scenario-body { grid-template-columns: 1fr; gap: 14px; }
  .scenario-metrics { grid-template-columns: repeat(3, 1fr); }
  .chart { height: 280px; }
  .panel.span-2 .chart { height: 300px; }
  footer { padding: 16px; }
}
@media (max-width: 440px) {
  .scenario-metrics { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
