/* Lyceum School OS — "exercise book" identity: royal ink blue, ruled paper, red margin line. */
@font-face { font-family: "Figtree"; src: url("../fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --ink: #1d3f9e;          /* royal ink */
  --ink-deep: #132a6b;
  --ink-soft: #e8eefc;
  --margin: #d9443f;       /* exercise-book margin red */
  --paper: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --rule: #dfe5f1;
  --rule-strong: #c9d2e5;
  --text: #182033;
  --text-2: #4a556e;
  --muted: #6b7690;
  --ok: #1d7a55;   --ok-bg: #e3f4ec;
  --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #b8322e;  --bad-bg: #fce8e7;
  --info: #1d5fae; --info-bg: #e5effb;
  --rail: #13285f;
  --rail-text: #c9d4f2;
  --rail-hover: rgba(255,255,255,.07);
  --rail-active: rgba(255,255,255,.13);
  --focus: 0 0 0 3px rgba(29,63,158,.28);
  --radius: 10px;
  --radius-sm: 7px;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #8fb0ff; --ink-deep: #c3d4ff; --ink-soft: #1c2a4d;
  --margin: #f0716c;
  --paper: #0e1424; --surface: #151d31; --surface-2: #1a233a;
  --rule: #26314b; --rule-strong: #34405e;
  --text: #e4e9f5; --text-2: #b4bed6; --muted: #8995b1;
  --ok: #5fd0a0; --ok-bg: #12352a; --warn: #f3b860; --warn-bg: #3a2b12;
  --bad: #ff8f8a; --bad-bg: #3d1c1d; --info: #8bbcff; --info-bg: #152a4a;
  --rail: #0b1430; --rail-text: #aebbe0;
  --focus: 0 0 0 3px rgba(143,176,255,.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--text);
  background: var(--paper); font-feature-settings: "tnum" 1, "cv01" 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.rail {
  background: var(--rail); color: var(--rail-text); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.crest {
  width: 36px; height: 36px; border-radius: 9px 9px 14px 14px; background: #fff; color: var(--rail);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; position: relative; overflow: hidden;
}
.crest::after { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: #d9443f; }
.crest img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font-size: 15px; font-weight: 700; line-height: 1.15; }
.brand span { display: block; font-size: 12px; color: var(--rail-text); }
.rail nav { padding: 4px 10px 24px; flex: 1; }
.nav-group { margin-top: 6px; }
.nav-group > button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: 0;
  color: #8e9cc6; font: 600 12.5px var(--sans); padding: 10px 10px 6px; cursor: pointer; letter-spacing: .01em;
}
.nav-group > button .i { width: 14px; height: 14px; transition: transform .18s; }
.nav-group.closed > button .i { transform: rotate(-90deg); }
.nav-group.closed ul { display: none; }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail li a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--rail-text); font-size: 14.5px;
}
.rail li a:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail li a.on { background: var(--rail-active); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #ff7b74; }
.rail li a .badge { margin-left: auto; }
.rail-foot { padding: 14px 18px; font-size: 12px; color: #7f8db8; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input, .search input[type=search] { width: 100%; padding: 9px 12px 9px 36px; border-radius: 9px; border: 1px solid var(--rule); background: var(--surface); font: inherit; color: var(--text); }
.search input:focus { border-color: var(--ink); outline: none; box-shadow: var(--focus); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(19,40,95,.14); padding: 6px; display: none; max-height: 380px; overflow: auto;
}
.search-results.show { display: block; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; color: var(--text); }
.search-results a:hover, .search-results a.hl { background: var(--ink-soft); text-decoration: none; }
.search-results .sub { font-size: 12.5px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.year-chip { font-size: 13px; color: var(--text-2); padding: 6px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); white-space: nowrap; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent;
  background: none; color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface); border-color: var(--rule); color: var(--text); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--margin); border: 2px solid var(--paper); }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text); font: inherit; }
.user-btn:hover { background: var(--surface); border-color: var(--rule); }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-size: 13.5px; font-weight: 600; }
.user-btn .who span { font-size: 12px; color: var(--muted); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(19,40,95,.14); padding: 6px; display: none; z-index: 30;
}
.dropdown.show { display: block; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--ink-soft); text-decoration: none; }
.dropdown hr { border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }

.content { padding: 26px 28px 60px; width: 100%; max-width: 1320px; }

/* ---------- Page head: the margin line ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 2px 0 16px 18px; margin-bottom: 22px; position: relative;
  background-image: linear-gradient(var(--rule), var(--rule)); background-size: 100% 1px; background-position: bottom; background-repeat: no-repeat;
}
.page-head::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 16px; width: 2px; background: var(--margin); border-radius: 2px; }
.page-head h1 { font-size: 1.55rem; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 14.5px; }
.page-head .crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.page-head .crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8.5px 15px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--text); font: 600 14px var(--sans);
  cursor: pointer; white-space: nowrap; line-height: 1.3; transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; border-color: var(--ink); background: var(--surface-2); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-deep); border-color: var(--ink-deep); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #0e1424; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--rule)); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--ink-soft); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline { display: inline; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 20px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.panel-head h2 { font-size: 1.02rem; }
.panel-head .muted { font-size: 13.5px; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(260px, 1fr) minmax(0, 2.4fr); }
.grid > .panel { margin-bottom: 0; }
.stack > * + * { margin-top: 20px; }

/* Figures strip (dashboard): one ruled band, not a row of cards */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.figure { padding: 16px 18px; border-left: 1px solid var(--rule); min-width: 0; }
.figure:first-child { border-left: 0; }
.figure .label { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.figure .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.figure .note { font-size: 12.5px; color: var(--muted); }
.figure .note.up { color: var(--ok); }
.figure .note.down { color: var(--bad); }
a.figure { color: inherit; }
a.figure:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14.2px; }
.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--rule); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: color-mix(in srgb, var(--ink-soft) 45%, transparent); }
.t tfoot td { font-weight: 700; border-top: 2px solid var(--rule-strong); padding: 10px 14px; background: var(--surface-2); }
.t .right, .t th.right { text-align: right; }
.t td.actions-cell { text-align: right; white-space: nowrap; }
.t tr.is-void td { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.t tr.is-void td .pill, .t tr.is-void td.actions-cell { text-decoration: none; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { font-weight: 600; display: block; }
.person .sub { font-size: 12.5px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 12.5px; font-weight: 700;
  background: var(--ink-soft); color: var(--ink); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 88px; height: 88px; font-size: 28px; border-radius: 18px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--rule); }
.badge { background: var(--margin); color: #fff; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.req::after { content: " *"; color: var(--margin); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=tel], input[type=search], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14.5px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--focus); }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236b7690' stroke-width='2'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }
input[type=file] { padding: 7px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--ink); }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend { font-weight: 650; font-size: 1rem; margin-bottom: 12px; padding-left: 12px; border-left: 2px solid var(--margin); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.filters .field label { font-size: 12.5px; }
.filters input, .filters select { min-height: 38px; padding-top: 7px; padding-bottom: 7px; }

/* ---------- Tabs (segmented) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Flash ---------- */
.flashes { position: fixed; top: 14px; right: 14px; z-index: 60; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 28px)); }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 10px 30px rgba(19,40,95,.16); font-size: 14.2px; animation: flash-in .25s ease-out; }
.flash-success { border-left: 4px solid var(--ok); }
.flash-error { border-left: 4px solid var(--bad); }
.flash-info { border-left: 4px solid var(--info); }
.flash .x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
@keyframes flash-in { from { transform: translateY(-6px); opacity: 0; } }
.alert { padding: 12px 14px; border-radius: 9px; font-size: 14.2px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty .i { width: 34px; height: 34px; stroke-width: 1.4; color: var(--rule-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 18px; border-bottom: 1px solid var(--rule); display: flex; gap: 12px; align-items: center; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: 12.5px; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14.2px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* Profile header */
.profile { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile h1 { font-size: 1.5rem; }
.profile .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* Progress */
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: #d69a2b; }
.bar.bad > span { background: var(--bad); }

/* ---------- Charts (inline SVG) ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 12px var(--sans); fill: var(--muted); }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Attendance register ---------- */
.att-row { display: flex; gap: 4px; }
.att-row input { position: absolute; opacity: 0; pointer-events: none; }
.att-row label {
  width: 38px; height: 34px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--rule-strong);
  font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--muted); background: var(--surface); user-select: none;
}
.att-row input:focus-visible + label { box-shadow: var(--focus); }
.att-row input:checked + label.c-P { background: var(--ok); border-color: var(--ok); color: #fff; }
.att-row input:checked + label.c-A { background: var(--bad); border-color: var(--bad); color: #fff; }
.att-row input:checked + label.c-L { background: #c98512; border-color: #c98512; color: #fff; }
.att-row input:checked + label.c-E { background: var(--info); border-color: var(--info); color: #fff; }
.att-summary { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.reg { border-collapse: collapse; font-size: 12.5px; }
.reg th, .reg td { border: 1px solid var(--rule); padding: 4px 6px; text-align: center; min-width: 26px; }
.reg td.name { text-align: left; white-space: nowrap; min-width: 170px; position: sticky; left: 0; background: var(--surface); }
.reg .P { color: var(--ok); font-weight: 700; } .reg .A { color: #fff; background: var(--bad); font-weight: 700; }
.reg .L { color: var(--warn); font-weight: 700; } .reg .E { color: var(--info); font-weight: 700; }
.reg .off { background: var(--surface-2); }

/* ---------- Timetable ---------- */
.tt { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 13px; min-width: 760px; }
.tt th { color: var(--muted); font-weight: 600; padding: 6px; text-align: left; }
.tt th.time { width: 110px; }
.tt th.time small { display: block; font-weight: 400; }
.tt td { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 7px 9px; height: 58px; vertical-align: top; }
.tt td.lesson { background: var(--ink-soft); border-color: color-mix(in srgb, var(--ink) 25%, var(--rule)); }
.tt td.lesson b { display: block; color: var(--ink); font-size: 13.5px; }
.tt td.lesson span { color: var(--text-2); font-size: 12px; }
.tt tr.break td { height: auto; background: none; border: 1px dashed var(--rule); color: var(--muted); text-align: center; padding: 4px; }
.tt td.editable { cursor: pointer; }
.tt td.editable:hover { border-color: var(--ink); }

/* ---------- Marks entry ---------- */
.marks-input { width: 90px !important; text-align: right; }
tr.row-error td { background: var(--bad-bg) !important; }

/* ---------- Admissions board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.lane h3 { font-size: 14px; display: flex; justify-content: space-between; padding: 4px 4px 10px; }
.lane h3 span { color: var(--muted); font-weight: 500; }
.ticket { display: block; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; color: var(--text); }
.ticket:hover { border-color: var(--ink); text-decoration: none; }
.ticket b { display: block; font-size: 14px; }
.ticket .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.cal > div { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-height: 96px; padding: 6px; font-size: 12.5px; background: var(--surface); }
.cal .dow { min-height: 0; background: var(--surface-2); font-weight: 600; color: var(--muted); text-align: center; }
.cal .out { background: var(--surface-2); color: var(--muted); }
.cal .today .d { background: var(--ink); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: inline-grid; place-items: center; }
.cal .d { font-weight: 600; }
.cal .ev { display: block; margin-top: 3px; padding: 2px 6px; border-radius: 5px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--ink-soft); color: var(--ink); }
.cal .ev.holiday { background: var(--bad-bg); color: var(--bad); }
.cal .ev.exam { background: var(--warn-bg); color: var(--warn); }
.cal .ev.sports { background: var(--ok-bg); color: var(--ok); }

/* ---------- Messages ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 18px; max-height: 60vh; overflow-y: auto; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--rule); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--ink-soft); border-color: color-mix(in srgb, var(--ink) 25%, var(--rule)); }
.bubble .meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* Notices */
.notice { padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.notice:last-child { border-bottom: 0; }
.notice h3 { font-size: 15px; display: flex; gap: 8px; align-items: center; }
.notice .meta { font-size: 12.5px; color: var(--muted); margin: 2px 0 6px; }
.notice .body { white-space: pre-line; color: var(--text-2); font-size: 14.2px; }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--rule); color: var(--text-2); }
.pager span.cur { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Dialog */
dialog { border: 1px solid var(--rule); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(10,20,50,.3); }
dialog::backdrop { background: rgba(14,22,46,.45); }
dialog .panel-head { border-bottom: 1px solid var(--rule); }
dialog form.body, dialog .body { padding: 18px; }
.x-btn { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-art {
  background: var(--rail); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(255,255,255,.07) 31px 32px);
}
.auth-art::before { content: ""; position: absolute; left: 88px; top: 0; bottom: 0; width: 2px; background: rgba(255,120,112,.75); }
.auth-art .brand { padding: 0; position: relative; }
.auth-art blockquote { margin: 0; position: relative; padding-left: 64px; max-width: 520px; }
.auth-art blockquote p { font-family: var(--serif); font-size: 2.1rem; line-height: 1.2; font-weight: 400; letter-spacing: -.01em; margin-bottom: 14px; }
.auth-art blockquote footer { color: var(--rail-text); font-size: 14px; }
.auth-art .foot { position: relative; padding-left: 64px; color: var(--rail-text); font-size: 13px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.7rem; margin-bottom: 6px; }
.auth-form .field { margin-bottom: 14px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; }
.demo-logins { margin-top: 26px; border-top: 1px solid var(--rule); padding-top: 16px; font-size: 13px; color: var(--muted); }
.demo-logins .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.demo-logins button { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 999px; padding: 4px 11px; font: 600 12.5px var(--sans); color: var(--text-2); cursor: pointer; }
.demo-logins button:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- Portal child switcher ---------- */
.kids { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.kid { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 12px; border: 1px solid var(--rule); background: var(--surface); color: var(--text); }
.kid:hover { border-color: var(--ink); text-decoration: none; }
.kid.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.kid .sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-main, .g-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .22s ease; visibility: hidden; }
  body.nav-open .rail { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10,18,40,.45); z-index: 40; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 60px; }
  .year-chip, .user-btn .who { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .g2, .g3, .g4, .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 1.35rem; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { border-left: 0; border-top: 1px solid var(--rule); }
  .figure:nth-child(-n+2) { border-top: 0; }
  .figure:nth-child(even) { border-left: 1px solid var(--rule); }
  .figure .value { font-size: 1.3rem; }
  /* Tables become stacked cards */
  table.t.stack-sm thead { display: none; }
  table.t.stack-sm, .t.stack-sm tbody, .t.stack-sm tr, .t.stack-sm td { display: block; width: 100%; }
  .t.stack-sm tr { border-bottom: 1px solid var(--rule); padding: 8px 0; }
  .t.stack-sm td { border: 0; padding: 4px 16px; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .t.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .t.stack-sm td.actions-cell { justify-content: flex-end; }
  .t.stack-sm td.actions-cell::before { content: none; }
  .t.stack-sm tfoot { display: block; }
  .t.stack-sm tfoot tr { display: flex; justify-content: space-between; }
  .t.stack-sm tfoot td { display: block; }
  .search { max-width: none; }
  .panel-body { padding: 14px; }
  .list > li { padding: 10px 14px; }
  .bubble { max-width: 92%; }
  .cal > div { min-height: 64px; padding: 3px; }
  .cal .ev { font-size: 10px; padding: 1px 3px; }
  .att-row label { width: 34px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Print ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 12px; }
  .rail, .topbar, .no-print, .flashes, .page-head .actions, .filters, .pager, .tabs { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; break-inside: avoid; }
  .t th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; }
}
