/* ==========================================================================
   School ERP — design system
   One file: tokens, layout, components, pages, print. No external fonts.
   The brand colour comes from Settings → School profile (--brand inline).
   ========================================================================== */

:root {
    --brand: #2563eb;
    --brand-ink: #ffffff;
    --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
    --brand-line: color-mix(in srgb, var(--brand) 30%, #fff);
    --brand-dark: color-mix(in srgb, var(--brand) 78%, #000);

    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;

    --green: #15803d;  --green-bg: #f0fdf4;  --green-line: #bbf7d0;
    --red: #b91c1c;    --red-bg: #fef2f2;    --red-line: #fecaca;
    --amber: #b45309;  --amber-bg: #fffbeb;  --amber-line: #fde68a;
    --blue: #1d4ed8;   --blue-bg: #eff6ff;   --blue-line: #bfdbfe;
    --violet: #6d28d9; --violet-bg: #f5f3ff; --violet-line: #ddd6fe;

    --r: 12px;
    --r-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --sidebar: 264px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.hidden, [hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1em; height: 1em; flex: none; vertical-align: -.14em; }

/* ---- Layout: sidebar + main ------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #0b1324; color: #cbd5e1;
    display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .95rem; flex: none; }
.sidebar-brand strong { display: block; font-size: .95rem; line-height: 1.2; }
.sidebar-brand small { display: block; color: #94a3b8; font-size: .74rem; }
.nav { padding: 10px 10px 30px; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #cbd5e1;
    font-size: .9rem; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.nav-link .icon { width: 17px; height: 17px; opacity: .9; }
.nav-group { margin-top: 2px; }
.nav-group > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
    font-size: .9rem; font-weight: 500; color: #cbd5e1; user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group > summary .icon { width: 17px; height: 17px; }
.nav-group > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); opacity: .6; transition: transform .15s; }
.nav-group[open] > summary::after { transform: rotate(45deg); }
.nav-group[open] > summary { color: #fff; }
.nav-sub { padding: 2px 0 6px 27px; }
.nav-sub .nav-link { padding: 6px 10px; font-size: .86rem; color: #94a3b8; }
.nav-sub .nav-link:hover { color: #fff; }
.nav-sub .nav-link.is-active { background: rgba(255,255,255,.1); color: #fff; }
.nav-title { padding: 14px 10px 4px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #64748b; font-weight: 700; }

.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 24px;
    background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-toggle { display: none; }
/* School name in the top bar on phones, where the sidebar is folded away */
.topbar-brand { display: none; align-items: center; gap: 8px; min-width: 0; color: var(--ink); font-weight: 700; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand img { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; flex: none; }
.topbar-brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: .78rem; }
.topbar-brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.topbar-spacer { flex: 1; }
.session-pill { display: flex; align-items: center; gap: 6px; }
.session-pill select { padding: 6px 28px 6px 10px; font-size: .85rem; border-radius: 999px; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 999px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--surface-2); }
.user-menu-name { font-size: .88rem; font-weight: 600; line-height: 1.1; }
.user-menu-name small { display: block; font-weight: 500; color: var(--muted); font-size: .74rem; }
.dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: #fff; border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 30;
}
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--ink-2); font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; }
.past-session { background: var(--amber-bg); border-bottom: 1px solid var(--amber-line); color: var(--amber); padding: 8px 24px; font-size: .88rem; }

/* ---- Page head ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }

/* ---- Cards and grids ---------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { display: grid; gap: 18px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid > .card, .grid-2 > .card, .grid-3 > .card, .grid-2-1 > .card, .grid-1-2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

/* ---- KPIs --------------------------------------------------------------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.kpi-icon .icon { width: 21px; height: 21px; }
.kpi-label { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi-value { display: block; font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.kpi-sub { display: block; color: var(--muted); font-size: .78rem; }
.kpi.green .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi.red .kpi-icon { background: var(--red-bg); color: var(--red); }
.kpi.amber .kpi-icon { background: var(--amber-bg); color: var(--amber); }
.kpi.violet .kpi-icon { background: var(--violet-bg); color: var(--violet); }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fafcff; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table-sm th, .table-sm td { padding: 7px 10px; }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: 4px; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 18px; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 18px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person strong { display: block; font-size: .9rem; line-height: 1.2; }
.person small { display: block; color: var(--muted); font-size: .78rem; }
.avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-initials { display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; }

/* ---- Toolbar (filters) -------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .field-grow { flex: 1; min-width: 200px; }
.toolbar .btn { height: 38px; }

/* ---- Forms -------------------------------------------------------------- */
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 10px 0 10px; padding-top: 12px; border-top: 1px dashed var(--line); grid-column: 1 / -1; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-2); }
.req { color: var(--red); font-weight: 700; }
.field-hint { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; }
.field-error { display: block; margin-top: 4px; color: var(--red); font-size: .8rem; font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time],
input[type=password], input[type=url], input[type=search], input[type=month], input[type=file], select, textarea {
    width: 100%; font: inherit; font-size: .92rem; color: var(--ink); background: #fff; border: 1px solid var(--line-2);
    border-radius: var(--r-sm); padding: 8px 11px; min-height: 38px; transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: 6px; background: var(--surface-2); }
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; }
textarea { min-height: 76px; resize: vertical; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select[multiple] { background-image: none; padding-right: 11px; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[readonly] { background: var(--surface-2); }
.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; cursor: pointer; font-size: .9rem; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.check small { display: block; color: var(--muted); font-size: .78rem; }
.input-group { display: flex; }
.input-group > input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group > .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 6px; }
.form-actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 6px; margin-top: -6px; z-index: 5; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: .9rem; font-weight: 600;
    padding: 8px 15px; min-height: 38px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
    background: var(--surface-2); color: var(--ink); line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: color-mix(in srgb, var(--green) 85%, #000); }
.btn-danger { background: #fff; border-color: var(--red-line); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: .84rem; }
.btn-xs { padding: 3px 8px; min-height: 26px; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: 11px 20px; min-height: 46px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Badges ------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }
.badge-danger { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.badge-warning { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.badge-info { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-line); }
.badge-violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-line); }
.badge-muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }

/* ---- Alerts / flash ----------------------------------------------------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid; margin-bottom: 16px; font-size: .9rem; }
.alert .icon { width: 18px; height: 18px; margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert a { color: inherit; text-decoration: underline; }
.alert-success { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.alert-error { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.alert-warning { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.alert-info { background: var(--blue-bg); border-color: var(--blue-line); color: var(--blue); }
.alert .alert-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.2rem; line-height: 1; opacity: .6; }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- Pagination, empty state, misc ------------------------------------- */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 14px 18px; }
.pagination a, .pagination span { padding: 5px 11px; border-radius: 7px; font-size: .86rem; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.pagination a:hover { text-decoration: none; border-color: var(--brand-line); background: var(--brand-soft); }
.pagination .is-current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination small { margin-left: auto; border: 0; background: none; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .icon { width: 38px; height: 38px; color: var(--faint); margin-bottom: 8px; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; word-break: break-word; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: .82rem; color: var(--ink-2); }
a.chip:hover { text-decoration: none; border-color: var(--brand-line); }
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- Profile head ------------------------------------------------------- */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head .avatar { width: 84px !important; height: 84px !important; font-size: 28px !important; }
.profile-head h1 { margin-bottom: 2px; }
.profile-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }

/* ---- Bar chart (CSS only) ---------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar span { display: block; width: 100%; max-width: 34px; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar small { font-size: .66rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bars .bar em { font-style: normal; font-size: .66rem; color: var(--ink-2); margin-bottom: 2px; white-space: nowrap; }

/* ---- Attendance marking ------------------------------------------------- */
.att-row td { padding-top: 8px; padding-bottom: 8px; }
.att-options { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.att-options label { position: relative; }
.att-options input { position: absolute; opacity: 0; pointer-events: none; }
.att-options span { display: inline-grid; place-items: center; min-width: 38px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line-2); font-weight: 700; font-size: .8rem; cursor: pointer; color: var(--muted); background: #fff; user-select: none; }
.att-options input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.att-options input[value=P]:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.att-options input[value=A]:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.att-options input[value=L]:checked + span { background: var(--amber); border-color: var(--amber); color: #fff; }
.att-options input[value=HD]:checked + span { background: #0e7490; border-color: #0e7490; color: #fff; }
.att-options input[value=LV]:checked + span { background: var(--violet); border-color: var(--violet); color: #fff; }
.att-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.register { font-size: .78rem; }
.register th, .register td { padding: 5px 4px !important; text-align: center !important; min-width: 26px; }
.register td.name, .register th.name { text-align: left !important; min-width: 170px; position: sticky; left: 0; background: #fff; z-index: 1; }
.register th.name { background: var(--surface-2); }
.st-P { color: var(--green); font-weight: 700; } .st-A { color: var(--red); font-weight: 700; background: var(--red-bg); }
.st-L { color: var(--amber); font-weight: 700; } .st-HD { color: #0e7490; font-weight: 700; } .st-LV { color: var(--violet); font-weight: 700; }
.st-H { color: var(--faint); background: var(--surface-2); } .st-W { background: var(--surface-2); }

/* ---- Marks entry -------------------------------------------------------- */
.marks-table input[type=number], .marks-table input[type=text] { width: 80px; min-height: 32px; padding: 4px 6px; text-align: center; }
.marks-table td.total { font-weight: 700; text-align: center; }
.marks-table .is-over { border-color: var(--red); background: var(--red-bg); }
.marks-table th small { display: block; font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ---- Timetable ---------------------------------------------------------- */
.tt { table-layout: fixed; min-width: 860px; }
.tt th, .tt td { text-align: center !important; vertical-align: top !important; padding: 6px !important; }
.tt td.tt-day { font-weight: 700; background: var(--surface-2); width: 92px; }
.tt-cell { border-radius: 8px; padding: 6px; background: var(--brand-soft); border: 1px solid var(--brand-line); min-height: 52px; font-size: .8rem; }
.tt-cell strong { display: block; color: var(--ink); font-size: .82rem; }
.tt-cell small { color: var(--muted); font-size: .74rem; }
.tt-break { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, #fff 6px, #fff 12px); color: var(--faint); font-weight: 700; font-size: .74rem; letter-spacing: .1em; }
.tt-edit select { font-size: .78rem; padding: 4px 22px 4px 6px; min-height: 30px; margin-bottom: 4px; }
.tt-clash { border-color: var(--red) !important; background: var(--red-bg) !important; }

/* ---- Calendar ----------------------------------------------------------- */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: .76rem; color: var(--muted); padding: 8px; text-transform: uppercase; }
.cal td { border: 1px solid var(--line); height: 96px; vertical-align: top; padding: 6px; font-size: .78rem; }
.cal td.is-other { background: var(--surface-2); color: var(--faint); }
.cal td.is-today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal .cal-day { font-weight: 700; font-size: .82rem; }
.cal .cal-ev { display: block; margin-top: 3px; padding: 2px 6px; border-radius: 5px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .cal-ev.holiday, .cal .cal-ev.vacation { background: var(--red-bg); color: var(--red); }
.cal .cal-ev.exam { background: var(--amber-bg); color: var(--amber); }
.cal .cal-ev.ptm { background: var(--violet-bg); color: var(--violet); }

/* ---- Fee collection ----------------------------------------------------- */
.dues td input[type=number] { width: 110px; min-height: 32px; padding: 4px 8px; text-align: right; }
.dues tr.is-overdue td:nth-child(3) { color: var(--red); font-weight: 600; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; font-size: .95rem; align-items: center; }
.totals .grand { font-size: 1.25rem; font-weight: 800; color: var(--brand-dark); }
.totals input { width: 120px; text-align: right; }

/* ---- Auth pages --------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.auth-side { background: linear-gradient(150deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 2rem; }
.auth-side p { color: rgba(255,255,255,.85); font-size: 1.02rem; max-width: 460px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.92); }
.auth-points .icon { width: 20px; height: 20px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-card .brand img { width: 46px; height: 46px; object-fit: contain; }
.auth-card .brand strong { display: block; font-size: 1.05rem; }
.auth-card .brand small { color: var(--muted); }

/* ---- Portal (parents / students) ---------------------------------------- */
.portal-kid { display: flex; gap: 12px; align-items: center; }
.kid-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- Blank / error ------------------------------------------------------ */
.blank { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.blank-card { max-width: 520px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 36px; box-shadow: var(--shadow); }
.blank-card .code { font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; }

/* ---- Install wizard ----------------------------------------------------- */
.wizard { max-width: 760px; margin: 32px auto; padding: 0 16px; }
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.wizard-steps span { flex: 1; min-width: 110px; text-align: center; padding: 8px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: .82rem; font-weight: 600; color: var(--muted); }
.wizard-steps span.is-done { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }
.wizard-steps span.is-current { background: var(--brand); color: #fff; border-color: var(--brand); }
.req-list { list-style: none; padding: 0; margin: 0; }
.req-list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.req-list .ok { color: var(--green); } .req-list .bad { color: var(--red); }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar); z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; }
    .topbar-toggle { display: inline-flex; }
    .topbar-brand { display: inline-flex; flex: 1 1 auto; }
    .topbar { padding: 8px 14px; }
    .content { padding: 16px 14px 40px; }
    .grid-2, .grid-3, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
    .auth { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .user-menu-name { display: none; }
}
@media (max-width: 640px) {
    .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .page-head h1 { font-size: 1.25rem; }
    .kpi-value { font-size: 1.2rem; }
    .session-pill label { display: none; }
}

/* ==========================================================================
   Print — receipts, report cards, ID cards, certificates, payslips
   ========================================================================== */
.print-body { background: #e5e7eb; }
.print-toolbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 8px; justify-content: center; padding: 10px; background: #0b1324; }
.status-icon { font-size: 56px; line-height: 1; margin: 4px 0 6px; }
.status-icon .icon { vertical-align: top; }
.print-flash { width: 210mm; max-width: calc(100% - 20px); margin: 14px auto 0; }
.print-flash:empty { display: none; }
.print-flash .alert { margin: 0; }
.sheet { background: #fff; width: 210mm; min-height: 297mm; margin: 14px auto; padding: 12mm; box-shadow: var(--shadow-lg); position: relative; color: #111; font-size: 13px; }
.sheet.landscape { width: 297mm; min-height: 210mm; }
.sheet.half { min-height: 148mm; }
.sheet + .sheet { page-break-before: always; }
.letterhead { display: flex; align-items: center; gap: 14px; border-bottom: 3px double #111; padding-bottom: 10px; margin-bottom: 12px; }
.letterhead img { width: 70px; height: 70px; object-fit: contain; }
.letterhead .lh-text { flex: 1; text-align: center; }
.letterhead h1 { font-size: 22px; margin: 0; letter-spacing: .02em; color: #111; text-transform: uppercase; }
.letterhead p { margin: 2px 0 0; font-size: 12px; color: #333; }
.letterhead .lh-photo { width: 70px; }
.doc-title { text-align: center; font-size: 16px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin: 10px 0 12px; }
.doc-title span { border-bottom: 2px solid #111; padding: 0 8px 2px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ptable th, .ptable td { border: 1px solid #333; padding: 5px 7px; }
.ptable th { background: #f1f5f9; font-weight: 700; text-align: center; }
.ptable td.num, .ptable th.num { text-align: right; }
.ptable td.c, .ptable th.c { text-align: center; }
.pfacts { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 10px; }
.pfacts td { padding: 3px 6px; vertical-align: top; }
.pfacts td.k { color: #444; width: 130px; white-space: nowrap; }
.pfacts td.v { font-weight: 700; border-bottom: 1px dotted #888; }
.signs { display: flex; justify-content: space-between; margin-top: 46px; font-size: 12.5px; }
.signs div { text-align: center; min-width: 140px; }
.signs img { max-height: 40px; display: block; margin: 0 auto 2px; }
.signs span { display: block; border-top: 1px solid #111; padding-top: 4px; font-weight: 700; }
.watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.watermark img { width: 55%; opacity: .05; }
.cancelled-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 56px; font-weight: 900; color: rgba(185,28,28,.22); border: 6px solid rgba(185,28,28,.22); padding: 6px 22px; border-radius: 12px; letter-spacing: .1em; }
.receipt-copy { border: 1px dashed #777; padding: 8mm; margin-bottom: 8mm; position: relative; }
.receipt-copy .copy-label { position: absolute; top: 6px; right: 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #555; }

/* ID cards: 85.6 × 54 mm (CR80), 8 per A4 */
.id-sheet { display: grid; grid-template-columns: repeat(2, 85.6mm); gap: 6mm 8mm; justify-content: center; align-content: start; }
.id-card { width: 85.6mm; height: 54mm; border-radius: 3.5mm; overflow: hidden; border: 1px solid #cbd5e1; display: flex; flex-direction: column; background: #fff; page-break-inside: avoid; position: relative; }
.id-card.vertical { width: 54mm; height: 85.6mm; }
.id-top { background: var(--brand); color: #fff; padding: 2mm 3mm; display: flex; align-items: center; gap: 2mm; }
.id-top img { width: 9mm; height: 9mm; object-fit: contain; background: #fff; border-radius: 1.5mm; }
.id-top strong { font-size: 9.5px; line-height: 1.15; display: block; text-transform: uppercase; }
.id-top small { font-size: 7px; opacity: .9; display: block; }
.id-body { flex: 1; display: flex; gap: 3mm; padding: 2.5mm 3mm; }
.id-photo { width: 20mm; height: 25mm; border-radius: 1.5mm; object-fit: cover; border: 1px solid #ddd; background: #f1f5f9; display: grid; place-items: center; font-weight: 800; color: #64748b; }
.id-info { flex: 1; font-size: 8px; line-height: 1.45; min-width: 0; }
.id-info h4 { font-size: 10.5px; margin: 0 0 1mm; color: #111; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-info b { display: inline-block; min-width: 15mm; color: #555; font-weight: 600; }
.id-qr { width: 15mm; height: 15mm; align-self: flex-end; }
.id-foot { background: color-mix(in srgb, var(--brand) 12%, #fff); font-size: 7px; padding: 1mm 3mm; display: flex; justify-content: space-between; color: #333; }

/* Certificates */
.cert { border: 10px double var(--brand); padding: 14mm 16mm; min-height: 255mm; position: relative; }
.landscape .cert { min-height: 168mm; }
.cert-body { font-size: 15px; line-height: 2.1; text-align: justify; margin-top: 10mm; }
.cert-body b { border-bottom: 1px dotted #333; }
.cert-qr { width: 70px; text-align: center; }
.cert-qr svg { width: 70px; height: 70px; display: block; }
.cert-qr small { display: block; font-size: 8px; color: #555; white-space: nowrap; }
.cert-foot { margin: 6mm 0 0; font-size: 10px; color: #555; text-align: center; }

@page { size: A4; margin: 0; }
@media print {
    body, .print-body { background: #fff !important; }
    .print-toolbar, .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .sheet { box-shadow: none; margin: 0; width: auto; min-height: auto; }
    .app { display: block; }
    .content { padding: 0; }
    a { color: inherit; text-decoration: none; }
    .card { box-shadow: none; border-color: #999; break-inside: avoid; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==========================================================================
   Additions for the modules
   ========================================================================== */

/* Small forms that open in place (edit a section, a session …) */
.inline-details { display: inline-block; position: relative; }
.inline-details > summary { list-style: none; cursor: pointer; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] > summary { background: var(--brand-soft); }
.pop-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 14px; text-align: left; white-space: normal; }
.pop-form .field { margin-bottom: 10px; }
.btn-row .inline-details .pop-form { left: 0; right: auto; }

/* Fee totals: label | amount */
.totals > div { display: contents; }
.totals span { color: var(--muted); }
.totals strong { text-align: right; }

/* Portal attendance calendar */
.cal .cal-ev.present { background: var(--green-bg); color: var(--green); }

/* Login slips */
.slips { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
.slip { border: 1px dashed #777; padding: 5mm; font-size: 12px; page-break-inside: avoid; }
.slip .pfacts { margin: 6px 0 0; }

/* Public pages (online admission, verification, payment) */
.public-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.public-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 20px; }
.public-head .sidebar-brand { padding: 0; color: var(--ink); border: 0; }
.public-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px; }
.public-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; }

/* Tables inside cards keep their padding on phones */
@media (max-width: 720px) {
    .pop-form { position: fixed; left: 12px; right: 12px; top: 80px; width: auto; }
    .slips { grid-template-columns: 1fr; }
}
