:root {
  --navy: #1a3a5c;
  --navy-deep: #0f2438;
  --gold: #c9a84c;
  --ink: #3d1f0a;
  --paper: #f7f4ef;
  --paper-2: #efe8dc;
  --line: rgba(26, 58, 92, 0.14);
  --ok: #2f6b4f;
  --warn: #8a5a12;
  --bad: #8b2e2e;
  --muted: #5c6b7a;
  --radius: 10px;
  --font: "Instrument Sans", "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--navy-deep);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(201, 168, 76, 0.18), transparent 55%),
    linear-gradient(160deg, #fbf8f3 0%, var(--paper) 45%, #e8eef5 100%);
}

[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-panel {
  width: min(420px, 100%);
  padding: 2.25rem 2rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(8px);
}
.brand-mark {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 600;
}
.login-panel h1 {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: 2.6rem;
  color: var(--navy);
  font-weight: 600;
}
.tagline { margin: 0.2rem 0 0.35rem; color: var(--muted); }
.login-version { margin: 0 0 1.5rem; font-size: 0.8rem; color: var(--muted); }
.login-panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}
.login-panel input, .command-box textarea, .edit-area {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.hint code { font-size: 0.75rem; }
.error { color: var(--bad); font-size: 0.9rem; }
button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}
button.danger { background: var(--bad); }
button.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line); }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand-name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--navy);
  display: block;
}
.brand-tag { font-size: 0.8rem; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.nav button {
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  font-weight: 500;
}
.nav button.active {
  background: var(--navy);
  color: #fff;
}
.user-meta { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.version-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--navy-deep);
  background: var(--gold);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
}

main { flex: 1; width: min(960px, 100%); margin: 0 auto; padding: 1.5rem; }
.panel { display: none; }
.panel.active { display: block; animation: rise 280ms ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
h2 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 0.35rem;
}
.lede { color: var(--muted); margin: 0 0 1.25rem; max-width: 42rem; }

.command-box { display: grid; gap: 0.75rem; }
.command-box button { justify-self: start; }
.status { color: var(--ok); font-size: 0.9rem; }
.result-card, .item {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.82);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 1rem;
}
.stack { display: grid; gap: 0.75rem; }
.item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
  list-style: none;
}
.item summary::-webkit-details-marker { display: none; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.pill.disconnected { color: var(--warn); border-color: rgba(138, 90, 18, 0.35); }
.pill.connected { color: var(--ok); }
.pill.tier-b { background: rgba(26, 58, 92, 0.08); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
.edit-box { margin-top: 0.75rem; display: grid; gap: 0.5rem; }
.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
pre.payload {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  background: var(--paper-2);
  padding: 0.75rem;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
}
.empty { color: var(--muted); padding: 1rem 0; }
.hint.examples { margin-top: 0.75rem; }
button.linkish {
  background: none;
  border: none;
  color: var(--navy);
  text-decoration: underline;
  padding: 0;
  font-weight: 500;
  cursor: pointer;
}
.marks-report { margin-top: 0.75rem; }
.qc-paper-list { margin: 0.75rem 0; padding-left: 1.2rem; font-size: 0.92rem; line-height: 1.45; }
.qc-paper-list a { color: inherit; font-weight: 600; }
.marks-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.65rem 0 0.85rem;
  font-size: 0.9rem;
}
.marks-stats .warn-stat { color: var(--warn); }
.marks-stats .bad-stat { color: var(--bad); }
pre.report-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.86rem;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
  border-radius: 8px;
  max-height: 420px;
  overflow: auto;
  font-family: var(--font);
}
.sched-wrap { margin: 0.85rem 0 1rem; }
.sched-wrap h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.sched-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,0.72); }
.sched-matrix {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
}
.sched-matrix th, .sched-matrix td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.4rem;
  text-align: center;
  vertical-align: middle;
}
.sched-matrix thead th { background: rgba(26, 58, 92, 0.06); font-weight: 600; }
.sched-matrix tbody th {
  text-align: left;
  white-space: nowrap;
  background: rgba(26, 58, 92, 0.03);
  font-weight: 600;
}
.sched-date { display: block; font-weight: 500; color: var(--muted); font-size: 0.7rem; }
.sched-code { display: block; color: var(--muted); font-size: 0.68rem; margin-bottom: 0.1rem; }
.sched-y { background: rgba(47, 107, 79, 0.12); color: var(--ok); }
.sched-n { background: rgba(139, 46, 46, 0.08); color: var(--bad); }
.sched-empty { color: var(--muted); }
.print-date-group { margin: 0.65rem 0; }
.print-date-group h4 { margin: 0 0 0.35rem; font-size: 0.9rem; }
.payload-fold { margin-top: 0.5rem; }
.payload-fold summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }

.school-label {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 14rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  display: inline-block;
  min-width: 1.1rem;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-deep);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  vertical-align: middle;
}
.attention-strip {
  border: 1px solid rgba(138, 90, 18, 0.28);
  background: rgba(201, 168, 76, 0.12);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.1rem;
}
.attention-strip h3 {
  margin: 0 0 0.45rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--navy);
  font-weight: 600;
}
.attention-strip ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}
.attention-strip li { color: var(--navy-deep); }
.attn-bad .linkish { color: var(--bad); }
.attn-warn .linkish { color: var(--warn); }
.attn-info .linkish { color: var(--navy); }

.glance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}
.glance-tile {
  text-align: left;
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: inherit;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}
.glance-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(26, 58, 92, 0.35);
  filter: none;
}
.tile-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.tile-value {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--navy);
  font-weight: 600;
  line-height: 1.25;
}
.tile-meta {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}
.shortcuts {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.shortcuts h3 {
  margin: 0 0 0.65rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--navy);
}
.shortcut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.hub-link {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  background: #fff;
}
.hub-link:hover { border-color: rgba(26, 58, 92, 0.35); }

@media (max-width: 720px) {
  .topbar { align-items: flex-start; }
  .nav { width: 100%; }
  .school-label { max-width: 100%; }
}

/* --- Exams tracker --- */
.exam-legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.exam-lg {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25rem 0.6rem; background: #fff;
}
.exam-dot { width: 0.6rem; height: 0.6rem; border-radius: 999px; display: inline-block; flex: none; }

.exam-term { margin-bottom: 1.6rem; }
.exam-term-head {
  font-family: var(--serif); color: var(--navy); font-size: 1.25rem;
  margin: 0 0 0.6rem; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem;
}
.exam-term-note { font-family: var(--font); font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.exam-block { margin-bottom: 1.1rem; }
.exam-block-head { display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0 0.4rem; flex-wrap: wrap; }
.exam-block-head h4 { margin: 0; font-size: 1rem; color: var(--navy); }
.exam-chip {
  font-size: 0.72rem; background: rgba(47, 107, 79, 0.12); color: var(--ok);
  border-radius: 999px; padding: 0.15rem 0.55rem; font-weight: 600;
}
.exam-scroll {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
}
table.exam-grid { border-collapse: collapse; width: 100%; font-size: 0.78rem; }
.exam-grid th, .exam-grid td {
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 0; text-align: left; white-space: nowrap;
}
.exam-grid thead th {
  background: #eef2f6; color: var(--navy); font-weight: 700; padding: 0.35rem 0.45rem;
  position: sticky; top: 0;
}
.exam-grid tbody th.exam-date { background: #f3f0ea; font-weight: 600; color: var(--navy); padding: 0.35rem 0.5rem; }
.exam-date-full { display: block; color: var(--muted); font-size: 0.66rem; font-weight: 400; }
.exam-cell { padding: 0; }
.exam-cell a { display: flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.45rem; text-decoration: none; color: inherit; }
.exam-cell a:hover { outline: 2px solid var(--gold); outline-offset: -2px; }
.exam-cell > .exam-dot { margin: 0.4rem 0.45rem; }
.exam-cell .exam-subj { font-weight: 500; }
.exam-empty { color: var(--muted); text-align: center; background: #f7f5f1; padding: 0.35rem 0.45rem; }
.exam-note { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--muted); }
.exam-source { margin: 0.25rem 0 0; font-size: 0.72rem; color: var(--muted); }

.exam-cell.st-entered { background: rgba(47, 107, 79, 0.14); }
.exam-cell.st-missing { background: rgba(139, 46, 46, 0.14); }
.exam-cell.st-pending { background: rgba(92, 107, 122, 0.1); }
.exam-cell.st-not_held { background: rgba(92, 107, 122, 0.1); }
.exam-cell.st-no_data { background: rgba(92, 107, 122, 0.07); }

.exam-dot.st-entered, .st-entered .exam-dot { background: var(--ok); }
.exam-dot.st-missing, .st-missing .exam-dot { background: var(--bad); }
.exam-dot.st-pending, .st-pending .exam-dot { background: #b7c0cb; }
.exam-dot.st-not_held, .st-not_held .exam-dot { background: #8a94a0; }
.exam-dot.st-no_data, .st-no_data .exam-dot { background: #cfd6de; }

/* --- Exams toolbar, coverage block & data integrity --- */
.exam-toolbar { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.9rem; flex-wrap: wrap; }
.exam-toolbar button { font-size: 0.82rem; padding: 0.35rem 0.8rem; }
.exam-toolbar button[disabled] { opacity: 0.55; cursor: progress; }
.exam-toolbar-note { font-size: 0.76rem; color: var(--muted); }

.exam-block-heads { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 6px; padding: 0.7rem 0.75rem 0.5rem; background: #fdfcf9; }
.exam-grid tbody th.exam-subject-head { background: #f3f0ea; font-weight: 600; color: var(--navy); padding: 0.35rem 0.5rem; text-align: left; white-space: nowrap; }

.exam-integrity { margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.75rem; background: #faf8f4; }
.exam-integrity h4 { margin: 0 0 0.35rem; font-size: 0.84rem; color: var(--navy); text-transform: uppercase; letter-spacing: 0.04em; }
.exam-integrity ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; }
.exam-integrity li { font-size: 0.78rem; color: var(--navy-deep); line-height: 1.5; }
.exam-check { display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }
.exam-check.ok { background: rgba(47, 107, 79, 0.14); color: var(--ok); }
.exam-check.bad { background: rgba(139, 46, 46, 0.14); color: var(--bad); }
.exam-integrity-note { display: block; color: var(--muted); font-size: 0.74rem; }
