/* 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);

  /* Table striping + hover: soft tints that build a readable rhythm without
     colouring the data itself. The head band is a touch stronger again. */
  --row-alt: #edefe9;
  --row-hover: #e2eee7;
  --thead-bg: #e5e8e0;

  /* Docenti brand accent: professional green on a white/black base. */
  --series-1: #15803d;
  --series-1-soft: #d6f0e0;
  --series-1-strong: #0f5c2e;

  /* Informational accent for "in progress" — distinct from the two greens. */
  --info: #2563eb;
  --info-soft: #dbeafe;

  --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);
    --row-alt: #242320;
    --row-hover: #2c362f;
    --thead-bg: #2a2925;
    --series-1: #34b46a;
    --series-1-soft: #14532d;
    --series-1-strong: #6ee7a0;
    --info: #60a5fa;
    --info-soft: #1e3a5f;
    --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);
  --row-alt: #242320;
  --row-hover: #2c362f;
  --thead-bg: #2a2925;
  --series-1: #34b46a;
  --series-1-soft: #14532d;
  --series-1-strong: #6ee7a0;
  --info: #60a5fa;
  --info-soft: #1e3a5f;
  --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 is a self-contained, full-viewport-height column that sticks to
   the top and scrolls on its own (overflow-y) when the nav is taller than the
   screen — independently of the main content, which scrolls the page. */
.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar__inner { min-height: 100%; }

.brand { padding: 0 8px 18px; }
/* Transparent monochrome mark: black in light mode, inverted to white in dark
   mode, so it reads as part of the app rather than a plated sticker. */
.brand__logo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 52px;
  height: auto;
  object-fit: contain;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .brand__logo { filter: invert(1); }
}
:root[data-theme="dark"] .brand__logo { filter: invert(1); }
.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;
  flex-wrap: wrap;
  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; }

/* The compact month-download control in the Activities topbar: a month picker,
   two small selects and a button laid out inline, wrapping on narrow screens. */
.month-download {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.month-download input,
.month-download select {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
}

.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--info { background: var(--info); }
.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--info { background: var(--info); }
.meter-key__swatch--warning { background: var(--warning); }
.meter-key__swatch--critical { background: var(--critical); }
.meter-key__swatch--neutral { background: var(--baseline); }
.meter-key__value { color: var(--text-primary); font-weight: 650; }

/* ---------------------------------------------------- academics dashboard */

/* status pill tone for "in progress", matching ModuleProgress.tone == "info" */
.status--info { color: var(--text-secondary); }
.status--info .status__dot { background: var(--info); }

/* donut / progress ring */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.donut { width: 100%; max-width: 168px; height: auto; display: block; }
.donut__track { stroke: var(--grid); }
.donut__seg { transition: stroke 0.15s ease; }
.donut__seg--good { stroke: var(--good); }
.donut__seg--info { stroke: var(--info); }
.donut__seg--warning { stroke: var(--warning); }
.donut__seg--serious { stroke: var(--serious); }
.donut__seg--critical { stroke: var(--critical); }
.donut__seg--neutral { stroke: var(--baseline); }
.donut__seg--track { stroke: var(--grid); }
.donut__value { fill: var(--text-primary); font-size: 34px; font-weight: 680; letter-spacing: -0.02em; }
.donut__center-label {
  fill: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.donut-key { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 12px; }
.donut-key__item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.donut-key__swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.donut-key__swatch--good { background: var(--good); }
.donut-key__swatch--info { background: var(--info); }
.donut-key__swatch--warning { background: var(--warning); }
.donut-key__swatch--critical { background: var(--critical); }
.donut-key__swatch--neutral { background: var(--baseline); }
.donut-key__value { color: var(--text-primary); font-weight: 650; font-variant-numeric: tabular-nums; }

/* overview band: two rings + a KPI stack */
.overview {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(200px, 1.1fr) minmax(220px, 1.2fr);
  gap: 14px;
  margin-bottom: 16px;
  align-items: stretch;
}
@media (max-width: 900px) { .overview { grid-template-columns: 1fr; } }
.overview__panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.overview__caption {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 650;
  align-self: flex-start;
}
.overview__sub { font-size: 12px; color: var(--text-muted); text-align: center; }
.overview__kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--baseline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi--good { border-left-color: var(--good); }
.kpi--warning { border-left-color: var(--warning); }
.kpi--serious { border-left-color: var(--serious); }
.kpi__label { font-size: 12px; color: var(--text-secondary); font-weight: 550; }
.kpi__value { font-size: 30px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.05; }
.kpi__note { font-size: 11px; color: var(--text-muted); }

/* inline completion bar used inside tables */
.progress-cell { display: flex; align-items: center; gap: 10px; }
.progress {
  flex: 1;
  min-width: 90px;
  height: 8px;
  background: var(--grid);
  border-radius: 4px;
  overflow: hidden;
}
.progress__fill { height: 100%; background: var(--series-1); border-radius: 4px; }
.progress__num {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  flex: 0 0 36px;
  text-align: right;
}

/* compact status-count chips (completed / in progress / not started) */
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.chip--good .chip__dot { background: var(--good); }
.chip--info .chip__dot { background: var(--info); }
.chip--neutral .chip__dot { background: var(--text-muted); }

/* 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__logo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 92px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 16px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .auth__logo { filter: invert(1); }
}
:root[data-theme="dark"] .auth__logo { filter: invert(1); }
.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;
}
/* sortable column headers */
.sort-th {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.sort-th:hover { color: var(--text-secondary); text-decoration: none; }
.sort-th.is-active { color: var(--series-1); }
.sort-th__arrow { font-size: 10px; opacity: 0.55; }
/* bulk-action bar (e.g. Grading "mark selected graded") */
.bulkbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bulkbar__count { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sort-th.is-active .sort-th__arrow { opacity: 1; }
table.data thead th .sort-th:hover .sort-th__arrow { opacity: 0.85; }

table.data tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:nth-child(even) td { background: var(--row-alt); }
table.data tbody tr:hover td { background: var(--row-hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .actions { text-align: right; white-space: nowrap; }
/* Long text is clipped to one line with a trailing "…"; the auto-tooltip in
   app.js reveals the full value on hover. Applied directly to <td> cells in many
   tables, so it must NOT change `display` (a `-webkit-box`/flex display drops the
   cell out of the table layout and collapses the column). Plain overflow + an
   ellipsis is safe on a table-cell and everywhere else. */
.truncate,
.ellipsis {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ellipsis { max-width: 260px; }
/* When the helper (or a template) has attached a tooltip, hint that it's there. */
.truncate[title], .ellipsis[title] { cursor: help; }

.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;
    overflow: visible;
    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; }
}

/* ---------------------------------------------------------- inline edit mode */
/* A tiny button variant for the per-row link tools (open / copy). */
.btn--xs {
  font-size: 11px;
  padding: 2px 6px;
  gap: 3px;
  line-height: 1.2;
}

/* The edit-mode toggle, once active, reads as pressed. */
[data-edit-toggle].is-active {
  background: var(--series-1-soft);
  color: var(--series-1-strong);
  border-color: var(--series-1);
}

/* Each editable cell holds a static view and a hidden control. Off by default;
   the control is revealed only when the page is in edit mode. */
.inline-ctl { display: none; }
.content[data-edit-mode] .cell-view { display: none; }
.content[data-edit-mode] .inline-ctl { display: inline-block; }

.inline-ctl {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 6px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text-primary);
}
.inline-ctl:focus {
  outline: none;
  border-color: var(--series-1);
  box-shadow: inset 0 0 0 1px var(--series-1);
}
.inline-ctl[type="text"], .inline-ctl[type="url"] { min-width: 180px; }

/* A brief confirmation / error flash on the cell after a save. */
.cell-saved { box-shadow: inset 0 0 0 2px var(--good); border-radius: var(--radius-sm); }
.cell-error { box-shadow: inset 0 0 0 2px var(--critical); border-radius: var(--radius-sm); }

/* The meeting-link cell: title, always-visible open/copy tools, and the
   (edit-mode only) paste input stacked beneath. */
.link-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.link-tools { display: inline-flex; gap: 4px; }
.link-cell .inline-ctl { flex-basis: 100%; }

/* Transient error toast for a failed inline save. */
.inline-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  max-width: 360px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.inline-toast.is-leaving { opacity: 0; transform: translateY(8px); }

/* ---------------------------------------------------------- tinted pills */
/* The base pill is neutral; these two tints carry a little meaning — brand
   green for the "primary" label (programme/intake, "Today"), info blue for a
   managed cohort — so a row scans faster without drowning it in colour. */
.pill--accent {
  background: var(--series-1-soft);
  border-color: transparent;
  color: var(--series-1-strong);
}
:root[data-theme="dark"] .pill--accent,
:root:where(:not([data-theme="light"])) .pill--accent { color: var(--series-1-strong); }
.pill--cohort {
  background: var(--info-soft);
  border-color: transparent;
  color: var(--info);
}
:root[data-theme="dark"] .pill--cohort,
:root:where(:not([data-theme="light"])) .pill--cohort { color: #bfdbfe; }

/* ---------------------------------------------- Activities list cell layout */
/* These columns used to clip to a single line; now they wrap and read in full. */
.cell-prog { min-width: 150px; max-width: 280px; }
.cell-prog__label { font-weight: 600; }
.cell-cohort { min-width: 120px; max-width: 240px; }
.cell-owner { min-width: 110px; }
.cell-host { min-width: 100px; max-width: 180px; }
.cell-session { min-width: 220px; }
/* The session title links to its preview page; let it wrap and stand out. */
.link-name { font-weight: 650; color: var(--text-primary); }
.link-name:hover { color: var(--series-1); text-decoration: none; }
.link-cell .link-title { flex: 1 1 100%; min-width: 0; }

/* ------------------------------------------------------- record preview page */

.detail { max-width: 1040px; }
.detail__hero {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--series-1);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, var(--series-1-soft) 0%, transparent 58%),
    var(--surface-1);
  box-shadow: var(--shadow);
}
.detail__heromain { min-width: 0; flex: 1 1 320px; }
.detail__state { margin-bottom: 8px; }
.detail__title {
  font-size: 24px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 12px;
}
.detail__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail__herometa {
  text-align: right;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail__when { font-size: 20px; font-weight: 680; letter-spacing: -0.01em; }
.detail__clock { font-size: 15px; color: var(--text-secondary); font-weight: 600; }

.detail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  align-items: start;
}
.detail__card--wide { grid-column: 1 / -1; }
.detail__defs { display: flex; flex-direction: column; gap: 0; padding-top: 4px; }
.deffield {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--grid);
  align-items: baseline;
}
.deffield:last-child { border-bottom: none; }
.deffield dt {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 650;
}
.deffield dd { margin: 0; font-size: 14px; color: var(--text-primary); overflow-wrap: anywhere; }
.deffield--wide { grid-template-columns: 1fr; gap: 4px; }
.detail__link { overflow-wrap: anywhere; }
.detail__pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.detail__foot { margin-top: 18px; }
@media (max-width: 560px) {
  .detail__herometa { text-align: left; }
  .deffield { grid-template-columns: 1fr; gap: 2px; }
}

/* ------------------------------------------------------- process sheet builder */

.psheet { display: flex; flex-direction: column; gap: 22px; }
.psheet__weekend { break-inside: avoid; }
.psheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.psheet__tab {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--series-1-strong);
  font-weight: 700;
}
.psheet__title { font-size: 17px; font-weight: 680; letter-spacing: -0.01em; margin: 2px 0 0; }
.psheet__table th.num, .psheet__table td.num { text-align: left; }
.psheet__band th {
  background: var(--series-1-soft);
  color: var(--series-1-strong);
  text-transform: none;
  letter-spacing: 0;
  padding: 7px 14px;
  position: static;
}
.psheet__day { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.psheet__daydate { color: var(--text-secondary); font-weight: 600; margin-left: 8px; }
/* The fee / total / materials columns are intentionally blank — mark them so the
   gap reads as "fill this in", not "missing data". */
.psheet__blank {
  background:
    repeating-linear-gradient(135deg, transparent, transparent 5px,
      var(--grid) 5px, var(--grid) 6px);
  min-width: 70px;
}

/* ---------------------------------------------------- monogram name avatars */
/* A coloured initials badge beside a person/record name. The tone (1–6) is
   chosen deterministically per name by the `avatar_tone` filter, so everyone
   keeps a consistent colour. Tones are muted and readable in both themes. */
.namecell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.namecell__text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.namecell__name { font-weight: 650; }
.namecell__name a { color: var(--text-primary); }
.namecell__name a:hover { color: var(--series-1); text-decoration: none; }
.namecell__sub { font-size: 11px; color: var(--text-muted); max-width: 220px; }

.avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar--1 { background: #d9f0e2; color: #116a37; }
.avatar--2 { background: #dbe8fe; color: #1d4ed8; }
.avatar--3 { background: #e7defb; color: #6d28d9; }
.avatar--4 { background: #fdeecb; color: #a15c07; }
.avatar--5 { background: #cdeeed; color: #0f766e; }
.avatar--6 { background: #fbdfe6; color: #b03159; }
:root[data-theme="dark"] .avatar--1,
:root:where(:not([data-theme="light"])) .avatar--1 { background: #13351f; color: #6ee7a0; }
:root[data-theme="dark"] .avatar--2,
:root:where(:not([data-theme="light"])) .avatar--2 { background: #142544; color: #93c5fd; }
:root[data-theme="dark"] .avatar--3,
:root:where(:not([data-theme="light"])) .avatar--3 { background: #241848; color: #c4b5fd; }
:root[data-theme="dark"] .avatar--4,
:root:where(:not([data-theme="light"])) .avatar--4 { background: #3a2a0c; color: #fcd36a; }
:root[data-theme="dark"] .avatar--5,
:root:where(:not([data-theme="light"])) .avatar--5 { background: #0d2e2c; color: #7fdbd5; }
:root[data-theme="dark"] .avatar--6,
:root:where(:not([data-theme="light"])) .avatar--6 { background: #3a1420; color: #f7a8bf; }

/* --------------------------------------------------------- professional polish */

/* A quiet accent bar to the left of the page title. */
.topbar__title {
  padding-left: 11px;
  border-left: 3px solid var(--series-1);
  line-height: 1.15;
}

/* The active nav item gains a coloured left edge inside its rounded pill. */
.nav__link.is-active { box-shadow: inset 3px 0 0 0 var(--series-1-strong); }

/* Table head reads as a distinct band, not just another row. */
table.data thead th {
  background: var(--thead-bg);
  border-bottom: 2px solid var(--border);
}

/* Wide registers scroll sideways, which used to hide the row's action buttons
   off the right edge. Pin the actions column so Edit / Delete / Mark-complete
   stay in view while the rest of the row scrolls under them. The pinned cell
   carries its row's own background (plain / striped / hovered) so scrolled
   content never shows through, with a hairline + soft shadow marking the edge. */
table.data th.actions,
table.data td.actions {
  position: sticky;
  right: 0;
  background: var(--surface-1);
  box-shadow: inset 1px 0 0 var(--border), -10px 0 12px -10px rgba(11, 11, 11, 0.18);
}
table.data tbody tr:nth-child(even) td.actions { background: var(--row-alt); }
table.data tbody tr:hover td.actions { background: var(--row-hover); }
table.data thead th.actions { background: var(--thead-bg); z-index: 3; }
:root[data-theme="dark"] table.data th.actions,
:root[data-theme="dark"] table.data td.actions,
:root:where(:not([data-theme="light"])) table.data th.actions,
:root:where(:not([data-theme="light"])) table.data td.actions {
  box-shadow: inset 1px 0 0 var(--border), -10px 0 12px -10px rgba(0, 0, 0, 0.5);
}

/* The process sheet groups rows under Saturday/Sunday day bands, so plain
   striping on top would fight those bands — keep its data rows unstriped. */
.psheet__table tbody tr:nth-child(even) td { background: transparent; }

/* Gentle lift on the cards and tiles that invite a look, so the page feels
   responsive without moving the dense data tables around. */
.tile, .kpi, .chooser__item, .detail__card, .overview__panel {
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.tile:hover, .kpi:hover, .detail__card:hover, .overview__panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(11, 11, 11, 0.06), 0 12px 28px rgba(11, 11, 11, 0.07);
}
:root[data-theme="dark"] .tile:hover,
:root[data-theme="dark"] .kpi:hover,
:root[data-theme="dark"] .detail__card:hover,
:root[data-theme="dark"] .overview__panel:hover,
:root:where(:not([data-theme="light"])) .tile:hover,
:root:where(:not([data-theme="light"])) .kpi:hover,
:root:where(:not([data-theme="light"])) .detail__card:hover,
:root:where(:not([data-theme="light"])) .overview__panel:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 12px 28px rgba(0, 0, 0, 0.4);
}

/* A hair of depth on the primary action so it reads as the main button. */
.btn--primary { box-shadow: 0 1px 2px rgba(21, 128, 61, 0.25); }
.btn--primary:hover { box-shadow: 0 2px 6px rgba(21, 128, 61, 0.32); }

/* Clear, consistent keyboard focus everywhere. */
a:focus-visible, .btn:focus-visible, .nav__link:focus-visible,
summary:focus-visible, [data-copy-link]:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* A softer, branded highlight for a row linked to from elsewhere. */
table.data tbody tr[style*="outline"] td { background: var(--series-1-soft) !important; }

/* ------------------------------------------------------------------ printing */
@media print {
  .sidebar, .topbar, .toolbar, .detail__foot, .psheet__head .pill { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .table-wrap { box-shadow: none; border-color: #ccc; }
  a { color: inherit; text-decoration: none; }
  body { background: #fff; }
}
