:root {
  color-scheme: light;
  --ink: #18202b;
  --muted: #5e6977;
  --line: #d8dee6;
  --panel: #ffffff;
  --page: #f5f7fa;
  --navy: #19324a;
  --green: #24735d;
  --gold: #b27824;
  --red: #b64b4b;
  --blue: #3f6f9f;
  --shadow: 0 16px 36px rgba(24, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: #eef2f5;
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
}

.brand h1,
.topbar h2,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.panel p,
.eyebrow,
.field span,
.year-control label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.district-picker {
  display: grid;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  font-size: 28px;
}

.year-control {
  display: grid;
  gap: 7px;
  min-width: 132px;
}

.panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 14px;
  box-shadow: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 16px;
}

.profile-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.profile-list dt {
  color: var(--muted);
  font-size: 12px;
}

.profile-list dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: #e5eaf0;
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 3px 12px rgba(24, 32, 43, 0.1);
}

.custom-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
}

.check-row input {
  margin-top: 2px;
}

.hidden {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card {
  min-height: 132px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  letter-spacing: 0;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.wide {
  min-width: 0;
}

.snapshot-panel {
  grid-column: 1 / -1;
  padding: 0;
  overflow: hidden;
}

.overview-panel {
  grid-column: 1 / -1;
  padding: 0;
  overflow: hidden;
}

.snapshot-title {
  padding: 18px 20px;
  color: #fff;
  background: #061329;
  border-bottom: 4px solid #dfe5ec;
}

.snapshot-title h2 {
  color: #fff;
  font-size: 22px;
}

.snapshot-title p {
  margin-top: 4px;
  color: #d7dde6;
  font-size: 16px;
}

.snapshot-wrap {
  padding: 14px 18px 18px;
}

.snapshot-table {
  min-width: 720px;
}

.snapshot-table th {
  color: #fff;
  background: #4b4b4b;
  border-right: 2px solid #fff;
  font-size: 14px;
  text-align: center;
}

.snapshot-table th:first-child,
.snapshot-table td:first-child {
  text-align: left;
}

.snapshot-table td {
  border-right: 2px solid #fff;
  background: #f8f9fb;
}

.snapshot-table tr:nth-child(even):not(.focus-row):not(.summary-row) td {
  background: #eef2f5;
}

.snapshot-table .focus-row td {
  color: #fff;
  background: #061329;
}

.snapshot-table .summary-row td {
  background: #9b9b9b;
  font-weight: 700;
}

.overview-grid {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.overview-chart {
  display: grid;
  gap: 12px;
}

.overview-chart h3,
.demographic-chart h3 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

.demographic-chart {
  display: grid;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.demographic-bars {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 18px;
  align-items: end;
  min-height: 300px;
}

.demographic-bar-column {
  display: grid;
  gap: 10px;
  justify-items: center;
  min-width: 0;
}

.demographic-bar-column strong {
  min-height: 34px;
  font-size: 12px;
  text-align: center;
}

.stacked-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: min(100%, 112px);
  height: 238px;
  overflow: hidden;
  background: #e7edf3;
  border: 1px solid #c6d1dc;
  border-radius: 4px;
}

.stack-segment {
  display: grid;
  place-items: center;
  min-height: 24px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.stack-segment span {
  padding: 2px 4px;
}

.stack-segment.free-reduced,
.demographic-legend i.free-reduced {
  background: #006281;
}

.stack-segment.other-students,
.demographic-legend i.other-students {
  background: #9aa8b3;
}

.stack-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.demographic-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.demographic-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.demographic-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.overview-bars {
  display: grid;
  gap: 10px;
}

.overview-bar-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 126px;
  gap: 12px;
  align-items: center;
}

.overview-bar-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.overview-bar-track {
  height: 28px;
  overflow: hidden;
  background: #e7edf3;
  border: 1px solid #d3dbe4;
  border-radius: 4px;
}

.overview-bar-fill {
  height: 100%;
  min-width: 3px;
  background: #006281;
  border-right: 4px solid #00384b;
}

.overview-bar-row.highlight .overview-bar-fill {
  background: #3c3c3c;
  border-right-color: #1f1f1f;
}

.overview-bar-value {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.focus-row td {
  background: #eef6f2;
  font-weight: 700;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-grid,
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .dashboard,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .overview-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .demographic-bars {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: auto;
  }

  .stacked-bar {
    height: 190px;
  }

  .overview-bar-value {
    text-align: left;
  }
}
