:root {
  --night: #071018;
  --night-2: #0d1d36;
  --panel: rgba(13, 27, 48, 0.84);
  --panel-solid: #0f1f38;
  --panel-soft: rgba(255, 255, 255, 0.04);
  --navy: #002868;
  --crimson: #bf0a30;
  --crimson-bright: #e01840;
  --gold: #d7b56d;
  --gold-soft: #ffe2a4;
  --emerald: #34d399;
  --cobalt: #60a5fa;
  --amber: #fbbf24;
  --paper: #f4efe4;
  --paper-dim: rgba(244, 239, 228, 0.74);
  --paper-muted: rgba(244, 239, 228, 0.56);
  --line: rgba(215, 181, 109, 0.24);
  --line-soft: rgba(244, 239, 228, 0.12);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--night);
  color: var(--paper);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(960px 540px at 12% -8%, rgba(31, 95, 178, 0.24), transparent 58%),
    radial-gradient(760px 500px at 96% 8%, rgba(191, 10, 48, 0.16), transparent 50%),
    linear-gradient(180deg, rgba(7, 16, 24, 0.78) 0%, rgba(7, 16, 24, 0.96) 100%);
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/brand/texas-home-bg.jpg") center / cover no-repeat;
  opacity: 0.18;
  filter: saturate(0.75) contrast(1.04);
}

.appShell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topBar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(215, 181, 109, 0.18);
  background: rgba(7, 16, 24, 0.82);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(215, 181, 109, 0.5);
}

.brandText {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--paper);
}

.brandText span {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.topBarActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.viewerPill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(215, 181, 109, 0.14);
  border: 1px solid rgba(215, 181, 109, 0.35);
  color: var(--gold-soft);
}

.demoBanner {
  background: rgba(215, 181, 109, 0.12);
  border-bottom: 1px solid rgba(215, 181, 109, 0.28);
  color: var(--gold-soft);
  text-align: center;
  font-size: 12.5px;
  padding: 8px 18px;
}

.demoBanner code {
  background: rgba(7, 16, 24, 0.55);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11.5px;
}

/* Typography & Buttons */
.kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

h1.display {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.015em;
}

h1.display em, h2.sectionTitle em {
  font-style: italic;
  color: var(--gold-soft);
}

h2.sectionTitle {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.08;
}

.dek {
  margin: 12px 0 0;
  font-size: 15.5px;
  color: var(--paper-dim);
  max-width: 680px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, background 140ms ease, border-color 140ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.small { font-size: 12.5px; padding: 7px 13px; border-radius: 8px; }

.btn.crimson {
  background: linear-gradient(135deg, var(--crimson-bright), var(--crimson));
  border-color: rgba(255, 110, 134, 0.5);
  color: #fff;
  box-shadow: 0 8px 22px rgba(191, 10, 48, 0.35);
}

.btn.gold {
  background: rgba(215, 181, 109, 0.16);
  border-color: rgba(215, 181, 109, 0.5);
  color: var(--gold-soft);
}
.btn.gold:hover:not(:disabled) { background: rgba(215, 181, 109, 0.25); }

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-soft);
  color: var(--paper);
}
.btn.ghost:hover:not(:disabled) { border-color: rgba(215, 181, 109, 0.45); }

/* Login Stage */
.loginStage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
}

.loginCard {
  width: min(500px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 36px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
}

.rolePicker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.roleCard {
  appearance: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  color: var(--paper);
  font-family: inherit;
  cursor: pointer;
  transition: all 150ms ease;
}

.roleCard:hover {
  border-color: rgba(215, 181, 109, 0.45);
  background: rgba(215, 181, 109, 0.06);
}

.roleCard.is-active {
  border-color: var(--gold);
  background: linear-gradient(155deg, rgba(215, 181, 109, 0.16), rgba(0, 40, 104, 0.35));
  box-shadow: 0 0 0 1px rgba(215, 181, 109, 0.35);
}

.roleIcon { font-size: 24px; line-height: 1; margin-top: 2px; }
.roleBody strong { display: block; font-size: 16px; color: #fff; }
.roleBody span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--paper-dim); line-height: 1.4; }

.loginForm {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.fieldGroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fieldGroup label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold-soft);
}

.fieldGroup input,
.controlInput,
.controlSelect {
  appearance: none;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(244, 239, 228, 0.2);
  background: rgba(5, 12, 22, 0.72);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
}

.fieldGroup input:focus,
.controlInput:focus,
.controlSelect:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 181, 109, 0.18);
}

.fieldHint {
  font-size: 12px;
  color: var(--paper-muted);
}

.formError {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(224, 24, 64, 0.55);
  background: rgba(191, 10, 48, 0.18);
  color: #ffd0d9;
  font-size: 13.5px;
}

.formActions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.demoQuickBar {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.demoQuickLabel {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.demoQuickBtns { display: flex; gap: 10px; flex-wrap: wrap; }

/* Report Stage */
.reportStage {
  flex: 1 1 auto;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.heroCard {
  background: linear-gradient(135deg, rgba(0, 40, 104, 0.52), rgba(13, 27, 48, 0.92));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.heroHeadRow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.blockFilterRow {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pillBtn {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 130ms ease;
}

.pillBtn:hover { color: #fff; border-color: rgba(215, 181, 109, 0.5); }
.pillBtn.is-active {
  background: rgba(215, 181, 109, 0.2);
  border-color: var(--gold);
  color: #fff;
}

/* KPI Grid */
.kpiGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.kpiCard {
  background: rgba(7, 16, 24, 0.55);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 16px;
}

.kpiLabel {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-muted);
}

.kpiValue {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1;
  color: #fff;
}

.kpiValue.gold { color: var(--gold-soft); }
.kpiValue.good { color: var(--emerald); }

.kpiSub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--paper-dim);
}

/* Tab Bar */
.tabBar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

.tabBtn {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper-dim);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 140ms ease;
}

.tabBtn:hover { color: #fff; border-color: rgba(215, 181, 109, 0.45); }
.tabBtn.is-active {
  background: linear-gradient(135deg, rgba(215, 181, 109, 0.22), rgba(0, 40, 104, 0.42));
  border-color: var(--gold);
  color: #fff;
}

/* Panels & Cards */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.panelHead h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  line-height: 1.1;
}

.panelSub {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--paper-dim);
}

.twoCol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.fourCol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* Badges / Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.partyR { background: rgba(191, 10, 48, 0.22); border-color: rgba(248, 113, 113, 0.45); color: #fecdd3; }
.badge.partyD { background: rgba(37, 99, 235, 0.24); border-color: rgba(96, 165, 250, 0.5); color: #bfdbfe; }
.badge.good { background: rgba(16, 185, 129, 0.18); border-color: rgba(52, 211, 153, 0.45); color: #a7f3d0; }
.badge.warn { background: rgba(245, 158, 11, 0.18); border-color: rgba(251, 191, 36, 0.45); color: #fde68a; }
.badge.info { background: rgba(56, 189, 248, 0.16); border-color: rgba(56, 189, 248, 0.4); color: #bae6fd; }
.badge.gold { background: rgba(215, 181, 109, 0.2); border-color: rgba(215, 181, 109, 0.5); color: var(--gold-soft); }
.badge.muted { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.16); color: var(--paper-muted); }

/* Split Bars (Elections & Policy) */
.splitStack { display: flex; flex-direction: column; gap: 14px; }

.splitRowHead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13.5px;
  margin-bottom: 6px;
}

.splitTrack {
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: rgba(255, 255, 255, 0.08);
}

.splitSeg.r { background: linear-gradient(90deg, #e01840, #bf0a30); }
.splitSeg.d { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.splitSeg.good { background: linear-gradient(90deg, #34d399, #059669); }
.splitSeg.warn { background: linear-gradient(90deg, #fbbf24, #d97706); }
.splitSeg.muted { background: rgba(255, 255, 255, 0.18); }

/* Tables */
.tableWrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

table.dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.dataTable th {
  text-align: left;
  padding: 11px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(7, 16, 24, 0.72);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

table.dataTable td {
  padding: 11px 13px;
  border-bottom: 1px solid rgba(244, 239, 228, 0.07);
  vertical-align: middle;
}

table.dataTable tbody tr:hover {
  background: rgba(215, 181, 109, 0.06);
}

table.dataTable tbody tr.is-highlight {
  background: rgba(215, 181, 109, 0.16);
}

table.dataTable tbody tr.is-clickable {
  cursor: pointer;
}

.numCell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.rankChip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
}

.rankChip.top1 { background: rgba(215, 181, 109, 0.28); color: var(--gold-soft); border: 1px solid var(--gold); }
.rankChip.top2 { background: rgba(148, 163, 184, 0.25); color: #f1f5f9; }
.rankChip.top3 { background: rgba(180, 83, 9, 0.3); color: #fed7aa; }

/* Narratives */
.narrativeGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.narrativeCard {
  background: rgba(7, 16, 24, 0.55);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.narrativeTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.narrativeHeadline {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--gold-soft);
  line-height: 1.15;
}

.narrativeBody {
  margin: 0;
  font-size: 14px;
  color: var(--paper-dim);
  line-height: 1.58;
}

.pillStrip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

details.timelineDetails summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gold);
  user-select: none;
}

.timelineList {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--paper-dim);
}

/* Filter Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .controlInput { max-width: 300px; }
.toolbar .controlSelect { max-width: 260px; }

.noteBox {
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid rgba(215, 181, 109, 0.25);
  background: rgba(215, 181, 109, 0.08);
  font-size: 13px;
  color: var(--paper-dim);
}

/* Election Outcome Cards (Student View) */
.electionCard {
  background: rgba(7, 16, 24, 0.58);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.electionRaceLabel {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-muted);
}

.electionWinner {
  font-family: var(--serif);
  font-size: 24px;
  color: #fff;
  line-height: 1.12;
}

/* Semester Activity Progression Chart */
.progressionChart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 176px;
  padding: 16px 12px 8px;
  border-radius: 14px;
  background: rgba(7, 16, 24, 0.52);
  border: 1px solid var(--line-soft);
  overflow-x: auto;
}

.progCol {
  flex: 1 1 36px;
  min-width: 34px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.progCount {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}

.progBarWrap {
  width: 100%;
  max-width: 34px;
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
}

.progBar {
  width: 100%;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--gold) 0%, #9b7a35 100%);
  transition: height 200ms ease;
}

.progLabel {
  font-size: 10px;
  color: var(--paper-muted);
  white-space: nowrap;
}

/* Outcome Correlation Insight Cards */
.insightGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.insightCard {
  background: rgba(7, 16, 24, 0.58);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--gold);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insightCard.good { border-left-color: var(--emerald); }
.insightCard.warn { border-left-color: var(--amber); }
.insightCard.info { border-left-color: var(--cobalt); }
.insightCard.gold { border-left-color: var(--gold); }

.insightHeadline {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.16;
  color: #fff;
}

.insightDetail {
  margin: 0;
  font-size: 13px;
  color: var(--paper-dim);
  line-height: 1.48;
}

/* Student Role Benchmark Strip */
.benchmarkStrip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(215, 181, 109, 0.1);
  border: 1px solid rgba(215, 181, 109, 0.3);
}

.benchmarkStats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
}

.benchmarkStats strong {
  color: var(--gold-soft);
}

.appFooter {
  margin-top: auto;
  padding: 16px 28px;
  border-top: 1px solid rgba(244, 239, 228, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--paper-muted);
}

@media (max-width: 820px) {
  .rolePicker, .twoCol { grid-template-columns: 1fr; }
  .loginCard { padding: 24px 20px; }
  .reportStage { padding: 18px 14px 44px; }
  .topBar { padding: 12px 16px; }
}

@media print {
  body { background: #fff; color: #111; }
  .atmosphere, .topBarActions, .tabBar, .toolbar, .demoBanner, .btn { display: none !important; }
  .panel, .heroCard, .kpiCard, .narrativeCard {
    background: #fff !important;
    color: #111 !important;
    border-color: #cbd5e1 !important;
    box-shadow: none !important;
  }
  .kpiValue, .narrativeHeadline, h1, h2, h3, .electionWinner { color: #111 !important; }
  .panelSub, .narrativeBody, .kpiSub, .dek { color: #334155 !important; }
}
