/* SchoolGate School Management System
 * One stylesheet for every screen: phones, tablets and desktops, portrait or landscape.
 * --brand / --accent come from Settings → Branding (set inline in the page head).
 */
:root {
    --brand: #0b3d91;
    --accent: #f5b301;
    --brand-soft: color-mix(in srgb, var(--brand) 11%, #f4f6fa);
    --brand-ink: color-mix(in srgb, var(--brand) 80%, #000);
    --bg: color-mix(in srgb, var(--brand) 6%, #e3e7ee);
    --surface: #f9fafc;
    --surface-2: #eef1f6;
    --line: #d5dbe5;
    --line-2: #c2cbd8;
    --text: #0f172a;
    --text-2: #334155;
    --text-3: #64748b;
    --green: #15803d; --green-soft: #dcfce7;
    --amber: #b45309; --amber-soft: #fef3c7;
    --red: #b91c1c;   --red-soft: #fee2e2;
    --blue: #1d4ed8;  --blue-soft: #dbeafe;
    --gray: #475569;  --gray-soft: #e2e8f0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(15, 23, 42, .04);
    --shadow-lg: 0 18px 50px rgba(15, 23, 42, .18);
    --brand-text: var(--brand);   /* brand colour for text and icons (lighter in dark mode) */
    --brand-fill: var(--brand);   /* buttons, bars (brighter in dark mode) */
    --green-ink: #14532d; --red-ink: #7f1d1d; --blue-ink: #1e3a8a; --amber-ink: #78350f;
    --topbar-bg: color-mix(in srgb, var(--surface) 88%, transparent);
    --print-bg: #e5e7eb;
    color-scheme: light;
    --sidebar-w: 256px;
    --topbar-h: 60px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    font-size: 15px;
}

/* ---------- Dark mode ----------
 * <html data-theme="dark"> is set before the page draws (see includes/header.php) from the user's choice
 * (Light / Dark / Auto = follow the device). Printed documents stay black on white.
 */
:root[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-2: #172136;
    --line: #243049;
    --line-2: #34425f;
    --text: #e6ebf5;
    --text-2: #c3cde0;
    --text-3: #8d9bb6;
    --green: #22c55e; --green-soft: rgba(34, 197, 94, .15);  --green-ink: #86efac;
    --amber: #f59e0b; --amber-soft: rgba(245, 158, 11, .15); --amber-ink: #fcd34d;
    --red: #ef4444;   --red-soft: rgba(239, 68, 68, .15);    --red-ink: #fca5a5;
    --blue: #3b82f6;  --blue-soft: rgba(59, 130, 246, .17);  --blue-ink: #93c5fd;
    --gray: #a3b0c7;  --gray-soft: rgba(148, 163, 184, .15);
    --brand-soft: color-mix(in srgb, var(--brand) 32%, #121a2b);
    --brand-text: color-mix(in srgb, var(--brand) 35%, #ffffff);
    --brand-fill: color-mix(in srgb, var(--brand) 70%, #5b8cff);
    --brand-ink: color-mix(in srgb, var(--brand) 40%, #060b16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    --topbar-bg: rgba(18, 26, 43, .9);
    --print-bg: #0b1220;
    color-scheme: dark;
}
:root[data-theme="dark"] .badge-green { color: var(--green-ink); }
:root[data-theme="dark"] .badge-red { color: var(--red-ink); }
:root[data-theme="dark"] .badge-blue { color: var(--blue-ink); }
:root[data-theme="dark"] .badge-amber { color: var(--amber-ink); }
:root[data-theme="dark"] .btn-warning { color: #111; }
:root[data-theme="dark"] img { opacity: .96; }
/* Dark mode switch: sun on the left, moon on the right, the knob slides over */
.theme-switch { position: relative; flex: none; width: 56px; height: 30px; padding: 0; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; transition: background .25s, border-color .25s; }
.theme-switch .ts-icon { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; color: var(--text-3); }
.theme-switch .ts-icon .icon { width: 14px; height: 14px; }
.theme-switch .ts-sun { left: 7px; color: #f59e0b; }
.theme-switch .ts-moon { right: 7px; }
.theme-switch .ts-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); }
:root[data-theme="dark"] .theme-switch { background: color-mix(in srgb, var(--brand-fill) 55%, var(--surface-2)); border-color: transparent; }
:root[data-theme="dark"] .theme-switch .ts-knob { transform: translateX(26px); background: #e6ebf5; }
:root[data-theme="dark"] .theme-switch .ts-moon { color: #fff; }
.theme-switch:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px; }
.ts-label { display: inline-flex; align-items: center; gap: 8px; }
.ts-state { color: var(--text-3); font-weight: 700; cursor: pointer; }
.ts-auto { font-size: .78rem; font-weight: 700; }
/* ---------- Loading / welcome screen: ring with the percentage inside, what is loading underneath ---------- */
.loader { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(6px); animation: ld-in .2s ease; }
/* Safety net: the welcome screen never stays up if scripts fail to load */
.loader.is-welcome { animation: ld-in .2s ease, ld-gone .4s ease 12s forwards; }
@keyframes ld-gone { to { opacity: 0; visibility: hidden; } }
.loader.is-welcome:not(.x) { background: radial-gradient(900px 500px at 20% 0%, color-mix(in srgb, var(--brand) 25%, transparent), transparent), var(--bg); }
.loader.fade { opacity: 0; transition: opacity .35s ease; }
@keyframes ld-in { from { opacity: 0; } to { opacity: 1; } }
.loader-box { width: min(380px, 100%); text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow-lg); }
.ring { position: relative; width: 132px; height: 132px; margin: 0 auto 14px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--gray-soft); }
.ring-fg { stroke: var(--brand-fill); stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset .25s ease; }
.ring::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--accent); animation: ld-spin 1.1s linear infinite; }
@keyframes ld-spin { to { transform: rotate(360deg); } }
.ring-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.loader-title { font-weight: 800; font-size: 1.1rem; }
.loader-detail { color: var(--text-3); font-size: .88rem; min-height: 1.4em; margin-top: 4px; }
.loader.done .ring::after { display: none; }
.welcome img { width: 76px; height: 76px; object-fit: contain; border-radius: 16px; margin-bottom: 8px; }
.welcome h2 { margin: 0 0 4px; font-size: 1.5rem; }
.welcome p { margin: 0 0 4px; color: var(--text-2); font-weight: 600; }
.welcome small { display: block; color: var(--text-3); margin-bottom: 16px; }
.welcome .btn { width: 100%; }
.loader.show-welcome .ring, .loader.show-welcome .loader-title, .loader.show-welcome .loader-detail { display: none; }
.loader.show-welcome .welcome { animation: ld-pop .35s cubic-bezier(.2, 1.3, .4, 1); }
/* Birthday welcome: confetti canvas above everything (clicks pass through), colourful greeting */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 400; pointer-events: none; }
.loader.is-birthday .welcome h2 { font-size: 1.7rem; }
.loader.is-birthday .welcome h2 .bd-text { background: linear-gradient(90deg, #e5484d, #eda100, #12a150, #2a78d6, #8e4ec6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.loader.is-birthday .welcome img { animation: bd-bounce 1s ease-in-out 3; }
@keyframes bd-bounce { 50% { transform: translateY(-8px) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .loader.is-birthday .welcome img { animation: none; } }
@keyframes ld-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
/* ---------- Student arrivals chart (dashboard) ----------
 * On time / Late / Not arrived stacked per school day. Colours validated for colour-blind separation in both modes
 * (dataviz validator: CVD ΔE 31 light / 27 dark); values are also in the legend, tooltip and table. */
.arr-legend, .arr-chart { --c-on: #2a78d6; --c-late: #eda100; --c-none: #d3d9e3; }
:root[data-theme="dark"] .arr-legend, :root[data-theme="dark"] .arr-chart { --c-on: #3987e5; --c-late: #c98500; --c-none: #2b3549; }
.arr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 12px; padding: 0; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.arr-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw.on { background: var(--c-on); } .sw.late { background: var(--c-late); } .sw.none { background: var(--c-none); }
.arr-chart { position: relative; display: flex; align-items: flex-end; gap: 10px; height: 210px; padding: 22px 0 26px 30px; }
.arr-grid { position: absolute; left: 30px; right: 0; top: 22px; bottom: 26px; pointer-events: none; }
.arr-grid span { position: absolute; left: -30px; right: 0; transform: translateY(50%); border-bottom: 1px dashed var(--line); font-size: .66rem; color: var(--text-3); line-height: 1; padding-bottom: 0; }
.arr-grid span[style*="bottom:0"] { border-bottom-style: solid; border-color: var(--line-2); }
.arr-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; outline: none; z-index: 1; }
.arr-stack { width: 100%; max-width: 44px; display: flex; flex-direction: column; gap: 2px; border-radius: 4px 4px 0 0; overflow: hidden; transition: filter .15s, transform .15s; }
.arr-stack .seg { display: block; min-height: 3px; flex-basis: 0; }
.seg.on { background: var(--c-on); } .seg.late { background: var(--c-late); } .seg.none { background: var(--c-none); }
.arr-total { position: absolute; top: -18px; font-size: .74rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.arr-day { position: absolute; bottom: -22px; font-size: .7rem; color: var(--text-3); white-space: nowrap; }
.arr-col.today .arr-day { color: var(--brand-text); font-weight: 800; }
.arr-col.today .arr-stack { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--c-on) 45%, transparent); }
.arr-col:hover .arr-stack, .arr-col:focus-visible .arr-stack { filter: brightness(1.08) saturate(1.1); transform: translateY(-2px); }
.arr-tip { display: none; position: absolute; bottom: calc(100% - 10px); left: 50%; transform: translateX(-50%); z-index: 5; min-width: 168px; padding: 10px 12px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); font-size: .78rem; color: var(--text-2); }
.arr-tip strong { display: block; color: var(--text); margin-bottom: 4px; }
.arr-tip span { display: flex; align-items: center; gap: 6px; } .arr-tip span b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.arr-tip em { display: block; margin-top: 4px; font-style: normal; font-weight: 700; color: var(--text); }
.arr-col:hover .arr-tip, .arr-col:focus-visible .arr-tip { display: block; }
.arr-col:first-of-type .arr-tip { left: 0; transform: none; }
.arr-col:last-child .arr-tip { left: auto; right: 0; transform: none; }
/* Period switch, summary chips, average line, % per day, best / lowest markers, grow-in animation */
.arr-period { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.arr-period a { padding: 4px 12px; border-radius: 999px; font-size: .76rem; font-weight: 700; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.arr-period a:hover { color: var(--text); }
.arr-period a.active { background: var(--surface); color: var(--brand-text); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.arr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0 0 14px; }
.arr-summary > div { position: relative; padding: 10px 12px 10px 15px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.arr-summary > div::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c-on, #2a78d6); }
.arr-summary > div.now::before { background: linear-gradient(var(--brand), color-mix(in srgb, var(--brand) 50%, #fff)); }
.arr-summary small { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.arr-summary b { display: block; font-size: 1.35rem; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }
.arr-summary span { font-size: .74rem; color: var(--text-2); }
.arr-summary { --c-on: #2a78d6; } :root[data-theme="dark"] .arr-summary { --c-on: #3987e5; }
.sw-empty { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px dashed var(--text-3); }
.sw-line { display: inline-block; width: 16px; border-top: 2px dashed var(--text-2); }
.arr-chart { --pb: 40px; height: 240px; padding-bottom: var(--pb); }
.arr-chart.many { --pb: 26px; gap: 3px; }
.arr-grid { bottom: var(--pb); }
.arr-chart { padding-right: 50px; } .arr-grid { right: 50px; }
.arr-avg { position: absolute; left: 0; right: -50px; height: 0; border-top: 2px dashed color-mix(in srgb, var(--text) 55%, transparent); z-index: 2; }
.arr-avg em { position: absolute; right: 0; top: 0; transform: translateY(-50%); padding: 1px 6px; border-radius: 6px; background: var(--surface); font-style: normal; font-size: .66rem; font-weight: 800; color: var(--text-2); }
.seg.on { background: linear-gradient(to top, var(--c-on), color-mix(in srgb, var(--c-on) 72%, #fff)); }
.seg.late { background: linear-gradient(to top, var(--c-late), color-mix(in srgb, var(--c-late) 75%, #fff)); }
.arr-stack { transform-origin: bottom; animation: arr-grow .7s cubic-bezier(.2, .9, .3, 1) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.arr-chart.many .arr-stack { animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes arr-grow { from { transform: scaleY(0); opacity: .3; } }
.arr-col.today .arr-stack { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--c-on) 55%, transparent), 0 0 22px 2px color-mix(in srgb, var(--c-on) 45%, transparent); }
.arr-col.today::before { content: ""; position: absolute; inset: 0 -3px calc(-1 * var(--pb) + 2px); border-radius: 10px; background: color-mix(in srgb, var(--c-on) 8%, transparent); z-index: -1; }
.arr-rate { font-size: .66rem; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.arr-day { text-align: center; line-height: 1.25; bottom: calc(-1 * var(--pb) + 4px); }
.arr-col.best .arr-total, .arr-col.low .arr-total { padding: 1px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); top: -22px; }
.arr-col.low .arr-total::before { content: "▼ "; font-size: .6rem; color: var(--text-3); }
.arr-chart.many .arr-col.best .arr-total, .arr-chart.many .arr-col.low .arr-total { font-size: .66rem; padding: 0 4px; }
.arr-col.no-taps .arr-stack { height: 100%; border: 1.5px dashed var(--line-2); border-bottom: 0; background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--line) 60%, transparent) 5px 6px); opacity: .7; }
.arr-chart.many .arr-col.no-taps .arr-stack { border-width: 1px; }
.arr-col.best .arr-total, .arr-col.low .arr-total { white-space: nowrap; }
@media (max-width: 640px) {
    .arr-summary { grid-template-columns: 1fr 1fr; gap: 8px; } .arr-summary b { font-size: 1.15rem; }
    .arr-chart.mid { gap: 4px; --pb: 30px; } .arr-chart.mid .arr-rate, .arr-chart.mid .dn { display: none; }
    .arr-chart.mid .arr-total { font-size: .62rem; } .arr-chart.mid .arr-col.best .arr-total, .arr-chart.mid .arr-col.low .arr-total { padding: 0 3px; }
    .arr-chart { padding-right: 42px; } .arr-grid { right: 42px; } .arr-avg { right: -42px; }
}
@media (prefers-reduced-motion: reduce) { .arr-stack { animation: none; } }
.arr-table { margin-top: 8px; font-size: .82rem; }
.arr-table summary { cursor: pointer; color: var(--brand-text); font-weight: 700; }
@media (max-width: 560px) { .arr-chart { gap: 6px; padding-left: 24px; } .arr-grid { left: 24px; } .arr-grid span { left: -24px; } .arr-day { font-size: .62rem; } }

/* ---------- Report charts (includes/charts.php) ----------
 * Validated palette (dataviz validator): categorical s1–s8 adjacent CVD ΔE ≥ 9.1 light / 8.4 dark;
 * ordinal o1–o5 one-hue blue ramp, monotone. Light-mode slots below 3:1 are relieved by printed values + tables. */
.fc { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
      --o1: #86b6ef; --o2: #5598e7; --o3: #2a78d6; --o4: #1c5cab; --o5: #104281; position: relative; font-size: .8rem; }
:root[data-theme="dark"] .fc { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
      --o1: #184f95; --o2: #256abf; --o3: #3987e5; --o4: #6da7ec; --o5: #9ec5f4; }
.fc .s1 { background: var(--s1); } .fc .s2 { background: var(--s2); } .fc .s3 { background: var(--s3); } .fc .s4 { background: var(--s4); }
.fc .s5 { background: var(--s5); } .fc .s6 { background: var(--s6); } .fc .s7 { background: var(--s7); } .fc .s8 { background: var(--s8); }
.fc .o1 { background: var(--o1); } .fc .o2 { background: var(--o2); } .fc .o3 { background: var(--o3); } .fc .o4 { background: var(--o4); } .fc .o5 { background: var(--o5); }
.fc .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.fc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 10px; padding: 0; font-weight: 600; color: var(--text-2); }
.fc-legend li { display: inline-flex; align-items: center; gap: 6px; }
/* Columns */
.fc-cols { height: 240px; padding: 14px 0 26px 44px; }
.fc-grouped { height: 270px; }
.fc-grid { position: absolute; left: 44px; right: 0; top: 14px; bottom: 26px; pointer-events: none; }
.fc-grouped .fc-grid, .fc-grouped .fc-plot { top: 44px; }
.fc-grid span { position: absolute; left: 0; right: 0; border-bottom: 1px dashed var(--line); }
.fc-grid span:first-child { border-bottom: 1px solid var(--line-2); }
.fc-grid i { position: absolute; right: calc(100% + 6px); bottom: -7px; font-style: normal; font-size: .68rem; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-plot { position: absolute; left: 44px; right: 0; top: 14px; bottom: 26px; display: flex; align-items: stretch; gap: 2px; }
.fc-col { position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.fc-col:hover, .fc-col:focus-visible { background: color-mix(in srgb, var(--brand) 6%, transparent); border-radius: 6px; }
.fc-bar { display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; transition: filter .15s; }
.fc-col:hover .fc-bar, .fc-col:focus-visible .fc-bar { filter: brightness(1.12) saturate(1.1); }
.fc-col.peak .fc-bar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--s1) 50%, transparent); }
.fc-pair { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 100%; }
.fc-pair .fc-bar { max-width: 18px; }
.fc-cap { position: absolute; left: 50%; transform: translate(-50%, -4px); margin-bottom: 2px; font-size: .72rem; font-weight: 800; color: var(--text); white-space: nowrap; pointer-events: none; }
.fc-x { position: absolute; top: 100%; margin-top: 6px; font-size: .68rem; color: var(--text-3); white-space: nowrap; }
.fc-col:first-child .fc-x { left: 0; } .fc-col:last-child .fc-x { right: 0; }   /* edge labels stay inside the card */
.fc-col:last-child .fc-cap { left: auto; right: 0; transform: translateY(-4px); }
.fc-avg { position: absolute; left: 0; right: 0; border-top: 2px dashed color-mix(in srgb, var(--text-3) 70%, transparent); pointer-events: none; z-index: 2; }
.fc-avg em { position: absolute; right: 0; bottom: 2px; font-style: normal; font-size: .68rem; font-weight: 700; color: var(--text-2); background: var(--surface); padding: 0 4px; border-radius: 4px; }
.fc-tip { display: none; position: absolute; bottom: calc(100% - 8px); left: 50%; transform: translateX(-50%); z-index: 6; min-width: 150px; padding: 9px 11px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); color: var(--text-2); font-size: .76rem; line-height: 1.5; text-align: left; }
.fc-tip strong { display: block; color: var(--text); }
.fc-tip b { color: var(--text); font-variant-numeric: tabular-nums; }
.fc-tip small { display: block; color: var(--text-3); }
.fc-tip .fc-row { display: flex; align-items: center; gap: 6px; } .fc-tip .fc-row b { margin-left: auto; padding-left: 10px; }
.fc-col:hover .fc-tip, .fc-col:focus-visible .fc-tip { display: block; }
.fc-col:first-child .fc-tip { left: 0; transform: none; } .fc-col:last-child .fc-tip { left: auto; right: 0; transform: none; }
/* Horizontal bars */
.fc-hbars { display: grid; gap: 8px; }
.fc-hrow { display: grid; grid-template-columns: minmax(90px, 28%) 1fr var(--vw, 11.5em); align-items: center; gap: 10px; padding: 3px 4px; border-radius: 8px; outline: none; }
.fc-hrow:hover, .fc-hrow:focus-visible { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.fc-hl { color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-track { position: relative; height: 18px; display: flex; align-items: center; }
.fc-percent { --vw: 4.5em; }
.fc-percent .fc-track { background: var(--gray-soft); border-radius: 0 4px 4px 0; }
.fc-hbar { display: block; height: 18px; border-radius: 0 4px 4px 0; min-width: 3px; }
.fc-hv { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fc-hv b { color: var(--text); } .fc-hv small { margin-left: 6px; color: var(--text-3); font-weight: 700; }
@media (max-width: 560px) { .fc-hrow { grid-template-columns: 1fr var(--vw, 11.5em); } .fc-track { grid-column: 1 / -1; grid-row: 2; } .fc-cols { padding-left: 38px; } .fc-grid, .fc-plot { left: 38px; } }

/* ---------- Dashboard ---------- */
.dash-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    padding: 22px 24px; margin-bottom: 18px; border-radius: 20px; color: #fff;
    background: radial-gradient(600px 260px at 100% 0%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%),
                linear-gradient(120deg, var(--brand-ink), color-mix(in srgb, var(--brand) 85%, #2a78d6)); box-shadow: var(--shadow-lg); }
.dash-hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; border: 36px solid rgba(255, 255, 255, .05); pointer-events: none; }
.dh-kicker { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .03em; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); }
.dash-hero h2 { margin: 10px 0 4px; font-size: clamp(1.35rem, 3vw, 1.9rem); color: #fff; }
.dash-hero p { margin: 0; color: rgba(255, 255, 255, .82); }
.dash-hero .dh-btn { background: #fff; color: var(--brand-ink); }
.dash-hero .dh-btn.ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); }
.dh-side { position: relative; z-index: 1; display: flex; align-items: center; gap: 18px; }
.dh-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dh-mini li { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 12px; background: rgba(255, 255, 255, .12); }
.dh-mini b { font-size: 1.15rem; min-width: 34px; } .dh-mini span { font-size: .78rem; color: rgba(255, 255, 255, .85); }
.ring-gauge { position: relative; width: 132px; height: 132px; flex: none; }
.ring-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-gauge circle { fill: none; stroke-width: 10; }
.ring-gauge .rg-track { stroke: rgba(255, 255, 255, .18); }
.ring-gauge .rg-fill { stroke: var(--tone); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-gauge .rg-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.1; padding: 18px; }
.ring-gauge .rg-text b { font-size: 1.7rem; } .ring-gauge .rg-text small { font-size: .66rem; opacity: .85; margin-top: 2px; }
/* Tiles */
.dk-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); margin-bottom: 18px; }
.dk { --tone-c: var(--brand-text); --tone-bg: var(--brand-soft); position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon label" "value value" "foot foot" "spark spark";
      gap: 2px 10px; align-items: center; padding: 14px 16px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
      color: inherit; text-decoration: none !important; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.dk::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone-c); opacity: .8; }
a.dk:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dk-icon { grid-area: icon; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-bg); color: var(--tone-c); }
.dk-icon .icon { width: 18px; height: 18px; }
.dk-label { grid-area: label; font-size: .8rem; font-weight: 700; color: var(--text-3); }
.dk-value { grid-area: value; font-size: 1.7rem; font-weight: 800; line-height: 1.15; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-value small { font-size: .95rem; color: var(--text-3); font-weight: 700; }
.dk-foot, .dk-delta { grid-area: foot; font-size: .76rem; color: var(--text-3); font-weight: 600; }
.dk-delta.up { color: var(--green-ink); } .dk-delta.down { color: var(--red-ink); }
.dk .spark { grid-area: spark; width: 100%; height: 34px; margin-top: 4px; }
.tone-green { --tone-c: var(--green-ink); --tone-bg: var(--green-soft); } .tone-blue { --tone-c: var(--blue-ink); --tone-bg: var(--blue-soft); }
.tone-amber { --tone-c: var(--amber-ink); --tone-bg: var(--amber-soft); } .tone-red { --tone-c: var(--red-ink); --tone-bg: var(--red-soft); }
.tone-violet { --tone-c: #6250d6; --tone-bg: color-mix(in srgb, #6250d6 14%, transparent); } .tone-pink { --tone-c: #c2417a; --tone-bg: color-mix(in srgb, #e87ba4 18%, transparent); }
.tone-cyan { --tone-c: #0e7490; --tone-bg: color-mix(in srgb, #0891b2 15%, transparent); }
:root[data-theme="dark"] .tone-violet { --tone-c: #a99ff0; } :root[data-theme="dark"] .tone-pink { --tone-c: #f0a3c1; } :root[data-theme="dark"] .tone-cyan { --tone-c: #67d4ea; }
/* Feed + quick links */
.dash-feed .avatar { width: 40px; height: 40px; border-radius: 12px; }
.dash-links { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.dash-links a { gap: 8px; padding: 14px 8px; }
.dash-links .ql-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--sec) 14%, transparent); color: var(--sec); }
.dash-links .ql-ic .icon { width: 20px; height: 20px; color: var(--sec); }
.dash-links a:hover { border-color: var(--sec); color: var(--text); }
@media (max-width: 720px) { .dash-hero { padding: 18px; } .dh-side { width: 100%; justify-content: space-between; } .ring-gauge { width: 112px; height: 112px; } .dk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .dk-value { font-size: 1.3rem; } }

/* Live updates (SMS Center) */
.live-pill { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 2px 9px; border-radius: 99px; font-size: .7rem; font-weight: 800; background: var(--green-soft); color: var(--green-ink); }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: live-blink 1.6s ease-in-out infinite; }
.live-pill.off { background: var(--gray-soft); color: var(--text-3); }
.live-pill.off i { background: var(--text-3); animation: none; }
@keyframes live-blink { 50% { opacity: .25; } }
.live-changed { animation: live-flash 1.6s ease; }
@keyframes live-flash { 0% { background: color-mix(in srgb, var(--green) 28%, transparent); } 100% { background: transparent; } }
.time12 { display: block; margin-top: 3px; color: var(--text-3); font-size: .78rem; font-weight: 700; }
.time12:empty { display: none; }
.sms-err { display: block; }
.sms-err:empty { display: none; }
/* Small book cover next to a title (library lists, portal, profile) */
.book-thumb { width: 36px; height: 52px; flex: none; display: inline-grid; place-items: center; border-radius: 3px 6px 6px 3px; overflow: hidden; background: var(--brand-soft); color: var(--brand-text); box-shadow: 0 2px 6px rgba(15, 23, 42, .18); }
.book-thumb img { width: 100%; height: 100%; object-fit: cover; }
.book-thumb .icon { width: 18px; height: 18px; }
.dev-mark { display: block; width: 150px; margin: 6px auto 8px; padding: 6px 10px; background: #fff; border-radius: 10px; }
.dev-mark img { display: block; width: 100%; height: auto; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-text); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link-btn .icon { width: 15px; height: 15px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .8rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .85em; word-break: break-all; }
small { font-size: .82rem; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.text-right { text-align: right; } .text-center { text-align: center; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.green { color: var(--green); } .red { color: var(--red); } .amber { color: var(--amber); }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: var(--brand-ink); color: #dbe4f5; display: flex; flex-direction: column;
    transition: transform .25s ease, width .2s ease;
}
.side-head { display: flex; align-items: center; gap: 4px; padding-right: 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; padding: 10px 6px 10px 16px; color: #fff; text-decoration: none !important; min-height: var(--topbar-h); }
.brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: #fff; padding: 3px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: #9fb2d6; font-size: .72rem; }
.collapse-btn { flex: none; width: 34px !important; height: 34px !important; border-radius: 9px !important; color: #a9badb !important; }
.collapse-btn:hover { background: rgba(255, 255, 255, .1) !important; color: #fff !important; }
.collapse-btn .icon { width: 18px; height: 18px; transition: transform .2s; }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px 14px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.nav-section { margin: 14px 8px 4px; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8ea3c9; display: flex; align-items: center; gap: 6px; }
.nav-section::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sec, #8ea3c9); }
.side-nav a {
    display: flex; align-items: center; gap: .7rem; padding: 9px 10px; border-radius: 10px;
    color: #d5def0; font-weight: 600; font-size: .9rem; text-decoration: none !important; position: relative;
}
.side-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-nav a.active { background: rgba(255, 255, 255, .13); color: #fff; }
.side-nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--sec, var(--accent)); }
.side-nav a .icon { color: var(--sec, #a9badb); }
.side-nav a span:not(.pill) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { background: var(--accent); color: #111; font-size: .7rem; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: 12px 14px calc(12px + var(--safe-b)); border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user-info { flex: 1; min-width: 0; line-height: 1.2; }
.side-user-info strong { display: block; color: #fff; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info small { color: #9fb2d6; font-size: .74rem; }
.side-user .icon-btn { color: #c9d5ec; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin .2s ease; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: .7rem;
    padding: 0 20px; background: var(--topbar-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.1rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.menu-btn { display: none !important; }
.content { flex: 1; padding: 22px; width: 100%; max-width: 1500px; margin: 0 auto; }
.site-footer { text-align: center; padding: 16px; color: var(--text-3); font-size: .8rem; }
.backdrop { display: none; }
.bottom-nav { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-text); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: var(--red); color: #fff; text-align: center; padding: 6px; font-size: .85rem; font-weight: 600; }

/* Collapsed (desktop) */
.nav-mini .sidebar { width: 72px; }
.nav-mini .main { margin-left: 72px; }
.nav-mini .brand span, .nav-mini .side-nav a span, .nav-mini .nav-section span, .nav-mini .side-user-info, .nav-mini .side-user .icon-btn { display: none; }
.nav-mini .side-nav a { justify-content: center; }
.nav-mini .nav-section { justify-content: center; margin: 10px 0 2px; }
.nav-mini .side-head { flex-direction: column; padding: 10px 0 8px; gap: 6px; }
.nav-mini .brand { justify-content: center; padding: 0; min-height: 0; flex: none; }
.nav-mini .side-user { justify-content: center; }
.nav-mini .collapse-btn .icon { transform: rotate(180deg); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    background: var(--brand-fill); color: #fff; font: inherit; font-weight: 700; font-size: .9rem; line-height: 1.2;
    cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: filter .15s, background .15s;
    min-height: 40px;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-light { background: var(--brand-soft); color: var(--brand-text); border-color: color-mix(in srgb, var(--brand) 16%, transparent); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--line-2); }
.btn-outline { background: var(--surface); color: var(--text-2); border-color: var(--line-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-warning { background: var(--accent); color: #111; }
.btn-sm { padding: 6px 11px; font-size: .82rem; min-height: 32px; }
.btn-lg { padding: 13px 22px; font-size: 1rem; min-height: 48px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; }
.btn-group { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0;
    background: transparent; color: var(--text-2); cursor: pointer; position: relative; text-decoration: none !important;
}
.icon-btn:hover { background: var(--surface-2); }
.bell .dot { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--red); color: #fff; font-size: .65rem; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: .6rem; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { margin: 0; flex: 1; display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.card-head h3 .icon { color: var(--brand-text); }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-body > :last-child { margin-bottom: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 2px; }
.page-head p { margin: 0; color: var(--text-3); }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.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: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side { grid-template-columns: minmax(260px, 1fr) minmax(0, 2.4fr); }

/* ---------- Stats ---------- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; gap: .9rem; align-items: center; box-shadow: var(--shadow); text-decoration: none !important; color: inherit; min-width: 0; }
a.stat:hover { border-color: var(--brand); }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); flex: none; }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { color: var(--text-3); font-size: .82rem; font-weight: 600; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--gray-soft); color: var(--gray); }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 600; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: var(--green-ink); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.alert-error { background: var(--red-soft); color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.alert-info { background: var(--blue-soft); color: var(--blue-ink); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.alert-warning { background: var(--amber-soft); color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
/* "SMS sent" notices (includes/sms.php sms_watch_*) – update live until the text leaves */
.sms-watch { display: flex; align-items: flex-start; gap: 10px; }
.sms-watch > .icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.sms-watch [data-sms-hint] { display: block; font-weight: 500; opacity: .85; }
.sms-watch:not([data-state]) > .icon, .sms-watch[data-state="waiting"] > .icon { animation: sms-fly 1.4s ease-in-out infinite; }
@keyframes sms-fly { 50% { transform: translate(2px, -2px); opacity: .6; } }
.sms-watch-print { max-width: 210mm; margin: 12px auto 0; }
@media (prefers-reduced-motion: reduce) { .sms-watch > .icon { animation: none !important; } }

/* ---------- Avatars ---------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-weight: 800; font-size: .85rem; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }
.avatar-xl { width: 120px; height: 120px; font-size: 2.2rem; border-radius: 18px; }
.side-user .avatar { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label, .label { display: block; font-weight: 700; font-size: .82rem; color: var(--text-2); margin-bottom: 5px; }
label.req::after { content: " *"; color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
input[type=search], input[type=tel], input[type=url], input[type=month], input[type=color], select, textarea {
    width: 100%; padding: 9px 12px; font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
    border: 1px solid var(--line-2); border-radius: var(--radius-sm); min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
input[type=color] { padding: 3px; width: 64px; }
textarea { min-height: 96px; resize: vertical; }
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[type=file] { font: inherit; font-size: .88rem; max-width: 100%; }
.hint { display: block; color: var(--text-3); font-size: .78rem; margin-top: 4px; font-weight: 500; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { display: grid; gap: 0 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2, .form-grid-3 .span-2 { grid-column: span 2; }
.form-grid .span-all, .form-grid-3 .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 6px; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-section { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 10px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; flex: 1 1 160px; }
.filters .btn { flex: none; }
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box .icon { position: absolute; left: 11px; top: 11px; color: var(--text-3); }
.photo-picker { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* ---------- 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 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); font-weight: 800; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 800; background: var(--surface-2); }
.table .person { display: flex; align-items: center; gap: .6rem; min-width: 180px; }
.table .person strong { display: block; line-height: 1.2; }
.table .person small { color: var(--text-3); }
.table input[type=number], .table input[type=text], .table select { min-height: 34px; padding: 5px 8px; }
.table-compact th, .table-compact td { padding: 6px 10px; }
.actions-cell { white-space: nowrap; text-align: right; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .8rem; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 700; line-height: 1.3; }
.list-item .sub { color: var(--text-3); font-size: .84rem; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--text-3); font-size: .84rem; font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 36px 18px; color: var(--text-3); }
.empty .icon { width: 42px; height: 42px; color: var(--line-2); margin-bottom: 8px; }
.empty h3 { color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { padding: 10px 14px; font-weight: 700; color: var(--text-3); border: 0; background: none; border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none !important; cursor: pointer; font: inherit; font-size: .9rem; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.active, .tabs button.active { color: var(--brand-text); border-bottom-color: var(--brand); }
.card > .tabs { padding: 0 12px; margin-bottom: 0; }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; flex-wrap: wrap; }
.pager a, .pager span.disabled { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; font-size: .85rem; }
.pager span.disabled { color: var(--line-2); }
.pager-info { color: var(--text-3); font-size: .85rem; }

/* ---------- Dialog ---------- */
.dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); color: var(--text); }
.dialog.wide { width: min(820px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
.dialog h3 { display: flex; gap: .5rem; align-items: center; }

/* ---------- Profile header ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head .info { flex: 1; min-width: 200px; }
.profile-head h2 { margin: 0; }
.profile-head .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-3); font-size: .88rem; margin-top: 4px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.timeline li.in::before { border-color: var(--green); }
.timeline li.out::before { border-color: var(--blue); }
.timeline li.late::before { border-color: var(--amber); }

/* ---------- Misc ---------- */
.progress { height: 8px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-fill); border-radius: 99px; }
.log-box { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; font: .8rem/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; max-height: 300px; overflow: auto; }
.diff-list { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; font: .8rem/1.7 ui-monospace, Consolas, monospace; }
.tag { display: inline-block; min-width: 64px; font-size: .68rem; font-weight: 800; margin-right: 8px; }
.tag-new { color: var(--green); } .tag-changed { color: var(--amber); } .tag-deleted { color: var(--red); }
.doc ol, .doc ul { padding-left: 1.2rem; margin: 0 0 .8rem; } .doc li { margin-bottom: .35rem; }
.secret { letter-spacing: .1em; font-weight: 800; }
.track-link { display: flex; gap: .4rem; } .track-link input { flex: 1; }
.row-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.mini-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.mini-bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.mini-bars .bar span { display: block; width: 100%; max-width: 38px; background: var(--brand-fill); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.mini-bars .bar small { font-size: .68rem; color: var(--text-3); white-space: nowrap; }
.mini-bars .bar b { font-size: .7rem; }
.quick-links { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.quick-links a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-weight: 700; font-size: .85rem; color: var(--text-2); text-align: center; text-decoration: none !important; }
.quick-links a:hover { border-color: var(--brand); color: var(--brand-text); }
.quick-links a .icon { width: 26px; height: 26px; color: var(--brand-text); }

/* ---------- Auth ---------- */
.layout-auth { background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 20%, transparent), transparent), var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 28px 26px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.auth-card.wide { max-width: 640px; }
.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.auth-logo img { width: 72px; height: 72px; border-radius: 16px; object-fit: contain; }
.auth-logo-text strong { display: block; font-size: 1.15rem; line-height: 1.2; }
.auth-logo-text span { color: var(--text-3); font-size: .82rem; }
.footer-links { display: flex; gap: 14px; justify-content: center; margin-bottom: 6px; flex-wrap: wrap; }

/* ---------- Password toggle ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px !important; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--brand-text); background: var(--brand-soft); }

/* ---------- Print pages (reports, SOA, receipts, report cards, IDs) ---------- */
.layout-print { background: var(--print-bg); }
.print-toolbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.print-page { background: #fff; width: 210mm; max-width: calc(100% - 24px); min-height: 280mm; margin: 18px auto; padding: 14mm; box-shadow: var(--shadow-lg); color: #000; font-size: 12.5px; }
.print-page.landscape { width: 297mm; min-height: 200mm; }
.doc-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
.doc-head img { width: 64px; height: 64px; object-fit: contain; }
.doc-head .school { flex: 1; text-align: center; }
.doc-head .school strong { display: block; font-size: 17px; text-transform: uppercase; letter-spacing: .02em; }
.doc-head .school span { display: block; font-size: 11.5px; }
.doc-title { text-align: center; font-size: 15px; font-weight: 800; text-transform: uppercase; margin: 6px 0 12px; letter-spacing: .05em; }
.print-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.print-table th, .print-table td { border: 1px solid #555; padding: 4px 6px; text-align: left; }
.print-table th { background: #eef0f4; font-weight: 800; }
.print-table .num { text-align: right; }
.sign-row { display: flex; justify-content: space-around; gap: 30px; margin-top: 40px; text-align: center; flex-wrap: wrap; }
.sign-row div { min-width: 180px; border-top: 1px solid #000; padding-top: 4px; font-size: 11.5px; }

@media print {
    @page { size: A4; margin: 10mm; }
    body, .layout-print { background: #fff !important; }
    .no-print, .print-toolbar, .sidebar, .topbar, .bottom-nav, .site-footer, .offline-bar { display: none !important; }
    .print-page { box-shadow: none; margin: 0; padding: 0; width: auto; max-width: none; min-height: 0; }
    .main { margin: 0 !important; }
    .content { padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
    .page-break { break-after: page; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .grid-main, .grid-side, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); width: min(290px, 86vw) !important; }
    .nav-open .sidebar { transform: none; }
    .nav-mini .brand span, .nav-mini .side-nav a span, .nav-mini .nav-section span, .nav-mini .side-user-info, .nav-mini .side-user .icon-btn { display: revert; }
    .nav-mini .side-nav a { justify-content: flex-start; }
    .nav-mini .side-head { flex-direction: row; padding: 0 10px 0 0; }
    .nav-mini .brand { flex: 1; justify-content: flex-start; padding: 10px 6px 10px 16px; min-height: var(--topbar-h); }
    .main, .nav-mini .main { margin-left: 0; }
    .collapse-btn { display: none !important; }
    .menu-btn { display: inline-grid !important; }
    .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }
    .content { padding: 18px; }
}
@media (max-width: 720px) {
    :root { font-size: 14.5px; --topbar-h: 56px; }
    .grid-2, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid-3 .span-2 { grid-column: auto; }
    .content { padding: 14px 12px calc(84px + var(--safe-b)); }
    .topbar { padding: 0 10px; }
    .sy-chip, .install-btn span { display: none; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 12px; gap: .6rem; }
    .stat-icon { width: 38px; height: 38px; }
    .stat-value { font-size: 1.15rem; }
    .card-body { padding: 14px; }
    .card-head { padding: 12px 14px; }
    .list-item { padding: 12px 14px; }
    .page-head { align-items: flex-start; }
    .page-head .actions { width: 100%; }
    .hide-sm { display: none !important; }
    .table th, .table td { padding: 8px 10px; }
    .layout-app .site-footer { display: none; }
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
        border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); box-shadow: 0 -4px 18px rgba(15, 23, 42, .06);
    }
    .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; font-size: .68rem; font-weight: 700; color: var(--text-3); background: none; border: 0; font-family: inherit; text-decoration: none !important; cursor: pointer; min-width: 0; }
    .bottom-nav span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .bottom-nav .icon { width: 22px; height: 22px; }
    .bottom-nav a.active { color: var(--brand-text); }
    .kv { grid-template-columns: 1fr; gap: 0 0; }
    .kv dd { margin-bottom: 8px; }
    .print-page { padding: 6mm; font-size: 11px; }
}
/* Phones and small tablets held sideways: keep the content usable in short screens */
@media (max-height: 500px) and (orientation: landscape) {
    .bottom-nav { display: none; }
    .content { padding-bottom: 16px; }
    .topbar { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Student documents: thumbnails + in-page viewer (student.php) ---------- */
.doc-thumb { flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; display: grid; place-items: center; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb span { font-size: .68rem; font-weight: 800; color: var(--red); letter-spacing: .03em; }
.doc-thumb:hover, .doc-thumb:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); outline: none; }
.dialog.doc-viewer { width: min(1100px, calc(100vw - 24px)); height: calc(100vh - 40px); max-height: none; padding: 0; display: none; flex-direction: column; overflow: hidden; background: var(--surface); }
.dialog.doc-viewer[open] { display: flex; }
.dv-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.dv-head h3 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-head .grow { min-width: 0; }
.dv-head #dvPos { font-size: .8rem; min-width: 38px; text-align: center; }
.dv-body { flex: 1; min-height: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--text) 6%, var(--surface-2)); overflow: auto; }
.dv-body img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: var(--shadow-lg); background: #fff; }
.dv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 560px) { .dialog.doc-viewer { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; margin: 0; } .dv-head #dvOpen { display: none; } }
.dv-pdf { text-align: center; padding: 24px; }
.dv-pdf span { display: inline-grid; place-items: center; width: 72px; height: 88px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); color: var(--red); font-weight: 900; box-shadow: var(--shadow); }
.dv-pdf p { font-weight: 700; color: var(--text); margin: 12px 0; }

/* ---------- Queue counter bar (includes/header.php + assets/js/queue-bar.js) ---------- */
.q-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 14px; padding: 8px 12px; border-radius: 14px;
    background: color-mix(in srgb, #0d9488 12%, var(--surface)); border: 1px solid color-mix(in srgb, #0d9488 35%, transparent); box-shadow: var(--shadow); font-size: .88rem; }
.q-bar-win { display: inline-flex; gap: 6px; align-items: center; font-weight: 800; color: #0d9488; text-decoration: none; }
.q-bar-now b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.q-bar-wait { color: var(--text-2); } .q-bar.has-wait .q-bar-wait b { color: #c2410c; }
.q-bar-btns { margin-left: auto; display: inline-flex; gap: 6px; }
.q-bar.on-break { opacity: .7; }
@media print { .q-bar { display: none; } }
