/* Didactic Operations — application styles.
   Palette roles follow the project data-viz guidance: one sequential blue for
   data marks, a reserved status palette that always ships with an icon + label,
   and text that never wears a data colour. */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --raised: #ffffff;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;

  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-1-soft: #cde2fb;
  --series-1-strong: #1c5cab;

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

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);

  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --raised: #201f1e;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-soft: #184f95;
    --series-1-strong: #86b6ef;
    --good-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --raised: #201f1e;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-soft: #184f95;
  --series-1-strong: #86b6ef;
  --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; align-items: stretch; }

/* The sidebar column spans the full page height so its surface and right border
   never stop part-way down; the nav inside it is what sticks while you scroll. */
.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
}
.sidebar__inner { position: sticky; top: 20px; }

.brand { padding: 0 8px 18px; }
.brand__mark {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.brand__name { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__heading {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 8px 6px;
  font-weight: 600;
}
.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
}
.nav__link:hover { background: var(--grid); text-decoration: none; color: var(--text-primary); }
.nav__link.is-active {
  background: var(--series-1-soft);
  color: var(--series-1-strong);
  font-weight: 600;
}
:root[data-theme="dark"] .nav__link.is-active,
:root:where(:not([data-theme="light"])) .nav__link.is-active { color: #ffffff; }
.nav__icon { width: 16px; text-align: center; opacity: 0.85; }
.nav__count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--critical);
  color: #fff;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.topbar__sub { font-size: 12px; color: var(--text-muted); }
.topbar__spacer { flex: 1; }

.content { padding: 24px 28px 56px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px 0;
}
.card__title { font-size: 13px; font-weight: 650; margin: 0; }
.card__hint { font-size: 12px; color: var(--text-muted); }
.card__body { padding: 14px 18px 18px; }

.section-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 650;
  margin: 28px 0 12px;
}
.section-label:first-child { margin-top: 0; }

/* -------------------------------------------------------------- stat tiles */

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

.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.tile__label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.tile__value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.tile__value--hero { font-size: 48px; }
.tile__note {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}
.tile a { color: inherit; }

/* ------------------------------------------------------------------ status */

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  box-shadow: 0 0 0 2px var(--surface-1);
}
.status--good .status__dot { background: var(--good); }
.status--warning .status__dot { background: var(--warning); }
.status--serious .status__dot { background: var(--serious); }
.status--critical .status__dot { background: var(--critical); }
.status--neutral .status__dot { background: var(--text-muted); }
.status--good { color: var(--good-text); }
.status--critical { color: var(--critical); }
.status--neutral,
.status--warning,
.status--serious { color: var(--text-secondary); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ charts */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart__grid-line { stroke: var(--grid); stroke-width: 1; }
.chart__baseline { stroke: var(--baseline); stroke-width: 1; }
.chart__bar { fill: var(--series-1); }
.chart__bar:hover { fill: var(--series-1-strong); }
.chart__tick { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart__cat { fill: var(--text-secondary); font-size: 10px; }
.chart__value { fill: var(--text-primary); font-size: 11px; font-weight: 650; }
.chart-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 28px 0;
  text-align: center;
}

/* meter */
.meter { display: flex; gap: 2px; height: 12px; margin: 6px 0 12px; }
.meter__seg { border-radius: 2px; }
.meter__seg:first-child { border-radius: 6px 2px 2px 6px; }
.meter__seg:last-child { border-radius: 2px 6px 6px 2px; }
.meter__seg--good { background: var(--good); }
.meter__seg--warning { background: var(--warning); }
.meter__seg--critical { background: var(--critical); }
.meter__seg--neutral { background: var(--baseline); }
.meter-key { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; }
.meter-key__item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.meter-key__swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.meter-key__swatch--good { background: var(--good); }
.meter-key__swatch--warning { background: var(--warning); }
.meter-key__swatch--critical { background: var(--critical); }
.meter-key__value { color: var(--text-primary); font-weight: 650; }

/* the standing daily checks: name on the left, live state right-aligned so the
   states form a readable column rather than pushing the names out of line */
.checks { display: flex; flex-direction: column; gap: 12px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--grid);
}
.check:last-child { border-bottom: none; padding-bottom: 0; }
.check__body { flex: 1; min-width: 0; }
.check__name { font-weight: 600; font-size: 13px; }
.check__rule { font-size: 12px; color: var(--text-muted); }
.check__state { flex: 0 0 auto; padding-top: 1px; }

/* rating bars in the faculty list */
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank__row { display: grid; grid-template-columns: 1fr 110px 46px; gap: 10px; align-items: center; }
.rank__name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__track { height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.rank__fill { height: 100%; background: var(--series-1); border-radius: 4px; }
.rank__value {
  font-size: 13px;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rank__meta { font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------------ sign-in pages */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--page);
}
.auth { width: 100%; max-width: 420px; }
.auth__brand { text-align: center; margin-bottom: 22px; }
.auth__mark {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.auth__title { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin: 2px 0 0; }
.auth__foot {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* -------------------------------------------------------------- user menu */

.usermenu { position: relative; }
.usermenu__trigger { list-style: none; cursor: pointer; display: block; }
.usermenu__trigger::-webkit-details-marker { display: none; }
.usermenu__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--series-1);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.usermenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 232px;
  padding: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 40;
}
.usermenu__name { font-weight: 650; font-size: 13px; }
.usermenu__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.usermenu__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--grid);
  font-size: 13px;
}

/* --------------------------------------------------------- dataset chooser */

.chooser {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.chooser__item {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
}
.chooser__item:hover {
  text-decoration: none;
  border-color: var(--series-1);
}
.chooser__item.is-active {
  border-color: var(--series-1);
  background: var(--series-1-soft);
  box-shadow: inset 0 0 0 1px var(--series-1);
}
:root[data-theme="dark"] .chooser__item.is-active,
:root:where(:not([data-theme="light"])) .chooser__item.is-active { color: #fff; }
.chooser__name { font-weight: 650; font-size: 13px; }
.chooser__desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.chooser__item.is-active .chooser__desc { color: inherit; opacity: 0.85; }

input[type="file"] {
  font-family: inherit;
  font-size: 13px;
  padding: 6px;
  border: 1px dashed var(--baseline);
  border-radius: var(--radius-sm);
  background: var(--raised);
  width: 100%;
}

/* ------------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow);
}
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data thead th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 650;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-1);
  position: sticky;
  top: 0;
}
table.data tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--page); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .actions { text-align: right; white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state__title { font-weight: 650; color: var(--text-secondary); margin-bottom: 4px; }

/* ------------------------------------------------------------------ forms */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field__label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.field__hint { font-size: 11px; color: var(--text-muted); }
.field--wide { grid-column: 1 / -1; }

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="email"],
input[type="search"],
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--raised);
  border: 1px solid var(--baseline);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  min-width: 0;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--series-1);
  outline-offset: -1px;
  border-color: var(--series-1);
}
textarea { resize: vertical; min-height: 72px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--baseline);
  background: var(--raised);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--grid); text-decoration: none; }
.btn--primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}
.btn--primary:hover { background: var(--series-1-strong); border-color: var(--series-1-strong); }
.btn--danger { color: var(--critical); border-color: var(--critical); }
.btn--danger:hover { background: var(--critical); color: #fff; }
.btn--sm { font-size: 12px; padding: 4px 9px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--grid); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--grid);
}

/* ------------------------------------------------------------------ alerts */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 13px;
  margin-bottom: 14px;
}
.alert__icon { flex: 0 0 auto; font-weight: 700; }
.alert--good { border-left: 3px solid var(--good); }
.alert--warning { border-left: 3px solid var(--warning); }
.alert--critical { border-left: 3px solid var(--critical); }
.alert--info { border-left: 3px solid var(--series-1); }

/* ----------------------------------------------------------- reminder list */

.reminders { display: flex; flex-direction: column; gap: 8px; }
.reminder {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}
.reminder__body { flex: 1; min-width: 0; }
.reminder__subject { font-weight: 600; font-size: 13px; }
.reminder__detail { font-size: 12px; color: var(--text-secondary); }
.reminder--critical { border-left: 3px solid var(--critical); }
.reminder--warning { border-left: 3px solid var(--warning); }
.reminder--info { border-left: 3px solid var(--series-1); }

/* --------------------------------------------------------------- utilities */

.row { display: flex; align-items: center; gap: 8px; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

details.disclosure { margin-top: 12px; }
details.disclosure summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__heading { width: 100%; padding-top: 8px; }
  .content { padding: 18px 16px 44px; }
  .topbar { padding: 14px 16px; }
}
