:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-muted: #eef3f5;
  --ink: #17202a;
  --muted: #5f6b76;
  --line: #d9e0e5;
  --teal: #107c83;
  --teal-dark: #075f66;
  --coral: #cf513d;
  --gold: #c99621;
  --blue: #2f5d9a;
  --shadow: 0 18px 45px rgba(22, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.dataset-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 32px 0;
  background: var(--bg);
}

.dataset-tab {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  background: #e9eef2;
  cursor: pointer;
  font-weight: 760;
}

.dataset-tab:hover {
  color: var(--ink);
  background: #f6f8fa;
}

.dataset-tab.is-active {
  border-bottom-color: var(--panel);
  color: var(--teal-dark);
  background: var(--panel);
}

.dataset-tab:focus-visible {
  outline: 3px solid rgba(201, 150, 33, 0.55);
  outline-offset: 2px;
}

.context-note {
  display: grid;
  gap: 4px;
  margin: 12px 32px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: #fbfcfd;
}

.context-note h2 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.context-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 20px;
  padding: 20px 32px 32px;
}

.map-panel,
.insight-panel,
.table-panel,
.department-control-panel,
.department-chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-heading,
.table-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

#map-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.select-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
}

select {
  min-width: 132px;
  padding: 0 34px 0 10px;
}

input {
  width: 190px;
  min-width: 140px;
  padding: 0 11px;
}

.map-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  min-height: 640px;
}

.map-canvas {
  position: relative;
  min-height: 640px;
  background:
    linear-gradient(90deg, rgba(47, 93, 154, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(47, 93, 154, 0.06) 1px, transparent 1px),
    #eef6f8;
  background-size: 56px 56px;
}

.map-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 640px;
}

.state-shape {
  fill: #f8faf9;
  stroke: #9db0bc;
  stroke-width: 2.4;
}

.border-line {
  stroke: rgba(95, 107, 118, 0.2);
  stroke-width: 1;
}

.region-label {
  fill: rgba(95, 107, 118, 0.62);
  font-size: 14px;
  font-weight: 700;
}

.marker {
  cursor: pointer;
  outline: none;
}

.marker circle {
  fill: var(--teal);
  stroke: #ffffff;
  stroke-width: 3;
  filter: drop-shadow(0 4px 8px rgba(18, 32, 42, 0.22));
  transition:
    fill 150ms ease,
    opacity 150ms ease,
    stroke-width 150ms ease,
    transform 150ms ease;
}

.marker text {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}

.marker.is-high circle {
  fill: var(--coral);
}

.marker.is-mid circle {
  fill: var(--blue);
}

.marker.is-muted {
  opacity: 0.28;
}

.marker.is-selected circle {
  stroke: #14212c;
  stroke-width: 4;
}

.marker:focus-visible circle {
  stroke: var(--gold);
  stroke-width: 5;
}

.detail-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 20px;
  border-left: 1px solid var(--line);
  background: #fbfcfd;
}

.detail-panel h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.18;
}

.detail-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-value {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 850;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-stat {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.insight-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
  box-shadow: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.stat-box span {
  display: block;
  min-height: 30px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.22rem;
  line-height: 1.1;
}

.table-panel {
  box-shadow: none;
}

.table-tools {
  align-items: center;
  padding: 14px;
}

.table-scroll {
  max-height: 515px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 54px;
}

th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4) {
  width: 74px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f1f8f8;
}

tbody tr:focus-visible {
  outline: 3px solid rgba(201, 150, 33, 0.55);
  outline-offset: -3px;
}

.campus-cell {
  display: grid;
  gap: 6px;
}

.campus-name {
  overflow-wrap: anywhere;
  font-weight: 760;
}

.bar-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaee;
}

.bar-fill {
  width: var(--bar-width);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.is-hidden {
  display: none !important;
}

.department-dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.department-control-panel {
  align-self: start;
  overflow: hidden;
}

.department-campus-control select {
  min-width: 180px;
}

.department-campus-summary {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.department-summary-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.department-summary-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.department-summary-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.26rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.department-summary-box-wide strong {
  font-size: 1rem;
}

.department-chart-panel {
  min-width: 0;
  overflow: hidden;
}

.department-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.department-chart-controls {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 14px;
}

#department-control-subtitle,
#department-chart-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.rank-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 580px;
  margin: 0;
  padding: 0;
  border: 0;
}

.rank-control legend {
  flex: 0 0 100%;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: right;
  text-transform: uppercase;
}

.rank-control label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f7f9fa;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 760;
  white-space: nowrap;
}

.rank-control input {
  width: 14px;
  min-width: 14px;
  height: 14px;
  accent-color: var(--teal);
}

.rank-control label:has(input:checked) {
  border-color: rgba(16, 124, 131, 0.45);
  color: var(--teal-dark);
  background: #e9f5f4;
}

.department-limit-control select {
  min-width: 120px;
}

.department-chart-scroll {
  max-height: 660px;
  overflow: auto;
}

.department-chart {
  min-width: 600px;
}

.department-bar-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(76px, 104px);
  gap: 14px;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.department-bar-row:last-child {
  border-bottom: 0;
}

.department-rank-number {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.department-bar-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.department-bar-label {
  min-width: 0;
}

.department-name {
  min-width: 0;
  font-weight: 780;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.department-value {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.department-bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaee;
}

.department-bar-fill {
  display: block;
  width: var(--bar-width);
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--teal));
}

.department-bar-row.is-comparison {
  align-items: start;
}

.comparison-bars {
  display: grid;
  gap: 8px;
}

.comparison-bar-line {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 38px;
  gap: 9px;
  align-items: center;
}

.comparison-bar-line .department-bar-track {
  height: 7px;
}

.comparison-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.comparison-value {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 830;
  text-align: right;
}

.comparison-delta {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.comparison-delta span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.comparison-delta strong {
  font-size: 1rem;
  line-height: 1;
}

.department-empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

.error-message {
  margin: 18px;
  padding: 14px;
  border: 1px solid #e6b3aa;
  border-radius: 8px;
  color: #842918;
  background: #fff4f1;
}

@media (max-width: 1080px) {
  .dashboard,
  .department-dashboard {
    grid-template-columns: 1fr;
  }

  .insight-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-header,
  .panel-heading,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header,
  .dataset-tabs,
  .context-note,
  .dashboard,
  .department-dashboard {
    padding-left: 16px;
    padding-right: 16px;
  }

  .context-note {
    margin-left: 16px;
    margin-right: 16px;
  }

  .dataset-tabs {
    overflow-x: auto;
  }

  .dataset-tab {
    flex: 0 0 auto;
  }

  .map-wrap {
    grid-template-columns: 1fr;
  }

  .map-canvas,
  .map-canvas svg {
    min-height: 520px;
  }

  .detail-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .department-chart-header,
  .department-chart-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .rank-control {
    justify-content: flex-start;
    max-width: none;
  }

  .rank-control legend {
    text-align: left;
  }

  .department-chart {
    min-width: 0;
  }

  .department-bar-row {
    grid-template-columns: 38px minmax(0, 1fr) 66px;
    gap: 10px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .comparison-bar-line {
    grid-template-columns: 72px minmax(0, 1fr) 34px;
  }

  input,
  select {
    width: 100%;
  }
}
