/* ============================================================ */
/*  THEME TOKENS                                                */
/*                                                              */
/*  Every colour in this file references a token below, so the   */
/*  dark theme is defined here once instead of being re-styled   */
/*  component by component. Elevated surfaces get LIGHTER in     */
/*  dark mode (page < card < sheet < modal), as they should.     */
/* ============================================================ */

:root {
    color-scheme: light;
    --bd-06b6d4: #06b6d4;
    --bd-111318: #111318;
    --bd-111827: #111827;
    --bd-16a34a: #16a34a;
    --bd-1e293b: #1e293b;
    --bd-22c55e: #22c55e;
    --bd-2563eb: #2563eb;
    --bd-38bdf8: #38bdf8;
    --bd-3b82f6: #3b82f6;
    --bd-475569: #475569;
    --bd-6366f1: #6366f1;
    --bd-64748b: #64748b;
    --bd-86efac: #86efac;
    --bd-9333ea: #9333ea;
    --bd-93c5fd: #93c5fd;
    --bd-94a3b8: #94a3b8;
    --bd-c7d2fe: #c7d2fe;
    --bd-cbd5e1: #cbd5e1;
    --bd-d1d9e0: #d1d9e0;
    --bd-d8b4fe: #d8b4fe;
    --bd-d97706: #d97706;
    --bd-dbe2ea: #dbe2ea;
    --bd-dc2626: #dc2626;
    --bd-dcfce7: #dcfce7;
    --bd-e2e8f0: #e2e8f0;
    --bd-e5e9ef: #e5e9ef;
    --bd-e8eef5: #e8eef5;
    --bd-ea580c: #ea580c;
    --bd-eef2f6: #eef2f6;
    --bd-ef4444: #ef4444;
    --bd-f1f5f9: #f1f5f9;
    --bd-f39c12: #f39c12;
    --bd-f59e0b: #f59e0b;
    --bd-f8fafc: #f8fafc;
    --bd-fb7185: #fb7185;
    --bd-fca5a5: #fca5a5;
    --bd-fcd34d: #fcd34d;
    --bd-fecaca: #fecaca;
    --bd-ffffff: #ffffff;
    --bg-0f1115: #0f1115;
    --bg-0f172a: #0f172a;
    --bg-111318: #111318;
    --bg-111827: #111827;
    --bg-15803d: #15803d;
    --bg-16a34a: #16a34a;
    --bg-17191d: #17191d;
    --bg-191c22: #191c22;
    --bg-1e293b: #1e293b;
    --bg-202329: #202329;
    --bg-2563eb: #2563eb;
    --bg-292d35: #292d35;
    --bg-334155: #334155;
    --bg-343943: #343943;
    --bg-475569: #475569;
    --bg-94a3b8: #94a3b8;
    --bg-a0a7ae: #a0a7ae;
    --bg-a5f3fc: #a5f3fc;
    --bg-b91c1c: #b91c1c;
    --bg-bbf7d0: #bbf7d0;
    --bg-bfdbfe: #bfdbfe;
    --bg-c1c7cd: #c1c7cd;
    --bg-c7d2fe: #c7d2fe;
    --bg-cbd5e1: #cbd5e1;
    --bg-cffafe: #cffafe;
    --bg-dbe3ec: #dbe3ec;
    --bg-dbeafe: #dbeafe;
    --bg-dc2626: #dc2626;
    --bg-dcfce7: #dcfce7;
    --bg-ddd6fe: #ddd6fe;
    --bg-e0e7ff: #e0e7ff;
    --bg-e0f2fe: #e0f2fe;
    --bg-e2e8f0: #e2e8f0;
    --bg-e7e9ed: #e7e9ed;
    --bg-e8eef8: #e8eef8;
    --bg-eceef1: #eceef1;
    --bg-ecfeff: #ecfeff;
    --bg-ede9fe: #ede9fe;
    --bg-eef2f6: #eef2f6;
    --bg-eef2f7: #eef2f7;
    --bg-eef2ff: #eef2ff;
    --bg-ef4444: #ef4444;
    --bg-eff6ff: #eff6ff;
    --bg-f0fdf4: #f0fdf4;
    --bg-f1f3f5: #f1f3f5;
    --bg-f1f5f9: #f1f5f9;
    --bg-f3e8ff: #f3e8ff;
    --bg-f59e0b: #f59e0b;
    --bg-f6f8fa: #f6f8fa;
    --bg-f7f8fa: #f7f8fa;
    --bg-f8f9fc: #f8f9fc;
    --bg-f8fafc: #f8fafc;
    --bg-fae8ff: #fae8ff;
    --bg-faf5ff: #faf5ff;
    --bg-fafafa: #fafafa;
    --bg-fafbfc: #fafbfc;
    --bg-fde68a: #fde68a;
    --bg-fdfdfe: #fdfdfe;
    --bg-fecdd3: #fecdd3;
    --bg-fed7aa: #fed7aa;
    --bg-fee2e2: #fee2e2;
    --bg-fef2f2: #fef2f2;
    --bg-fef3c7: #fef3c7;
    --bg-fef9e7: #fef9e7;
    --bg-ffe4e6: #ffe4e6;
    --bg-ffedd5: #ffedd5;
    --bg-fff1f2: #fff1f2;
    --bg-fff7ed: #fff7ed;
    --bg-fffafa: #fffafa;
    --bg-fffbeb: #fffbeb;
    --bg-ffffff: #ffffff;
    --fg-0284c7: #0284c7;
    --fg-0369a1: #0369a1;
    --fg-0f172a: #0f172a;
    --fg-111318: #111318;
    --fg-14532d: #14532d;
    --fg-155e75: #155e75;
    --fg-15803d: #15803d;
    --fg-164e63: #164e63;
    --fg-166534: #166534;
    --fg-16a34a: #16a34a;
    --fg-17191d: #17191d;
    --fg-172033: #172033;
    --fg-1e293b: #1e293b;
    --fg-1e3a5f: #1e3a5f;
    --fg-1e3a8a: #1e3a8a;
    --fg-1e40af: #1e40af;
    --fg-202329: #202329;
    --fg-242830: #242830;
    --fg-2563eb: #2563eb;
    --fg-272c33: #272c33;
    --fg-303640: #303640;
    --fg-334155: #334155;
    --fg-3730a3: #3730a3;
    --fg-3f4650: #3f4650;
    --fg-4338ca: #4338ca;
    --fg-475569: #475569;
    --fg-4c1d95: #4c1d95;
    --fg-581c87: #581c87;
    --fg-5b21b6: #5b21b6;
    --fg-6366f1: #6366f1;
    --fg-64748b: #64748b;
    --fg-78350f: #78350f;
    --fg-7c2d12: #7c2d12;
    --fg-7c3aed: #7c3aed;
    --fg-7d6608: #7d6608;
    --fg-7e22ce: #7e22ce;
    --fg-7f1d1d: #7f1d1d;
    --fg-881337: #881337;
    --fg-92400e: #92400e;
    --fg-9299a4: #9299a4;
    --fg-94a3b8: #94a3b8;
    --fg-991b1b: #991b1b;
    --fg-9a3412: #9a3412;
    --fg-9f1239: #9f1239;
    --fg-b45309: #b45309;
    --fg-b91c1c: #b91c1c;
    --fg-cbd5e1: #cbd5e1;
    --fg-d97706: #d97706;
    --fg-dc2626: #dc2626;
    --fg-e2e8f0: #e2e8f0;
    --fg-f59e0b: #f59e0b;
    --fg-ffffff: #ffffff;
    --ink-rgb: 0, 0, 0;
    --surface-rgb: 255,255,255;
    --scroll-thumb: #c1c7cd;
    --header-hairline: rgba(15, 23, 42, 0.06);
    --surface-raised: #ffffff;
    --surface-sunken: #f8fafc;
    --surface-active: #e9eef5;
    --cat-hover: rgba(15, 23, 42, 0.05);
    --check-border: #cbd5e1;
    --check-border-hover: #94a3b8;
    --check-fill: #1e293b;
    --cat-active: rgba(15, 23, 42, 0.10);
    --toggle-off: #cbd5e1;
    --toggle-on: #1e293b;
    --toggle-knob: #ffffff;
    --toggle-knob-on: #ffffff;
    /* Elevation scale — light and dark carry the same depth. */
    --elev-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 5px 12px -6px rgba(15, 23, 42, 0.11);
    --elev-2: 0 12px 24px -12px rgba(15, 23, 42, 0.21), 0 4px 10px -4px rgba(15, 23, 42, 0.10);
    /* Contact shadow for the raised button faces: the bevel does the 3D,
       this only keeps the face sitting on the surface. Dark mode needs a
       real dark shadow here or the grey face reads flat. */
    --btn-contact: 0 1px 2px rgba(15, 23, 42, 0.06);
    --btn-contact-hover: 0 2px 4px rgba(15, 23, 42, 0.08);
    /* Lit / shaded card edges — the 1px border itself carries the 3D,
       so the top edge is exactly as thick as the other three. */
    /* A pure white top edge is invisible on white cards, which left the
       top of every card looking unfinished. This is a visible hairline
       one step lighter than the sides, so the bevel still reads. */
    /* Same as the side borders: a lighter top line reads as a missing
       border on white. The bevel now comes from the darker bottom edge
       and the drop shadow, so the ring is complete on all four sides. */
    --card-edge-top: #e2e8f0;
    --card-edge-top-hover: #dbe2ea;
    --card-edge-bottom: #d9e1ea;
    /* Buttons sit on plain white surfaces where a white top edge would
       vanish, so their lit edge is a real, slightly darker line. */
    --button-edge-top: #d1d9e0;
    /* Raised-button bevel. Light mode reads like the cards: a lit top
       lip, a shaded bottom, and a 2px extruded base under the button.
       Dark mode swaps the white lip for a low-alpha one so it can
       never bloom into a glow. */
    --btn-lip: rgba(255, 255, 255, 0.92);
    --btn-inner-shade: rgba(15, 23, 42, 0.10);
    --btn-base: rgba(15, 23, 42, 0.13);
    --btn-drop: rgba(15, 23, 42, 0.30);
    --btn-solid-lip: rgba(255, 255, 255, 0.26);
    --btn-solid-shade: rgba(0, 0, 0, 0.20);
    --btn-solid-base: rgba(15, 23, 42, 0.42);
    --btn-face-top: #fdfefe;
    --btn-face-bottom: #eef2f7;
    /* Outlined (flat) buttons: one step stronger than the old hairline,
       which disappeared on white surfaces. */
    --outline-btn-line: #bcc8d5;
    --outline-btn-line-top: #c8d2dd;
    --outline-btn-line-bottom: #b0bdcb;
    /* Buttons wear the same 1px ring as a card: a lit top line, a
       shaded bottom line, and one soft contact shadow. The old 2px
       extruded slab under the button read pixelated at this size. */
    --btn-line: #cbd5e1;
    --btn-line-top: #dde5ee;
    --btn-line-bottom: #b4c1d0;
    --btn-solid-line: rgba(15, 23, 42, 0.40);
    --btn-solid-line-top: rgba(255, 255, 255, 0.24);
    --btn-solid-line-bottom: rgba(0, 0, 0, 0.42);
    --well-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.055), inset 0 -1px 0 rgba(255, 255, 255, 0.75);
    --well-edge-top: #d7dfe8;
    --well-edge-bottom: #e4ecf6;
    --elev-3: 0 28px 68px -24px rgba(15, 23, 42, 0.34), 0 10px 24px -14px rgba(15, 23, 42, 0.18);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bd-06b6d4: #2d6c76;
    --bd-111318: #313131;
    --bd-111827: #313131;
    --bd-16a34a: #2d7648;
    --bd-1e293b: #313131;
    --bd-22c55e: #2d7648;
    --bd-2563eb: #2d4476;
    --bd-38bdf8: #2d6076;
    --bd-3b82f6: #2d4976;
    --bd-475569: #313131;
    --bd-6366f1: #2d2e76;
    --bd-64748b: #313131;
    --bd-86efac: #2d7647;
    --bd-9333ea: #532d76;
    --bd-93c5fd: #2d5076;
    --bd-94a3b8: #313131;
    --bd-c7d2fe: #2d3c76;
    --bd-cbd5e1: #313131;
    --bd-d1d9e0: #373737;
    --bd-d8b4fe: #512d76;
    --bd-d97706: #76542d;
    --bd-dbe2ea: #3a3a3a;
    --bd-dc2626: #762d2d;
    --bd-dcfce7: #2d7646;
    --bd-e2e8f0: #3b3b3b;
    --bd-e5e9ef: #383838;
    --bd-e8eef5: #313131;
    --bd-ea580c: #76462d;
    --bd-eef2f6: #323232;
    --bd-ef4444: #762d2d;
    --bd-f1f5f9: #313131;
    --bd-f39c12: #765a2d;
    --bd-f59e0b: #765b2d;
    --bd-f8fafc: #313131;
    --bd-fb7185: #762d38;
    --bd-fca5a5: #762d2d;
    --bd-fcd34d: #76652d;
    --bd-fecaca: #762d2d;
    --bd-ffffff: #303030;
    --bg-0f1115: #3d3d3d;
    --bg-0f172a: #232323;
    --bg-111318: #3e3e3e;
    --bg-111827: #666666;
    --bg-15803d: #2ba157;
    --bg-16a34a: #28a456;
    --bg-17191d: #3d3d3d;
    --bg-191c22: #3e3e3e;
    --bg-1e293b: #343434;
    --bg-202329: #3d3d3d;
    --bg-2563eb: #224daa;
    --bg-292d35: #3d3d3d;
    --bg-334155: #545454;
    --bg-343943: #3d3d3d;
    --bg-475569: #545454;
    --bg-94a3b8: #4a4a4a;
    --bg-a0a7ae: #4a4a4a;
    --bg-a5f3fc: #183b3f;
    --bg-b91c1c: #a22a2a;
    --bg-bbf7d0: #183f25;
    --bg-bfdbfe: #18293f;
    --bg-c1c7cd: #3a3a3a;
    --bg-c7d2fe: #18203f;
    --bg-cbd5e1: #333333;
    --bg-cffafe: #183c3f;
    --bg-dbe3ec: #2c2c2c;
    --bg-dbeafe: #17243a;
    --bg-dc2626: #a12b2b;
    --bg-dcfce7: #16311d;
    --bg-ddd6fe: #2c2c2c;
    --bg-e0e7ff: #2c2c2c;
    --bg-e0f2fe: #2c2c2c;
    --bg-e2e8f0: #303030;
    --bg-e7e9ed: #2c2c2c;
    --bg-e8eef8: #2c2c2c;
    --bg-eceef1: #2c2c2c;
    --bg-ecfeff: #183d3f;
    --bg-ede9fe: #2c2c2c;
    --bg-eef2f6: #2a2a2a;
    --bg-eef2f7: #2a2a2a;
    --bg-eef2ff: #2c2c2c;
    --bg-ef4444: #801919;
    --bg-eff6ff: #17243a;
    --bg-f0fdf4: #13291b;
    --bg-f1f3f5: #2c2c2c;
    --bg-f1f5f9: #252525;
    --bg-f3e8ff: #2b183f;
    --bg-f59e0b: #b1791b;
    --bg-f6f8fa: #161616;
    --bg-f7f8fa: #161616;
    --bg-f8f9fc: #2c2c2c;
    --bg-f8fafc: #161616;
    --bg-fae8ff: #36183f;
    --bg-faf5ff: #2b183f;
    --bg-fafafa: #161616;
    --bg-fafbfc: #161616;
    --bg-fde68a: #887011;
    --bg-fdfdfe: #2c2c2c;
    --bg-fecdd3: #3f181d;
    --bg-fed7aa: #3f2d18;
    --bg-fee2e2: #3a1e1e;
    --bg-fef2f2: #3a1e1e;
    --bg-fef3c7: #33270f;
    --bg-fef9e7: #3f3618;
    --bg-ffe4e6: #3f181b;
    --bg-ffedd5: #3f2e18;
    --bg-fff1f2: #3f181b;
    --bg-fff7ed: #3f2e18;
    --bg-fffafa: #3f1818;
    --bg-fffbeb: #3f3718;
    --bg-ffffff: #252525;
    --fg-0284c7: #49b9f4;
    --fg-0369a1: #66c2f4;
    --fg-0f172a: #f8f8f8;
    --fg-111318: #ebebeb;
    --fg-14532d: #afe8c6;
    --fg-155e75: #67e8f9;
    --fg-15803d: #4ade80;
    --fg-164e63: #a0d2e5;
    --fg-166534: #86efac;
    --fg-16a34a: #4ade80;
    --fg-17191d: #e5e5e5;
    --fg-172033: #cccccc;
    --fg-1e293b: #eeeeee;
    --fg-1e3a5f: #a3bcde;
    --fg-1e3a8a: #7a94dc;
    --fg-1e40af: #93c5fd;
    --fg-202329: #dbdbdb;
    --fg-242830: #d5d5d5;
    --fg-2563eb: #60a5fa;
    --fg-272c33: #d2d2d2;
    --fg-303640: #c7c7c7;
    --fg-334155: #dadada;
    --fg-3730a3: #746fce;
    --fg-3f4650: #b8b8b8;
    --fg-4338ca: #736cd1;
    --fg-475569: #c6c6c6;
    --fg-4c1d95: #9a70dc;
    --fg-581c87: #b37dde;
    --fg-5b21b6: #c4b5fd;
    --fg-6366f1: #5558e7;
    --fg-64748b: #a2a2a2;
    --fg-78350f: #ebae8c;
    --fg-7c2d12: #e8a188;
    --fg-7c3aed: #8b55e7;
    --fg-7d6608: #f1dc88;
    --fg-7e22ce: #a260dd;
    --fg-7f1d1d: #dd8585;
    --fg-881337: #e67d9d;
    --fg-92400e: #fbbf24;
    --fg-9299a4: #8c8c8c;
    --fg-94a3b8: #7e7e7e;
    --fg-991b1b: #fca5a5;
    --fg-9a3412: #e68a6c;
    --fg-9f1239: #e6678a;
    --fg-b45309: #fbbf24;
    --fg-b91c1c: #f87171;
    --fg-cbd5e1: #6e6e6e;
    --fg-d97706: #f1a44c;
    --fg-dc2626: #f87171;
    --fg-e2e8f0: #9e9e9e;
    --fg-f59e0b: #eeb34e;
    --fg-ffffff: #ffffff;
    --ink-rgb: 0, 0, 0;
    --surface-rgb: 37, 37, 37;
    --scroll-thumb: #4a4a4a;
    --header-hairline: rgba(255, 255, 255, 0.08);
    --surface-raised: #2b2b2b;
    --surface-sunken: #1b1b1b;
    --surface-active: #353535;
    --cat-hover: rgba(255, 255, 255, 0.07);
    --check-border: #4d4d4d;
    --check-border-hover: #666666;
    --check-fill: #4a4a4a;
    --cat-active: rgba(255, 255, 255, 0.13);
    --toggle-off: #3d3d3d;
    --toggle-on: #ededed;
    --toggle-knob: #cfcfcf;
    --toggle-knob-on: #1c1c1c;
    --elev-1: 0 1px 2px rgba(0, 0, 0, 0.28), 0 6px 16px -6px rgba(0, 0, 0, 0.34);
    --elev-2: 0 12px 26px -12px rgba(0, 0, 0, 0.42), 0 4px 10px -4px rgba(0, 0, 0, 0.28);
    --btn-contact: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 10px -4px rgba(0, 0, 0, 0.45);
    --btn-contact-hover: 0 2px 5px rgba(0, 0, 0, 0.55), 0 6px 14px -4px rgba(0, 0, 0, 0.5);
    /* Same 1px lit edge as light mode — never a second, thicker line. */
    --card-edge-top: #4b4b4b;
    --card-edge-top-hover: #565656;
    --card-edge-bottom: #262626;
    --button-edge-top: #4b4b4b;
    /* Never a bright lip on a dark surface — that was the white glow. */
    --btn-lip: rgba(255, 255, 255, 0.10);
    --btn-inner-shade: rgba(0, 0, 0, 0.45);
    --btn-base: rgba(0, 0, 0, 0.50);
    --btn-drop: rgba(0, 0, 0, 0.55);
    --btn-solid-lip: rgba(255, 255, 255, 0.12);
    --btn-solid-shade: rgba(0, 0, 0, 0.40);
    --btn-solid-base: rgba(0, 0, 0, 0.70);
    --btn-face-top: rgba(255, 255, 255, 0.055);
    --btn-face-bottom: rgba(255, 255, 255, 0.012);
    --outline-btn-line: #606060;
    --outline-btn-line-top: #6e6e6e;
    --outline-btn-line-bottom: #4f4f4f;
    /* Same card-style ring, one step away from the dark surface. */
    --btn-line: #4c4c4c;
    --btn-line-top: #5e5e5e;
    --btn-line-bottom: #2b2b2b;
    --btn-solid-line: rgba(255, 255, 255, 0.10);
    --btn-solid-line-top: rgba(255, 255, 255, 0.16);
    --btn-solid-line-bottom: rgba(0, 0, 0, 0.55);
    --well-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 -1px 0 rgba(255, 255, 255, 0.04);
    --well-edge-top: #181818;
    --well-edge-bottom: #3a3a3a;
    --elev-3: 0 30px 76px -26px rgba(0, 0, 0, 0.8), 0 12px 28px -16px rgba(0, 0, 0, 0.6);
}

/* Print always uses the light palette. */
@media print {
    html[data-theme="dark"] {
        color-scheme: light;
        --bd-06b6d4: #06b6d4;
        --bd-111318: #111318;
        --bd-111827: #111827;
        --bd-16a34a: #16a34a;
        --bd-1e293b: #1e293b;
        --bd-22c55e: #22c55e;
        --bd-2563eb: #2563eb;
        --bd-38bdf8: #38bdf8;
        --bd-3b82f6: #3b82f6;
        --bd-475569: #475569;
        --bd-6366f1: #6366f1;
        --bd-64748b: #64748b;
        --bd-86efac: #86efac;
        --bd-9333ea: #9333ea;
        --bd-93c5fd: #93c5fd;
        --bd-94a3b8: #94a3b8;
        --bd-c7d2fe: #c7d2fe;
        --bd-cbd5e1: #cbd5e1;
        --bd-d1d9e0: #d1d9e0;
        --bd-d8b4fe: #d8b4fe;
        --bd-d97706: #d97706;
        --bd-dbe2ea: #dbe2ea;
        --bd-dc2626: #dc2626;
        --bd-dcfce7: #dcfce7;
        --bd-e2e8f0: #e2e8f0;
        --bd-e5e9ef: #e5e9ef;
        --bd-e8eef5: #e8eef5;
        --bd-ea580c: #ea580c;
        --bd-eef2f6: #eef2f6;
        --bd-ef4444: #ef4444;
        --bd-f1f5f9: #f1f5f9;
        --bd-f39c12: #f39c12;
        --bd-f59e0b: #f59e0b;
        --bd-f8fafc: #f8fafc;
        --bd-fb7185: #fb7185;
        --bd-fca5a5: #fca5a5;
        --bd-fcd34d: #fcd34d;
        --bd-fecaca: #fecaca;
        --bd-ffffff: #ffffff;
        --bg-0f1115: #0f1115;
        --bg-0f172a: #0f172a;
        --bg-111318: #111318;
        --bg-111827: #111827;
        --bg-15803d: #15803d;
        --bg-16a34a: #16a34a;
        --bg-17191d: #17191d;
        --bg-191c22: #191c22;
        --bg-1e293b: #1e293b;
        --bg-202329: #202329;
        --bg-2563eb: #2563eb;
        --bg-292d35: #292d35;
        --bg-334155: #334155;
        --bg-343943: #343943;
        --bg-475569: #475569;
        --bg-94a3b8: #94a3b8;
        --bg-a0a7ae: #a0a7ae;
        --bg-a5f3fc: #a5f3fc;
        --bg-b91c1c: #b91c1c;
        --bg-bbf7d0: #bbf7d0;
        --bg-bfdbfe: #bfdbfe;
        --bg-c1c7cd: #c1c7cd;
        --bg-c7d2fe: #c7d2fe;
        --bg-cbd5e1: #cbd5e1;
        --bg-cffafe: #cffafe;
        --bg-dbe3ec: #dbe3ec;
        --bg-dbeafe: #dbeafe;
        --bg-dc2626: #dc2626;
        --bg-dcfce7: #dcfce7;
        --bg-ddd6fe: #ddd6fe;
        --bg-e0e7ff: #e0e7ff;
        --bg-e0f2fe: #e0f2fe;
        --bg-e2e8f0: #e2e8f0;
        --bg-e7e9ed: #e7e9ed;
        --bg-e8eef8: #e8eef8;
        --bg-eceef1: #eceef1;
        --bg-ecfeff: #ecfeff;
        --bg-ede9fe: #ede9fe;
        --bg-eef2f6: #eef2f6;
        --bg-eef2f7: #eef2f7;
        --bg-eef2ff: #eef2ff;
        --bg-ef4444: #ef4444;
        --bg-eff6ff: #eff6ff;
        --bg-f0fdf4: #f0fdf4;
        --bg-f1f3f5: #f1f3f5;
        --bg-f1f5f9: #f1f5f9;
        --bg-f3e8ff: #f3e8ff;
        --bg-f59e0b: #f59e0b;
        --bg-f6f8fa: #f6f8fa;
        --bg-f7f8fa: #f7f8fa;
        --bg-f8f9fc: #f8f9fc;
        --bg-f8fafc: #f8fafc;
        --bg-fae8ff: #fae8ff;
        --bg-faf5ff: #faf5ff;
        --bg-fafafa: #fafafa;
        --bg-fafbfc: #fafbfc;
        --bg-fde68a: #fde68a;
        --bg-fdfdfe: #fdfdfe;
        --bg-fecdd3: #fecdd3;
        --bg-fed7aa: #fed7aa;
        --bg-fee2e2: #fee2e2;
        --bg-fef2f2: #fef2f2;
        --bg-fef3c7: #fef3c7;
        --bg-fef9e7: #fef9e7;
        --bg-ffe4e6: #ffe4e6;
        --bg-ffedd5: #ffedd5;
        --bg-fff1f2: #fff1f2;
        --bg-fff7ed: #fff7ed;
        --bg-fffafa: #fffafa;
        --bg-fffbeb: #fffbeb;
        --bg-ffffff: #ffffff;
        --fg-0284c7: #0284c7;
        --fg-0369a1: #0369a1;
        --fg-0f172a: #0f172a;
        --fg-111318: #111318;
        --fg-14532d: #14532d;
        --fg-155e75: #155e75;
        --fg-15803d: #15803d;
        --fg-164e63: #164e63;
        --fg-166534: #166534;
        --fg-16a34a: #16a34a;
        --fg-17191d: #17191d;
        --fg-172033: #172033;
        --fg-1e293b: #1e293b;
        --fg-1e3a5f: #1e3a5f;
        --fg-1e3a8a: #1e3a8a;
        --fg-1e40af: #1e40af;
        --fg-202329: #202329;
        --fg-242830: #242830;
        --fg-2563eb: #2563eb;
        --fg-272c33: #272c33;
        --fg-303640: #303640;
        --fg-334155: #334155;
        --fg-3730a3: #3730a3;
        --fg-3f4650: #3f4650;
        --fg-4338ca: #4338ca;
        --fg-475569: #475569;
        --fg-4c1d95: #4c1d95;
        --fg-581c87: #581c87;
        --fg-5b21b6: #5b21b6;
        --fg-6366f1: #6366f1;
        --fg-64748b: #64748b;
        --fg-78350f: #78350f;
        --fg-7c2d12: #7c2d12;
        --fg-7c3aed: #7c3aed;
        --fg-7d6608: #7d6608;
        --fg-7e22ce: #7e22ce;
        --fg-7f1d1d: #7f1d1d;
        --fg-881337: #881337;
        --fg-92400e: #92400e;
        --fg-9299a4: #9299a4;
        --fg-94a3b8: #94a3b8;
        --fg-991b1b: #991b1b;
        --fg-9a3412: #9a3412;
        --fg-9f1239: #9f1239;
        --fg-b45309: #b45309;
        --fg-b91c1c: #b91c1c;
        --fg-cbd5e1: #cbd5e1;
        --fg-d97706: #d97706;
        --fg-dc2626: #dc2626;
        --fg-e2e8f0: #e2e8f0;
        --fg-f59e0b: #f59e0b;
        --fg-ffffff: #ffffff;
        --ink-rgb: 0, 0, 0;
        --surface-rgb: 255,255,255;
    }
}

/* ============================================================ */
/*                     RESET & BASE                             */
/* ============================================================ */
@font-face {
    font-family: 'SolaimanLipi';
    src: url('/assets/fonts/SolaimanLipi.woff') format('woff'),
         url('/assets/fonts/SolaimanLipi.ttf') format('truetype');
    font-style: normal;
    font-display: block;
    unicode-range: U+0980-09FF;
}
@media (prefers-reduced-motion: reduce) {
    .notice-equation-guide-content,
    .notice-equation-guide-inner {
        transition: none;
    }
}

.bangla-text {
    font-family: 'SolaimanLipi', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

button, a, .btn, .exam-item, .sidebar-link, .dropdown-item, .student-chip, .card {
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-f6f8fa);
    color: var(--fg-1e293b);
    line-height: 1.5;
    height: 100%;
    overflow: hidden auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    margin: 0;
    padding: 0;
    scrollbar-gutter: stable;
}

/* ============================================================ */
/*                   CUSTOM SCROLLBAR                           */
/* ============================================================ */
html, body {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 6px;
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: transparent;
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background: var(--bg-c1c7cd);
    border-radius: 8px;
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
    background: var(--bg-a0a7ae);
}

/* ============================================================ */
/*                    VIEW SYSTEM                               */
/* ============================================================ */
.view {
    display: none;
    opacity: 0;
    /* Switching is cross-faded once by the View Transition in showView().
       A transition here layered a second fade and made swaps blink. */
    overflow: visible;
}
.view.active-view {
    display: block;
    opacity: 1;
}
.app-booting .view {
    display: none !important;
}

.app-booting #global-app-header,
.app-booting .header-user-menu,
.app-booting .user-menu-dropdown,
.app-booting .mobile-profile-trigger,
.app-booting .mobile-profile-dropdown,
.app-booting .hamburger-toggle,
.app-booting .header-actions .btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Simple show/hide for user triggers */
.user-menu-trigger.hidden,
.mobile-profile-trigger.hidden {
    display: none !important;
}

/* Ensure triggers are visible when not hidden */
.user-menu-trigger:not(.hidden),
.mobile-profile-trigger:not(.hidden) {
    display: inline-flex !important;
}

/* ============================================================ */
/*              STUDENT MARKS VIEW — FADE TRANSITIONS            */
/* ============================================================ */
/* View swaps already cross-fade through the native View Transition in
   showView(). A second animation here, layered on top of the manual
   fade-out on the way back, made the marksheet blink twice. */


/* ============================================================ */
/*                      BUTTONS                                 */
/* ============================================================ */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    transition: all 0.08s ease;
    cursor: pointer;
    border: 1px solid var(--btn-line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    text-decoration: none;
    line-height: 1;
}

/* Base icon styling */
.btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    line-height: 1;
    position: relative;
    top: 0;
}

/* Specific fix if using Font Awesome SVGs instead of font files */
.btn svg {
    display: block;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    line-height: 1;
    position: relative;
    top: 0;
}

.btn span,
.btn strong,
.btn em,
.btn b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.custom-select-wrapper {
    position: relative;
    display: inline-block;
    min-width: 140px;
    flex-shrink: 0;
}

.custom-select-wrapper .input-field,
.filter-select-wrapper select {
    font-family: 'SolaimanLipi',
                 -apple-system,
                 BlinkMacSystemFont,
                 'Segoe UI',
                 Roboto,
                 sans-serif;
}

.custom-select-wrapper .input-field {
    cursor: pointer;
    padding-right: 2.2rem;
}

.custom-select-wrapper input[readonly],
.combo-wrapper input[readonly] {
    caret-color: transparent;
}

/* Greyed-out placeholder tint for "Select [group]" prompts. Chrome
   shows the placeholder text automatically when value="" — this rule
   just matches the app's muted-grey token so it doesn't look like an
   active selection. */
.input-field::placeholder {
    color: var(--fg-94a3b8);
    opacity: 1;   /* Firefox dims placeholders by default */
}
.input-field.input-placeholder {
    color: var(--fg-94a3b8);
}

.custom-select-wrapper .filter-arrow {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--fg-94a3b8);
    font-size: 0.75rem;
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    display: none;
    max-height: 220px;
    overflow-y: auto;
    z-index: 90;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}

.custom-select-menu.show {
    display: block;
}

.custom-select-option {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    color: var(--fg-1e293b);
    cursor: pointer;
    transition: background 0.12s ease;
}

.custom-select-option:hover,
.custom-select-option.active {
    background: var(--bg-f1f5f9);
}
.btn-sm {
    font-size: 0.8rem;
    padding: 0.6rem 0.8rem;
}
.btn-primary {
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
}
.btn-primary:hover {
    background: var(--bg-0f172a);
}
.btn-outline {
    background: transparent;
    color: var(--fg-1e293b);
    border: 1px solid var(--bd-d1d9e0);
}
.btn-outline:hover {
    background: var(--bg-f1f5f9);
}
.btn-danger {
    background: var(--bg-dc2626);
    color: var(--fg-ffffff);
}
.btn-danger:hover {
    background: var(--bg-b91c1c);
}
#confirm-proceed {
    opacity: 0.5;
    cursor: not-allowed;
    filter: saturate(0.7);
}
#confirm-proceed:not(:disabled) {
    opacity: 1;
    cursor: pointer;
    filter: saturate(1);
}
.btn-success {
    background: var(--bg-16a34a);
    color: var(--fg-ffffff);
}
.btn-success:hover {
    background: var(--bg-15803d);
}
.btn-full {
    width: 100%;
    justify-content: center;
}

/* ============================================================ */
/*           INSTANT TACTILE FEEDBACK & ACTIVE STATES           */
/* ============================================================ */
button:active,
.btn:active,
.sidebar-link:active,
.dropdown-item:active,
.preset-btn:active,
.custom-select-option:active,
.hamburger-toggle:active {
    transform: scale(0.96) !important;
    transition: transform 0.06s cubic-bezier(0, 0, 0.2, 1) !important;
}

/* In-Button Async Action Loading */
.btn-loading {
    position: relative !important;
    pointer-events: none !important;
    opacity: 0.85 !important;
    cursor: wait !important;
    user-select: none !important;
}
.btn-spinner {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
    flex-shrink: 0;
}
/* Spinner with no label beside it: centre it instead of reserving the
   gap the label would have taken. */
.btn-spinner.is-solo { margin-right: 0; }
@keyframes btnSpin {
    to { transform: rotate(360deg); }
}


/* ============================================================ */
/*                      INPUTS                                  */
/* ============================================================ */
.input-field {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--bg-ffffff);
    transition: border 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}
.input-field:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30,41,59,0.08);
}
.input-field:disabled {
    background: var(--bg-f1f5f9);
    color: var(--fg-94a3b8);
}

/* ============================================================ */
/*                      LOGIN                                   */
/* ============================================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

/* Sign-in screen: one screenful, card dead centre, never scrolls. */
body.login-page {
    height: 100dvh;
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.login-page .login-container {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    padding: clamp(12px, 4vh, 28px) 16px;
}

/* Landscape phones are shorter than the card: tighten it rather than scroll. */
@media (max-height: 620px) {
    body.login-page .login-card { padding: 1.1rem 1.25rem; }
    body.login-page .login-title { font-size: 1.35rem; margin-bottom: 0.75rem; }
    body.login-page .login-subtitle { display: none; }
    body.login-page .form-group { margin-bottom: 0.6rem; }
    body.login-page .login-error { margin-top: 0.35rem; min-height: 0; }
    body.login-page .login-card p { margin-top: 0.4rem; }
}
.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    background: var(--bg-ffffff);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    border: 1px solid var(--bd-eef2f6);
}
.login-title {
    font-size: 1.75rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.login-subtitle {
    text-align: center;
    color: var(--fg-64748b);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
.login-error {
    color: var(--fg-dc2626);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: center;
}

/* ========================================================================== */
/* [START] APPLE-GRADE LIQUID GLASS HEADER — macOS DOCK STYLE                 */
/* ========================================================================== */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.7rem 1.5rem;
    width: 100%;
    margin: 0;
    border-radius: 0;

    /* Attached state — matches page background exactly */
    background: var(--bg-f6f8fa);
    border: none;
    border-bottom: 1px solid var(--header-hairline);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;

    transition:
        top 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        margin 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);

    will-change: top, width, margin, padding, border-radius, background, box-shadow, transform;
    min-height: 56px;
    isolation: isolate;
}

/* ---- DETACHED + LIQUID GLASS ---- */
.app-header.scrolled {
    top: 10px;

    /* Narrower than viewport, centred, capped at inner-content width + pill gutter */
    width: calc(100% - 28px);
    max-width: calc(1200px + 24px);
    margin: 0 auto;

    padding: 0.55rem 1.5rem;
    border-radius: 22px;
    border-bottom: none;

    /* Tint layer — bg-matched translucent fill */
    background: rgba(var(--surface-rgb), 0.6);

    /* SVG refraction — this is the "liquid" part */
    backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    -webkit-backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);

    /* 3D depth — the bar is a slab of glass floating over the page:
       a lit top lip, a shaded bottom lip, a crisp plinth line where it
       meets the page, and a soft drop below that. */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.09),
        0 1px 0 rgba(255, 255, 255, 0.65),
        0 2px 0 -1px rgba(15, 23, 42, 0.1),
        0 10px 16px -8px rgba(15, 23, 42, 0.26),
        0 22px 46px -22px rgba(15, 23, 42, 0.22);

    min-height: 52px;
}

/* Specular shine + inner bevel — the “glass catching light” layer.
   Sits above the refraction but below the header content. */
.app-header.scrolled::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;

    /* Edge highlight — top-left lit, bottom-right shaded */
    box-shadow:
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.55),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);

    /* Subtle vertical sheen so the surface reads as curved glass */
    background: linear-gradient(
        180deg,
        rgba(var(--surface-rgb), 0.22) 0%,
        rgba(var(--surface-rgb), 0) 40%,
        rgba(var(--surface-rgb), 0) 65%,
        rgba(var(--surface-rgb), 0.10) 100%
    );
    mix-blend-mode: overlay;
}

/* ========================================================================== */
/* [LIQUID-GLASS FALLBACK] — plain blur for browsers without SVG-in-backdrop-filter
   Remove this whole block if you remove the Liquid Glass effect.            */
/* ========================================================================== */
@supports not (backdrop-filter: url(#glass-distortion)) {
    .app-header.scrolled {
        backdrop-filter: blur(20px) saturate(180%) contrast(108%);
        -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(108%);
    }
}
/* [END LIQUID-GLASS FALLBACK] */

/* Keep header content above the glass layers */
.app-header .header-inner {
    position: relative;
    z-index: 2;
}

/* ---- Hover bump (PC only) — macOS Dock-style lift ---- */
@media (min-width: 769px) {
    .app-header.scrolled:hover {
        transform: scale(1.015) translateY(-3px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset 0 -1px 0 rgba(15, 23, 42, 0.09),
            0 1px 0 rgba(255, 255, 255, 0.65),
            0 3px 0 -1px rgba(15, 23, 42, 0.12),
            0 16px 28px -10px rgba(15, 23, 42, 0.3),
            0 32px 62px -28px rgba(15, 23, 42, 0.26);
    }
}

.app-header.scrolled .branding {
    font-size: 1.14rem;
    transition: font-size 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-header.scrolled .header-actions .btn {
    padding: 0.38rem 0.85rem;
    font-size: 0.8rem;
    transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- Mobile: same glass, tighter geometry ---- */
@media (max-width: 768px) {
    .app-header {
        padding: 0.6rem 1rem;
        min-height: 50px;
    }
    .app-header.scrolled {
        top: 8px;
        width: calc(100% - 16px);
        margin: 0 8px;
        padding: 0.3rem 0.65rem;
        border-radius: 18px;
        min-height: 48px;
    }
    .app-header .branding {
        font-size: 1.08rem;
    }
    .app-header.scrolled .branding {
        font-size: 1.02rem;
    }
}

/* ========================================================================== */
/* [END] APPLE-GRADE LIQUID GLASS HEADER — macOS DOCK STYLE                   */
/* ========================================================================== */

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    width: 100%;
}

.branding {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'League Spartan', 'Segoe UI', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    color: var(--fg-1e293b);
    letter-spacing: -0.02em;
}

.branding i,
.branding span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.branding span {
    transform: translateY(2px);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-user-menu {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.25rem 0.2rem;
    box-shadow: none;
    color: var(--fg-1e293b);
    cursor: pointer;
    transition: none;
    min-width: fit-content;
}

.user-menu-trigger .user-avatar,
.mobile-profile-trigger .user-avatar {
    display: inline-flex;
}

.user-menu-trigger:hover {
    transform: none;
    box-shadow: none;
}

.user-menu-trigger[aria-expanded="true"] .user-menu-caret {
    transform: rotate(180deg);
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-0f172a), var(--bg-475569));
    color: var(--fg-ffffff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    white-space: nowrap;
}

.user-menu-caret {
    font-size: 0.72rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: var(--bg-ffffff);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.25rem 0.15rem;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    overflow: hidden;
    max-height: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.25s ease, padding 0.25s ease;
}

.user-menu-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    max-height: 220px;
}

.user-menu-profile-summary {
    display: none;
}

.profile-menu-action {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--fg-1e293b);
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    text-align: left;
    min-width: fit-content;
    white-space: nowrap;
}

.profile-menu-action.logout-btn,
.profile-menu-action.logout-btn.danger {
    color: var(--fg-dc2626);
}

.profile-menu-action:hover {
    background: rgba(148, 163, 184, 0.08);
}

.header-actions .btn {
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================ */
/*              GLASS EFFECT – LIGHT BORDER & SHADOW            */
/* ============================================================ */
/* Add a subtle glow on the border for extra glass feel */
.app-header.scrolled::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 21px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(var(--surface-rgb), 0.2), rgba(var(--surface-rgb), 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

/* ============================================================ */
/*                    PAGE HEADERS                              */
/* ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.page-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    flex: 1;
    text-align: left;
}
.page-header .btn {
    flex-shrink: 0;
}

/* ============================================================ */
/*                    BACK ROW                                  */
/* ============================================================ */
.back-row {
    max-width: 1200px;
    margin: 0.75rem auto 0.5rem;
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--bd-eef2f6);
}
.class-title-large {
    font-size: 1.4rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    margin-right: 2.5rem;
}

/* ============================================================ */
/*                    DASHBOARD                                 */
/* ============================================================ */
.dashboard-main {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

/* ============================================================ */
/*                    CLASS LAYOUT                              */
/* ============================================================ */
.class-layout {
    display: flex;
    max-width: 1200px;
    margin: 0.5rem auto 1.5rem;
    padding: 0 1.5rem;
    gap: 1.5rem;
    align-items: flex-start;
    position: relative;
}

.sidebar {
    width: 180px;
    position: sticky;
    top: 76px;
    left: 0;
    height: auto;
    max-height: calc(100vh - 92px);
    max-height: calc(100dvh - 92px);
    border-right: 1px solid var(--bd-e2e8f0);
    padding-right: 1rem;
    overflow-y: auto;
    box-sizing: border-box;
}

.class-layout > .sidebar {
    width: 220px;
    flex: 0 0 220px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    color: var(--fg-475569);
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.08s ease;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.sidebar-link:hover {
    background: var(--bg-f1f5f9);
    color: var(--fg-1e293b);
}
.sidebar-link.active {
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
}
.sidebar-link i {
    width: 1.2rem;
    text-align: center;
}

.class-content {
    flex: 1;
    min-width: 0;
    overflow: visible;
}
.tab-content {
    animation: fadeIn 0.2s ease;
    overflow: visible;
}
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.tab-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.tab-header .btn {
    flex-shrink: 0;
}

/* ============================================================ */
/*                    EXAM CARDS (flex)                         */
/* ============================================================ */
.exam-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.exam-card-item {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    overflow: visible !important;
    transition: box-shadow 0.15s ease;
    z-index: auto;
}

.class-card-item:has(.dropdown-menu.show),
.exam-card-item:has(.dropdown-menu.show) {
    position: relative;
    z-index: 100;
}
.exam-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
}
.exam-card-header .exam-title-cell {
    flex: 1;
}
.exam-card-header .exam-date {
    font-size: 0.7rem;
    color: var(--fg-94a3b8);
    letter-spacing: 0.02em;
    line-height: 1.2;
}
.exam-card-header .exam-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.1rem;
    line-height: 1.3;
}
.actions-cell,
.actions-wrapper {
    overflow: visible !important;
}
.exam-card-header .actions-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.exam-card-header .actions-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.exam-details-container, .student-exam-details {
    max-height: 0;
    overflow: hidden;
    padding: 0 1rem;
    transition: max-height 0.35s ease, padding 0.35s ease;
}
.exam-details-container.expanded {
    padding: 0.5rem 1rem 1rem 1rem;
}
/* The stats sit flat on the card's own surface — no tile, no panel. They
   share one line while the card is wide enough; when they run out of room
   the flex basis lets the line break, and the items on the new line grow
   to fill it, so a wrapped stat reads centred across the full width. */
.exam-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    justify-content: space-around;
    align-items: flex-start;
    padding: 0.5rem 0;
}
.exam-details .stat-item {
    flex: 1 1 18%; /* five per line while there is room for five */
    min-width: 70px;
    text-align: center;
}
.exam-details .stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    letter-spacing: 0.03em;
}
.student-exam-details .view-marks-wrapper {
    padding-bottom: 1rem;
    text-align: right;
}
.exam-details .stat-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--fg-1e293b);
}
.top-scorers-wrapper {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}
.top-scorers-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    margin-bottom: 0.25rem;
}
.top-scorers {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 7.5rem;
    overflow-y: auto;
}
.top-scorers li {
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--bd-f1f5f9);
    font-size: 0.9rem;
    height: 1.5rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}
.top-scorers li:last-child {
    border-bottom: none;
}
/* Nobody passed: the list prints the same dash as the marksheet. */
.top-scorers li.top-scorers-empty {
    justify-content: center;
    color: var(--fg-94a3b8);
    font-weight: 600;
}

/* ---- Mobile: exam cards ---- */
@media (max-width: 768px) {
    .login-title {
        font-size: 1.45rem;
    }

    .login-subtitle{
        font-size: 0.92rem
    }
    .exam-card-header {
        flex-wrap: nowrap;
        gap: 0.4rem;
        padding: 0.6rem 0.75rem;
    }
    .exam-card-header .exam-title-cell {
        flex: 1 1 auto;
        min-width: 0;
        order: 0;
    }
    .exam-card-header .actions-cell {
        flex: 0 0 auto;
        justify-content: flex-end;
        order: 0;
        width: auto;
    }
    .exam-card-header .actions-wrapper {
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 0.3rem;
    }
    .exam-card-header .actions-wrapper .open-marks-btn {
        display: none;
    }
    .exam-details .stat-item {
        flex: 1 1 45%;
        min-width: 60px;
    }
    .exam-details .stat-value {
        font-size: 1.2rem;
    }
    .exam-details-container.expanded {
        padding: 0.5rem 0.75rem 0.75rem;
    }
}

/* ============================================================ */
/*                    CLASS CARDS (flex rows)                   */
/* ============================================================ */
.class-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.class-card-item {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.08s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.class-card-item:hover {
    background: var(--bg-ffffff);
}

/* ============================================================ */
/*  CLASS CARD — ADMIN FLAGS                                     */
/*                                                              */
/*  Same physical pattern as the notice card flags: a tab-       */
/*  shaped pill attached above the card's top-left corner.      */
/*  Shown only when:                                            */
/*    • viewer is a class admin of this class → "ADMIN"         */
/*    • viewer is admin/superadmin AND this class has a         */
/*      class admin → "C/O [name]" (+N if multiple)             */
/*                                                              */
/*  Both flags paint in the slate family so every "staff         */
/*  authority" signal in the app shares one colour language:    */
/*  header avatar, notice creator avatar, and now class admin.  */
/* ============================================================ */
.class-card-item.has-flags {
    position: relative;
    margin-top: 1.65rem;
    border-top-left-radius: 0;
}

.class-card-flags {
    position: absolute;
    top: -1.65rem;
    left: -1px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    width: fit-content;
    max-width: calc(100% - 1rem);
    height: 1.65rem;
    gap: 0.4rem;
    margin: 0;
    padding: 0.32rem 1rem;
    border: 1px solid var(--bd-e2e8f0);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: var(--bg-f8fafc);
    transition: border-color 180ms ease, opacity 180ms ease;
}

/* ============================================================ */
/*  CLASS CARD — CLICK-STRIP ABOVE THE CARD BODY                 */
/*                                                              */
/*  The flag pill is `width: fit-content` — only as wide as the */
/*  text inside it. So on a card with a short flag (e.g. one     */
/*  class admin, "C/O Sayad"), the space to the right of the     */
/*  flag is inside the card's margin-top area. Clicks there hit  */
/*  empty margin, NOT the card, so nothing happens. That was     */
/*  the intermittent "clicking on class does nothing" bug.       */
/*                                                              */
/*  This pseudo-element is a transparent full-width strip that   */
/*  covers the entire margin area. Because it is a ::before      */
/*  pseudo-child of the card, a click landing on it counts as a  */
/*  click on the card itself — the click handler fires. The      */
/*  strip sits BELOW the flag (z-index 0 vs the flag's 1) so it  */
/*  never blocks interaction with the flag's own hover/title.    */
/* ============================================================ */
.class-card-item.has-flags::before {
    content: '';
    position: absolute;
    top: -1.65rem;
    left: 0;
    right: 0;
    height: 1.65rem;
    z-index: 0;
    pointer-events: auto;
}

/* Defensive: keep the card itself clickable regardless of any
   pointer-events inheritance from a future ancestor rule. */
.class-card-item {
    pointer-events: auto;
}

.class-card-item:hover .class-card-flags {
    border-color: var(--bd-dbe2ea);
    border-bottom: 0;
}

/* Two states, one extension. No inner chip — the tab shape itself
   carries the text. Hierarchy comes from weight + colour, not from a
   second background layer. */

.class-flag-admin-self {
    color: var(--fg-1e293b);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.6rem;
    line-height: 1;
}

.class-flag-c-admin {
    display: inline-flex;
    align-items: baseline;   /* was: center — aligns TEXT baselines, not boxes */
    gap: 0.35rem;
    color: var(--fg-475569);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1;
    max-width: 100%;
    min-width: 0;
}

.class-flag-c-admin .prefix {
    color: var(--fg-64748b);
    /* Uppercase rendered via CSS; the HTML keeps "Admin:" so the
       source stays readable. The colon survives the transform. */
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.6rem;
    line-height: 1;
    flex-shrink: 0;
    /* Cancel the trailing letter-space so ":" sits tight against
       the gap between prefix and name. */
    margin-right: -0.08em;
}

.class-flag-c-admin .name {
    color: var(--fg-475569);
    font-weight: 600;
    font-size: 0.72rem;
    line-height: 1;
    /* Belt and braces: never inherit uppercase from any ancestor,
       no matter how the .class-flag base rule evolves. */
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Flags should never eat the card's click — the whole card is the
   hit target, and the flag is a direct child of the card so clicks
   already bubble to the card's handler. Just make sure no cursor or
   focus styling makes it look interactive. */
.class-card-flags {
    pointer-events: auto;
    cursor: inherit;
}

/* ============================================================ */
/*  CLASS-CARD FLAGS — auto-hide when the teacher portal is off  */
/*                                                              */
/*  Disabling the portal removes the Teachers tab from the pill  */
/*  switcher and the Teachers link from the class sidebar. A C/O */
/*  badge on a class card is meaningless in that state — the     */
/*  class admin it names can't log in to administer anything.    */
/*  The ADMIN chip is the same story: if the portal is off, the  */
/*  viewer is being force-signed-out on their next navigation.   */
/*                                                              */
/*  Driven purely by body.teacher-portal-enabled, which is       */
/*  toggled synchronously by app.updateTeacherPortalVisibility.  */
/*  Works retroactively on cards that were rendered while the    */
/*  portal was on; no JS refresh, no dashboard re-render.        */
/*                                                              */
/*  The margin-top + border-radius reset on .has-flags is what   */
/*  collapses the empty tab slot back to a normal 16px radius    */
/*  card — without it, the flag was hidden but the extra 1.65rem */
/*  top margin and squared top-left corner would remain, leaving */
/*  an odd gap above the class name.                             */
/* ============================================================ */
body:not(.teacher-portal-enabled) .class-card-flags {
    display: none !important;
}

body:not(.teacher-portal-enabled) .class-card-item.has-flags {
    margin-top: 0 !important;
    border-top-left-radius: 16px !important;
}

.class-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
    width: 100%;
}

.class-card-name {
    font-weight: 600;
    font-size: 1.25rem; /* larger on desktop */
    flex-shrink: 0;
    white-space: nowrap;
}

.class-card-meta {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    justify-content: flex-end; /* anchor stats to the right */
    align-items: center;
}

.class-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.class-meta-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    letter-spacing: 0.03em;
}

.class-meta-value {
    font-size: 1.4rem; /* larger */
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.2;
}

/* ---- Mobile: keep everything in one line, smaller fonts ---- */
@media (max-width: 768px) {
    .class-card-content {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    .class-card-name {
        font-size: 1rem;
        flex-shrink: 0;
    }
    .class-card-meta {
        gap: 0.75rem;
        justify-content: end;
        flex: 1;
    }
    .class-meta-value {
        font-size: 1rem;
    }
}

/* ============================================================ */
/*                    STUDENT TABLE                             */
/* ============================================================ */
.student-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--bg-ffffff);
    border-radius: 12px;
    overflow: visible;
    border: 1px solid var(--bd-e2e8f0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.student-table th {
    background: var(--bg-f8fafc);
    font-weight: 500;
    color: var(--fg-475569);
    text-align: left;
    border-bottom: 1px solid var(--bd-e2e8f0);
    padding: 0.75rem 1rem;
}
.student-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    vertical-align: middle;
}
.student-table tbody tr {
    background: var(--bg-ffffff);
    transition: background 0.08s ease;
}
.student-table tbody tr:hover {
    background: var(--bg-f8fafc);
}
.student-table tr:last-child td {
    border-bottom: none;
}
.student-table .actions-cell {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}
.student-table .actions-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.student-table tr:focus-within,
.student-table tr:hover,
.student-table td:focus-within {
    z-index: 100 !important;
}

/* Base relative positioning for table cells/rows */
.student-table tr {
    position: relative;
    z-index: 1;
}

.student-table td {
    position: relative;
}

/* ============================================================ */
/*                    MARKS TABLE                               */
/* ============================================================ */
.marks-main {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}
.marks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--bg-ffffff);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--bd-e2e8f0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.marks-table th,
.marks-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    text-align: left;
    white-space: nowrap;
}

.class-card-item {
    opacity: 0;
    animation: fadeInUp 0.45s ease forwards;
}

.entrance-fade {
    opacity: 0;
    animation: fadeInUp 0.45s ease forwards;
}

.student-exam-card.entrance-fade {
    animation: studentExamFadeIn 0.35s ease both;
}

@keyframes studentExamFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.marks-table tr:last-child td,
.marks-table tr:last-child th {
    border-bottom: none;
}
.marks-table th {
    background: var(--bg-f8fafc);
    font-weight: 500;
    color: var(--fg-475569);
    white-space: nowrap;
}
/* Sortable marksheet headers: every column keeps its own direction, and
   only the active arrow is lit. */
.marks-table th.marks-sort-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
}
.marks-table th.marks-sort-th:hover { color: var(--fg-1e293b); }
.marks-table th.marks-sort-th:focus-visible {
    outline: 2px solid var(--bg-2563eb, #2563eb);
    outline-offset: -2px;
}
.marks-sort-arrows {
    display: inline-flex;
    flex-direction: column;
    line-height: 0.62;
    margin-left: 0.22rem;
    vertical-align: middle;
    font-size: 0.55rem;
}
.marks-sort-arrows .sort-caret {
    opacity: 0.2;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.marks-table th.is-sort-primary .sort-caret-down,
.marks-table th.is-sort-reverse .sort-caret-up {
    opacity: 1;
    color: var(--fg-2563eb);
}
.marks-table tr:hover {
    background: var(--bg-f8fafc);
}
/* The pending CQ cell is merged across every row, so it belongs to the
   first row only — tint it whenever any row in the body is hovered, or the
   highlight stops dead at its edge. */
.marks-table tbody:has(tr:hover) .mark-seg-pending[rowspan] {
    background: var(--bg-f8fafc);
    transition: background 0.12s ease;
}
.marks-table th:nth-child(1),
.marks-table td:nth-child(1),
.marks-table th:nth-child(3),
.marks-table td:nth-child(3),
.marks-table th:nth-child(4),
.marks-table td:nth-child(4),
.marks-table th:nth-child(5),
.marks-table td:nth-child(5) {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}
.marks-table th:nth-child(2),
.marks-table td:nth-child(2) {
    width: auto;
    white-space: normal;
}

/* Edit mode matches view mode's column structure exactly:
   Merit | Student | Marks | Absent | Percentage (/ Time).
   The editable input lives in the Marks cell; the absent toggle
   has its own column. */
.marks-table-edit .marks-edit-merit {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.marks-table-edit .marks-edit-input-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.marks-table-edit .marks-edit-input-cell .mark-input {
    width: 80px;
    min-width: 80px;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.marks-table-edit .marks-edit-input-cell .mark-input:disabled {
    background: var(--bg-f1f5f9);
    color: var(--fg-94a3b8);
}

.marks-table-edit .marks-edit-absent-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.marks-table-edit .marks-edit-absent-cell .absent-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.marks-table-edit .marks-edit-absent-cell .absent-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bd-d1d9e0);
    border-radius: 50%;
    margin: 0;
    background: var(--bg-ffffff);
    transition: all 0.15s ease;
    position: relative;
    cursor: pointer;
}

/* The absent mark fills its circle red and draws the same tick every
   checkbox uses, in white — one tick shape, both themes. */
.marks-table-edit .marks-edit-absent-cell .absent-toggle input[type="checkbox"]:checked {
    background: var(--bg-dc2626);
    border-color: var(--bd-dc2626);
}

.marks-table-edit .marks-edit-absent-cell .absent-toggle input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 4px;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: translate(-50%, -70%) rotate(-45deg);
    transform-origin: center;
}

/* Percentage column — same look as view mode. */
.marks-table-edit .marks-edit-pct {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
.marks-table .mark-input {
    width: 80px;
    min-width: 80px;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}
.marks-table .mark-input:disabled {
    background: var(--bg-f1f5f9);
    color: var(--fg-94a3b8);
}
.marks-table .absent-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
}
.marks-table .absent-toggle input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bd-d1d9e0);
    border-radius: 50%;
    margin: 0;
    background: var(--bg-ffffff);
    transition: all 0.15s ease;
    position: relative;
    cursor: pointer;
}
.marks-table .absent-toggle input[type="checkbox"]:checked {
    background: var(--bg-dc2626);
    border-color: var(--bd-dc2626);
}
.marks-table .absent-toggle input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 4px;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: translate(-50%, -70%) rotate(-45deg);
    transform-origin: center;
}
.marks-table .absent-toggle .absent-label {
    font-size: 0.75rem;
    color: var(--fg-475569);
}
.marks-table .absent-text {
    color: var(--fg-dc2626);
    font-weight: 500;
    font-size: 0.85rem;
}
.marks-table .percentage-text {
    font-weight: 600;
    color: var(--fg-1e293b);
}

/* ============================================================ */
/*                    DROPDOWN MENU                             */
/* ============================================================ */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    /* all styles are applied inline via JS, so we only need to ensure clean base */
    list-style: none;
    margin: 0;
}
.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem 0.75rem;
    min-width: 40px;
    min-height: 40px;
    border-radius: 6px;
    color: var(--fg-64748b);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.08s ease;
    -webkit-tap-highlight-color: transparent;
}
@media (max-width: 768px) {
    .dropdown-toggle { min-width: 44px; min-height: 44px; }
}
/* Touch has no hover state to leave: a tap used to pin this background on
   the ⋮ until something else was tapped. Only a real pointer gets it. */
@media (hover: hover) and (pointer: fine) {
    .dropdown-toggle:hover {
        background: var(--bg-f1f5f9);
    }
}
/* A tap must not leave a grey block behind the ⋮ on a phone: the browser's
   tap highlight is off above, and a pressed / focused toggle stays flat. */
@media (hover: none), (pointer: coarse) {
    .dropdown-toggle:active,
    .dropdown-toggle:focus,
    .dropdown-toggle:focus-visible {
        background: none;
    }
}
.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--fg-1e293b);
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.08s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.dropdown-menu .dropdown-item:hover {
    background: var(--bg-f1f5f9);
}
.dropdown-menu .dropdown-item.danger {
    color: var(--fg-dc2626);
}
.dropdown-menu .dropdown-item.danger:hover {
    background: var(--bg-fef2f2);
}

/* ============================================================ */
/*                    LOADING SPINNER                           */
/* ============================================================ */
.loading-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--bd-e2e8f0);
    border-radius: 50%;
    border-top-color: var(--bd-1e293b);
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-container {
    text-align: center;
    padding: 2rem 0;
}

/* ============================================================ */
/*              LIQUID GLASS TOAST — auto-width                  */
/* ============================================================ */
.toast {
    position: relative;              /* was: fixed; bottom: 1.5rem; left: 50%; transform */
    transform: translateY(8px);      /* was: translateX(-50%) translateY(8px) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: max-content;
    max-width: min(92vw, 480px);
    padding: 0.7rem 1.3rem;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fg-1e293b);
    line-height: 1.4;
    text-align: left;
    background: rgba(var(--surface-rgb), 0.6);
    backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    -webkit-backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.12),
        0 0 20px rgba(0, 0, 0, 0.06),
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.5),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    word-wrap: break-word;
    margin: 0 auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================ */
/*                    TOAST STACK CONTAINER                      */
/*  All toasts live inside this fixed-position column, which     */
/*  centres horizontally and stacks them vertically at the       */
/*  bottom of the viewport.                                      */
/* ============================================================ */
.toast-stack {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;   /* newest at bottom, closest to edge */
    align-items: center;
    gap: 0.5rem;
    z-index: 2000;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 24px);
}

.toast-stack .toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 480px) {
    .toast-stack {
        bottom: 1rem;
        gap: 0.4rem;
    }
    .toast-stack .toast {
        max-width: calc(100vw - 24px);
        padding: 0.8rem 1.1rem;
        font-size: 0.82rem;
    }
    .toast-stack .toast .toast-text {
        white-space: normal;
    }
}

/* Icon slot — SVG centres with the text */
.toast .toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
}
.toast .toast-icon svg { display: block; }
.toast .toast-text {
    display: inline-block;
    white-space: nowrap;             /* keep short messages on one line */
}

/* Toast tone variants (icon + tint) */
.toast.toast-offline,
.toast.toast-online {
    backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    -webkit-backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    border-color: rgba(255, 255, 255, 0.62);
    box-shadow:
        0 10px 30px rgba(15, 23, 42, 0.14),
        inset 0 1px rgba(255, 255, 255, 0.72),
        inset 0 -1px rgba(255, 255, 255, 0.24);
}

.toast.toast-offline {
    background: rgba(241, 245, 249, 0.48);
    color: var(--fg-334155);
}
.toast.toast-offline .toast-icon { color: var(--fg-dc2626); }

.toast.toast-online {
    background: rgba(240, 253, 244, 0.48);
    color: var(--fg-166534);
}
.toast.toast-online .toast-icon { color: var(--fg-16a34a); }

/* Tones need their own dark surfaces. The text colour already comes from
   theme tokens, but the backgrounds above are fixed light tints — in dark
   mode the "No Internet" / "Back online" toast stayed a white slab. */
html[data-theme="dark"] .toast.toast-offline {
    background: rgba(42, 42, 42, 0.72);
    color: var(--fg-334155);
    border-color: rgba(248, 113, 113, 0.30);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .toast.toast-online {
    background: rgba(26, 42, 32, 0.72);
    color: var(--fg-166534);
    border-color: rgba(74, 222, 128, 0.30);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ============================================================ */
/*                      ANIMATIONS                              */
/* ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================================ */
/*                    MOBILE MENU                               */
/* ============================================================ */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-ffffff);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    padding: 0.75rem 1rem 0.4rem;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.mobile-menu.open {
    right: 0;
}
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(var(--ink-rgb), 0.3);
    z-index: 999;
    display: none;
}
.mobile-overlay.show {
    display: block;
}
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    margin-bottom: 0.75rem;
    flex: 0 0 auto;
}
.mobile-menu-header .branding {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.mobile-menu-header .branding span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-menu-header .hamburger-close {
    flex: 0 0 auto;
}
.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.mobile-menu-footer {
    margin-top: auto;
    padding-top: 0.55rem;
    border-top: 1px solid var(--bd-eef2f6);
    flex: 0 0 auto;
}
.mobile-menu-footer .mobile-profile-fab {
    display: block;
    width: 100%;
    margin-bottom: 0.3rem;
}
.mobile-menu-footer .mobile-profile-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    background: rgba(var(--surface-rgb), 0.8);
    color: var(--fg-1e293b);
    cursor: pointer;
    justify-content: flex-start;
    box-shadow: none;
}
.mobile-menu-footer .mobile-profile-dropdown {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-top: none;
    border-radius: 0 0 12px 12px;
    background: var(--bg-ffffff);
    padding: 0.25rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}
.mobile-menu-footer .btn {
    width: 100%;
    justify-content: center;
    margin-bottom: 0 !important;
}
.hamburger-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    display: none;
    padding: 0.25rem 0.5rem;
    color: var(--fg-1e293b);
    transition: transform 0.2s ease;
}

body.student-mobile-view .hamburger-toggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hamburger-toggle.rotated {
    transform: rotate(180deg);
}

.hamburger-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}
/* ============================================================ */
/*              LIQUID GLASS INSTALL BUTTON                      */
/* ============================================================ */
#install-app-btn {
    display: none;
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 100;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 52px;
    border-radius: 999px;
    padding: 0;
    justify-content: center;
    align-items: center;
    gap: 0;
    color: var(--fg-1e293b);
    font-weight: 600;

    /* Liquid Glass — byte-for-byte the nav pill's refraction recipe */
    background: rgba(var(--surface-rgb), 0.6);
    backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    -webkit-backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    isolation: isolate;

    border: 1px solid rgba(255, 255, 255, 0.55);

    /* Layered depth + rim + specular shine */
    box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.12),
        0 0 20px rgba(0, 0, 0, 0.06),
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.5),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);

    overflow: hidden;
    white-space: nowrap;
    flex-direction: row;
    margin: 0;
    cursor: pointer;
    transition:
        width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        min-width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        max-width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.3s ease,
        box-shadow 0.3s ease,
        opacity 0.3s ease;
}

/* The install buttons wear the nav's liquid glass, not the flat outline
   fill their .btn-outline class would otherwise give them. */
#install-app-btn,
#install-app-btn.btn-outline {
    background-color: rgba(var(--surface-rgb), 0.42) !important;
    background-image: none !important;
    backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    -webkit-backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
}

@supports not (backdrop-filter: url(#glass-distortion)) {
    #install-app-btn,
    #install-app-btn.btn-outline {
        background-color: rgba(var(--surface-rgb), 0.76) !important;
        backdrop-filter: blur(18px) saturate(180%) contrast(106%);
        -webkit-backdrop-filter: blur(18px) saturate(180%) contrast(106%);
    }
}

#install-app-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(
        155deg,
        rgba(255, 255, 255, 0.42) 0%,
        rgba(255, 255, 255, 0.12) 34%,
        transparent 68%,
        rgba(15, 23, 42, 0.08) 100%
    );
    box-shadow:
        inset 2px 2px 1px rgba(255, 255, 255, 0.62),
        inset -1px -1px 0 rgba(255, 255, 255, 0.16);
}

#install-app-btn .install-icon,
#install-app-btn .install-text {
    position: relative;
    z-index: 1;
}

@supports not (backdrop-filter: url(#glass-distortion)) {
    #install-app-btn {
        backdrop-filter: blur(20px) saturate(180%) contrast(108%);
        -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(108%);
    }
}

#install-app-btn.expanded::before {
    background: linear-gradient(
        155deg,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0.16) 36%,
        transparent 70%,
        rgba(15, 23, 42, 0.1) 100%
    );
}

html[data-theme="dark"] #install-app-btn::before {
    background: linear-gradient(
        155deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.035) 36%,
        transparent 70%,
        rgba(0, 0, 0, 0.24) 100%
    );
    box-shadow:
        inset 2px 2px 1px rgba(255, 255, 255, 0.12),
        inset -1px -1px 0 rgba(0, 0, 0, 0.22);
}

#install-app-btn.mobile-menu-open {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

#install-app-btn .install-icon {
    font-size: 1.15rem;
    width: 1.15rem;
    height: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#install-app-btn .install-text {
    display: inline-block;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateX(8px);
    transition:
        max-width 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.2s ease 0.15s,
        transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    font-weight: 600;
    line-height: 1;
}

#install-app-btn.expanded {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;
    padding: 0 0.95rem;
    border-radius: 999px;
    justify-content: center;
    gap: 0.55rem;
    transform: translateY(-2px);
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.16),
        0 0 32px rgba(0, 0, 0, 0.08),
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.6),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);
}

#install-app-btn.expanded .install-text {
    max-width: 120px;
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0s;
}

#install-app-btn:active {
    transform: translateY(-2px) !important;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.desktop-only {
    display: inline-flex;
}

.mobile-menu-nav .sidebar-link {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: var(--fg-334155);
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#student-mobile-menu .mobile-menu-nav .sidebar-link {
    display: flex;
}

.mobile-menu-nav .sidebar-link.visible {
    display: flex;
}

.mobile-menu-nav .sidebar-link.active {
    background-color: var(--bg-1e293b);
    color: var(--fg-ffffff);
}

.mobile-menu-nav .sidebar-link:hover {
    background: var(--bg-f1f5f9);
    color: var(--fg-1e293b);
}


.mobile-menu-nav .sidebar-link {
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

/* ========================================================================== */
/* [START] GLASS DROPDOWN + NO-BUMP ON PROFILE                                */
/* ========================================================================== */

/* ---------- 1. Opaque glass surface for both profile dropdowns ---------- */
.user-menu-dropdown,
.mobile-profile-dropdown {
    /* Solid token surface. The old translucent gradient + backdrop-filter
       forced a blurred-backdrop recompute on every theme swap, which is
       what made the menu recolour a beat after the page did. */
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    box-shadow: var(--elev-3);

    border-radius: 14px;
    overflow: hidden;
    padding: 0.4rem;
}

/* ---------- 2. Flush against the header (kill the 0.4rem gap) ---------- */
.user-menu-dropdown {
    top: 100%;
    margin-top: -1px;   /* overlap the header's 1px bottom rule cleanly */
}

/* ---------- 3. Mobile dropdown — same treatment, already flush ---------- */
.mobile-profile-dropdown {
    border-top: none;
    border-radius: 0 0 14px 14px;
}
.mobile-profile-dropdown.show {
    border-radius: 0 0 14px 14px;
}

/* ---------- 4. Menu item hover + radius ---------- */
.user-menu-dropdown .profile-menu-action,
.mobile-profile-dropdown .profile-menu-action {
    border-radius: 8px;
}
.user-menu-dropdown .profile-menu-action:hover,
.mobile-profile-dropdown .profile-menu-action:hover {
    background: rgba(15, 23, 42, 0.06);
}

/* ---------- 5. Cancel the tactile "click bump" on the profile trigger ---------- */
/* Overrides the global `button:active { transform: scale(0.96) }` rule. */
.user-menu-trigger:active,
.mobile-profile-trigger:active {
    transform: none !important;
    transition: none !important;
}

/* Belt and braces — freeze inner text/avatar/caret during click as well */
.user-menu-trigger:active .user-name,
.user-menu-trigger:active .user-avatar,
.user-menu-trigger:active .user-menu-caret,
.mobile-profile-trigger:active .mobile-profile-name,
.mobile-profile-trigger:active .user-avatar,
.mobile-profile-trigger:active .mobile-profile-caret {
    transform: none !important;
}

/* No tap highlight on the trigger */
.user-menu-trigger,
.mobile-profile-trigger {
    -webkit-tap-highlight-color: transparent;
}

/* ========================================================================== */
/* [END] GLASS DROPDOWN + NO-BUMP ON PROFILE                                  */
/* ========================================================================== */


/* ============================================================ */
/*                      ICON ALIGNMENT                          */
/* ============================================================ */
.btn i,
.sidebar-link i,
.branding i,
.dropdown-item i,
.mobile-menu-nav .sidebar-link i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    text-align: center;
}

/* ============================================================ */
/*                      SEARCH INPUT                            */
/* ============================================================ */
#student-search {
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--bg-ffffff);
}
.tab-header .btn {
    height: 36px;
}

/* ============================================================ */
/*                    SIDEBAR ACTIVE SYNC                       */
/* ============================================================ */
.sidebar-link.active,
.mobile-menu-nav .sidebar-link.active {
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
}

/* ============================================================ */
/*                    DROPDOWN OVERFLOW FIX                     */
/* ============================================================ */
.exam-card,
.class-table td,
.student-table td {
    overflow: visible !important;
}
.dropdown-menu {
    z-index: 200;
    min-width: 160px;
}

/* ============================================================ */
/*                      FOOTER                                  */
/* ============================================================ */
.app-footer {
    max-width: 1200px;
    margin: 1rem auto 0.5rem;
    padding: 0.75rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--fg-94a3b8);
    border-top: 1px solid var(--bd-eef2f6);
    width: 100%;
}

/* ============================================================ */
/*                RESPONSIVE (MOBILE)                           */
/* ============================================================ */
@media (max-width: 768px) {
    /* ---- Hamburger ---- */
    #global-app-header .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: inline-block;
    }
    .desktop-only {
        display: none;
    }
    .desktop-sidebar {
        display: none;
    }

    /* ---- Layout ---- */
    .class-layout {
        flex-direction: column;
        padding: 0 0.75rem;
        gap: 0.75rem;
        margin: 0.5rem auto 1rem;
        overflow: visible;
    }
    .class-content {
        width: 100%;
        overflow: visible;
    }

    /* ---- Sidebar (slide‑in) ---- */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100%;
        background: var(--bg-ffffff);
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        z-index: 20;
        padding: 1rem;
        border-right: 1px solid var(--bd-e2e8f0);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: block;
        border-right: 1px solid var(--bd-e2e8f0);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar:not(.open) {
        overflow-y: visible;
    }
    .sidebar-link span {
        display: inline;
        white-space: nowrap;
    }

    /* ---- Back row ---- */
    .back-row {
        padding: 0.5rem 0.75rem;
        margin: 0.25rem auto 0;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .class-title-large {
        font-size: 1.1rem;
        margin-right: 0;
        text-align: left;
        flex: 1;
    }

    .exam-card-header {
        flex-wrap: nowrap;
        gap: 0.4rem;
        padding: 0.6rem 0.75rem;
    }
    .exam-card-header .exam-title-cell {
        flex: 1 1 auto;
        min-width: 0;
        order: 0;
    }
    .exam-card-header .actions-cell {
        flex: 0 0 auto;
        justify-content: flex-end;
        order: 0;
        width: auto;
    }
    .exam-card-header .actions-wrapper {
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 0.3rem;
    }
    .exam-card-header .actions-wrapper .open-marks-btn {
        display: none;
    }
    .exam-details .stat-item {
        flex: 1 1 45%;
        min-width: 60px;
    }
    .exam-details .stat-value {
        font-size: 1.2rem;
    }
    .exam-details-container.expanded {
        padding: 0.5rem 0.75rem 0.75rem;
    }

    /* ---- Class table ---- */
    .class-table {
        border-spacing: 0 8px;
    }
    .class-table td {
        padding: 0.6rem 0.75rem;
        height: auto; /* let cells adjust naturally on mobile */
    }
    .class-table .class-name-cell {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0.3rem;
    }
    .class-table .class-name {
        font-size: 1rem;
    }
    .class-table .class-meta {
        gap: 0.6rem;
    }
    .class-table .class-meta-item {
        min-width: 30px;
    }
    .class-table .class-meta-label {
        font-size: 0.5rem;
    }
    .class-table .class-meta-value {
        font-size: 1rem;
    }
    .class-table .actions-cell {
        width: auto;
        white-space: nowrap;
    }

    /* ---- Student table ---- */
    .student-table {
        font-size: 0.8rem;
        border-radius: 8px;
    }
    .student-table td,
    .student-table th {
        padding: 0.4rem 0.5rem;
    }
    .student-table .actions-cell {
        width: auto;
    }

    /* ---- Marks table ---- */
    .marks-table {
        font-size: 0.8rem;
    }
    .marks-table td,
    .marks-table th {
        padding: 0.3rem 0.4rem;
    }
    .marks-table .mark-input {
        width: 60px;
        padding: 0.15rem 0.2rem;
        font-size: 0.8rem;
    }

    /* ---- Page & tab headers ---- */
    .page-header,
    .tab-header {
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-bottom: 0.75rem;
    }
    .page-header h2,
    .tab-header h2 {
        font-size: 1.1rem;
    }
    #student-search {
        width: 100px;
        height: 32px;
        font-size: 0.8rem;
    }
    .tab-header .btn {
        height: 32px;
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }

    /* ---- Dropdown ---- */
    .dropdown-menu {
        min-width: 130px;
        right: 0;
        left: auto;
    }

    /* ---- Dashboard ---- */
    .dashboard-main {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }

    /* ---- General overflow prevention ---- */
    .view {
        overflow: visible;
    }
    body {
        overflow-x: hidden;
        overflow-y: hidden;
    }
    body::-webkit-scrollbar {
        display: none;
    }
    
    body {
        scrollbar-width: none;
    }
    
    body {
        -ms-overflow-style: none;
    }
    .tab-content {
        overflow: visible;
    }
}

/* ============================================================ */
/*                    STUDENT VIEW - COMPLETE                    */
/* ============================================================ */

/* Student layout */
.student-layout {
    display: flex;
    max-width: 1200px;
    margin: 0.5rem auto 1.5rem;
    padding: 0 1.5rem;
    gap: 1.5rem;
    align-items: flex-start;
    position: relative;
    overflow-anchor: none;
}

#student-sidebar {
    width: 160px;
    position: sticky;
    top: 76px;
    left: 0;
    height: auto;
    max-height: calc(100vh - 92px);
    max-height: calc(100dvh - 92px);
    border-right: 1px solid var(--bd-e2e8f0);
    padding-right: 1rem;
    overflow-y: auto;
    box-sizing: border-box;
    overflow-anchor: none;
}

.student-content {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

.student-tab-content {
    animation: fadeIn 0.2s ease;
    overflow: visible;
}

/* Student page header */
#student-name-header {
    font-size: 1.5rem;
    font-weight: 650;
    text-align: center;
    width: 100%;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

/* Alert banner styling */
.student-alert-banner {
    margin-bottom: 1.5rem;
}

/* ============================================================ */
/*              STUDENT PAYMENT ALERT — SMOOTH EXPAND           */
/* ============================================================ */
.student-alert-banner {
    /* Base look */
    background: var(--bg-fef9e7);
    border-left: 4px solid var(--bd-f39c12);
    border-radius: 8px;
    color: var(--fg-7d6608);
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);

    /* Collapsed starting state */
    max-height: 0;
    padding: 0 1.1rem;
    opacity: 0;
    margin-bottom: 0;
    overflow: hidden;

    display: flex;
    align-items: flex-start;
    gap: 0.75rem;

    /* Smooth expand / collapse */
    transition:
        max-height  0.42s cubic-bezier(0.22, 1, 0.36, 1),
        padding     0.42s cubic-bezier(0.22, 1, 0.36, 1),
        opacity     0.32s ease 0.06s,
        margin-bottom 0.42s cubic-bezier(0.22, 1, 0.36, 1);

    will-change: max-height, opacity;
}

.student-alert-banner.expanded {
    max-height: 220px;
    padding: 0.85rem 1.1rem;
    opacity: 1;
    margin-bottom: 1rem;
}

/* Student exam cards */
.student-exam-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
@media (hover: hover) and (pointer: fine) {
    .student-exam-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    }
}

.student-exam-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
}
.student-exam-header .exam-date {
    font-size: 0.7rem;
    color: var(--fg-94a3b8);
    letter-spacing: 0.02em;
}
.student-exam-header .exam-title {
    font-size: 1.1rem;
    font-weight: 650;
}
.student-exam-marks {
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
}
.student-exam-marks .total-marks {
    color: var(--fg-94a3b8);
    font-weight: 400;
}
.student-exam-marks .absent-text {
    color: var(--fg-dc2626);
    font-weight: 500;
}

/* Student filters */
.student-exam-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center !important;
    flex-direction: row !important;
    background: var(--bg-ffffff);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--bd-eef2f6);
}

.filter-group.student-filter-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    flex: 1 1 auto;
}

.filter-group.student-filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fg-475569);
    white-space: nowrap;
    margin-bottom: 0;
}

.filter-group.student-filter-group .custom-select-wrapper {
    flex: 1 1 180px;
    min-width: 120px;
}

/* ============================================================ */
/*                    RESPONSIVE - MOBILE                        */
/* ============================================================ */

@media (max-width: 768px) {
    /* Layout */
    .student-layout {
        padding: 0 0.75rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #student-sidebar {
        display: none;
    }
    
    .student-content {
        width: 100%;
    }

    /* Greeting */
    #student-name-header {
        font-size: 1.3rem;
    }

    /* Show hamburger on mobile, hide user menu */
    #view-student .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: inline-flex !important;
    }

    #view-student .header-user-menu,
    #view-student .user-menu-trigger,
    #view-marks .header-user-menu,
    #view-marks .user-menu-trigger {
        display: none !important;
    }

    /* Exam cards on mobile */
    .student-exam-header {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    .student-exam-marks {
        font-size: 1rem;
    }

    /* Filters on mobile */
    .student-exam-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-group.student-filter-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .filter-group.student-filter-group .custom-select-wrapper {
        flex: 1 1 auto;
        min-width: 100px;
    }
}

/* ============================================================ */
/*                    DESKTOP - OVERRIDES                        */
/* ============================================================ */

@media (min-width: 769px) {
    /* Hide hamburger on desktop */
    #view-student .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: none !important;
    }

    /* Show user menu on desktop */
    #view-student .header-user-menu,
    #view-marks .header-user-menu {
        display: flex !important;
    }

    /* Greeting */
    #student-name-header {
        font-size: 1.5rem;
    }
}
/* ============================================================ */
/*                    RESPONSIVE                                */
/* ============================================================ */
@media (max-width: 768px) {
    .mobile-gear-menu {
        display: inline-block;
    }
    .desktop-only {
        display: none;
    }
    .student-main .page-header h2 {
        font-size: 1.3rem;
    }
    .student-exam-header {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    .student-exam-marks {
        font-size: 1rem;
    }
    .student-main {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }
}

/* ===== MARK COLOR CODING ===== */
.mark-pass {
    color: var(--fg-15803d) !important;
    font-weight: 600;
}
.mark-fail {
    color: var(--fg-b91c1c) !important;
    font-weight: 600;
}
.student-mark.mark-pass {
    color: var(--fg-15803d) !important;
}
.student-mark.mark-fail {
    color: var(--fg-b91c1c) !important;
}

/* Also for the absent text */
.absent-text {
    color: var(--fg-94a3b8) !important;
    font-weight: 500;
}

/* ===== 5-SPLIT STATS ===== */
/* Narrower cards simply break the line sooner: three per line on a tablet,
   two per line on a phone, and a stat left alone on the last line takes the
   whole width and centres its number. */
@media (max-width: 768px) {
    .exam-details .stat-item {
        flex: 1 1 30%;
    }
}

@media (max-width: 500px) {
    .exam-details .stat-item {
        flex: 1 1 45%;
    }
    .exam-details .stat-item:last-child {
        flex: 1 1 100%;
    }
}

/* ===== STUDENT DASHBOARD – 5‑split stats ===== */
/* Student header - always visible when in student view */
#view-student .app-header,
#student-app-header {
    display: block !important;
}

/* Student trigger - always visible in student view */
#view-student .user-menu-trigger,
#student-user-trigger {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Student trigger hidden state */
.user-menu-trigger.hidden,
#student-user-trigger.hidden {
    display: none !important;
}

/* Student header user menu */
#view-student .header-user-menu,
.student-header-user-menu {
    display: flex !important;
}

/* Ensure student header actions are visible */
#view-student .header-actions {
    display: flex !important;
}

/* ===== STUDENT EXAM CARD – spacing and padding ===== */
.student-exam-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

/* ===== CUSTOM FILTER DROPDOWNS ===== */
.filter-select-wrapper {
    position: relative;
    display: inline-block;
    min-width: 140px;
}

.reports-filters .filter-select-wrapper {
    display: block;
    width: 100%;
    min-width: 0;
}

.filter-select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--bg-ffffff);
    cursor: pointer;
    transition: border 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    color: var(--fg-1e293b);
    font-weight: 500;
    min-height: 36px;
}

.filter-select-wrapper select:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
}

.filter-select-wrapper select:hover {
    border-color: var(--bd-94a3b8);
}

.filter-select-wrapper select:disabled {
    background: var(--bg-f1f5f9);
    color: var(--fg-94a3b8);
    cursor: not-allowed;
}

.filter-select-wrapper .filter-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-94a3b8);
    pointer-events: none;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.filter-select-wrapper select:focus + .filter-arrow {
    color: var(--fg-1e293b);
}

.filter-select-wrapper select option {
    padding: 0.5rem;
    font-weight: 400;
}

.custom-select-menu {
    z-index: 9999 !important;
}
/* Filter container */
.exam-filters,
.student-exam-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center !important;
    flex-direction: row !important;
    background: var(--bg-ffffff);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--bd-eef2f6);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fg-475569);
    white-space: nowrap;
}

.filter-group .filter-select-wrapper {
    min-width: 140px;
}

/* Keep the compact Subject/Type controls label-and-select side by side. */
.exam-filter-group,
.student-filter-group {
    flex-wrap: nowrap;
    align-items: center;
}

.filter-group.exam-filter-group label,
.filter-group.student-filter-group label {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin-bottom: 0;
}

.exam-filter-group .custom-select-wrapper,
.student-filter-group .custom-select-wrapper {
    display: inline-block;
}

/* Clear filter button */
.filter-clear-btn {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-f8fafc);
    color: var(--fg-64748b);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-clear-btn:hover {
    background: var(--bg-f1f5f9);
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
}

.filter-clear-btn i {
    font-size: 0.65rem;
}

/* Responsive */
@media (max-width: 640px) {
    .filter-group {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    .filter-group.exam-filter-group,
    .filter-group.student-filter-group {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.4rem;
    }
    .filter-group.exam-filter-group .custom-select-wrapper,
    .filter-group.student-filter-group .custom-select-wrapper {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
    }
    .filter-group.exam-filter-group .custom-select-wrapper .input-field,
    .filter-group.student-filter-group .custom-select-wrapper .input-field {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .filter-group .filter-select-wrapper {
        min-width: 100px;
    }
    .filter-group label {
        font-size: 0.75rem;
    }
}

/* ===== EXAM TAGS - ABOVE DATE ===== */
.exam-tags-above {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.exam-tag {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.6;
}

.subject-tag {
    background: var(--bg-e0f2fe);
    color: var(--fg-0369a1);
}

.type-tag {
    background: var(--bg-fae8ff);
    color: var(--fg-7e22ce);
}

/* Student exam tags */
.student-exam-card .exam-tag {
    font-size: 0.55rem;
    padding: 0.05rem 0.5rem;
}

/* ===== COMBOBOX ===== */
.combo-wrapper {
    position: relative;
    width: 100%;
}
.combo-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-top: 2px;
}
.combo-dropdown .combo-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.08s ease;
    font-size: 0.875rem;
}
.combo-dropdown .combo-item:hover {
    background: var(--bg-f1f5f9);
}
.combo-dropdown .combo-item:not(:last-child) {
    border-bottom: 1px solid var(--bd-f1f5f9);
}

/* ===== FADE-IN ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

.fade-in-up-delay-1 {
    animation: fadeInUp 0.5s ease 0.1s forwards;
    opacity: 0;
}

.fade-in-up-delay-2 {
    animation: fadeInUp 0.5s ease 0.2s forwards;
    opacity: 0;
}

.fade-in-up-delay-3 {
    animation: fadeInUp 0.5s ease 0.3s forwards;
    opacity: 0;
}

.fade-in-up-delay-4 {
    animation: fadeInUp 0.5s ease 0.4s forwards;
    opacity: 0;
}

/* Stagger children */
.stagger-fade > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}

.stagger-fade > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-fade > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-fade > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-fade > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-fade > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-fade > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-fade > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-fade > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-fade > *:nth-child(9) { animation-delay: 0.45s; }
.stagger-fade > *:nth-child(10) { animation-delay: 0.5s; }
.stagger-fade > *:nth-child(11) { animation-delay: 0.55s; }
.stagger-fade > *:nth-child(12) { animation-delay: 0.6s; }

/* ===== REPORTS FILTERS & LAYOUT ===== */

/* ============================================================ */
/*              REPORTS — GENERATE BUTTON FADE                   */
/*  Pure opacity transition. No max-height collapse, no         */
/*  display:none toggle — the button keeps its slot so nothing  */
/*  reflows when it fades.                                      */
/* ============================================================ */
#generate-report-btn {
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}
#generate-report-btn.generating-hidden {
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
}

.reports-panel {
    padding: 0.5rem 0;
}

.word-header h1,
.report-title,
.section-title {
    font-family: 'League Spartan', 'Segoe UI', sans-serif;
    font-weight: 600;
}

.reports-filters {
    background: var(--bg-ffffff);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--bd-eef2f6);
    margin-bottom: 1rem;
}

/* ============================================================ */
/*  REPORTS FILTERS — DROPDOWN PAINT ORDER                       */
/*                                                              */
/*  Row 2 hosts the Subject + Exam Type custom-select dropdowns. */
/*  Those dropdowns absolutely-position downward and must overlay */
/*  Row 3 (the "Select Students" card) and beyond.               */
/*                                                              */
/*  Even if a stagger animation ever leaves a lingering stacking */
/*  context on the rows, explicitly z-indexing the dropdown row  */
/*  above its siblings guarantees the overlay wins.              */
/* ============================================================ */
.reports-filters .filter-row {
    position: relative;
}
.reports-filters .filter-row:nth-child(2) {
    z-index: 5;
}

.filter-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    align-items: flex-start;
}
.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    flex: 1 1 220px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

#pass-indication-group {
    min-width: 240px;
    flex: 1 1 260px;
}

.report-option-group {
    flex: 1 1 260px;
    min-width: 220px;
}

.option-help {
    margin-top: 0.45rem;
    color: var(--fg-64748b);
    font-size: 0.72rem;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.option-help i {
    font-size: 0.7rem;
    margin-top: 0.15rem;
    color: var(--fg-475569);
}

.filter-group.full-width {
    flex: 1 1 100%;
}

/* Date Range Inputs */
.date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.date-range input {
    flex: 1;
    min-width: 0;
}
.date-range span {
    color: var(--fg-94a3b8);
    font-size: 0.8rem;
}

/* Radio Group Row */
.radio-group {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
    min-height: 38px;
    row-gap: 0.5rem;
}

.radio-label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.4rem !important;
    /* .form-group label adds a margin-bottom; inside a radio row it is
       what made the gap to the group title look different. */
    margin-bottom: 0 !important;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--fg-334155);
    font-weight: 500;
    user-select: none;
    line-height: 1;
}

.radio-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--bd-cbd5e1);
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    display: grid;
    place-content: center;
    margin: 0;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.radio-label input[type="radio"]:checked {
    border-color: var(--bd-1e293b);
}

.radio-label input[type="radio"]:checked::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--bg-1e293b);
}

html[data-theme="dark"] .radio-label input[type="radio"] {
    background-color: #202020;
    border-color: #737373;
}

html[data-theme="dark"] .radio-label input[type="radio"]:checked {
    border-color: #d0d0d0;
}

html[data-theme="dark"] .radio-label input[type="radio"]:checked::before {
    background-color: #f0f0f0;
}

html[data-theme="dark"] .radio-label input[type="radio"]:focus-visible {
    outline: 2px solid #a6a6a6;
    outline-offset: 2px;
}

/* Actions Bar */
.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    align-items: center;
}

/* ===== STUDENT SELECTION GRID (HORIZONTAL CHIPS) ===== */
.student-selector-card {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* Subject and Type filters stay compact and centered at every viewport size. */
.exam-filters .filter-group.exam-filter-group,
.student-exam-filters .filter-group.student-filter-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    flex: 0 1 auto;
}

.exam-filters .filter-group.exam-filter-group .custom-select-wrapper,
.student-exam-filters .filter-group.student-filter-group .custom-select-wrapper {
    flex: 0 1 220px;
    min-width: 0;
}

@media (max-width: 640px) {
    .exam-filters .filter-group.exam-filter-group,
    .student-exam-filters .filter-group.student-filter-group {
        flex: 1 1 100%;
        width: 100%;
    }

    .exam-filters .filter-group.exam-filter-group .custom-select-wrapper,
    .student-exam-filters .filter-group.student-filter-group .custom-select-wrapper {
        flex: 1 1 auto;
        max-width: 220px;
    }
}

.student-selector-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.student-selector-header .student-search-box {
    flex: 1 1 180px;
    min-width: 0;
}
.student-selector-header .report-filter-wrapper {
    /* Auto-sized: only as wide as the label needs. Doesn't grow. */
    flex: 0 1 auto;
    min-width: 90px;
    max-width: 150px;
}
.student-selector-header .report-filter-wrapper .input-field {
    padding: 0.5rem 1.8rem 0.5rem 0.75rem;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.student-selector-header .select-all-toggle {
    flex: 0 0 auto;
}

.student-search-box {
    position: relative;
    flex: 1;
}

.student-search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-94a3b8);
    font-size: 0.85rem;
}

.student-search-box input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.85rem 0.5rem 2.2rem;
    border-radius: 8px;
    border: 1px solid var(--bd-cbd5e1);
    background: var(--bg-ffffff);
    font-size: 0.85rem;
    outline: none;
}

.student-search-box input:focus {
    border-color: var(--bd-1e293b);
}

/* Select All Header Button */
.select-all-toggle {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem !important;
    background: var(--bg-ffffff);
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--bd-cbd5e1);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fg-475569);
    user-select: none;
    white-space: nowrap;
    margin: 0 !important;
    opacity: 1;
    transform: none;
    animation: none !important;
}

.select-all-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-94a3b8);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    display: grid;
    place-content: center;
    margin: 0;
    flex-shrink: 0;
}

/* Reports' Select All follows the green of the student chips. */
.select-all-toggle input[type="checkbox"]:checked {
    background-color: var(--bg-16a34a);
    border-color: var(--bd-16a34a);
}

/* Horizontal Grid Chips */
.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.65rem;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
    width: 100%;
}

.student-chip {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
    background: var(--bg-ffffff);
    border: 1.5px solid var(--bd-e2e8f0);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    margin: 0 !important;
    transition: all 0.15s ease;
}

.student-chip-animate {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.35s ease forwards;
    animation-delay: var(--chip-delay, 0ms);
}

.student-chip:hover {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-ffffff);
}

.student-chip.selected {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-16a34a);
}

.student-chip input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-94a3b8);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    display: grid;
    place-content: center;
    margin: 0;
    flex-shrink: 0;
}

.student-chip input[type="checkbox"]:checked {
    background-color: var(--bg-16a34a);
    border-color: var(--bd-16a34a);
}

/* Shared custom-checkbox tick: absolute-positioned so centering
   is exact, regardless of parent box size. */
.select-all-toggle input[type="checkbox"]:checked::before,
.student-chip input[type="checkbox"]:checked::before,
.payment-select-all input[type="checkbox"]:checked::before,
.payment-student-checkbox:checked::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 4px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: translate(-50%, -70%) rotate(-45deg);
    transform-origin: center;
}

/* Ensure the checkbox itself is a positioning context */
.select-all-toggle input[type="checkbox"],
.student-chip input[type="checkbox"],
.payment-select-all input[type="checkbox"],
.payment-student-checkbox {
    position: relative;
}

.student-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-e2e8f0);
    color: var(--fg-475569);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

.student-chip.selected .student-avatar {
    background: var(--bg-dcfce7);
    color: var(--fg-15803d);
}

.student-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fg-334155);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

.timeframe-group {
    width: 100%;
    margin-bottom: 0.5rem;
}

/* Timeframe & Presets Layout */
.timeframe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.date-presets {
    display: flex;
    gap: 0.4rem;
}

.preset-btn {
    background: var(--bg-f1f5f9);
    border: 1px solid var(--bd-cbd5e1);
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-475569);
    cursor: pointer;
    transition: all 0.15s ease;
}

.preset-btn:hover {
    background: var(--bg-e2e8f0);
    color: var(--fg-1e293b);
}

.preset-btn.active {
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border-color: var(--bd-1e293b);
}

/* Download Button Transition & Fade Effect */
#download-pdf-btn {
    transition: opacity 0.25s ease, background-color 0.2s ease;
    min-width: 170px; /* Maintains stable button width during text changes */
}

.btn-fade-out {
    opacity: 0;
    pointer-events: none;
}

.btn-fade-in {
    opacity: 1;
}

/* ============================================================ */
/*              HIDE HEADER ON LOGIN VIEW                       */
/* ============================================================ */

/* Hide global header when login view is active */
#view-login.active-view ~ #global-app-header,
#view-login.active-view + #global-app-header,
body:has(#view-login.active-view) #global-app-header {
    display: none !important;
}

/* Alternative approach using header visibility */
#view-login.active-view #global-app-header {
    display: none !important;
}

/* Also hide when login view is visible */
#view-login[style*="display: block"] ~ #global-app-header {
    display: none !important;
}

/* Ensure header is hidden on login */
.view#view-login.active-view ~ .app-header {
    display: none !important;
}

/* Profile fade-in animation */
.profile-loading .user-avatar,
.profile-loading .user-name,
.profile-loading .user-menu-caret {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

.profile-visible .user-avatar,
.profile-visible .user-name,
.profile-visible .user-menu-caret {
    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

/* For mobile profile */
.mobile-profile-trigger.profile-loading .user-avatar,
.mobile-profile-trigger.profile-loading .mobile-profile-name,
.mobile-profile-trigger.profile-loading .mobile-profile-caret {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

.mobile-profile-trigger.profile-visible .user-avatar,
.mobile-profile-trigger.profile-visible .mobile-profile-name,
.mobile-profile-trigger.profile-visible .mobile-profile-caret {
    opacity: 1 !important;
    transition: opacity 0.3s ease;
}

/* ============================================================ */
/*                    OFFLINE MODAL                              */
/* ============================================================ */
body.admin-offline-locked {
    overflow: hidden !important;
    touch-action: none;
}

.offline-modal .modal-box {
    max-width: 360px;
    text-align: center;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
}

.offline-icon {
    margin: 0 auto 0;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    padding: 16px;
    border-radius: 50%;
    background: var(--bg-e0f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
}

.offline-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
}

/* WiFi arcs + dot — muted slate, matching the toast icon. */
.offline-icon svg .wifi,
.offline-icon svg .wifi-dot {
    stroke: var(--fg-64748b);
}

/* Crossing slash — the "no signal" mark. */
.offline-icon svg .slash {
    stroke: var(--fg-dc2626);
}

.offline-modal h1 {
    font-size: 1.3rem;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    color: var(--fg-1e293b);
    text-align: center;
    width: 100%;
}

.offline-modal p {
    color: var(--fg-64748b);
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
    text-align: center;
    width: 100%;
}

.offline-modal .btn {
    min-width: 140px;
    justify-content: center;
    transition: all 0.2s ease;
}

.offline-modal .btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.offline-modal .btn .fa-spin {
    animation: fa-spin 1s linear infinite;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================ */
/*                    PAYMENTS                                  */
/* ============================================================ */

/* ---------- Month List Cards (PLAIN — no color themes) ---------- */
.payment-month-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-month-card {
    background: var(--bg-ffffff);
    border: 1.5px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.payment-month-card:hover {
    border-color: var(--bd-cbd5e1);
}
.payment-month-card.highlight-month {
    border: 2px solid var(--fg-2563eb);
    background: var(--bg-ffffff);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.payment-month-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.payment-month-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fg-0f172a);
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 0;
}

.payment-due-badge {
    background: var(--bg-ef4444);
    color: var(--fg-ffffff);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
/* One stat per line: the monthly fee's own paid/exempt/due first, then
   each separately collected sector on its own line under it, so the
   card reads as a short list instead of one crowded row. */
.payment-month-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: right;
    margin-left: auto;              /* pins the list to the far right */
}
/* The monthly fee's own counts read as one line ("1 paid  2 due"),
   wrapping only when the card is too narrow to hold them. */
.payment-stat-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    column-gap: 0.55rem;
    row-gap: 0.05rem;
}
.payment-stat { white-space: nowrap; }
.payment-stat.paid   { color: var(--fg-16a34a); }
.payment-stat.exempt { color: var(--fg-64748b); }
.payment-stat.unpaid { color: var(--fg-dc2626); }
/* A separately collected sector gets a label row of its own: the name in
   plain text on the left, its status on the right in the same colour the
   statuses use everywhere else (red due, green paid, grey exempt). Both
   columns hang off the card's right edge, so the statuses line up under
   each other instead of each row drifting with its label. */
.payment-sector-stats {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    align-items: baseline;
    column-gap: 0.55rem;
    row-gap: 0.05rem;
    margin-top: 0.1rem;
}
.payment-sector-row { display: contents; }
.payment-sector-name {
    color: var(--fg-475569, #475569);
    font-weight: 600;
    text-align: left;
}
.payment-sector-status {
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}
.payment-sector-status.is-due    { color: var(--fg-dc2626, #dc2626); }
.payment-sector-status.is-paid   { color: var(--fg-16a34a, #16a34a); }
.payment-sector-status.is-exempt { color: var(--fg-64748b, #64748b); }

/* ---------- Detail Header ---------- */
.payment-detail-header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    background: var(--bg-ffffff);
    padding: 1rem 1.15rem;
    border-radius: 12px;
    border: 1px solid var(--bd-e2e8f0);
    width: 100%;
    box-sizing: border-box;
}

.payment-detail-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.payment-detail-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--fg-0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Summary Cards (COLOR-CODED) ---------- */
.payment-detail-summary-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
}

.payment-detail-summary-cards .payment-summary-card {
    flex: 1 1 0;
    min-width: 120px;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    border: 1.5px solid var(--bd-e2e8f0);
    background-color: var(--bg-ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    text-align: center;
    transition: all 0.15s ease-in-out;
}

.payment-summary-card .card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    display: block;
    color: var(--fg-64748b);
}

.payment-summary-card .card-value {
    font-size: 0.925rem;
    font-weight: 700;
    display: block;
    color: var(--fg-0f172a);
}

/* Paid — green */
.payment-summary-card.summary-paid {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-86efac);
}
.payment-summary-card.summary-paid .card-label { color: var(--fg-166534); }
.payment-summary-card.summary-paid .card-value { color: var(--fg-15803d); }

/* Due — red */
.payment-summary-card.summary-due {
    background: var(--bg-fef2f2);
    border-color: var(--bd-fca5a5);
}
.payment-summary-card.summary-due .card-label { color: var(--fg-991b1b); }
.payment-summary-card.summary-due .card-value { color: var(--fg-b91c1c); }

/* Exempt — grey */
.payment-summary-card.summary-exempt {
    background: var(--bg-f8fafc);
    border-color: var(--bd-cbd5e1);
}
.payment-summary-card.summary-exempt .card-label { color: var(--fg-475569); }
.payment-summary-card.summary-exempt .card-value { color: var(--fg-334155); }

/* Total — blue */
.payment-summary-card.summary-total {
    background: var(--bg-eff6ff);
    border-color: var(--bd-93c5fd);
}
.payment-summary-card.summary-total .card-label { color: var(--fg-1e40af); }
.payment-summary-card.summary-total .card-value { color: var(--fg-1e3a8a); }

/* ---------- Actions & Checkboxes ---------- */
.payment-detail-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.payment-select-all {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--fg-475569);
    cursor: pointer;
    user-select: none;
}

/* Base checkbox (payment checkboxes use the SVG tick) */
input[type="checkbox"],
.payment-select-all input[type="checkbox"],
.payment-student-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-94a3b8);
    border-radius: 4px;
    cursor: pointer;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.15s ease;
    vertical-align: middle;
    background-color: var(--bg-ffffff);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 11px 11px;
    display: inline-block;
    flex-shrink: 0;
}

input[type="checkbox"]:hover:not(:disabled),
.payment-select-all input[type="checkbox"]:hover:not(:disabled),
.payment-student-checkbox:hover:not(:disabled) {
    border-color: var(--bd-1e293b);
}

input[type="checkbox"]:checked,
.payment-select-all input[type="checkbox"]:checked,
.payment-student-checkbox:checked {
    background-color: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3.5 8.5 6.5 11.5 12.5 4.5'%3E%3C/polyline%3E%3C/svg%3E");
}

input[type="checkbox"]:disabled,
.payment-select-all input[type="checkbox"]:disabled,
.payment-student-checkbox:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- Table ---------- */
.payment-detail-table-wrapper {
    overflow: visible !important;
}

/* While a group switch slides, the wrapper becomes the window the two
   tables travel across: the outgoing one is lifted out of the flow so
   the incoming one sets the width and the height is free to tween. */
.payment-detail-table-wrapper.is-sliding {
    position: relative;
    overflow: hidden !important;
}
.payment-detail-table-wrapper.is-sliding > .payment-detail-table.is-slide-leaving {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
}
.payment-detail-table.is-drag-preview { pointer-events: none; }

.payment-detail-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    overflow: visible !important;
}

.payment-detail-table th,
.payment-detail-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--bd-f1f5f9);
    position: relative;
    z-index: 1;
}

.payment-detail-table th {
    background: var(--bg-f8fafc);
    font-weight: 600;
    color: var(--fg-475569);
    white-space: nowrap;
}

.payment-detail-table th:first-child { border-top-left-radius: 12px; }
.payment-detail-table th:last-child { border-top-right-radius: 12px; }
.payment-detail-table tr:last-child td:first-child { border-bottom-left-radius: 12px; }
.payment-detail-table tr:last-child td:last-child { border-bottom-right-radius: 12px; }

.payment-detail-table tr {
    position: relative;
    z-index: 1;
}

.payment-detail-table tr:hover,
.payment-detail-table tr:focus-within,
.payment-detail-table tr:has(.dropdown-menu.show) {
    z-index: 100 !important;
}

.payment-detail-table tr:last-child td {
    border-bottom: none;
}

.student-info-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    word-break: break-word;
}

.quick-actions-desktop {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.quick-actions-mobile {
    display: none;
}

/* ---------- Status Pills ---------- */
.payment-status {
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    font-size: 0.725rem;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}
.payment-status.status-paid   { background: var(--bg-dcfce7); color: var(--fg-15803d); }
.payment-status.status-exempt { background: var(--bg-f1f5f9); color: var(--fg-64748b); }
.payment-status.status-unpaid { background: var(--bg-fee2e2); color: var(--fg-b91c1c); }

/* ---------- Mobile Split Button ---------- */
.split-btn-group {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.split-btn-group .split-btn-main {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

/* ---------- Empty State ---------- */
.payment-empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--bg-ffffff);
    border-radius: 12px;
    border: 1px solid var(--bd-e2e8f0);
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .quick-actions-desktop { display: none; }
    .quick-actions-mobile  { display: block; }

    .payment-detail-table-wrapper {
        overflow-x: visible !important;
    }

    .payment-detail-table {
        table-layout: fixed;
    }

    .payment-detail-table th,
    .payment-detail-table td {
        padding: 0.45rem 0.35rem;
        white-space: normal !important;
    }

    .payment-detail-table th:nth-child(1),
    .payment-detail-table td:nth-child(1) { width: 28px; }

    .payment-detail-table th:nth-child(2),
    .payment-detail-table td:nth-child(2) { width: auto; }

    .payment-detail-table th:nth-child(3),
    .payment-detail-table td:nth-child(3) { width: 60px; text-align: center; }

    .payment-detail-table th:nth-child(4),
    .payment-detail-table td:nth-child(4) { width: 95px; text-align: right; }

    /* Month card stacks; chips stay left-aligned under the month name */
    .payment-month-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
    .payment-month-stats {
        align-items: flex-start;
        text-align: left;
        margin-left: 0;
        font-size: 0.78rem;
    }
    .payment-stat-row { justify-content: flex-start; }
    .payment-sector-stats { justify-content: start; }
}

@media (max-width: 480px) {
    .payment-detail-summary-cards .payment-summary-card {
        flex: 1 1 100%;
        min-width: 0;
    }
}

#view-student .app-header,
#student-app-header,
#view-marks .app-header,
#student-app-header-marks {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Desktop: hide hamburger, show user menu */
@media (min-width: 769px) {
    #view-student .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    #view-student .header-user-menu,
    #view-marks .header-user-menu {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    #view-student .user-menu-trigger,
    #view-marks .user-menu-trigger {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Mobile: show hamburger, hide user menu */
@media (max-width: 768px) {
    #view-student .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    #view-student .header-user-menu,
    #view-marks .header-user-menu,
    #view-student .user-menu-trigger,
    #view-marks .user-menu-trigger {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* ============================================================ */
/*          MOBILE MENU – OVERALL STYLES                        */
/* ============================================================ */
.mobile-menu {
    background: var(--bg-ffffff);
}

/* ============================================================ */
/*          MOBILE PROFILE TRIGGER & DROPDOWN                   */
/* ============================================================ */
.mobile-profile-fab {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
}

.mobile-profile-trigger {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.75rem 0.8rem;
    border-radius: 12px;
    background: rgba(var(--surface-rgb), 0.8);
    color: var(--fg-1e293b);
    cursor: pointer;
    justify-content: flex-start;
    text-align: left;
    /* Radius and the bottom border must never animate: the joint has to
       open and close in the same frame as aria-expanded flips. */
    transition: background 0.3s ease;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.mobile-profile-trigger .mobile-profile-name {
    flex: 1;
    font-weight: 700;
    color: var(--fg-1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.mobile-profile-trigger .user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-0f172a), var(--bg-475569));
    color: var(--fg-ffffff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 700;
    flex-shrink: 0;
}

.mobile-profile-caret {
    margin-left: auto;
    transition: transform 0.52s cubic-bezier(0.22, 1, 0.36, 1);
    font-size: 0.8rem;
    color: var(--fg-94a3b8);
}

/* The trigger keeps its full radius in every state. There is no
   "joined" square-bottom variant any more, so closing and opening
   can never leave a corner rounding late. */
/* The menu grows out of the profile button: while expanded the trigger's
   bottom is square and borderless and the dropdown has no top border, so
   the two read as one surface. Both flip with aria-expanded, so closing
   restores the rounding in the same frame — there is no class or timer
   left that could restore it late. */
.mobile-profile-trigger[aria-expanded="true"] {
    border-radius: 12px 12px 0 0;
    border-bottom-color: transparent;
    background: rgba(var(--surface-rgb), 0.95);
    transition: background 0.3s ease;
}

.mobile-profile-trigger[aria-expanded="true"] .mobile-profile-caret {
    transform: rotate(180deg);
}

/* Dropdown container – uses scaleY for super smooth animation */
.mobile-profile-dropdown {
    display: block;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top center;
    padding: 0 0.25rem;
    border-radius: 0 0 12px 12px;
    background: var(--bg-ffffff);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-top: none;
    /* A calm, longer glide instead of a snap: the panel unfolds and
       settles without overshoot, and closes on the same curve so both
       directions read as one motion. */
    transition: max-height 0.52s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.34s cubic-bezier(0.33, 1, 0.68, 1),
                transform 0.52s cubic-bezier(0.22, 1, 0.36, 1),
                padding 0.34s cubic-bezier(0.33, 1, 0.68, 1),
                box-shadow 0.34s ease;
    will-change: transform, opacity, max-height;
}

.mobile-profile-dropdown.show {
    max-height: 260px;
    opacity: 1;
    transform: scaleY(1);
    padding: 0.25rem 0.25rem;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 14px 28px -14px rgba(15, 23, 42, 0.28);
}

/* Dropdown items – match web style */
.mobile-profile-dropdown .profile-menu-action {
    width: 100%;
    font-size: 0.92rem;
    padding: 0.8rem 0.9rem;
    border-radius: 0px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mobile-profile-dropdown .profile-menu-action:hover {
    background: rgba(148, 163, 184, 0.08);
}

.mobile-profile-dropdown .profile-menu-action.danger {
    color: var(--fg-dc2626);
}
.mobile-profile-dropdown .profile-menu-action.danger:hover {
    background: var(--bg-fef2f2);
}

/* ============================================================ */
/*   ADMIN HEADER – HIDE USER MENU ON MOBILE, SHOW HAMBURGER    */
/* ============================================================ */
@media (max-width: 768px) {
    #global-app-header .header-user-menu,
    #global-app-header .user-menu-trigger {
        display: none;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }

    #global-app-header .hamburger-toggle {
        display: inline-flex;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }
}

/* ============================================================ */
/*   STUDENT HEADER – HIDE USER MENU ON MOBILE, SHOW HAMBURGER  */
/* ============================================================ */
@media (max-width: 768px) {
    #view-student .header-user-menu,
    #view-student .user-menu-trigger,
    #view-marks .header-user-menu,
    #view-marks .user-menu-trigger {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    #view-student .hamburger-toggle,
    #view-marks .hamburger-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

#view-marks.active-view #student-hamburger-toggle-marks,
#view-marks[style*="display: block"] #student-hamburger-toggle-marks {
    display: none !important;
}

/* ============================================================ */
/*                      MODALS                                  */
/* ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Notice modals: no scale on the full-screen wrapper (avoids the
   backdrop-filter re-layout that reads as "shaky"). The box itself
   slides in with a small translate. */
.notice-editor-modal,
#modal-notice-targeting,
#modal-notice-recipients,
#modal-notice-detail {
    animation: none;
}
.notice-editor-modal .modal-box,
#modal-notice-targeting .modal-box,
#modal-notice-recipients .modal-box,
#modal-notice-detail .modal-box {
    animation: modalBoxIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes modalBoxIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--ink-rgb), 0.35);
    backdrop-filter: blur(6px);
    transition: backdrop-filter 0.2s ease;
    z-index: 1;
}
.modal-box {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    margin: 1rem;
    background: var(--bg-ffffff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.settings-modal-box {
    max-width: 860px;
    padding: 1.25rem;
    max-height: min(78vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--bd-e2e8f0);
}
.settings-modal-header h3 {
    margin: 0;
}
.settings-close-btn {
    background: transparent;
    border: none;
    color: var(--fg-475569);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.35rem;
}
.settings-mobile-back {
    display: none;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    background: var(--bg-f1f5f9);
    border: none;
    border-radius: 8px;
    color: var(--fg-1e293b);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.settings-mobile-back:hover {
    background: var(--bg-e2e8f0);
}
.settings-mobile-back i {
    font-size: 0.72rem;
}
.settings-content-inner {
    min-height: 0;
}
.settings-modal-layout {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 1rem;
    min-height: 360px;
    max-height: calc(78vh - 88px);
    overflow: hidden;
}
.settings-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem;
    border-right: 1px solid var(--bd-e2e8f0);
    min-width: 0;
}
.settings-category {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-width: 0;
    padding: 0.75rem 0.85rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--fg-475569);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.08s ease, color 0.08s ease, opacity 0.08s ease;
    white-space: nowrap;
}
.settings-category:hover {
    background: var(--cat-hover);
    color: var(--fg-1e293b);
}
.settings-category.active {
    background: var(--cat-active);
    color: var(--fg-0f172a);
}
.settings-content {
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.settings-content::-webkit-scrollbar,
.settings-pane::-webkit-scrollbar {
    display: none;
}
.settings-pane {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.settings-pane.active {
    display: block;
}
.settings-panel-block {
    padding: 0.15rem 0 0.7rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    margin-bottom: 0.8rem;
}
.settings-panel-block.settings-panel-heading {
    border-bottom: none;
    padding-bottom: 0.3rem;
    margin-bottom: 0.6rem;
}

/* ============================================================ */
/*  SETTINGS FRAMES                                              */
/*                                                              */
/*  Each setting is its own bounded card so the settings screen  */
/*  reads as a list of independent controls, not a wall of       */
/*  toggles. Grouped settings (Payments + Prepaid + Alert) live  */
/*  in one frame that expands in place when the master toggle    */
/*  is on.                                                       */
/* ============================================================ */
.settings-frame {
    background: var(--surface-raised);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.7rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.settings-frame:hover {
    border-color: var(--bd-d1d9e0);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.settings-frame:last-child {
    margin-bottom: 0;
}
.settings-frame .settings-toggle {
    padding: 0;
    font-size: 0.95rem;
}
.settings-frame .settings-toggle > span i {
    color: var(--fg-64748b);
}
.settings-frame-help {
    margin: 0.3rem 0 0;
    font-size: 0.78rem;
    color: var(--fg-64748b);
    line-height: 1.45;
}

/* Inline field inside a settings frame (e.g. the maintenance return time). */
.settings-field {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px dashed var(--bd-eef2f6);
}
.settings-field > label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--fg-334155);
}
.settings-field .input-field {
    max-width: 16rem;
}
.settings-field .settings-frame-help {
    margin-top: 0.35rem;
}

/* Nested sub-frame — animated via grid-template-rows (0fr → 1fr)
   rather than max-height. The browser interpolates the grid track
   directly, without a full re-layout per frame. Matches the same
   pattern used by .recipient-group-body. */
.settings-subframe {
    display: grid;
    grid-template-rows: minmax(0, 0fr);
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    margin-top: 0;
    border-top: 1px solid transparent;
    transition:
        grid-template-rows 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        margin-top 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.24s ease,
        visibility 0s linear 0.34s;
}
.settings-subframe-content {
    min-height: 0;
    overflow: hidden;
}
.settings-subframe.expanded {
    grid-template-rows: minmax(0, 1fr);
    visibility: visible;
    pointer-events: auto;
    margin-top: 0.7rem;
    border-top-color: var(--bd-f1f5f9);
    transition:
        grid-template-rows 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        margin-top 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.24s ease,
        visibility 0s linear 0s;
}
.settings-subframe .settings-toggle {
    padding: 0.45rem 0;
    font-size: 0.9rem;
}
.settings-subframe .settings-toggle:first-child {
    padding-top: 0.7rem;
}
.settings-subframe .settings-frame-help {
    margin: 0.2rem 0 0.55rem;
}

@media (max-width: 640px) {
    .settings-frame { padding: 0.75rem 0.85rem; }
    .settings-frame .settings-toggle { font-size: 0.92rem; }
    .settings-subframe .settings-toggle { font-size: 0.86rem; }
}
.settings-panel-block h4 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}
.settings-panel-block p {
    margin: 0;
    color: var(--fg-64748b);
    line-height: 1.5;
}
.settings-password-form {
    display: block;
}
.settings-password-form .form-group.compact {
    margin-bottom: 0.85rem;
}
.settings-password-form .form-group.compact label {
    font-size: 0.78rem;
}
.settings-panel-block.muted {
    border-bottom: none;
    padding-bottom: 0;
}
.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0;
    color: var(--fg-334155);
    font-weight: 500;
}
.settings-toggle input {
    accent-color: var(--fg-0f172a);
}
.settings-action-btn {
    width: auto;
    margin-top: 0.75rem;
}
.storage-overview {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 1rem;
}
.storage-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--fg-0f172a);
    margin-bottom: 0.75rem;
}
.storage-progress {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: var(--bg-e2e8f0);
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.storage-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--bg-334155), var(--bg-0f172a));
}
.storage-meta {
    margin: 0 0 0.9rem;
    font-size: 0.9rem;
    color: var(--fg-475569);
}
.storage-tables {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.storage-row {
    padding: 0.75rem 0.8rem;
    border-radius: 10px;
    background: rgba(var(--surface-rgb), 0.75);
    border: 1px solid var(--bd-e2e8f0);
}
.storage-row strong {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.92rem;
}
.storage-row small {
    color: var(--fg-64748b);
}
.storage-progress-fill {
    display: flex;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.storage-progress .storage-seg {
    display: block;
    height: 100%;
    min-width: 2px;
    background-image: none;
    border-radius: 0;
}
.storage-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}
.storage-row-head strong { margin-bottom: 0; }
.storage-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px var(--bg-ffffff), 0 0 0 3px var(--bd-e2e8f0);
}
.modal-box h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--fg-475569);
}
.confirm-box .confirm-message {
    margin-bottom: 0.5rem;
    color: var(--fg-475569);
}
.confirm-box .confirm-instruction {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.confirm-box #confirm-input {
    margin-bottom: 0.75rem;
}
#confirm-proceed {
    opacity: 0.5;
    cursor: not-allowed;
    filter: saturate(0.7);
}
#confirm-proceed:not(:disabled) {
    opacity: 1;
    cursor: pointer;
    filter: saturate(1);
    background: var(--bg-dc2626);
    box-shadow: 0 8px 16px rgba(220, 38, 38, 0.18);
}

/* ============================================================ */
/*                    TOGGLE SWITCH                              */
/* ============================================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    position: absolute;
    pointer-events: none;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-cbd5e1);
    border-radius: 24px;
    transition: background 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--bg-ffffff);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--bg-1e293b);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.45;
    cursor: not-allowed;
}

.toggle-switch input:disabled + .toggle-slider::before {
    opacity: 0.6;
}

.toggle-switch:hover input:not(:disabled) + .toggle-slider {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(30, 41, 59, 0.1);
}

.toggle-switch:hover input:checked:not(:disabled) + .toggle-slider {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(30, 41, 59, 0.15);
}

/* ============================================================ */
/*         SETTINGS TOGGLE ROW (label + switch)                 */
/* ============================================================ */
.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    color: var(--fg-1e293b);
    font-weight: 500;
}

.settings-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.settings-toggle > span i {
    width: 1.2rem;
    text-align: center;
    color: var(--fg-64748b);
}
/* ============================================================ */
/*          SETTINGS MODAL – MOBILE FULLSCREEN DRILL-DOWN       */
/* ============================================================ */
@media (max-width: 768px) {
    /* Fullscreen modal shell */
    #modal-settings {
        align-items: stretch !important;
        justify-content: stretch !important;
        padding: 0 !important;
    }

    #modal-settings .settings-modal-box {
        width: 100%;
        max-width: none;
        max-height: none;
        height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 0.85rem 1rem 1rem;
        animation: settingsMobileIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    #modal-settings.closing .settings-modal-box {
        animation: settingsMobileOut 0.32s cubic-bezier(0.4, 0, 1, 1) forwards;
    }

    #modal-settings .modal-overlay {
        animation: settingsOverlayFadeIn 0.3s ease forwards;
    }

    #modal-settings.closing .modal-overlay {
        animation: settingsOverlayFadeOut 0.3s ease forwards;
    }

    @keyframes settingsMobileIn {
        from { opacity: 0; transform: translateY(18px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes settingsMobileOut {
        from { opacity: 1; transform: translateY(0); }
        to   { opacity: 0; transform: translateY(18px); }
    }

    @keyframes settingsOverlayFadeIn {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    @keyframes settingsOverlayFadeOut {
        from { opacity: 1; }
        to   { opacity: 0; }
    }

    /* ============================================================ */
    /*  HEADER — 3-column grid. Side columns are FIXED 36px, so the */
    /*  title NEVER shifts, whether the back button is shown or not.*/
    /*  The back button occupies its cell always; only its          */
    /*  `visibility` toggles. `display: none` would collapse the    */
    /*  column and left-align the title — that was the bug.         */
    /* ============================================================ */
    #modal-settings .settings-modal-header {
        flex-shrink: 0;
        display: grid;
        grid-template-columns: 36px 1fr 36px;
        align-items: center;
        justify-items: center;
        gap: 0;
        padding: 0.25rem 0 0.6rem 0;
        margin-bottom: 0.6rem;
        border-bottom: 1px solid var(--bd-e2e8f0);
    }

    /* Title: identical in both views */
    #modal-settings .settings-modal-header h3 {
        margin: 0;
        padding: 0;
        min-width: 0;
        max-width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        font-size: 1rem;
        font-weight: 600;
        line-height: 1.2;
        color: var(--fg-1e293b);
        text-align: center;
        overflow: hidden;
    }

    /* Hide the desktop-only sliders icon on mobile */
    #modal-settings .settings-modal-header h3 > i {
        display: none !important;
    }

    /* Title text handles ellipsis on long category names */
    #modal-settings .settings-modal-header h3 #settings-modal-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        display: inline-block;
    }

    /* ---- Back button: ALWAYS occupies its grid cell, only visible in drill-down ---- */
    #modal-settings .settings-mobile-back {
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--fg-475569);

        font-weight: 500;
        font-size: 1rem;
        line-height: 1;

        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        cursor: pointer;

        /* Reserved space — the grid column stays 36px even when hidden */
        visibility: hidden;
        pointer-events: none;
        transition: background 0.15s ease, color 0.15s ease;
    }

    /* Never show the "Categories" label on mobile */
    #modal-settings .settings-mobile-back .settings-back-label {
        display: none !important;
    }

    /* Reveal during drill-down — same geometry, just visible */
    #modal-settings:has(.settings-modal-layout.mobile-drilldown) .settings-mobile-back {
        visibility: visible;
        pointer-events: auto;
    }

    #modal-settings .settings-mobile-back:hover {
        background: rgba(15, 23, 42, 0.06);
        color: var(--fg-1e293b);
    }

    #modal-settings .settings-mobile-back:active {
        background: rgba(15, 23, 42, 0.10);
    }

    /* ---- Close button: identical geometry + hover to the back button ---- */
    #modal-settings .settings-close-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--fg-475569);

        font-size: 1rem;
        font-weight: 500;
        line-height: 1;

        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }

    #modal-settings .settings-close-btn:hover {
        background: rgba(15, 23, 42, 0.06);
        color: var(--fg-1e293b);
    }

    #modal-settings .settings-close-btn:active {
        background: rgba(15, 23, 42, 0.10);
    }

    /* Layout becomes a stack: sidebar OR content (not side-by-side) */
    #modal-settings .settings-modal-layout {
        display: block !important;
        position: relative;
        flex: 1;
        min-height: 0;
        overflow: hidden;
        grid-template-columns: none !important;
        max-height: none;
    }

    /* --- VIEW 1: Category list --- */
    #modal-settings .settings-sidebar {
        position: absolute;
        inset: 0;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0 !important;
        border-right: none !important;
        width: 100% !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }

    #modal-settings .settings-category {
        width: 100% !important;
        padding: 0.9rem 1rem !important;
        font-size: 0.92rem !important;
        font-weight: 600 !important;
        border-radius: 12px !important;
        background: var(--surface-raised) !important;
        border: 1px solid var(--bd-e2e8f0) !important;
        color: var(--fg-1e293b) !important;
        justify-content: flex-start;
        transition: background 0.15s ease, border-color 0.15s ease;
    }

    #modal-settings .settings-category::after {
        content: "\f054";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: 0.75rem;
        margin-left: auto;
    }

    #modal-settings .settings-category i {
        width: 1.3rem;
    }

    #modal-settings .settings-category.active,
    #modal-settings .settings-category:hover {
        background: var(--cat-hover) !important;
        color: var(--fg-0f172a) !important;
    }

    #modal-settings .settings-category.active {
        background: var(--surface-active) !important;
        color: var(--fg-0f172a) !important;
        border-color: var(--bd-d1d9e0) !important;
    }

    #modal-settings .settings-category.active i,
    #modal-settings .settings-category.active::after {
        color: var(--fg-1e293b) !important;
    }

    /* --- VIEW 2: Category content (slides in) --- */
    #modal-settings .settings-content {
        position: absolute;
        inset: 0;
        padding: 0 !important;
        background: var(--bg-ffffff);
        transform: translateX(100%);
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #modal-settings .settings-content-inner {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    #modal-settings .settings-content-inner::-webkit-scrollbar {
        display: none;
    }

    /* Drill-down trigger state */
    #modal-settings .settings-modal-layout.mobile-drilldown .settings-sidebar {
        transform: translateX(-100%);
    }

    #modal-settings .settings-modal-layout.mobile-drilldown .settings-content {
        transform: translateX(0);
    }

    /* Single scroll container — panes grow naturally */
    #modal-settings .settings-pane {
        height: auto;
        overflow: visible;
        padding: 0 !important;
    }

    #modal-settings .settings-pane.active {
        animation: settingsPaneIn 0.28s ease;
    }

    @keyframes settingsPaneIn {
        from { opacity: 0; transform: translateX(16px); }
        to   { opacity: 1; transform: translateX(0); }
    }

    #modal-settings .settings-panel-block h4 { font-size: 0.95rem; }
    #modal-settings .settings-panel-block p { font-size: 0.82rem; }

    #modal-settings .settings-toggle {
        padding: 0.6rem 0;
        font-size: 0.88rem;
    }

    #modal-settings #settings-payment-nested {
        padding-left: 0.75rem;
        margin-left: 0.15rem;
    }

    #modal-settings .settings-action-btn {
        width: 100%;
        justify-content: center;
    }

    /* Storage adjustments */
    #modal-settings .storage-overview { padding: 0.75rem; }
    #modal-settings .storage-header-row { font-size: 0.85rem; }
    #modal-settings .storage-row { padding: 0.55rem 0.65rem; }
    #modal-settings .storage-row strong { font-size: 0.82rem; }
    #modal-settings .storage-row small { font-size: 0.72rem; }
}

/* Small phones */
/* ============================================================ */
/*  SETTINGS SAVE-ON-CLOSE LOADER                                */
/*                                                              */
/*  Shown only if flushing pending changes takes longer than    */
/*  150 ms on close. Blurs the modal body and centres a small   */
/*  spinner so the user gets immediate feedback without the     */
/*  close animation being cancelled.                            */
/* ============================================================ */
.settings-saving-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--surface-rgb), 0.55);
    backdrop-filter: blur(3px) saturate(140%);
    -webkit-backdrop-filter: blur(3px) saturate(140%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: inherit;
    animation: fadeIn 0.15s ease;
}
.settings-saving-spinner {
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--bd-cbd5e1);
    border-top-color: var(--bd-1e293b);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@media (max-width: 480px) {
    #modal-settings .settings-modal-box {
        padding: 0.7rem 0.8rem 0.9rem !important;
    }

    /* Keep the header grid in sync with the smaller hit targets */
    #modal-settings .settings-modal-header {
        grid-template-columns: 32px 1fr 32px;
    }

    #modal-settings .settings-mobile-back,
    #modal-settings .settings-close-btn {
        width: 32px;
        height: 32px;
    }

    #modal-settings .settings-modal-header h3 {
        font-size: 0.95rem;
    }

    #modal-settings .settings-category {
        padding: 0.8rem 0.9rem !important;
        font-size: 0.85rem !important;
    }

    #modal-settings .settings-toggle {
        font-size: 0.82rem;
    }
}

/* ============================================================ */
/*          SETTINGS MODAL – CLEAN ANIMATIONS + HELPERS         */
/* ============================================================ */

body.modal-open #install-app-btn {
    display: none;
    opacity: 0.4;
    pointer-events: none;
    transition: filter 0.25s ease, opacity 0.25s ease;
}

#install-app-btn {
    transition: filter 0.3s ease, opacity 0.3s ease,
                width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                min-width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                max-width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                border-radius 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                padding 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.3s ease,
                box-shadow 0.3s ease;
}

.settings-category,
.settings-category i,
.settings-category::before {
    color: var(--fg-475569);
}
.settings-category:hover,
.settings-category:hover i {
    color: var(--fg-1e293b);
}
.settings-category.active,
.settings-category.active i {
    color: var(--fg-0f172a);
}
.settings-category i {
    opacity: 1 !important;
}

@media (max-width: 768px) {
    #modal-settings .settings-modal-layout:not(.mobile-drilldown) .settings-category.active {
        background: var(--bg-f8fafc) !important;
        color: var(--fg-1e293b) !important;
        border-color: var(--bd-e2e8f0) !important;
    }
    #modal-settings .settings-modal-layout:not(.mobile-drilldown) .settings-category.active i,
    #modal-settings .settings-modal-layout:not(.mobile-drilldown) .settings-category.active::after {
        color: var(--fg-1e293b) !important;
    }
    #modal-settings .settings-modal-layout.mobile-drilldown .settings-category.active {
        background: var(--bg-1e293b) !important;
        color: var(--fg-ffffff) !important;
        border-color: var(--bd-1e293b) !important;
    }
    #modal-settings .settings-modal-layout.mobile-drilldown .settings-category.active i,
    #modal-settings .settings-modal-layout.mobile-drilldown .settings-category.active::after {
        color: var(--fg-ffffff) !important;
    }
    .settings-category,
    .settings-category i,
    .settings-category::before {
        color: var(--fg-1e293b);
    }
}

@media (max-width: 768px) {
    body.modal-open #install-app-btn {
        display: none !important;
    }
}
/* ============================================================ */
/*              STUDENTS TAB — HEADER CONTROLS                  */
/* ============================================================ */
/* Stack the heading and controls vertically (only in Students tab) */
#tab-students .tab-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}
#tab-students .tab-header h2 {
    margin: 0;
}

.student-header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

/* Filter pinned to the far left */
.student-header-controls .student-filter-wrapper {
    flex-shrink: 0;
    min-width: 0;
}

.student-header-controls .student-filter-wrapper .input-field {
    width: 140px;               /* comfortable desktop width */
    height: 36px;
    padding: 0.4rem 1.7rem 0.4rem 0.7rem;
    cursor: pointer;
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.student-header-controls .student-filter-wrapper .filter-arrow {
    right: 0.6rem;
    font-size: 0.7rem;
}

/* Search absorbs the free space and pushes itself + add-button to the right.
   margin-left:auto keeps them right-aligned even when the filter is hidden. */
.student-header-controls #student-search {
    flex: 0 1 240px;
    min-width: 0;
    height: 36px;
    width: auto;
    margin-left: auto;
}

.student-header-controls #create-student-btn {
    flex-shrink: 0;
    height: 36px;
    white-space: nowrap;
}

/* ---- Mobile: single row, filter left, search grows, add → icon only ---- */
@media (max-width: 640px) {
    #tab-students .tab-header {
        gap: 0.5rem;
    }
    #tab-students .tab-header h2 {
        font-size: 1.05rem;
    }

    .student-header-controls {
        gap: 0.35rem;
    }

    /* Search gets the remaining space */
    .student-header-controls #student-search {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    /* Filter stays as tight as possible on phones */
    .student-header-controls .student-filter-wrapper .input-field {
        width: auto;
        min-width: 52px;
        max-width: 78px;
        padding: 0.4rem 1.4rem 0.4rem 0.5rem;
        font-size: 0.78rem;
    }
    .student-header-controls .student-filter-wrapper .filter-arrow {
        right: 0.4rem;
        font-size: 0.62rem;
    }

    /* Add button collapses to icon only */
    .student-header-controls #create-student-btn {
        padding: 0.5rem 0.55rem;
        min-width: 34px;
        justify-content: center;
        gap: 0;
    }
    .student-header-controls #create-student-btn .btn-add-text {
        display: none;
    }
}

/* ============================================================ */
/*                    STUDENT CARDS                              */
/* ============================================================ */
.student-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    animation: cbsParentFade 220ms ease-out;
}

/* ------------------------------------------------------------ */
/*  DESKTOP                                                       */
/* ------------------------------------------------------------ */
.student-card-item {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: box-shadow 0.15s ease, background 0.08s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.student-card-item:hover {
    background: var(--bg-ffffff);
    border-color: var(--bd-dbe2ea);
}

.student-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-eef2f7), var(--bg-dbe3ec));
    color: var(--fg-475569);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    user-select: none;
}
.user-avatar.avatar-science,
.student-card-avatar.avatar-science {
    background: linear-gradient(135deg, var(--bg-dbeafe), var(--bg-bfdbfe)); color: var(--fg-1e40af);
}
.user-avatar.avatar-humanities,
.student-card-avatar.avatar-humanities {
    background: linear-gradient(135deg, var(--bg-fef3c7), var(--bg-fde68a)); color: var(--fg-92400e);
}
.user-avatar.avatar-business,
.student-card-avatar.avatar-business {
    background: linear-gradient(135deg, var(--bg-dcfce7), var(--bg-bbf7d0)); color: var(--fg-166534);
}

.student-card-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* Title: name + tag share the same inline flow on desktop.
   Natural whitespace between them (no margin-left) means the
   tag hugs the name's last word — and if it ever wraps to its
   own line, the leading space collapses, so it aligns flush
   with the name's left edge. */
.student-card-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--fg-1e293b);
}

.student-card-name {
    overflow-wrap: break-word;
    word-break: break-word;
}

.student-card-tag {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.4rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.7;
    white-space: nowrap;
}
.student-card-tag.tag-science    { background: var(--bg-dbeafe); color: var(--fg-1e40af); }
.student-card-tag.tag-humanities { background: var(--bg-fef3c7); color: var(--fg-92400e); }
.student-card-tag.tag-business   { background: var(--bg-dcfce7); color: var(--fg-166534); }

.student-card-mobile {
    flex: 0 0 auto;
    font-size: 0.96rem;
    color: var(--fg-64748b);
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.student-card-last-seen {
    flex: 0 0 100%;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--fg-94a3b8);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-card-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ------------------------------------------------------------ */
/*  MOBILE                                                        */
/*                                                                */
/*    [AV]   SCIENCE                                              */
/*           Mohammad Sayad Uddin Tahsin              ⋮           */
/*           +8801976015184                                       */
/*           LAST SEEN TODAY 2:36 AM                              */
/*                                                                */
/*  • Tag on top, its own line, flush with the name's left.       */
/*  • Avatar and ⋮ out of flow, both vertically centered.         */
/*  • Tight row-gap (0.15rem) between stacked lines.              */
/*  • Fonts bumped up across the board.                           */
/* ------------------------------------------------------------ */
@media (max-width: 640px) {
    .student-card-item {
        position: relative;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0;
        row-gap: 0;
        padding: 0.7rem 2.4rem 0.7rem calc(0.85rem + 38px + 0.55rem);
    }
    .student-card-name {
        flex: 1 1 auto;
        min-width: 0;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    /* Pinned to the header row, never to the card's vertical centre: an
       inline report grows the card, and centring the avatar / ⋮ made them
       slide up the moment it opened. */
    .student-card-avatar {
        position: absolute;
        top: 0.7rem;
        left: 0.85rem;
        transform: none;
        width: 38px;
        height: 38px;
        font-size: 0.8rem;
    }

    .student-card-actions {
        position: absolute;
        top: 0.72rem;
        right: 0.6rem;
        transform: none;
        margin: 0;
    }

    /* Dissolve the info wrapper so its children (title, last-seen)
       become direct flex children of the card — same trick used to
       slot the mobile number between them. */
    .student-card-info {
        display: contents;
    }

    .student-card-title {
        order: 1;
        flex: 1 1 100%;
        min-width: 0;
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
        font-size: 0.96rem;
        line-height: 1.2;
    }

    .student-card-mobile {
        order: 2;
        flex: 1 1 100%;
        font-size: 0.82rem;
        font-weight: 500;
        text-align: left;
    }
    .student-card-tag {
        flex: 0 0 auto;
        align-self: flex-start;
        margin-left: 0;
        font-size: 0.58rem;
        padding: 0.08rem 0.5rem;
    }
    .student-card-last-seen {
        order: 3;
        flex: 1 1 100%;
        font-size: 0.65rem;
        line-height: 1.2;
    }
}
/* ============================================================ */
/*              FILTER FADE ANIMATIONS                          */
/* ============================================================ */
.filter-fade-out {
    animation: filterFadeOut 0.24s ease forwards !important;
    pointer-events: none !important;
}
@keyframes filterFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
}

.filter-fade-in {
    animation: filterFadeIn 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}
@keyframes filterFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================================ */
/*              REQUIRED FIELD MARKERS                          */
/* ============================================================ */
.required-star {
    color: var(--fg-dc2626);
    margin-left: 2px;
    font-weight: 700;
    font-size: 0.9em;
    line-height: 1;
}

.hint-text {
    font-weight: 400;
    color: var(--fg-94a3b8);
    font-size: 0.82em;
    margin-left: 2px;
}

/* ============================================================ */
/*         MODAL BOX — cap height & scroll (non-settings)       */
/* ============================================================ */
.modal-box:not(.settings-modal-box) {
    max-height: calc(100vh - 2rem);
    /* dvh tracks mobile browser chrome + keyboard. */
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.modal-box:not(.settings-modal-box)::-webkit-scrollbar {
    width: 6px;
}
.modal-box:not(.settings-modal-box)::-webkit-scrollbar-track {
    background: transparent;
}
.modal-box:not(.settings-modal-box)::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
.modal-box:not(.settings-modal-box)::-webkit-scrollbar-thumb:hover {
    background: var(--bg-94a3b8);
}

@media (max-width: 640px) {
    .modal-box:not(.settings-modal-box) {
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
        margin: 0.5rem;
    }
}

/* ============================================================ */
/*              EXAM MODAL — GROUP PICKER                       */
/* ============================================================ */
.exam-groups-container {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.exam-groups-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    min-height: 26px;
}
.exam-groups-header .select-all-toggle {
    padding: 0.25rem 0.6rem !important;
    font-size: 0.75rem !important;
    gap: 0.4rem !important;
    line-height: 1 !important;
    border-radius: 6px !important;
}
.exam-groups-header .select-all-toggle input[type="checkbox"] {
    width: 15px !important;
    height: 15px !important;
    margin: 0 !important;
}
.exam-groups-header .select-all-toggle span {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.exam-groups-count {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    font-weight: 500;
    white-space: nowrap;
}

/* Scrollable chip area — caps modal height */
.exam-groups-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 30px;
    max-height: 132px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.exam-groups-grid::-webkit-scrollbar { width: 6px; }
.exam-groups-grid::-webkit-scrollbar-track { background: transparent; }
.exam-groups-grid::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
.exam-groups-grid::-webkit-scrollbar-thumb:hover { background: var(--bg-94a3b8); }

.group-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1.5px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-475569);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    line-height: 1.3;
}
.group-chip:hover { border-color: var(--bd-cbd5e1); background: var(--bg-f8fafc); }
.group-chip.selected {
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border-color: var(--bd-1e293b);
}
.exam-groups-help {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    margin: 0;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}
.exam-groups-help i { margin-top: 0.15rem; color: var(--fg-94a3b8); }

/* Examinees tag on exam cards */
.exam-tag.examinees-tag {
    background: var(--bg-fef3c7);
    color: var(--fg-92400e);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.exam-tag.examinees-tag i { font-size: 0.55rem; margin-right: 0.15rem; }


/* ============================================================ */
/*         EXAM MODAL — FIXED HEADER/ACTIONS, BODY SCROLLS      */
/* ============================================================ */
#modal-exam .modal-box {
    padding: 0;
    height: min(560px, calc(100vh - 2rem));
    max-height: min(560px, calc(100vh - 2rem));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modal-exam .modal-box > h3 {
    flex-shrink: 0;
    padding: 1.5rem 1.5rem 0 1.5rem;
    /* A little more air under the config title, so the first field
       (Title) does not sit tight against it once the body scrolls. */
    margin: 0 0 1.5rem 0;
}

#modal-exam .modal-box > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Scrollable body — only this part scrolls */
#modal-exam .exam-form-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
#modal-exam .exam-form-body::-webkit-scrollbar { width: 6px; }
#modal-exam .exam-form-body::-webkit-scrollbar-track { background: transparent; }
#modal-exam .exam-form-body::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
#modal-exam .exam-form-body::-webkit-scrollbar-thumb:hover { background: var(--bg-94a3b8); }

/* Stationary action row — sits below the scrollable body */
#modal-exam .modal-actions {
    flex-shrink: 0;
    padding: 1rem 1.5rem 1.5rem 1.5rem;   /* bottom padding matches modal top */
    border-top: 1px solid var(--bd-eef2f6);
    background: var(--bg-ffffff);
    margin: 0;
}

@media (max-width: 640px) {
    #modal-exam .modal-box {
        height: min(520px, calc(100vh - 1rem));
        max-height: min(520px, calc(100vh - 1rem));
        margin: 0.5rem;
    }
    #modal-exam .modal-box > h3 { padding: 1.25rem 1.25rem 0 1.25rem; margin-bottom: 1.25rem; }
    #modal-exam .exam-form-body { padding: 0 1.25rem; }
    #modal-exam .modal-actions { padding: 0.85rem 1.25rem 1.25rem 1.25rem; }
}

/* ============================================================ */
/*  TEACHER MODAL — fixed header + actions, body scrolls         */
/*                                                              */
/*  Same three-slot pattern as the exam modal: h3 pinned top,   */
/*  modal-actions pinned bottom, only .teacher-form-body scrolls. */
/*  Inner max-height caps on .subjects-tree and                  */
/*  .class-admin-picker are released inside this modal so there  */
/*  is exactly ONE scrollbar, not three stacked ones.            */
/* ============================================================ */
#modal-teacher .modal-box {
    padding: 0;
    height: min(620px, calc(100vh - 2rem));
    height: min(620px, calc(100dvh - 2rem));
    max-height: min(620px, calc(100vh - 2rem));
    max-height: min(620px, calc(100dvh - 2rem));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modal-teacher .modal-box > h3 {
    flex-shrink: 0;
    padding: 1.5rem 1.5rem 0 1.5rem;
    margin: 0 0 1rem 0;
}

#modal-teacher .modal-box > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#modal-teacher .teacher-form-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.15rem 1.5rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}

#modal-teacher .teacher-form-body::-webkit-scrollbar { width: 6px; }
#modal-teacher .teacher-form-body::-webkit-scrollbar-track { background: transparent; }
#modal-teacher .teacher-form-body::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
#modal-teacher .teacher-form-body::-webkit-scrollbar-thumb:hover { background: var(--bg-94a3b8); }

#modal-teacher .modal-actions {
    flex-shrink: 0;
    padding: 1rem 1.5rem 1.5rem 1.5rem;
    border-top: 1px solid var(--bd-eef2f6);
    background: var(--bg-ffffff);
    margin: 0;
}

/* Release inner scroll caps inside this modal — the body is now the
   single scroll surface. Keeps the tree fully expandable and the
   picker shows every class without an inner scrollbar. */
#modal-teacher .subjects-tree {
    max-height: none;
    overflow-y: visible;
}

#modal-teacher .class-admin-picker {
    max-height: none;
    overflow-y: visible;
}

@media (max-width: 640px) {
    #modal-teacher .modal-box {
        height: min(560px, calc(100vh - 1rem));
        height: min(560px, calc(100dvh - 1rem));
        max-height: min(560px, calc(100vh - 1rem));
        max-height: min(560px, calc(100dvh - 1rem));
        margin: 0.5rem;
    }
    #modal-teacher .modal-box > h3 { padding: 1.25rem 1.25rem 0 1.25rem; }
    #modal-teacher .teacher-form-body { padding: 0.15rem 1.25rem 0.5rem; }
    #modal-teacher .modal-actions { padding: 0.85rem 1.25rem 1.25rem 1.25rem; }
}

/* Mobile-only stacking for #modal-online-exam actions —
   Cancel + Save Draft share a row, Publish takes the full
   width below. Buttons keep the standard .btn padding. */
@media (max-width: 640px) {
    #modal-online-exam .modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.75rem 1rem 0.9rem;
    }
    #modal-online-exam .modal-actions > button {
        width: 100%;
        justify-content: center;
    }
    #modal-online-exam .modal-actions #modal-online-cancel {
        order: 1;
    }
    #modal-online-exam .modal-actions #online-save-draft {
        order: 2;
    }
    #modal-online-exam .modal-actions #online-publish {
        order: 3;
        grid-column: 1 / -1;
    }
}


/* ============================================================ */
/*              FIX: DOUBLE CHECKMARK ON CUSTOM CHECKBOXES      */
/* ============================================================ */
/* Ticks now come from the shared SVG in ONE CHECKBOX EVERYWHERE;
   the old ::before ticks and this suppression are gone. */

/* ============================================================ */
/*              STUDENTS — GROUP STATS ROW                      */
/* ============================================================ */
.student-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.student-stat-card {
    /* flex-basis 22% = at most 4 per row (5 would need 110%). */
    flex: 1 1 22%;
    min-width: 0;
    padding: 0.6rem 0.8rem;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.1rem;

    background: var(--bg-ffffff);
    border: 1.5px solid var(--bd-e2e8f0);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.student-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

@media (max-width: 640px) {
    .student-stat-card { flex: 1 1 42%; }
}
.student-stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    line-height: 1.2;
}

.student-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    line-height: 1.1;
}

.student-stat-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.student-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    line-height: 1.1;
}

/* ---- Total: inverted, matches app's dark accent ---- */
.student-stat-card.stat-total {
    background: var(--bg-f1f5f9);
    border-color: var(--bd-cbd5e1);
}
.student-stat-card.stat-total .student-stat-label { color: var(--fg-64748b); }
.student-stat-card.stat-total .student-stat-value { color: var(--fg-1e293b); }

/* ---- Group cards: border + light bg in the group's colour ---- */
.student-stat-card.stat-science {
    background: var(--bg-eff6ff);              /* blue-50 */
    border-color: var(--bd-3b82f6);
}
.student-stat-card.stat-science .student-stat-label { color: var(--fg-1e40af); }
.student-stat-card.stat-science .student-stat-value { color: var(--fg-1e3a8a); }

.student-stat-card.stat-humanities {
    background: var(--bg-fffbeb);              /* amber-50 */
    border-color: var(--bd-f59e0b);
}
.student-stat-card.stat-humanities .student-stat-label { color: var(--fg-92400e); }
.student-stat-card.stat-humanities .student-stat-value { color: var(--fg-78350f); }

.student-stat-card.stat-business {
    background: var(--bg-f0fdf4);              /* green-50 */
    border-color: var(--bd-16a34a);
}
.student-stat-card.stat-business .student-stat-label { color: var(--fg-166534); }
.student-stat-card.stat-business .student-stat-value { color: var(--fg-14532d); }

/* ============================================================ */
/*              STUDENT ANALYTICS — FULL                        */
/* ============================================================ */
.analytics-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}


#analytics-output {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
/* ---------- Filters ---------- */
.analytics-filters {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.analytics-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}
.analytics-filter-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-64748b);
    margin-right: 0.25rem;
}
.analytics-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.analytics-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 180px;
    min-width: 0;
}
.analytics-filter-group .custom-select-wrapper {
    flex: 1 1 auto;
    min-width: 0;
}
.analytics-filter-group .custom-select-wrapper .input-field {
    height: 36px;
    cursor: pointer;
}

/* Custom date range row */
.analytics-custom-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.analytics-custom-range .input-field {
    height: 34px;
    max-width: 160px;
    font-size: 0.82rem;
}
.analytics-range-sep {
    color: var(--fg-94a3b8);
    font-size: 0.8rem;
}
#analytics-apply-custom {
    height: 34px;
    padding: 0 0.9rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
}
#analytics-apply-custom i {
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
#analytics-apply-custom span {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

/* ---------- Summary cards ---------- */
.analytics-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}
.analytics-summary-card {
    flex: 1 1 110px;
    min-width: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: var(--bg-f1f5f9);
    border: 1.5px solid var(--bd-cbd5e1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.15rem;
}
.analytics-card-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-64748b);
}
.analytics-card-value {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--fg-1e293b);
    line-height: 1.1;
}
/* Accent (blue) — Your Avg */
.analytics-summary-card.analytics-card-accent {
    background: var(--bg-eff6ff);
    border-color: var(--bd-93c5fd);
}
.analytics-summary-card.analytics-card-accent .analytics-card-label { color: var(--fg-1e40af); }
.analytics-summary-card.analytics-card-accent .analytics-card-value { color: var(--fg-1e3a8a); }

/* Warm (amber) — Class Avg */
.analytics-summary-card.analytics-card-warm {
    background: var(--bg-fffbeb);
    border-color: var(--bd-fcd34d);
}
.analytics-summary-card.analytics-card-warm .analytics-card-label { color: var(--fg-92400e); }
.analytics-summary-card.analytics-card-warm .analytics-card-value { color: var(--fg-78350f); }

/* ---------- Sections ---------- */
.analytics-section {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
    border-radius: 12px;
    padding: 1rem 1.15rem;
}
.analytics-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-334155);
    margin: 0 0 0.85rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.analytics-section-title i { color: var(--fg-64748b); }

/* ---------- Chart ---------- */
.analytics-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
    font-size: 0.72rem;
    color: var(--fg-64748b);
    padding-left: 0.25rem;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
}
.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
}
.legend-solid-blue  { background: var(--bg-2563eb); }
.legend-solid-amber { background: var(--bg-f59e0b); }
.legend-dashed-blue {
    height: 0;
    border-top: 2px dashed var(--bd-2563eb);
    background: transparent;
    border-radius: 0;
}

/* Outer — never scrolls vertically */
.analytics-chart-outer {
    width: 100%;
    overflow: visible;
}
.analytics-chart-wrap {
    position: relative;
    width: 100%;
    overflow: visible;
    padding-bottom: 4px;
    min-height: 200px;
    scrollbar-width: thin;
}

.analytics-chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

/* Dots — clickable */
.chart-dot {
    cursor: pointer;
    transition: r 0.15s ease, filter 0.15s ease;
}
.chart-dot:hover { r: 5.5; filter: brightness(1.05); }

/* Fixed-position tooltip — survives any scroll parent */
.analytics-chart-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.72rem;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    max-width: 220px;
    white-space: nowrap;
}
.analytics-chart-tooltip.show,
.analytics-chart-tooltip[style*="opacity: 1"] {
    opacity: 1;
    transform: translateY(0);
}
.analytics-chart-tooltip .tooltip-title {
    font-weight: 700;
    margin-bottom: 0.2rem;
    white-space: normal;
    word-break: break-word;
}
.analytics-chart-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 500;
}
.analytics-chart-tooltip .tooltip-row span   { color: var(--fg-cbd5e1); }
.analytics-chart-tooltip .tooltip-row strong { color: var(--fg-ffffff); }

/* ---------- Bars ---------- */
.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.analytics-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
}
.analytics-bar-label {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.analytics-bar-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.analytics-bar-count {
    font-size: 0.68rem;
    color: var(--fg-94a3b8);
}
.analytics-bar-track {
    height: 14px;
    background: var(--bg-f1f5f9);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.analytics-bar-fill {
    height: 100%;
    border-radius: 999px;
    min-width: 3px;
}
.analytics-bar-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.analytics-bar-value.mark-terminated {
    color: var(--fg-dc2626);
}

/* ---------- Subject Performance ---------- */
.analytics-subjects {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.analytics-subject-item {
    display: flex;
    flex-direction: column;
}
.analytics-bar-row-clickable {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto auto;
    cursor: pointer;
    border-radius: 6px;
    padding: 0.4rem 0.35rem;
    transition: background 0.15s ease;
}
.analytics-bar-row-clickable:hover { background: var(--bg-f8fafc); }

.subject-caret {
    color: var(--fg-94a3b8);
    font-size: 0.72rem;
    transition: transform 0.25s ease;
    margin-left: 0.35rem;
}
.analytics-bar-row-clickable.open .subject-caret {
    transform: rotate(180deg);
}

/* Outer — animation only, no scrollbar ever */
.analytics-subject-exams {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.analytics-subject-exams.open {
    max-height: 340px;
}
/* Inner — the actual scroller */
.analytics-subject-exams-inner {
    max-height: 340px;
    overflow-y: auto;
    padding: 0.4rem 0.35rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.analytics-subject-exams-inner::-webkit-scrollbar { width: 6px; }
.analytics-subject-exams-inner::-webkit-scrollbar-track { background: transparent; }
.analytics-subject-exams-inner::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}

/* ============================================================ */
/*              ANALYTICS — EXAM TABLE (report style)           */
/* ============================================================ */
.exam-list-table-wrap {
    overflow-x: auto;
    padding: 0.35rem 0.25rem 0.5rem;
}

.exam-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: var(--bg-ffffff);
}
.exam-list-table thead th {
    padding: 0.5rem 0.7rem;
    text-align: left;
    background: var(--bg-f8fafc);
    font-weight: 600;
    color: var(--fg-475569);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--bd-e2e8f0);
    white-space: nowrap;
}
.exam-list-table tbody td {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--bd-f1f5f9);
    color: var(--fg-1e293b);
    vertical-align: middle;
    white-space: nowrap;
}
.exam-list-table tbody tr:last-child td { border-bottom: none; }
.exam-list-table tbody tr:hover { background: var(--bg-f8fafc); }

/* Column alignment & sizing */
.exam-list-table .col-date {
    color: var(--fg-64748b);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 1%;
}
.exam-list-table .col-exam {
    font-weight: 500;
    white-space: normal;
    min-width: 110px;
}
.exam-list-table .col-obt,
.exam-list-table .col-high,
.exam-list-table .col-total,
.exam-list-table .col-pct {
    text-align: center;
    font-variant-numeric: tabular-nums;
    width: 1%;
    white-space: nowrap;
}
.exam-list-table thead th.col-obt,
.exam-list-table thead th.col-high,
.exam-list-table thead th.col-total,
.exam-list-table thead th.col-pct,
.exam-list-table thead th.col-merit {
    text-align: center;
}
/* Merit sits beside the exam name, the student's own rank on that paper.
   The blue belongs to the number itself — the heading is a heading like
   every other one in the table. */
.exam-list-table th.col-merit {
    color: inherit;
    font-weight: 700;
}
.exam-list-table .col-merit {
    text-align: center;
    width: 1%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.exam-list-table td.col-merit { color: var(--fg-2563eb); }
.exam-list-table .col-merit.is-blank {
    color: var(--fg-94a3b8);
    font-weight: 600;
}
/* First place on a paper is an award here too, matching the exam card's
   gold. The badge is the chip the flat table never had. */
.exam-list-table .merit-badge {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0 0.3rem;
    border-radius: 6px;
    font-size: 0.68rem;
    line-height: 1.45;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
/* Flat gold: one colour, no metallic gradient, no highlight. */
.exam-list-table .merit-badge.is-top {
    background: #f1dc94;
    color: #6b500e;
    border: 1px solid rgba(184, 146, 40, 0.38);
    box-shadow: none;
}
html[data-theme="dark"] .exam-list-table .merit-badge.is-top {
    background: #d9b646;
    color: #1a1405;
    border-color: rgba(212, 175, 55, 0.45);
}
.exam-list-table .col-obt { font-weight: 700; }
.exam-list-table .col-pct { color: var(--fg-1e293b); font-weight: 600; }

/* Obtained passes/fails per exam's own passing marks */
.exam-list-table .col-obt.mark-pass { color: var(--fg-16a34a); }
.exam-list-table .col-obt.mark-fail { color: var(--fg-dc2626); }
.exam-list-table .col-obt:not(.mark-pass):not(.mark-fail) { color: var(--fg-94a3b8); } /* Abst. */

/* A void attempt is red like a fail, never the grey of an absence. The
   doubled selector beats the :not() abstraction rule above. */
.exam-list-table .col-obt.mark-terminated,
.exam-list-table .col-obt.mark-terminated:not(.mark-pass):not(.mark-fail) { color: var(--fg-dc2626); }
.exam-list-table .col-pct.mark-terminated { color: var(--fg-dc2626); }
.exam-list-table .col-pct.mark-absent { color: var(--fg-dc2626); }
.exam-list-table .col-pct.mark-pass { color: var(--fg-16a34a); }

/* Combined exam splits inside one analytics row ("mcq / cq") */
.analytics-seg-pass { color: var(--fg-16a34a); }
.analytics-seg-fail { color: var(--fg-dc2626); }
.analytics-seg-pending { color: var(--fg-94a3b8); }
/* "+" and "=" are part of the equation, not decoration: they keep the
   same ink as the numbers so they survive a black-and-white print. */
.analytics-seg-sep { color: var(--text-strong); font-weight: 500; margin: 0 2px; }
/* The "= total" tail of an MCQ+CQ=Total cell */
.analytics-seg-total { font-weight: 700; color: inherit; }

/* Slight indent for the tables nested inside subject expansions */
.analytics-subject-exams-inner .exam-list-table-wrap {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

/* ---------- Highlights ---------- */
.analytics-highlights {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.analytics-highlight {
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border: 1.5px solid var(--bd-e2e8f0);
    background: var(--bg-f8fafc);
}
.analytics-highlight-best  { background: var(--bg-f0fdf4); border-color: var(--bd-86efac); }
.analytics-highlight-worst { background: var(--bg-fef2f2); border-color: var(--bd-fca5a5); }
.highlight-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-64748b);
}
.analytics-highlight-best  .highlight-label { color: var(--fg-166534); }
.analytics-highlight-worst .highlight-label { color: var(--fg-991b1b); }
.highlight-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.highlight-value {
    font-size: 0.8rem;
    color: var(--fg-475569);
    font-weight: 500;
}

/* ---------- Empty ---------- */
.analytics-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--fg-94a3b8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.analytics-empty i { font-size: 2rem; opacity: 0.5; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .analytics-filters { padding: 0.85rem 0.9rem; }
    .analytics-filter-group { flex: 1 1 100%; }
    .analytics-custom-range .input-field { max-width: 100%; flex: 1 1 100px; }

    .analytics-bar-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "label value" "bar bar";
        row-gap: 0.25rem;
    }
    .analytics-bar-label { grid-area: label; }
    .analytics-bar-value { grid-area: value; }
    .analytics-bar-track { grid-area: bar; }

    .analytics-bar-row-clickable {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "label value caret" "bar bar bar";
    }
    .analytics-bar-row-clickable .analytics-bar-label { grid-area: label; }
    .analytics-bar-row-clickable .analytics-bar-value { grid-area: value; }
    .analytics-bar-row-clickable .subject-caret      { grid-area: caret; }
    .analytics-bar-row-clickable .analytics-bar-track{ grid-area: bar; }

    .analytics-highlights { grid-template-columns: 1fr; }
}

/* Grey framed subject items with expansion */
.analytics-subject-item {
    background: var(--bg-f1f5f9);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.analytics-subject-item:hover {
    border-color: var(--bd-cbd5e1);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.analytics-bar-row-clickable {
    padding: 0.65rem 0.85rem;
    background: transparent;
}
.analytics-bar-row-clickable:hover { background: var(--bg-e2e8f0); }

.analytics-subject-exams {
    max-height: 0;
    overflow: hidden;
    background: var(--bg-ffffff);
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.analytics-subject-exams-inner {
    max-height: 340px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.analytics-subject-exams-inner::-webkit-scrollbar { width: 6px; }
.analytics-subject-exams-inner::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
.student-tab-content.fade-in-up {
    animation: fadeInUp 0.5s ease forwards !important;
}

.analytics-chart-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2147483000;      /* above modals, dropdowns, everything */
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.72rem;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    max-width: 220px;
    white-space: nowrap;
    will-change: left, top, opacity, transform;
}

/* ============================================================ */
/*      STUDENT TAG FILTER — DROPDOWN WIDER THAN INPUT          */
/* ============================================================ */
/* Anchor the menu to the left edge of the input so it grows    */
/* rightward into view instead of extending off-screen left.    */
.student-header-controls .student-filter-wrapper .custom-select-menu {
    left: 0;
    right: auto;
    min-width: 200px;
    width: max-content;
    max-width: min(280px, calc(100vw - 32px));
    padding: 0.35rem 0;
}

/* Prevent the input text from being clipped when the value is long */
.student-header-controls .student-filter-wrapper .input-field {
    text-overflow: ellipsis;
}

/* ============================================================ */
/*              CACHE-MODE BANNER (student portal)              */
/* ============================================================ */
.cache-mode-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(var(--surface-rgb), 0.98), rgba(var(--surface-rgb), 0.94));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-left: 3px solid var(--bd-38bdf8);
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--fg-334155);
    line-height: 1.4;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    animation: fadeInUp 0.35s ease forwards;
}
.cache-mode-banner i {
    color: var(--fg-0284c7);
    font-size: 1rem;
    flex-shrink: 0;
}
.cache-mode-banner strong {
    font-weight: 700;
    color: var(--fg-0f172a);
    font-variant-numeric: tabular-nums;
}

/* Table rows can't reliably animate transforms — fade them via
   opacity only. Overrides the generic fadeInUp for <tr>. */
tr.entrance-fade {
    animation: fadeInRow 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes fadeInRow {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================ */
/*           LOGIN INPUT ERROR & SHAKE                          */
/* ============================================================ */
.input-field.input-error {
    border-color: var(--bd-ef4444) !important;
    background-color: var(--bg-fef2f2) !important;
    color: var(--fg-991b1b) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
    animation: inputShake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes inputShake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* ============================================================ */
/*                 GLOBAL FOCUS-VISIBLE RING                    */
/* ============================================================ */
:focus-visible {
    outline: 2px solid var(--bd-2563eb) !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Inputs — no focus ring, use their own border/shadow treatment */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.input-field:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
}

/* Buttons and interactive elements — visible ring on keyboard nav */
button:focus-visible,
.btn:focus-visible,
.custom-select-option:focus-visible,
.sidebar-link:focus-visible,
.preset-btn:focus-visible,
.dropdown-toggle:focus-visible,
.dropdown-item:focus-visible,
.profile-menu-action:focus-visible,
.hamburger-toggle:focus-visible {
    outline: 2px solid var(--bd-2563eb) !important;
    outline-offset: 2px !important;
}

/* Rounded elements get a matching-radius ring so it doesn't look square */
.btn:focus-visible,
.btn-sm:focus-visible {
    border-radius: 8px;
}
.sidebar-link:focus-visible,
.preset-btn:focus-visible,
.profile-menu-action:focus-visible {
    border-radius: 8px;
}
.dropdown-item:focus-visible {
    border-radius: 6px;
}


/* ============================================================ */
/*            ADDITIONAL ANALYTICS SUMMARY CARD THEMES          */
/* ============================================================ */
.analytics-summary-card.analytics-card-success {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-86efac);
}
.analytics-summary-card.analytics-card-success .analytics-card-label { color: var(--fg-15803d); }
.analytics-summary-card.analytics-card-success .analytics-card-value { color: var(--fg-14532d); }

.analytics-summary-card.analytics-card-purple {
    background: var(--bg-faf5ff);
    border-color: var(--bd-d8b4fe);
}
.analytics-summary-card.analytics-card-purple .analytics-card-label { color: var(--fg-7e22ce); }
.analytics-summary-card.analytics-card-purple .analytics-card-value { color: var(--fg-581c87); }

/* Red — Terminated attempts */
.analytics-summary-card.analytics-card-danger {
    background: var(--bg-fef2f2);
    border-color: var(--bd-fca5a5);
}
.analytics-summary-card.analytics-card-danger .analytics-card-label { color: var(--fg-991b1b); }
.analytics-summary-card.analytics-card-danger .analytics-card-value { color: var(--fg-b91c1c); }

/* ============================================================ */
/*            PREFERS-REDUCED-MOTION SUPPORT                    */
/*                                                              */
/*  Users who opt out of motion get an instant, quiet UI.       */
/*  Every animation collapses to near-zero; the skeleton        */
/*  shimmer becomes a static tinted fill; the analytic chart    */
/*  bars snap to their final width instead of growing.          */
/* ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Static skeleton — visible, no shimmer */
    .skeleton {
        animation: none !important;
        background: var(--bg-eef2f7);
    }

    /* Content that would otherwise fade/slide in is shown instantly */
    .chart-plot,
    .chart-dot,
    .fade-in,
    .fade-in-up,
    .fade-in-up-delay-1,
    .fade-in-up-delay-2,
    .fade-in-up-delay-3,
    .fade-in-up-delay-4,
    .entrance-fade,
    .student-card-item,
    .exam-card-item,
    .class-card-item,
    .student-chip-animate {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    /* Staggered children (they set inline opacity:0 before running) */
    [style*="opacity: 0"] {
        opacity: 1 !important;
    }
}

/* ============================================================ */
/*  INPUT FOCUS — no native ring, no autofill tint              */
/* ============================================================ */
.input-field:focus,
.input-field:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
}

/* ============================================================ */
/*                    SKELETON LOADERS                          */
/*                                                              */
/*  ONE shimmer per card. Inner .skeleton blocks are static     */
/*  grey shapes; a single ::before gradient sweeps across the    */
/*  whole card. This is what makes the placeholder read as one   */
/*  object instead of a dozen boxes flickering on their own.     */
/* ============================================================ */
@keyframes cbsShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes cbsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.skeleton {
    display: block;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 6px;
    pointer-events: none;
    user-select: none;
}

.skeleton-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-eef2f7);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 60px;
}

.skeleton-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(var(--surface-rgb), 0.75) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: cbsShimmer 1.6s linear infinite;
    pointer-events: none;
    z-index: 2;
}

.skeleton-card > * {
    position: relative;
    z-index: 1;
}

.skeleton-avatar { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; }
.skeleton-line   { height: 0.75rem; flex: 1; }
.skeleton-line.w-25  { max-width: 25%; }
.skeleton-line.w-40  { max-width: 40%; }
.skeleton-line.w-60  { max-width: 60%; }
.skeleton-line.w-75  { max-width: 75%; }
.skeleton-line.w-100 { max-width: 100%; }
.skeleton-chip { flex-shrink: 0; width: 64px; height: 18px; border-radius: 999px; }
.skeleton-stack {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.skeleton-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.55rem 0; border-bottom: 1px solid var(--bd-f1f5f9);
}
.skeleton-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.skeleton-list > .skeleton-card { animation: cbsFadeIn 0.35s ease both; }
.skeleton-list > .skeleton-card:nth-child(1)    { animation-delay: 0s;    }
.skeleton-list > .skeleton-card:nth-child(2)    { animation-delay: 0.05s; }
.skeleton-list > .skeleton-card:nth-child(3)    { animation-delay: 0.1s;  }
.skeleton-list > .skeleton-card:nth-child(4)    { animation-delay: 0.15s; }
.skeleton-list > .skeleton-card:nth-child(5)    { animation-delay: 0.2s;  }
.skeleton-list > .skeleton-card:nth-child(n+6)  { animation-delay: 0.25s; }

@media (prefers-reduced-motion: reduce) {
    .skeleton-card::before { animation: none; opacity: 0; }
    .skeleton-list > .skeleton-card { animation: none; }
}

/* ============================================================ */
/*                    EMPTY STATES                              */
/*                                                              */
/*  Used wherever a list has no rows to show. Replaces the      */
/*  bare "No X yet." text with something that has weight and    */
/*  (optionally) an action.                                     */
/* ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--fg-94a3b8);
    gap: 0.5rem;
}

.empty-state-icon {
    font-size: 2rem;
    color: var(--fg-cbd5e1);
    margin-bottom: 0.25rem;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg-64748b);
    margin: 0;
}

.empty-state-message {
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 320px;
    margin: 0;
}

.empty-state-action {
    margin-top: 0.85rem;
}

/* ============================================================ */
/*                    VIEW TRANSITIONS                          */
/*                                                              */
/*  Native cross-fade between views and tabs. Chrome/Edge 111+. */
/*  Firefox/Safari fall through to the existing CSS fades        */
/*  because @supports (view-transition-name: none) is false      */
/*  there, so the legacy animations stay active.                 */
/*                                                              */
/*  Header and sidebar get their own view-transition-names so    */
/*  they stay pinned while the rest of the page cross-fades.     */
/* ============================================================ */

/* --- Cross-fade timing --- */
::view-transition-old(root) {
    animation: 140ms cubic-bezier(0.22, 1, 0.36, 1) both vtFadeOut;
}
::view-transition-new(root) {
    animation: 200ms cubic-bezier(0.22, 1, 0.36, 1) both vtFadeIn;
}

@keyframes vtFadeOut {
    to { opacity: 0; }
}
@keyframes vtFadeIn {
    from { opacity: 0; }
}

/* --- Persistent chrome: header --- */
#global-app-header,
#student-app-header,
#student-app-header-marks {
    view-transition-name: app-header;
}

/* --- Persistent chrome: sidebars (admin class view + student view) --- */
.class-layout .sidebar,
.student-layout .sidebar {
    view-transition-name: app-sidebar;
}

/* --- Persistent chrome: mobile nav drawer. Without a name it was part
       of the root snapshot and cross-faded with everything else, which is
       the "nav blink" on every tab change. --- */
#student-mobile-menu,
#mobile-menu {
    view-transition-name: app-mobile-nav;
}

/* --- Chrome swaps instantly. Named elements still get the default
       cross-fade, and fading an opaque nav out while fading an identical
       one in is exactly the flash we want to lose. Only the content below
       the chrome should animate. --- */
::view-transition-old(app-header),
::view-transition-new(app-header),
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar),
::view-transition-old(app-mobile-nav),
::view-transition-new(app-mobile-nav) {
    animation: none;
}
::view-transition-old(app-header),
::view-transition-old(app-sidebar),
::view-transition-old(app-mobile-nav) {
    opacity: 0;
}

/* The exam runner/review header is a different element from the
   dashboard header. Naming it keeps it out of the root cross-fade, so
   leaving a review through browser Back swaps the bar instantly instead
   of dissolving it into the page. */
#exam-app-header {
    view-transition-name: exam-header;
}
::view-transition-old(exam-header),
::view-transition-new(exam-header) {
    animation: none;
}
::view-transition-old(exam-header) {
    opacity: 0;
}

/* --- Suppress legacy fades when VT is available, so they don't
       layer on top of the native cross-fade --- */
@supports (view-transition-name: none) {
    /* Gate the legacy fades on the transition ACTUALLY running
       (startViewTransition sets data-vt-active). Previously they were
       muted for every browser that supports view-transition-name, so a
       skipped transition left the switch completely un-animated. */
    html[data-vt-active="1"] #view-marks.active-view {
        animation: none !important;
    }
    html[data-vt-active="1"] .tab-content {
        animation: none !important;
    }
}

/* --- Reduced motion — collapse VT to a hard swap --- */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.01ms !important;
    }
}

/* ============================================================ */
/*  DASHBOARD TABS — scrollable pill with chevron overlays        */
/*                                                                */
/*  Two-state visibility (shown/hidden by body class) is applied  */
/*  to the OUTER wrapper so the chevrons travel with the pill.    */
/*  The pill itself scrolls horizontally if its tabs overflow.    */
/* ============================================================ */
.dashboard-tabs-outer {
    position: relative;
    display: flex;
    justify-content: center;

    /* hidden state — animated by body class */
    max-height: 0;
    margin-bottom: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
        max-height 0.42s cubic-bezier(0.22, 1, 0.36, 1),
        margin-bottom 0.42s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.06s,
        transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

body.role-superadmin.teacher-portal-enabled .dashboard-tabs-outer {
    max-height: 64px;
    margin-bottom: 1.5rem;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.dashboard-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-f1f5f9);
    padding: 0.3rem;
    border-radius: 999px;

    /* Only as wide as needed — no stretching */
    width: fit-content;
    max-width: 100%;

    /* Horizontal scroll on overflow, no visible scrollbar */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.dashboard-tabs::-webkit-scrollbar { display: none; }

.dashboard-tab {
    background: transparent;
    border: none;
    padding: 0.55rem 1.15rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--fg-64748b);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.dashboard-tab:hover { color: var(--fg-1e293b); }
.dashboard-tab.active {
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08),
        0 4px 12px rgba(15, 23, 42, 0.04);
}
.dashboard-tab i { font-size: 0.85em; }

#dashboard-teachers-tab { display: none; }
body.role-superadmin.teacher-portal-enabled #dashboard-teachers-tab {
    display: inline-flex;
}

/* --- Chevron overlays --- */
.dashboard-tabs-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    color: var(--fg-475569);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 180ms ease, transform 0.12s ease;
}
.dashboard-tabs-scroll-btn:hover { background: var(--bg-f8fafc); }
.dashboard-tabs-scroll-btn:active { transform: translateY(-50%) scale(0.94); }

.dashboard-tabs-scroll-btn.left  { left: 0; }
.dashboard-tabs-scroll-btn.right { right: 0; }

/* Only show a chevron when there's content to scroll that way. */
.dashboard-tabs-outer.can-scroll-left  .dashboard-tabs-scroll-btn.left,
.dashboard-tabs-outer.can-scroll-right .dashboard-tabs-scroll-btn.right {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================================ */
/*  DASHBOARD PANELS — slide container                            */
/* ============================================================ */
.dashboard-panels {
    position: relative;
}
.dashboard-panel {
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-tabs { transition: none; }
}
/* ============================================================ */
/*              TEACHER CARDS — expandable                        */
/* ============================================================ */
.teachers-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    animation: cbsParentFade 220ms ease-out;
}

.teacher-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.teacher-card:hover {
    border-color: var(--bd-dbe2ea);
}
.teacher-card.expanded { border-color: var(--bd-cbd5e1); }

/* ---- Desktop: grid [avatar] [name] [email] ------------------- */
.teacher-card-header {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "avatar name email";
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 4.4rem 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease;
}
.teacher-card-header:hover { background: transparent; }

.teacher-card-avatar {
    grid-area: avatar;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-e0e7ff), var(--bg-c7d2fe));
    color: var(--fg-3730a3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    user-select: none;
    align-self: center;
}

.teacher-card-name {
    grid-area: name;
    min-width: 0;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    overflow-wrap: break-word;
    align-self: center;
}

.teacher-card-email {
    grid-area: email;
    min-width: 0;
    text-align: right;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--fg-64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    align-self: center;
}

.teacher-card-last-seen { display: none; }

/* ---- Caret: ▾ rest, ▴ when expanded --------------------------- */
.teacher-card-caret {
    position: absolute;
    top: 50%;
    right: 2.6rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--fg-94a3b8);
    font-size: 0.8rem;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.teacher-card.expanded .teacher-card-caret {
    transform: translateY(-50%) rotate(180deg);
}

/* ---- ⋮ — always visible, sits right of the caret -------------- */
.teacher-card-actions {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

/* ---- Body ----------------------------------------------------- */
.teacher-card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    background: var(--bg-fafbfc);
}
.teacher-card-body-inner {
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--bd-f1f5f9);
}
.teacher-subject-group { margin-bottom: 0.75rem; }
.teacher-subject-group:last-child { margin-bottom: 0; }
.teacher-subject-group-name {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-64748b);
    margin-bottom: 0.4rem;
}
.teacher-subject-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.teacher-subject-pill {
    display: inline-block;
    padding: 0.15rem 0.65rem;
    background: var(--bg-eef2ff);
    color: var(--fg-4338ca);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.teacher-card-no-subjects {
    color: var(--fg-94a3b8);
    font-size: 0.82rem;
    font-style: italic;
    padding: 0.5rem 0;
}

/* ============================================================ */
/*  CLASS-LEVEL TEACHER LIST — admin badge                       */
/*                                                              */
/*  Inline chip next to the teacher's name in the class-view     */
/*  Teachers tab, marking them as a class admin of THIS class.   */
/*  Same visual family as the notice flags and the class-card    */
/*  ADMIN flag — dark slate, uppercase, tracked.                 */
/* ============================================================ */
.class-teacher-admin-badge {
    display: inline-block;
    padding: 0.08rem 0.42rem;
    margin-left: 0.45rem;
    border-radius: 4px;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

/* ============================================================ */
/*  CLASS ADMIN PICKER  (dashboard-level teacher modal)          */
/*                                                              */
/*  Same visual family as the .student-chip grid in reports: a   */
/*  wrapping row of checkbox-pills on a muted surface. Dark       */
/*  accent when checked. Superadmin-only surface — never shown   */
/*  to a class admin.                                            */
/* ============================================================ */
.class-admin-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.55rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}

/* The `.form-group label` rule (specificity 0,1,1 — one class +
   one element) sets `display: block; margin-bottom: 0.25rem`,
   which was overriding the plain `.class-admin-checkbox` (0,1,0).
   Result: checkboxes rendered as stacked full-width blocks instead
   of inline pills. Scoping the selector under `.form-group` bumps
   specificity to (0,2,0) which wins cleanly. `margin-bottom: 0`
   resets the stray spacing from the same rule. */
.form-group .class-admin-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.42rem 0.8rem;
    background: var(--bg-ffffff);
    border: 1.5px solid var(--bd-e2e8f0);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fg-334155);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    min-width: 0;
    /* Explicit line-height:1 so the text box is exactly font-size
       tall, matching the checkbox's 16px. align-items:center then
       centres both at the same geometric midpoint. */
    line-height: 1;
}

.class-admin-checkbox:hover {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-fafbfc);
}

.class-admin-checkbox:has(input:checked) {
    background: var(--bg-f1f5f9);
    border-color: var(--bd-1e293b);
    color: var(--fg-0f172a);
}

.class-admin-checkbox input {
    appearance: none;
    -webkit-appearance: none;
    /* display:grid + place-items:center forces the ::after tick
       to sit at the box's true geometric centre — no baseline
       drift. */
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    margin: 0;
    line-height: 0;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.class-admin-checkbox input:checked {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
}

.class-admin-checkbox input:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 4px;
    border-left: 2px solid var(--bd-ffffff);
    border-bottom: 2px solid var(--bd-ffffff);
    transform: translate(-50%, -70%) rotate(-45deg);
}

.class-admin-checkbox span {
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* ---- Mobile: 4-column grid, caret + ⋮ side-by-side ----------- */
@media (max-width: 640px) {
    .teacher-card-header {
        position: static;
        grid-template-columns: auto 1fr auto auto;
        grid-template-areas:
            "avatar name  caret actions"
            "avatar email caret actions"
            "avatar seen  caret actions";
        gap: 0.05rem 0.5rem;
        padding: 0.7rem 0.85rem;
        align-items: center;
    }
    .teacher-card-avatar {
        grid-area: avatar;
        align-self: center;
        width: 38px;
        height: 38px;
        font-size: 0.8rem;
    }
    .teacher-card-name {
        grid-area: name;
        font-size: 0.96rem;
        align-self: end;
    }
    .teacher-card-email {
        grid-area: email;
        text-align: left;
        font-size: 0.78rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        align-self: start;
    }
    .teacher-card-last-seen {
        grid-area: seen;
        display: block;
        font-size: 0.64rem;
        font-weight: 500;
        color: var(--fg-94a3b8);
        letter-spacing: 0.03em;
        text-transform: uppercase;
        line-height: 1.2;
        margin-top: 0.1rem;
        align-self: start;
    }
    .teacher-card-caret {
        grid-area: caret;
        position: static;
        transform: none;
        align-self: center;
        pointer-events: auto;
    }
    .teacher-card.expanded .teacher-card-caret {
        transform: rotate(180deg);
    }
    .teacher-card-actions {
        grid-area: actions;
        position: static;
        transform: none;
        align-self: center;
    }
    .teacher-card-body-inner { padding: 0.75rem 0.85rem 0.85rem; }
}

/* ============================================================ */
/*              SUBJECT CHIP INPUT                               */
/* ============================================================ */
.subjects-chip-input {
    position: relative;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    background: var(--bg-ffffff);
    padding: 0.3rem 0.4rem;
    min-height: 42px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
    cursor: text;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
.subjects-chip-input:focus-within {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30,41,59,0.08);
}

.subjects-chips {
    display: contents;
}

.subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.45rem 0.15rem 0.6rem;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}
.subject-chip-remove {
    background: transparent;
    border: none;
    color: var(--fg-ffffff);
    opacity: 0.65;
    cursor: pointer;
    padding: 0;
    font-size: 0.62rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transition: opacity 0.12s ease, background 0.12s ease;
}
.subject-chip-remove:hover { opacity: 1; background: rgba(var(--surface-rgb), 0.15); }

.subjects-text-input {
    flex: 1 1 120px;
    min-width: 100px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    padding: 0.25rem 0.15rem;
    color: var(--fg-1e293b);
    font-family: inherit;
}

.subjects-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    box-shadow: 0 12px 24px rgba(15,23,42,0.08);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.subjects-suggestions.show { display: block; }
.subject-suggestion {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--fg-1e293b);
}
.subject-suggestion:hover { background: var(--bg-f1f5f9); }
.subject-suggestion.create {
    color: var(--fg-2563eb);
    font-weight: 500;
    border-top: 1px solid var(--bd-f1f5f9);
}

/* ============================================================ */
/*              SUBJECTS TREE (teacher modal)                    */
/* ============================================================ */
.subjects-tree {
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 10px;
    background: var(--bg-f8fafc);
    max-height: 320px;
    overflow-y: auto;
    padding: 0.35rem;
}

.tree-class {
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.25rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
}
.tree-class:last-child { margin-bottom: 0; }

.tree-class-header {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    text-align: left;
    transition: background 0.12s ease;
}
.tree-class-header:hover { background: var(--bg-f1f5f9); }

.tree-caret {
    font-size: 0.65rem;
    color: var(--fg-94a3b8);
    transition: transform 0.2s ease;
    width: 10px;
    text-align: center;
}
.tree-class.expanded .tree-caret { transform: rotate(90deg); }

.tree-class-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-class-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--fg-94a3b8);
    background: var(--bg-f1f5f9);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}

.tree-class-body {
    display: none;
    padding: 0.15rem 0.4rem 0.4rem 1.35rem;
    border-top: 1px solid var(--bd-f1f5f9);
}
.tree-class.expanded .tree-class-body { display: block; }

.tree-subject {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--fg-334155);
    transition: background 0.1s ease;
    user-select: none;
    line-height: 1.35;
}

/* Nudge the checkbox down so its centre aligns with the first text
   line's optical centre rather than the top of the line-box. */
.tree-subject .tree-subject-box {
    margin-top: 2px;
}
.tree-subject-box {
    margin-top: 2px;
}
.tree-subject:hover { background: var(--bg-f1f5f9); }

.tree-subject input[type="checkbox"] {
    /* Visually hidden but still focusable + accessible */
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tree-subject-box {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-ffffff);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.tree-subject-box::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translate(0.5px, -1px);
    opacity: 0;
    transition: opacity 0.1s ease;
}
.tree-subject.checked .tree-subject-box {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
}
.tree-subject.checked .tree-subject-box::after { opacity: 1; }

.tree-subject-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.tree-subject.tree-orphan .tree-subject-name {
    color: var(--fg-7c3aed);
    font-style: italic;
}

/* --- Add-subject row (modal tree) --- */
.tree-add {
    margin-top: 0.35rem;
    padding: 0 0.35rem;
}

.tree-add-btn {
    background: transparent;
    border: 1px dashed var(--bd-cbd5e1);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-64748b);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.12s ease;
}
.tree-add-btn:hover {
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
    background: var(--bg-f8fafc);
}
.tree-add-btn i { font-size: 0.65rem; }

.tree-add-row {
    display: flex;
    gap: 0.35rem;
    align-items: stretch;
}

.tree-add-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--bd-1e293b);
    border-radius: 6px;
    font-size: 0.82rem;
    outline: none;
    box-shadow: 0 0 0 3px rgba(30,41,59,0.08);
    font-family: inherit;
    background: var(--bg-ffffff);
}

/* Tick — commits the typed subject. Present for mobile where the
   soft keyboard's Enter is unreliable. */
.tree-add-confirm {
    flex: 0 0 auto;
    min-width: 38px;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    transition: background 0.12s ease, transform 0.06s ease;
}
.tree-add-confirm:hover { background: var(--bg-0f172a); }
.tree-add-confirm:active { transform: scale(0.94); }

/* --- Empty state --- */
.subjects-tree-empty {
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--fg-94a3b8);
    font-size: 0.82rem;
}

/* --- Desktop/mobile tweaks --- */
@media (max-width: 640px) {
    .subjects-tree { max-height: 260px; }
    .tree-class-header { font-size: 0.82rem; padding: 0.55rem 0.65rem; }
    .tree-subject { font-size: 0.8rem; padding: 0.4rem 0.55rem; }
}

/* ============================================================ */
/*  DASHBOARD TABS — fade + slide-in                             */
/* ============================================================ */
@keyframes tabsFadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes tabsFadeSlideOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}

#dashboard-tabs.tabs-entering {
    animation: tabsFadeSlideIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#dashboard-tabs.tabs-leaving {
    animation: tabsFadeSlideOut 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
    pointer-events: none;
}

/* ============================================================ */
/*  STUDENT GROUP TAGS — religion colors                         */
/* ============================================================ */
.student-card-tag.tag-islam        { background: var(--bg-dcfce7); color: var(--fg-166534); }
.student-card-tag.tag-hinduism     { background: var(--bg-ffedd5); color: var(--fg-9a3412); }
.student-card-tag.tag-christianity { background: var(--bg-ede9fe); color: var(--fg-5b21b6); }

/* Avatar — religion colors reuse the same slot as academic.
   Academic wins when both exist (avatar reflects academic group). */
.student-card-avatar.avatar-islam        { background: linear-gradient(135deg, var(--bg-dcfce7), var(--bg-bbf7d0)); color: var(--fg-166534); }
.student-card-avatar.avatar-hinduism     { background: linear-gradient(135deg, var(--bg-ffedd5), var(--bg-fed7aa)); color: var(--fg-9a3412); }
.student-card-avatar.avatar-christianity { background: linear-gradient(135deg, var(--bg-ede9fe), var(--bg-ddd6fe)); color: var(--fg-5b21b6); }

/* ============================================================ */
/*  STUDENT STATS — dual rows                                    */
/* ============================================================ */
.student-stats-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.student-stats-block:last-child { margin-bottom: 0; }

.exam-targets-container {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.exam-target-dim { display: flex; flex-direction: column; gap: 0.35rem; }
.exam-target-dim + .exam-target-dim {
    padding-top: 0.35rem;
    border-top: 1px dashed var(--bd-e2e8f0);
}

.student-stats-row-title {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-94a3b8);
    margin-bottom: 0.25rem;
    padding-left: 0.15rem;
}

.student-stat-card.stat-islam        { background: var(--bg-f0fdf4); border-color: var(--bd-16a34a); }
.student-stat-card.stat-islam        .student-stat-label { color: var(--fg-166534); }
.student-stat-card.stat-islam        .student-stat-value { color: var(--fg-14532d); }

.student-stat-card.stat-hinduism     { background: var(--bg-fff7ed); border-color: var(--bd-ea580c); }
.student-stat-card.stat-hinduism     .student-stat-label { color: var(--fg-9a3412); }
.student-stat-card.stat-hinduism     .student-stat-value { color: var(--fg-7c2d12); }

.student-stat-card.stat-christianity { background: var(--bg-faf5ff); border-color: var(--bd-9333ea); }
.student-stat-card.stat-christianity .student-stat-label { color: var(--fg-5b21b6); }
.student-stat-card.stat-christianity .student-stat-value { color: var(--fg-4c1d95); }

/* ============================================================ */
/*  STUDENT MODAL — dual group selects                           */
/* ============================================================ */
.student-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 640px) {
    .student-group-row { grid-template-columns: 1fr; }
}

/* ============================================================ */
/*  EXAMS — dual target picker (used in next message too)         */
/* ============================================================ */
.exam-targets-container {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}


.exam-target-dim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 22px;
}

.exam-target-dim-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-475569);
}

.exam-target-dim-count {
    font-size: 0.7rem;
    color: var(--fg-64748b);
    font-weight: 500;
    white-space: nowrap;
}

.exam-target-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 28px;
}

.exam-targets-summary {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--fg-475569);
    padding-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.exam-targets-summary i { color: var(--fg-94a3b8); }
.exam-targets-summary.muted { color: var(--fg-94a3b8); }

/* ============================================================ */
/*  TEACHER MODAL — cap tree height, ensure internal scroll       */
/* ============================================================ */
.subjects-tree {
    max-height: 260px;   /* reduced from 320 — keeps modal compact */
    overflow-y: auto;
}
@media (max-width: 640px) {
    .subjects-tree { max-height: 220px; }
}

/* ============================================================ */
/*              CLASS TAB SLIDE TRANSITIONS                      */
/*                                                              */
/*  Both the outgoing and incoming tab panels become absolute    */
/*  during the animation. The parent gets position: relative +   */
/*  overflow: hidden + a locked height so nothing jumps.         */
/*                                                              */
/*  Forward (→): new slides in from right, old exits left        */
/*  Backward (←): new slides in from left, old exits right       */
/* ============================================================ */
.class-content {
    position: relative;
}

/* Overshoot bounce — fires when swiping past either end */
@keyframes tabOvershootRight {
    0%   { transform: translateX(0); }
    40%  { transform: translateX(40px); }
    100% { transform: translateX(0); }
}
@keyframes tabOvershootLeft {
    0%   { transform: translateX(0); }
    40%  { transform: translateX(-40px); }
    100% { transform: translateX(0); }
}

.tab-content.tab-overshoot-right {
    animation: tabOvershootRight 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.tab-content.tab-overshoot-left {
    animation: tabOvershootLeft 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Reduced motion — instant swap */
@media (prefers-reduced-motion: reduce) {
    .tab-content.tab-overshoot-right,
    .tab-content.tab-overshoot-left {
        animation: none !important;
    }
}

/* ============================================================ */
/*  REPORTS FILTER ROWS — sync wrap point                        */
/*                                                              */
/*  Trend Graph / Absent Exams (top row) and Theme / Pass         */
/*  Condition (bottom row) must wrap to column at the same        */
/*  viewport width. Both get identical flex-basis + min-width,    */
/*  identical gap. The theme group is upgraded to match the       */
/*  report-option-group sizing.                                   */
/* ============================================================ */
.reports-filters .filter-row {
    gap: 1rem;
}

/* Force the theme group (which lacks report-option-group) to
   match the option-group's sizing so all four configs behave
   identically. */
#pass-indication-group,
.reports-filters .filter-row:has(#pass-indication-group) > .filter-group {
    flex: 1 1 240px;
    min-width: 200px;
}

.reports-filters .filter-row > .report-option-group {
    flex: 1 1 240px;
    min-width: 200px;
}

/* Under 640px, BOTH rows stack. Same breakpoint for both. */
@media (max-width: 640px) {
    .reports-filters .filter-row > .report-option-group,
    #pass-indication-group,
    .reports-filters .filter-row:has(#pass-indication-group) > .filter-group {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
    }
}

/* ============================================================ */
/*  CHECKBOX FOCUS — no browser ring                              */
/* ============================================================ */
.select-all-toggle input[type="checkbox"],
.student-chip input[type="checkbox"],
.payment-select-all input[type="checkbox"],
.payment-student-checkbox {
    -webkit-tap-highlight-color: transparent;
}
.select-all-toggle input[type="checkbox"]:focus,
.select-all-toggle input[type="checkbox"]:focus-visible,
.student-chip input[type="checkbox"]:focus,
.student-chip input[type="checkbox"]:focus-visible,
.payment-select-all input[type="checkbox"]:focus,
.payment-select-all input[type="checkbox"]:focus-visible,
.payment-student-checkbox:focus,
.payment-student-checkbox:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
}

/* ============================================================ */
/*  REPORTS — student selector header with filters                */
/* ============================================================ */
.student-selector-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.student-selector-header .student-search-box {
    flex: 1 1 180px;
    min-width: 0;
}
.student-selector-header .custom-select-wrapper {
    flex: 0 0 auto;
    min-width: 130px;
}
.student-selector-header .select-all-toggle {
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    .student-selector-header .custom-select-wrapper {
        flex: 1 1 130px;
    }
}

/* ============================================================ */
/*  WARNING TOAST — amber tint                                    */
/* ============================================================ */
.toast.toast-warning {
    background: rgba(254, 243, 199, 0.78);
    border-color: rgba(251, 191, 36, 0.55);
    color: var(--fg-92400e);
}
.toast.toast-warning .toast-icon { color: var(--fg-d97706); }

/* ============================================================ */
/*  TEACHER AVATAR — cyan (nothing else uses it)                 */
/* ============================================================ */
.teacher-card-avatar {
    background: linear-gradient(135deg, var(--bg-cffafe), var(--bg-a5f3fc));
    color: var(--fg-155e75);
}

/* ============================================================ */
/*  RELIGION COLORS — unique, no collisions with academic         */
/*                                                                */
/*   • Islam       — cyan   (distinct from Business green)        */
/*   • Hinduism    — rose   (distinct from Humanities amber)      */
/*   • Christianity— purple (real tint, not near-white)           */
/* ============================================================ */

/* --- Tags (chip in student card title) --- */
.student-card-tag.tag-islam        { background: var(--bg-cffafe); color: var(--fg-155e75); }
.student-card-tag.tag-hinduism     { background: var(--bg-ffe4e6); color: var(--fg-9f1239); }
.student-card-tag.tag-christianity { background: var(--bg-ede9fe); color: var(--fg-5b21b6); }

/* --- Avatar gradients --- */
.student-card-avatar.avatar-islam        { background: linear-gradient(135deg, var(--bg-cffafe), var(--bg-a5f3fc)); color: var(--fg-155e75); }
.student-card-avatar.avatar-hinduism     { background: linear-gradient(135deg, var(--bg-ffe4e6), var(--bg-fecdd3)); color: var(--fg-9f1239); }
.student-card-avatar.avatar-christianity { background: linear-gradient(135deg, var(--bg-ede9fe), var(--bg-ddd6fe)); color: var(--fg-5b21b6); }

/* --- Stat cards — visible tint so the background reads clearly --- */
.student-stat-card.stat-islam {
    background: var(--bg-ecfeff);          /* cyan-50 */
    border-color: var(--bd-06b6d4);        /* cyan-500 */
}
.student-stat-card.stat-islam        .student-stat-label { color: var(--fg-155e75); }
.student-stat-card.stat-islam        .student-stat-value { color: var(--fg-164e63); }

.student-stat-card.stat-hinduism {
    background: var(--bg-fff1f2);          /* rose-50 */
    border-color: var(--bd-fb7185);        /* rose-400 */
}
.student-stat-card.stat-hinduism     .student-stat-label { color: var(--fg-9f1239); }
.student-stat-card.stat-hinduism     .student-stat-value { color: var(--fg-881337); }

.student-stat-card.stat-christianity {
    background: var(--bg-f3e8ff);          /* purple-100 — real tint, not near-white */
    border-color: var(--bd-9333ea);        /* purple-600 */
}
.student-stat-card.stat-christianity .student-stat-label { color: var(--fg-5b21b6); }
.student-stat-card.stat-christianity .student-stat-value { color: var(--fg-4c1d95); }

/* ============================================================ */
/*  EXAM TARGET — required star + placeholder                     */
/* ============================================================ */
.exam-target-dim-label .required-star {
    color: var(--fg-dc2626);
    margin-left: 2px;
    font-weight: 700;
    font-size: 0.9em;
}

.exam-target-dim-count.placeholder {
    font-style: italic;
    color: var(--fg-94a3b8);
    font-weight: 400;
}
/* ============================================================ */
/*  REPORTS — unified multi-select filter menu                    */
/* ============================================================ */
.report-filter-wrapper .custom-select-menu {
    min-width: 200px;
    padding: 0.35rem 0;
}

.report-filter-section + .report-filter-section {
    border-top: 1px solid var(--bd-f1f5f9);
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}

.report-filter-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-94a3b8);
    padding: 0.35rem 0.75rem 0.2rem;
}

.report-filter-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--fg-1e293b);
    transition: background 0.08s ease;
}
.report-filter-option:hover { background: var(--bg-f1f5f9); }
.report-filter-option.active { color: var(--fg-0f172a); font-weight: 500; }

.report-filter-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 3px;
    flex-shrink: 0;
    background: var(--bg-ffffff);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.report-filter-check i {
    font-size: 8px;
    color: var(--fg-ffffff);
    opacity: 0;
    transition: opacity 0.1s ease;
}
.report-filter-option.active .report-filter-check {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
}
.report-filter-option.active .report-filter-check i { opacity: 1; }

/* ============================================================ */
/*  STATISTICAL OVERVIEW — collapse on search                    */
/* ============================================================ */
#student-stats {
    overflow: hidden;
    transition:
        max-height  0.42s cubic-bezier(0.22, 1, 0.36, 1),
        opacity     0.28s ease,
        margin-bottom 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: max-height, opacity;
}

/* ============================================================ */
/*  Custom-select label — loading state                          */
/*                                                              */
/*  A tiny spinner appears next to "Subject" / "Exam Type" while */
/*  options are being fetched for the current date range.        */
/* ============================================================ */
.filter-group > label.label-loading::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 6px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-top-color: var(--bd-1e293b);
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* ============================================================ */
/*  Custom-select — disabled (no options in range)               */
/* ============================================================ */
.custom-select-wrapper .input-field.input-empty,
.custom-select-wrapper .input-field:disabled {
    background: var(--bg-f8fafc);
    color: var(--fg-94a3b8);
    cursor: not-allowed;
    border-color: var(--bd-e2e8f0);
}
.custom-select-wrapper .input-field.input-empty + .filter-arrow,
.custom-select-wrapper .input-field:disabled + .filter-arrow {
    color: var(--fg-cbd5e1);
}

/* ---- teacher role scoping ---- */

/* Non-class-admin teachers have no Payments tab. Teachers WITH at
   least one class-admin assignment pass this CSS gate — the link is
   then shown/hidden per-class by router.refreshPaymentsLink(). */
body.role-teacher:not(.has-class-admin) #admin-payments-link,
body.role-teacher:not(.has-class-admin) #mobile-admin-payments-link {
    display: none !important;
    visibility: hidden !important;
}

/* Non-class-admin teachers can't create students. Class admins see
   the button — per-class gating happens in router.refreshPerClassAdminUI(). */
body.role-teacher:not(.has-class-admin) #create-student-btn {
    display: none !important;
}

/* Class creation is superadmin-only. Hidden for admin, teacher, and
   class admin alike. The JS guard in setupDashboardEvents() runs at
   module load — before role-teacher is applied to <body> — so it is
   a no-op on first paint. CSS is the only gate that is guaranteed
   to fire. */
body:not(.role-superadmin) #create-class-btn {
    display: none !important;
}

/* Reclaim the ⋮ gutter when no dropdown renders */
@media (max-width: 640px) {
    body.role-teacher:not(.has-class-admin) .student-card-item {
        padding-right: 0.85rem;
    }
}

/* Settings: teachers only see Security */
body:not(.role-superadmin) .settings-category[data-category="maintenance"] {
    display: none !important;
}
body.role-teacher .settings-category[data-category="general"],
body.role-teacher .settings-category[data-category="storage"] {
    display: none !important;
}
@media (max-width: 768px) {
    body.role-teacher #modal-settings .settings-mobile-back {
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* ============================================================ */
/*  NOTICES — cards, editor, tree, markdown, table picker */
/* ============================================================ */

/* ---------- Card list ---------- */

.notice-cards-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    animation: cbsParentFade 220ms ease-out;
}

@keyframes cbsParentFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.notice-card {
    position: relative;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    padding: 0.9rem 3rem 0.9rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition:
        box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.24s ease,
        translate 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
}
.notice-card:hover {
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
    border-color: var(--bd-dbe2ea);
}
.notice-card.draft {
    border-left: 3px solid var(--bd-f59e0b);
}

.notice-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--fg-94a3b8);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}
.notice-meta .notice-draft-chip {
    background: var(--bg-fef3c7);
    color: var(--fg-92400e);
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
}

.notice-title-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.55rem;
}
.notice-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.notice-pin {
    color: var(--fg-f59e0b);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.notice-chip-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.notice-target-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.65rem;
    background: var(--bg-eff6ff);
    color: var(--fg-1e40af);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.12s ease;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: none;
    letter-spacing: 0;
}
.notice-target-chip:hover { background: var(--bg-dbeafe); }
.notice-target-chip i { font-size: 0.62rem; opacity: 0.7; }

.notice-read-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: filter 0.12s ease;
}
.notice-read-chip:hover { filter: brightness(0.95); }
.notice-read-chip.all-read     { background: var(--bg-dcfce7); color: var(--fg-15803d); }
.notice-read-chip.partial-read { background: var(--bg-fef3c7); color: var(--fg-92400e); }
.notice-read-chip.no-read      { background: var(--bg-fee2e2); color: var(--fg-b91c1c); }

.notice-card-actions {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    flex-shrink: 0;
}

.notice-class-check {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-ffffff);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.notice-class-check:hover { border-color: var(--bd-94a3b8); }
.notice-class-check.partial {
    background: var(--bg-cbd5e1);
    border-color: var(--bd-cbd5e1);
}
.notice-class-check.partial::after {
    content: '';
    width: 8px;
    height: 2px;
    background: var(--bg-ffffff);
    border-radius: 1px;
}
.notice-class-check.full {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
}
.notice-class-check.full::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 2px solid var(--bd-ffffff);
    border-bottom: 2px solid var(--bd-ffffff);
    transform: rotate(-45deg) translate(0.5px, -1px);
}

/* ---------- Dashboard tab visibility ---------- */
/* Notices tab must show for admin and teacher, not just
   superadmin with the teacher portal enabled. */

body.role-admin .dashboard-tabs-outer,
body.role-superadmin .dashboard-tabs-outer,
body.role-teacher .dashboard-tabs-outer {
    max-height: 64px;
    margin-bottom: 1.5rem;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Single-tab collapse — overrides every role-based show rule above
   so the bar animates shut when there's nothing to switch between. */
body.dashboard-single-tab .dashboard-tabs-outer {
    max-height: 0 !important;
    margin-bottom: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
}

/* ---------- Editor modal ---------- */

.notice-editor-box {
    max-width: 760px;
    padding: 0;
    max-height: min(90vh, 900px);
    max-height: min(90dvh, 900px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notice-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    flex-shrink: 0;
}
.notice-editor-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notice-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.notice-editor-body::-webkit-scrollbar { width: 6px; }
.notice-editor-body::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}

.notice-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notice-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-475569);
}
.notice-target-count {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--fg-2563eb);
}
.notice-target-count.empty { color: var(--fg-94a3b8); }

.notice-editor-actions {
    flex-shrink: 0;
    padding: 0.85rem 1.5rem 1.1rem;
    border-top: 1px solid var(--bd-eef2f6);
    background: var(--bg-ffffff);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    /* Pin the editor modal to the actual visible viewport so the
       keyboard can't push it off-screen. */
    .notice-editor-box {
        width: calc(100% - 0.75rem);
        max-width: calc(100% - 0.75rem);
        max-height: calc(100dvh - 0.75rem);
        margin: 0.375rem;
        border-radius: 14px;
        /* Respect notch / home indicator. */
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .notice-editor-header { padding: 0.7rem 0.9rem 0.5rem; }
    .notice-editor-body   { padding: 0.75rem 0.9rem 0.75rem; }
    .notice-editor-actions { padding: 0.6rem 0.9rem 0.75rem; flex-wrap: wrap; }
    .notice-editor-actions .btn { flex: 1 1 auto; min-width: 0; }
    .notice-editor-actions #notice-cancel { flex: 0 0 auto; }
}

/* ---------- Targeting tree (editor) ---------- */

.notice-target-tree {
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 10px;
    background: var(--bg-f8fafc);
    max-height: 320px;
    overflow-y: auto;
    padding: 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.notice-target-tree::-webkit-scrollbar { width: 6px; }
.notice-target-tree::-webkit-scrollbar-thumb { background: var(--bg-cbd5e1); border-radius: 8px; }

.notice-target-tree-empty {
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--fg-94a3b8);
    font-size: 0.82rem;
}

/* class node */
.notice-class {
    border-radius: 8px;
    margin-bottom: 0.25rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
    overflow: hidden;
}
.notice-class:last-child { margin-bottom: 0; }

.notice-class-header {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    text-align: left;
    transition: background 0.12s ease;
}
.notice-class-header:hover { background: var(--bg-f1f5f9); }

.notice-class-caret {
    font-size: 0.65rem;
    color: var(--fg-94a3b8);
    width: 10px;
    text-align: center;
    transition: transform 0.2s ease;
}
.notice-class.expanded .notice-class-caret { transform: rotate(90deg); }

.notice-class-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notice-class-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--fg-94a3b8);
    background: var(--bg-f1f5f9);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}
.notice-class.has-selection .notice-class-count {
    background: var(--bg-dbeafe);
    color: var(--fg-1e40af);
}

.notice-class-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.notice-class.expanded > .notice-class-body {
    grid-template-rows: 1fr;
}
.notice-class-body-inner {
    min-height: 0;
    overflow: hidden;
}
.notice-class-body-inner > *:first-child { margin-top: 0.4rem; }
.notice-class-body-inner > *:last-child  { margin-bottom: 0.55rem; }

/* dimension node */
.notice-dim { margin-bottom: 0.35rem; }
.notice-dim:last-child { margin-bottom: 0; }

.notice-dim-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.45rem;
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
}
.notice-dim-header:hover { background: var(--bg-f1f5f9); }

.notice-dim-caret {
    font-size: 0.6rem;
    color: var(--fg-94a3b8);
    width: 10px;
    text-align: center;
    transition: transform 0.2s ease;
}
.notice-dim.expanded .notice-dim-caret { transform: rotate(90deg); }

.notice-dim-label {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-475569);
}
.notice-dim-count {
    font-size: 0.68rem;
    color: var(--fg-94a3b8);
    font-weight: 500;
}
.notice-dim.has-selection .notice-dim-count { color: var(--fg-1e40af); }

.notice-dim-body {
    padding: 0.15rem 0.85rem 0.15rem 2.15rem;
}
.notice-dim-header { cursor: pointer; }

/* option row (checkbox) */
.notice-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--fg-334155);
    user-select: none;
    transition: background 0.1s ease;
}
.notice-option:hover { background: var(--bg-f1f5f9); }

.notice-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.notice-option-box {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-ffffff);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.notice-option-box::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translate(0.5px, -1px);
    opacity: 0;
    transition: opacity 0.1s ease;
}
.notice-option.checked .notice-option-box {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
}
.notice-option.checked .notice-option-box::after { opacity: 1; }

.notice-option-name { flex: 1; min-width: 0; }

.notice-class-actions {
    display: flex;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem 0.35rem;
    border-bottom: 1px dashed var(--bd-e2e8f0);
    margin-bottom: 0.35rem;
}
.notice-class-actions button {
    border: none;
    background: var(--bg-f1f5f9);
    color: var(--fg-475569);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.notice-class-actions button:hover { background: var(--bg-e2e8f0); color: var(--fg-1e293b); }
.notice-class-actions button.primary { background: var(--bg-1e293b); color: var(--fg-ffffff); }
.notice-class-actions button.primary:hover { background: var(--bg-0f172a); }

.notice-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bd-f1f5f9);
}

/* ---------- Markdown editor ---------- */

.editor-tabs {
    display: inline-flex;
    background: var(--bg-f1f5f9);
    padding: 0.15rem;
    border-radius: 8px;
    gap: 0.1rem;
}
.editor-tab {
    border: none;
    background: transparent;
    padding: 0.3rem 0.85rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-64748b);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.editor-tab:hover { color: var(--fg-1e293b); }
.editor-tab.active {
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.editor-surface-wrapper {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 10px;
    background: var(--bg-ffffff);
    overflow: hidden;
}

/* Notice title — render Bengali with SolaimanLipi, English
   with the system font. The @font-face has a Bengali unicode-range,
   so only Bengali codepoints pick up the custom font. */
#notice-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'SolaimanLipi', sans-serif;
}

/* Same treatment for the link popover text field, so link labels
   in Bengali display in the popover while typing. */
#editor-link-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'SolaimanLipi', sans-serif;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-f8fafc);
    border-bottom: 1px solid var(--bd-eef2f6);
}
.editor-surface-wrapper.previewing .editor-toolbar { display: none; }
.editor-surface-wrapper.previewing .editor-source { display: none; }

.editor-toolbar button {
    border: none;
    background: transparent;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--fg-475569);
    cursor: pointer;
    min-width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
    line-height: 1;
}
.editor-toolbar button:not(.is-active):hover {
    background: var(--bg-e2e8f0);
    color: var(--fg-1e293b);
}
.editor-toolbar button.is-active,
.editor-toolbar button.is-active:hover,
.editor-toolbar button.is-active:focus {
    background: var(--bg-1e293b) !important;
    color: var(--fg-ffffff) !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.editor-toolbar button i { font-size: 0.75rem; }
.editor-toolbar button[data-editor="bold"]      { font-weight: 800; }
.editor-toolbar button[data-editor="italic"]    { font-style: italic; }
.editor-toolbar button[data-editor="underline"] { text-decoration: underline; }

.editor-toolbar-sep {
    display: inline-block;
    width: 1px;
    height: 16px;
    background: var(--bg-e2e8f0);
    margin: 0 0.2rem;
}

.editor-source {
    width: 100%;
    min-height: 240px;
    padding: 0.85rem 1rem;
    border: none;
    outline: none;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--fg-1e293b);
    background: var(--bg-ffffff);
    box-sizing: border-box;
}

.editor-preview {
    padding: 0.85rem 1.1rem;
    min-height: 240px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--fg-1e293b);
    overflow-wrap: break-word;
}
.editor-preview h1, .editor-preview h2, .editor-preview h3,
.editor-preview h4, .editor-preview h5, .editor-preview h6 {
    margin: 1em 0 0.4em;
    font-weight: 700;
    line-height: 1.3;
}
.editor-preview h1 { font-size: 1.25rem; }
.editor-preview h2 { font-size: 1.1rem; }
.editor-preview h3 { font-size: 0.98rem; }
.editor-preview h1:first-child, .editor-preview h2:first-child, .editor-preview h3:first-child { margin-top: 0; }
.editor-preview p { margin: 0.6em 0; }
.editor-preview p:first-child { margin-top: 0; }
.editor-preview ul, .editor-preview ol { margin: 0.5em 0; padding-left: 1.5em; }
.editor-preview li { margin: 0.2em 0; }
.editor-preview blockquote {
    margin: 0.6em 0;
    padding: 0.35rem 0.9rem;
    border-left: 3px solid var(--bd-cbd5e1);
    color: var(--fg-475569);
    background: var(--bg-f8fafc);
    border-radius: 0 6px 6px 0;
}
.editor-preview code {
    background: var(--bg-f1f5f9);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}
.editor-preview pre {
    background: var(--bg-1e293b);
    color: var(--fg-e2e8f0);
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.82em;
    margin: 0.6em 0;
}
.editor-preview pre code { background: transparent; color: inherit; padding: 0; }
.editor-preview a { color: var(--fg-2563eb); text-decoration: underline; }
.editor-preview hr { border: none; border-top: 1px solid var(--bd-e2e8f0); margin: 1em 0; }
.editor-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.6em 0;
    font-size: 0.88em;
}
.editor-preview th, .editor-preview td {
    border: 1px solid var(--bd-e2e8f0);
    padding: 0.4rem 0.65rem;
    text-align: left;
}
.editor-preview th { background: var(--bg-f8fafc); font-weight: 600; }
.editor-preview .bangla-text { font-family: 'SolaimanLipi', sans-serif; }

/* ---------- Table picker popover ---------- */

.editor-table-picker {
    position: fixed;
    z-index: 9999999;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    padding: 0.7rem;
    min-width: 220px;
    animation: fadeIn 0.14s ease;
}

.editor-table-picker-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}
.editor-table-picker-head span {
    color: var(--fg-94a3b8);
    font-weight: 600;
    font-size: 0.85rem;
}
.editor-table-picker-head input[type="number"] {
    width: 52px;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
    outline: none;
}
.editor-table-picker-head input[type="number"]:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30,41,59,0.08);
}
.editor-table-picker-head label {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.editor-table-picker-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.editor-table-picker-actions button {
    text-align: left;
    border: none;
    background: var(--bg-f8fafc);
    color: var(--fg-1e293b);
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.editor-table-picker-actions button:hover { background: var(--bg-eef2f7); }
.editor-table-picker-actions button.danger { color: var(--fg-dc2626); }
.editor-table-picker-actions button.danger:hover { background: var(--bg-fef2f2); }
.editor-table-picker-actions button i { width: 14px; text-align: center; font-size: 0.72rem; color: var(--fg-64748b); }
.editor-table-picker-actions button[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}
.editor-table-picker-head button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--bd-d1d9e0);
    background: var(--bg-ffffff);
    border-radius: 6px;
    cursor: pointer;
    color: var(--fg-475569);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.editor-table-picker-head button:hover {
    background: var(--bg-eef2f7);
    color: var(--fg-1e293b);
    border-color: var(--bd-94a3b8);
}
.editor-table-picker-head button i {
    font-size: 0.72rem;
}
.editor-table-picker-actions button.danger i { color: var(--fg-dc2626); }

.editor-table-picker-sep {
    height: 1px;
    background: var(--bg-eef2f6);
    margin: 0.35rem 0;
}

.editor-table-picker-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    padding: 0.15rem 0.3rem 0.35rem;
}

/* Notice detail as page (not modal) */
.notice-detail-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notice-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--bd-d1d9e0);
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
    transition: background 0.12s ease;
}
.notice-detail-back:hover { background: var(--bg-f8fafc); }

.notice-detail-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    padding: 1.5rem 1.75rem 1.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.notice-detail-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--fg-0f172a);
    margin: 0 0 0.4rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.notice-detail-title .notice-pin { color: var(--fg-f59e0b); font-size: 0.95rem; }

.notice-detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--fg-94a3b8);
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bd-f1f5f9);
}
.notice-detail-meta .notice-draft-chip {
    background: var(--bg-fef3c7);
    color: var(--fg-92400e);
    padding: 0.08rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    font-weight: 700;
}
.notice-detail-meta .detail-target-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--fg-1e40af);
    background: var(--bg-eff6ff);
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.72rem;
    border: none;
    cursor: pointer;
}
.notice-detail-meta .detail-target-chip:hover { background: var(--bg-dbeafe); }

.notice-detail-body { font-size: 0.94rem; line-height: 1.65; color: var(--fg-1e293b); }
.notice-detail-body .editor-preview {
    padding: 0;
    min-height: 0;
}

.notice-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bd-f1f5f9);
}

@media (max-width: 640px) {
    .notice-detail-card { padding: 1.1rem 1.15rem 1.25rem; border-radius: 12px; }
    .notice-detail-title { font-size: 1.15rem; }
}

/* ---------- Recipients / targeting modals ---------- */

.recipients-box {
    max-width: 540px;
    width: 100%;
    max-height: min(72vh, 620px);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.recipients-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    flex-shrink: 0;
}
.recipients-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.recipients-subtitle {
    padding: 0.6rem 1.25rem 0.5rem;
    margin: 0;
    font-size: 0.78rem;
    color: var(--fg-64748b);
    font-weight: 500;
    border-bottom: 1px solid var(--bd-f1f5f9);
    flex-shrink: 0;
}
.recipients-subtitle strong {
    color: var(--fg-1e293b);
    font-weight: 700;
}

.recipients-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 1rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.recipients-body::-webkit-scrollbar { width: 6px; }
.recipients-body::-webkit-scrollbar-thumb { background: var(--bg-cbd5e1); border-radius: 8px; }

/* ============================================================ */
/*  RECIPIENT GROUP (Classes / Teachers / per-class)            */
/*                                                              */
/*  Collapsed → inner padding is zero so grid-template-rows:0fr */
/*  truly collapses to nothing. Expanded → padding animates in  */
/*  alongside the row expansion.                                */
/* ============================================================ */

.recipient-group {
    border-radius: 10px;
    margin-bottom: 0.4rem;
    background: var(--bg-f1f5f9);
    border: 1px solid var(--bd-e8eef5);
    overflow: hidden;
    transition: background 0.24s ease;
}
.recipient-group:last-child { margin-bottom: 0; }
.recipient-group.expanded { background: var(--bg-eef2f7); }

.recipient-group-header {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s ease;
}
.recipient-group-header:hover { background: rgba(15, 23, 42, 0.03); }

.recipient-caret {
    font-size: 0.65rem;
    color: var(--fg-94a3b8);
    width: 10px;
    text-align: center;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* only THIS group's own caret rotates — not descendants */
.recipient-group.expanded > .recipient-group-header > .recipient-caret {
    transform: rotate(90deg);
}

.recipient-group-name {
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recipient-group-name i { color: var(--fg-94a3b8); margin-right: 0.35rem; font-size: 0.75rem; }

.recipient-group-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-64748b);
    background: var(--bg-f1f5f9);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.recipient-group-count.all-read { background: var(--bg-dcfce7); color: var(--fg-15803d); }
.recipient-group-count.none-read { background: var(--bg-fee2e2); color: var(--fg-b91c1c); }

.recipient-group-body {
    display: grid;
    grid-template-rows: minmax(0, 0fr);
    visibility: hidden;
    pointer-events: none;
    transition: grid-template-rows 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.recipient-group.expanded > .recipient-group-body {
    grid-template-rows: minmax(0, 1fr);
    visibility: visible;
    pointer-events: auto;
}

.recipient-group-body-inner {
    min-height: 0;
    overflow: hidden;
    background: var(--bg-ffffff);
    /* zero padding while collapsed so nothing leaks */
    padding: 0 0.55rem;
    border-top: 1px solid transparent;
    border-radius: 0 0 9px 9px;
    transition:
        padding 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.28s ease;
}

/* expand → animate padding in alongside the row expansion */
.recipient-group.expanded > .recipient-group-body > .recipient-group-body-inner {
    padding: 0.35rem 0.55rem 0.5rem;
    border-top-color: var(--bd-e8eef5);
}

/* nested groups stack tightly; extra breathing room comes from parent padding */
.recipient-group .recipient-group {
    margin-bottom: 0.35rem;
}
.recipient-group .recipient-group:last-child { margin-bottom: 0; }

.notice-class-header:active,
.notice-dim-header:active,
.recipient-group-header:active,
.editor-tab:active,
.editor-toolbar button:active {
    transform: none !important;
    transition: none !important;
}

.recipient-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--bd-f8fafc);
    font-size: 0.82rem;
}
.recipient-row:last-child { border-bottom: none; }

.recipient-status {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.6rem;
}
.recipient-status.read {
    background: var(--bg-dcfce7);
    color: var(--fg-15803d);
}
.recipient-status.unread {
    background: var(--bg-fee2e2);
    color: var(--fg-b91c1c);
}

.recipient-name {
    flex: 1;
    min-width: 0;
    color: var(--fg-1e293b);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recipient-time {
    font-size: 0.72rem;
    color: var(--fg-94a3b8);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.recipient-row.unread .recipient-name { color: var(--fg-475569); }
.recipient-row.unread .recipient-time { color: var(--fg-b91c1c); font-weight: 600; }

.recipients-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--fg-94a3b8);
    font-size: 0.85rem;
}

/* ---------- Teacher-side: authoring is allowed; only admin-only
   actions (pin / publish / unpublish) are hidden, and those are
   filtered inside the dropdown itself. ---------- */

/* ============================================================ */
/*  AUTHOR CHIP                                                  */
/*                                                              */
/*  Bordered pill with a circular initials avatar on the left,   */
/*  mirroring the teacher-card header from the Teachers tab.     */
/*  Sits inline with the notice date.                            */
/* ============================================================ */
.notice-creator {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.15rem 0.75rem 0.15rem 0.2rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 999px;
    color: var(--fg-334155);
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1.2;
    max-width: 100%;
}

.notice-creator-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-0f172a), var(--bg-475569));   /* dark slate — admin/superadmin */
    color: var(--fg-ffffff);
    font-weight: 700;
    font-size: 0.58rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    user-select: none;
}

/* Teacher creator — matches .teacher-card-avatar so teacher-authored
   notices read at a glance as "made by a teacher" (same cyan family
   as the teacher cards) vs "made by admin" (dark slate). */
.notice-creator-avatar.notice-creator-avatar-teacher {
    background: linear-gradient(135deg, var(--bg-cffafe), var(--bg-a5f3fc));
    color: var(--fg-155e75);
}

.notice-creator-name {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Undo the parent .notice-meta's text-transform: uppercase —
       a person's name must render in its real case. */
    text-transform: none;
    letter-spacing: 0;
}

/* Teacher's own notices — subtle indigo wash on the chip itself is
   the "this is yours" signal. The avatar stays dark slate so the
   authority signal (staff creator) is uniform across all authors. */
.notice-creator-you {
    background: var(--bg-eef2ff);
    border-color: var(--bd-c7d2fe);
    color: var(--fg-3730a3);
}
/* The "You" chip only ever appears on a teacher's own notice — so
   the avatar uses the teacher cyan, identical to what a superadmin
   viewing the same notice would see. Consistency beats "special
   colour for self". */
.notice-creator-you .notice-creator-avatar {
    background: linear-gradient(135deg, var(--bg-cffafe), var(--bg-a5f3fc));
    color: var(--fg-155e75);
}

/* Slightly tighter on the list card so it doesn't push the row */
.notice-meta .notice-creator {
    padding: 0.1rem 0.6rem 0.1rem 0.15rem;
    font-size: 0.68rem;
}
.notice-meta .notice-creator-avatar {
    width: 1.15rem;
    height: 1.15rem;
    font-size: 0.5rem;
}

/* Detail-view variant — match the surrounding meta row's height.
   The date span and the target chip both sit at the meta font
   size, so the author chip must too. */
.notice-detail-meta .notice-creator {
    padding: 0.08rem 0.6rem 0.08rem 0.12rem;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.4rem;
    vertical-align: middle;
}
.notice-detail-meta .notice-creator-avatar {
    width: 1.1rem;
    height: 1.1rem;
    font-size: 0.48rem;
}

/* The meta row itself — align every child on their baselines so
   the taller avatar doesn't push the flex row taller. */
.notice-detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    column-gap: 0.55rem;
}

/* ---------- Mobile tweaks ---------- */

@media (max-width: 640px) {
    .notice-card { padding: 0.75rem 2.75rem 0.75rem 0.85rem; }
    .notice-title { font-size: 0.96rem; }
    .notice-chip-row { gap: 0.35rem; }
    .notice-target-chip { font-size: 0.68rem; padding: 0.15rem 0.55rem; }
    .notice-read-chip   { font-size: 0.68rem; padding: 0.15rem 0.55rem; }

    .editor-source, .editor-preview { min-height: 200px; font-size: 0.82rem; }
    .editor-toolbar button { min-width: 28px; height: 28px; padding: 0.25rem 0.45rem; }

    .recipients-header { padding: 0.85rem 1rem 0.55rem; }
    .recipients-subtitle { padding: 0.5rem 1rem 0.4rem; }
    .recipients-body { padding: 0.6rem 0.75rem 0.85rem; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .editor-table-picker { animation: none; }
    .notice-class-caret, .notice-dim-caret, .recipient-caret { transition: none; }
}

.notice-dim-body { display: block !important; padding-left: 0.85rem; }
.notice-dim-header { cursor: pointer; }

body.role-teacher #dashboard-teachers-tab { display: none !important; }

.notice-detail-view {
    transition: opacity 220ms ease;
}

/* ---------- Notice detail header row ---------- */

.notice-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}
.notice-detail-header-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.notice-detail-header-actions .btn { white-space: nowrap; }

/* ---------- Recipients subtitle: title line + stats line ---------- */

.recipients-title {
    font-weight: 700;
    color: var(--fg-1e293b);
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    line-height: 1.35;
}
.recipients-stats {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--fg-64748b);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* ---------- Bangla font fallback on notice surfaces ---------- */

.notice-detail-title,
.notice-detail-meta,
.notice-detail-body,
.editor-preview,
.editor-source,
.recipients-title,
.notice-title,
.notice-meta {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
}

/* ---------- Detail view smooth transition ---------- */

.notice-detail-view {
    transition: opacity 220ms ease;
}

/* ---------- Recipients body scroll polish ---------- */

.recipients-body {
    scrollbar-gutter: stable;
}
/* Bangla rendering inside markdown + detail — put SolaimanLipi LAST
   in the stack so it only kicks in for Bengali codepoints (its
   @font-face declares a unicode-range). English stays on the system font. */
.editor-preview,
.editor-source,
.notice-detail-body,
.notice-detail-title,
.notice-detail-meta,
.recipients-title,
.recipients-stats,
.notice-title,
.notice-meta {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
}

/* Normal text selection everywhere, including Bengali runs */
.bangla-text,
.editor-preview *,
.notice-detail-body * {
    -webkit-user-select: text;
    user-select: text;
}

/* Bigger detail title */
.notice-detail-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--fg-0f172a);
    margin: 0 0 0.4rem;
    line-height: 1.3;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}
@media (max-width: 640px) {
    .notice-detail-title { font-size: 1.25rem; }
}

/* Recipients modal: fixed height, internal scroll — no snap-jump
   when groups expand. */
.recipients-box {
    height: min(72vh, 620px);
    max-height: min(72vh, 620px);
}

/* Smooth grow / shrink for ALL modals that own a flex body.
   The transition is on max-height so the browser interpolates
   when the target value doesn't change (which is our case — the
   value is fixed but the inner content changes, so no jump). */
.modal-box {
    transition: box-shadow 0.2s ease;
}

.recipients-box {
    transition: max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* SolaimanLipi is last in the stack with a Bengali unicode-range,
   so it only kicks in for Bengali codepoints. English keeps the system
   font. Applies to the markdown preview and any surface that hosts
   rendered body text. */
.editor-preview,
.editor-source,
.notice-detail-body,
.notice-detail-title,
.notice-detail-meta,
.recipients-title,
.recipients-stats {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
}

/* tick: absolute-centre so it can't y-offset regardless of parent box */
.notice-option-box {
    position: relative;
}
.notice-option-box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: translate(-50%, -60%) rotate(-45deg);
    transform-origin: center;
    opacity: 0;
    transition: opacity 0.1s ease;
}
.notice-option.checked .notice-option-box::after { opacity: 1; }

.editor-link-popover {
    position: fixed;
    z-index: 9999999;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    padding: 0.7rem;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: fadeIn 0.14s ease;
}
.editor-link-popover .input-field {
    height: 34px;
    font-size: 0.85rem;
}
.editor-link-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

/* ============================================================ */
/*  MARKDOWN LISTS — bullets align with the content margin,      */
/*  text indented, wrapped lines align with text not bullet      */
/* ============================================================ */
.editor-preview ul,
.editor-preview ol,
.notice-detail-body ul,
.notice-detail-body ol {
    list-style-position: outside;
    padding-left: 1.5em;
    margin: 0.5em 0;
}
.editor-preview li,
.notice-detail-body li {
    padding-left: 0.45em;
    text-indent: 0;
    margin: 0.15em 0;
}
.editor-preview li > ul,
.editor-preview li > ol,
.notice-detail-body li > ul,
.notice-detail-body li > ol {
    margin: 0.15em 0 0.15em 1.15em;
}

/* ---------- Notice surfaces: quiet, fluid, and crisp ---------- */

#dashboard-panel-notices {
    --notice-ink: #172033;
    --notice-muted: #718096;
    --notice-line: rgba(148, 163, 184, 0.2);
    --notice-accent: #4263eb;
    color: var(--notice-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#dashboard-panel-notices .page-header {
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

#dashboard-panel-notices .report-filter-section + .report-filter-section {
    border-top: 1px solid var(--bd-f1f5f9);
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}

#dashboard-panel-notices .report-filter-section-label {
    padding: 0.35rem 0.75rem 0.2rem;
    color: var(--fg-94a3b8);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

#dashboard-panel-notices .report-filter-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    color: var(--fg-1e293b);
    font-size: 0.85rem;
}

#dashboard-panel-notices .report-filter-check {
    display: inline-flex;
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 3px;
    background: var(--bg-ffffff);
    color: transparent;
    font-size: 0.55rem;
}

#dashboard-panel-notices .report-filter-option.active .report-filter-check {
    border-color: var(--bd-111318);
    background: var(--bg-111318);
    color: var(--fg-ffffff);
}

.class-teacher-header-actions,
.split-action-group {
    display: flex;
    align-items: center;
}

.class-teacher-header-actions {
    gap: 0.75rem;
}

.class-teacher-admin-note {
    margin: 0;
    color: var(--fg-64748b);
    font-size: 0.78rem;
}

.split-action-group {
    position: relative;
}

.split-action-group.has-split > .btn + .btn {
    margin-left: -1px;
    border-left-color: rgba(255, 255, 255, 0.24);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.split-action-group.has-split > #add-class-teacher-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.split-action-group:not(.has-split) > #add-class-teacher-btn {
    border-radius: 8px;
}

.split-action-toggle {
    display: inline-flex;
    width: 26px;
    min-width: 26px;
    height: 32px;
    padding: 0 5px;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.split-action-toggle i {
    font-size: 0.68rem;
}

.split-action-group.has-split > #add-class-teacher-btn {
    white-space: nowrap;
}

.payment-detail-table tr[data-ghost="true"] .payment-ghost-student {
    max-width: 120px;
    overflow: hidden;
    text-align: left;
}

.payment-detail-table tr[data-ghost="true"] .payment-ghost-student strong {
    font-style: normal;
}

.payment-detail-table tr[data-ghost="true"] .payment-ghost-deleted {
    text-align: center;
    white-space: nowrap;
}

.payment-detail-table tr[data-ghost="true"] .payment-ghost-deleted span {
    color: var(--fg-94a3b8);
    font-size: 0.7rem;
}

.split-action-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 120;
    min-width: 150px;
    padding: 0.3rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 9px;
    background: var(--bg-ffffff);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}

.split-action-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--fg-1e293b);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.split-action-menu button:hover {
    background: var(--bg-f1f5f9);
}

.split-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 148px;
    margin-top: 4px;
    padding: 0.25rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 9px;
    box-shadow: var(--elev-2);
}

.split-dropdown-menu .dropdown-item {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--fg-1e293b);
    font-size: 0.85rem;
    text-align: left;
}

.split-dropdown-menu .dropdown-item:hover {
    background: var(--bg-f1f5f9);
}

/* ---------- Collapsible class → groups filter tree ---------- */
.flt-tree {
    border-top: 1px solid var(--bd-eef2f6);
}

.flt-tree:first-child {
    border-top: 0;
}

.flt-tree-head {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.6rem;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--fg-0f172a);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.flt-tree-head:hover {
    background: var(--bg-f1f5f9);
}

.flt-tree-caret {
    flex: 0 0 auto;
    font-size: 0.6rem;
    color: var(--fg-94a3b8);
    transition: transform 0.18s ease;
}

.flt-tree-head[aria-expanded="true"] .flt-tree-caret {
    transform: rotate(90deg);
}

.flt-tree-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flt-tree-count {
    flex: 0 0 auto;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    background: var(--bg-eff6ff);
    color: var(--fg-2563eb);
    font-size: 0.66rem;
    font-weight: 600;
}

.flt-tree-body {
    margin: 0 0.35rem 0.45rem 0.6rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--bd-eef2f6);
}

.flt-tree-body .report-filter-section {
    padding: 0;
}

.flt-tree-body .report-filter-section-label {
    padding-left: 0.15rem;
    font-size: 0.62rem;
}

.add-existing-teacher-list {
    display: grid;
    max-height: min(320px, 45vh);
    gap: 0.35rem;
    overflow-y: auto;
}

.add-existing-teacher-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    background: var(--bg-ffffff);
    color: var(--fg-172033);
    cursor: pointer;
    text-align: left;
}

.add-existing-teacher-option:hover {
    border-color: var(--bd-94a3b8);
    background: var(--bg-f8fafc);
}

.add-existing-teacher-option small {
    color: var(--fg-64748b);
}

.teacher-assignment-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    background: var(--bg-f8fafc);
}

.teacher-assignment-avatar {
    display: inline-flex;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-e2e8f0);
    color: var(--fg-334155);
    font-weight: 700;
}

.teacher-assignment-details {
    display: grid;
    min-width: 0;
    gap: 0.15rem;
}

.teacher-assignment-details strong,
.teacher-assignment-details small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.teacher-assignment-details strong {
    color: var(--fg-172033);
    font-size: 0.9rem;
}

.teacher-assignment-details small {
    color: var(--fg-64748b);
}

/* The header row is tight next to a long class name; let the actions
   drop under the title instead of squeezing the label out of its pill. */
.tab-header {
    flex-wrap: wrap;
    row-gap: 0.5rem;
}

#add-class-teacher-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.class-teacher-header-actions,
.split-action-group {
    flex: 0 0 auto;
}

@media (max-width: 900px) {
    .class-teacher-header-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    #add-class-teacher-btn {
        width: auto;
        min-width: 36px;
        height: 32px;
        min-height: 32px;
        padding: 0 0.55rem;
        justify-content: center;
        gap: 0;
    }

    .split-action-group.has-split > #add-class-teacher-btn {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .split-action-group.has-split .split-action-toggle {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }

    .split-action-group:not(.has-split) > #add-class-teacher-btn {
        border-radius: 8px;
    }
}

/* Dashboard panel headings — match the class-level tab headings.
   League Spartan with a small baseline offset so the text sits on
   the same optical line as the sans-serif headings on other views. */
#dashboard-panel-notices .page-header h2,
#dashboard-panel-classes .page-header h2,
#dashboard-panel-teachers .page-header h2 {
    min-width: 0;
    color: var(--notice-ink, var(--fg-172033));
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(1.45rem, 2.4vw, 1.9rem);
    font-weight: 600;
    letter-spacing: -0.035em;
    transform: translateY(2px);
}

#view-dashboard .dashboard-panel .page-header > .btn {
    min-height: 36px;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-top-color: rgba(255, 255, 255, 0.16);
    border-bottom-color: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--bg-292d35), var(--bg-111318));
    /* The bevel is the border pair and the gradient face. The old second
       drop shadow under the button is gone — it read as a detached base. */
    box-shadow: var(--btn-contact);
    color: var(--fg-ffffff);
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

#view-dashboard .dashboard-panel .page-header > .btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, var(--bg-343943), var(--bg-191c22));
    border-top-color: rgba(255, 255, 255, 0.2);
    border-bottom-color: rgba(0, 0, 0, 0.55);
    box-shadow: var(--btn-contact-hover);
}

/* A shared raised face for the newer in-panel actions (View Marks,
   Print, Edit). Each variant keeps its own fill — the 3D comes from a
   lit top edge, a shaded bottom edge and a soft highlight across the
   upper half, not from a grey gradient that washes the colour out. */
.btn-raised.btn-primary,
.btn-raised.btn-success,
.btn-raised.btn-danger {
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.20),
        rgba(255, 255, 255, 0.04) 46%,
        rgba(0, 0, 0, 0.10));
    border-color: rgba(0, 0, 0, 0.16);
    border-top-color: rgba(255, 255, 255, 0.34);
    border-bottom-color: rgba(0, 0, 0, 0.34);
    box-shadow: var(--btn-contact), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    color: #ffffff;
}
.btn-raised.btn-primary { background-color: var(--bg-1e293b); }
.btn-raised.btn-success { background-color: var(--bg-16a34a); }
.btn-raised.btn-danger  { background-color: var(--bg-dc2626); }

/* The plain variants reset their face with a `background` shorthand on
   hover, so the gradient has to be restated here to survive. */
.btn-raised.btn-primary:hover,
.btn-raised.btn-success:hover,
.btn-raised.btn-danger:hover {
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.24),
        rgba(255, 255, 255, 0.06) 46%,
        rgba(0, 0, 0, 0.10));
    border-top-color: rgba(255, 255, 255, 0.42);
    border-bottom-color: rgba(0, 0, 0, 0.38);
    box-shadow: var(--btn-contact-hover), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-raised.btn-primary:hover { background-color: var(--bg-0f172a); }
.btn-raised.btn-success:hover { background-color: var(--bg-15803d); }
.btn-raised.btn-danger:hover  { background-color: var(--bg-b91c1c); }
.btn-raised {
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.btn-raised:hover { transform: translateY(-1px); }

#dashboard-panel-notices #create-notice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    gap: 0.45rem;
    white-space: nowrap;
}

#view-dashboard .dashboard-action-btn {
    flex-shrink: 0;
    gap: 0.45rem;
    white-space: nowrap;
}

#dashboard-panel-notices .notice-cards-wrapper {
    gap: 0.65rem;
}

#dashboard-panel-notices .notice-card,
#dashboard-panel-notices .notice-detail-card {
    border-color: var(--notice-line);
    border-radius: 16px;
    background: rgba(var(--surface-rgb), 0.92);
    box-shadow: var(--elev-1);
    transition:
        border-color 0.24s ease,
        box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

#dashboard-panel-notices .notice-card {
    padding: 1.05rem 3.1rem 1.05rem 1.2rem;
}

#dashboard-panel-notices .notice-card:hover {
    border-color: var(--notice-line);
    box-shadow: var(--elev-2);
}

#dashboard-panel-notices .notice-title {
    color: var(--notice-ink);
    font-size: 1.04rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

#dashboard-panel-notices .notice-meta {
    color: var(--notice-muted);
    letter-spacing: 0.045em;
}

#dashboard-panel-notices .notice-target-chip,
#dashboard-panel-notices .notice-read-chip,
#dashboard-panel-notices .detail-target-chip {
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 999px;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

#dashboard-panel-notices .notice-target-chip,
#dashboard-panel-notices .notice-detail-meta .detail-target-chip {
    color: var(--fg-303640);
    background: var(--bg-f1f3f5);
}

#dashboard-panel-notices .notice-target-chip:hover,
#dashboard-panel-notices .notice-detail-meta .detail-target-chip:hover {
    background: var(--bg-e7e9ed);
}

#dashboard-panel-notices .notice-target-chip:hover,
#dashboard-panel-notices .notice-read-chip:hover,
#dashboard-panel-notices .detail-target-chip:hover {
    transform: translateY(-1px);
    border-color: var(--notice-line);
}

#modal-notice-editor .notice-editor-box,
#modal-notice-targeting .recipients-box,
#modal-notice-recipients .recipients-box {
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

#modal-notice-editor .notice-editor-header,
#modal-notice-editor .notice-editor-actions,
#modal-notice-targeting .recipients-header,
#modal-notice-recipients .recipients-header {
    border-color: rgba(148, 163, 184, 0.17);
}

#modal-notice-editor .notice-editor-header h3 {
    color: var(--notice-ink);
    font-weight: 680;
    letter-spacing: -0.025em;
}

#modal-notice-editor .editor-surface-wrapper {
    border-color: rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

#modal-notice-editor .editor-surface-wrapper:focus-within {
    border-color: rgba(45, 49, 56, 0.62);
    box-shadow: 0 0 0 4px rgba(45, 49, 56, 0.09);
}

#modal-notice-editor .editor-toolbar {
    gap: 0.2rem;
    padding: 0.45rem 0.55rem;
    background: var(--bg-f8f9fc);
}

#modal-notice-editor .editor-toolbar button {
    border-radius: 8px;
}

#modal-notice-editor .editor-toolbar button:hover {
    background: var(--bg-eceef1);
    color: var(--fg-202329);
}

#modal-notice-editor .btn-primary,
#editor-link-popover .btn-primary {
    border-color: rgba(17, 24, 39, 0.08);
    background: linear-gradient(180deg, var(--bg-292d35), var(--bg-111318));
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.16);
}

#modal-notice-editor .btn-primary:hover,
#editor-link-popover .btn-primary:hover {
    background: linear-gradient(180deg, var(--bg-343943), var(--bg-191c22));
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.2);
}

#modal-notice-editor .editor-source {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SolaimanLipi", sans-serif;
    font-size: 0.93rem;
    line-height: 1.7;
}

#modal-notice-editor .editor-tab {
    transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

#modal-notice-editor .editor-tab.active {
    color: var(--fg-ffffff);
    background: var(--bg-202329);
    box-shadow: 0 2px 5px rgba(17, 24, 39, 0.18);
}

#dashboard-panel-notices .notice-detail-view {
    gap: 1.15rem;
}

#dashboard-panel-notices .notice-detail-card {
    padding: clamp(1.25rem, 4vw, 2.25rem);
}

#dashboard-panel-notices .notice-detail-title {
    color: var(--notice-ink);
    font-size: clamp(1.3rem, 3vw, 1.85rem);
    letter-spacing: -0.04em;
}

#dashboard-panel-notices .notice-detail-body h1 {
    font-size: 1.25rem;
}

#dashboard-panel-notices .notice-detail-body h2 {
    font-size: 1.1rem;
}

.notice-detail-body h1,
.notice-detail-body h2 {
    margin-top: 1em;
    margin-bottom: 0.4em;
    line-height: 1.35;
}

.notice-detail-body h1 { font-size: 1.25rem; }
.notice-detail-body h2 { font-size: 1.1rem; }
.notice-detail-body > :first-child:is(h1, h2) { margin-top: 0; }

.editor-preview table,
.notice-detail-body table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 0.6rem 0;
    font-size: 0.88em;
    border: 1px solid var(--bd-cbd5e1);
    border-radius: 8px;
    table-layout: fixed;
    box-shadow: 0 0 0 1px var(--bd-cbd5e1);
}

.editor-preview th,
.editor-preview td,
.notice-detail-body th,
.notice-detail-body td {
    min-width: 120px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--bd-e2e8f0);
    text-align: center;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.editor-preview th,
.notice-detail-body th {
    border-color: var(--bd-d1d9e0);
}

.editor-preview th,
.notice-detail-body th {
    background: var(--bg-eff6ff);
    color: var(--fg-1e3a5f);
    font-weight: 700;
}

.editor-preview tr:first-child th,
.notice-detail-body tr:first-child th {
    border-top: none;
}

#dashboard-panel-notices .notice-detail-meta .detail-target-chip {
    color: var(--fg-3f4650);
    background: var(--bg-f1f3f5);
    border: 1px solid rgba(100, 116, 139, 0.15);
}

#dashboard-panel-notices .notice-detail-meta .detail-target-chip:hover {
    color: var(--fg-272c33);
    background: var(--bg-e7e9ed);
}

#dashboard-panel-notices .notice-detail-meta {
    color: var(--notice-muted);
}

#dashboard-panel-notices .notice-detail-body a,
#modal-notice-editor .editor-preview a {
    color: var(--fg-242830);
    text-decoration-color: var(--fg-9299a4);
    text-underline-offset: 3px;
}

#modal-notice-targeting .recipient-group,
#modal-notice-recipients .recipient-group {
    border-color: rgba(148, 163, 184, 0.19);
    border-radius: 13px;
}

#dashboard-panel-notices :focus-visible,
#modal-notice-editor :focus-visible,
#modal-notice-targeting :focus-visible,
#modal-notice-recipients :focus-visible {
    outline: 3px solid rgba(45, 49, 56, 0.3);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    #view-dashboard .dashboard-panel .page-header > .dashboard-action-btn {
        width: 36px;
        min-width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        justify-content: center;
    }

    #view-dashboard .dashboard-action-label {
        display: none;
    }

    #dashboard-panel-notices .notice-card {
        padding: 0.95rem 2.75rem 0.95rem 1rem;
        border-radius: 16px;
    }
    #dashboard-panel-notices .page-header {
        align-items: flex-start;
    }
}

.editor-link-popover {
    width: min(340px, calc(100vw - 24px));
    min-width: min(280px, calc(100vw - 24px));
    padding: 0.9rem;
    border-color: rgba(148, 163, 184, 0.3);
    border-radius: 16px;
    box-shadow: 0 18px 55px rgba(15, 23, 42, 0.18);
}

.editor-link-popover label {
    color: var(--fg-475569);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.015em;
}

.editor-link-popover .input-field {
    border-radius: 9px;
}

.editor-link-popover .input-field:focus {
    border-color: var(--bd-475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.dashboard-tabs,
.dashboard-tab {
    -webkit-tap-highlight-color: transparent;
}

#view-dashboard,
#view-dashboard .dashboard-main {
    touch-action: pan-y pinch-zoom;
}

#dashboard-panels {
    touch-action: pan-y pinch-zoom;
}

#dashboard-tabs,
#dashboard-tabs-outer {
    touch-action: pan-x pinch-zoom;
}

@media (prefers-reduced-motion: reduce) {
    #dashboard-panel-notices *,
    #modal-notice-editor *,
    #modal-notice-targeting *,
    #modal-notice-recipients * {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* The selected tab is a full-height pill that follows tab selection. */
#dashboard-tabs {
    position: relative;
    isolation: isolate;
    align-items: stretch;
    gap: 0;
    padding: 0;
    overflow-x: auto;
}

#dashboard-tabs::before {
    position: absolute;
    z-index: 0;
    inset: 0 auto 0 0;
    width: var(--dashboard-indicator-width, 0px);
    border-radius: 999px;
    background: var(--bg-17191d);
    content: "";
    transform: translate3d(var(--dashboard-indicator-x, 0px), 0, 0);
    transition:
        transform var(--dashboard-indicator-duration, 260ms) cubic-bezier(0.22, 1, 0.36, 1),
        width var(--dashboard-indicator-duration, 260ms) cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

#dashboard-tabs .dashboard-tab {
    position: relative;
    z-index: 1;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    transition: color 160ms ease;
}

#dashboard-tabs .dashboard-tab.active {
    color: var(--fg-ffffff);
    background: transparent;
    box-shadow: none;
}

#dashboard-tabs .dashboard-tab:hover {
    color: var(--fg-202329);
}

#dashboard-tabs .dashboard-tab.active:hover {
    color: var(--fg-ffffff);
}

#dashboard-tabs .dashboard-tab:active {
    transform: none !important;
    transition: color 160ms ease !important;
}

@media (prefers-reduced-motion: reduce) {
    #dashboard-tabs::before {
        transition-duration: 1ms;
    }
}

#view-class .tab-header h2,
#view-class #class-title {
    color: var(--fg-17191d);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: -0.045em;
}

#view-class #class-title {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(1.5rem, 2vw, 1.7rem);
    font-weight: 600;
}

#view-class .tab-header h2 {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(1.3rem, 1.6vw, 1.4rem);
    font-weight: 550;
    margin-top: 0.3rem;
    transform: translateY(2px);
}

.page-header h2,
.tab-header h2 {
    margin-top: 0.3rem;
}

#student-sidebar {
    width: 200px;
    flex: 0 0 200px;
}

@media (min-width: 769px) {
    .student-layout {
        min-height: calc(60vh - 76px);
    }
}

#student-sidebar .sidebar-link,
#student-mobile-menu .mobile-menu-nav .sidebar-link {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
}

#student-sidebar .sidebar-link.active,
#student-mobile-menu .mobile-menu-nav .sidebar-link.active {
    background: var(--bg-17191d);
    color: var(--fg-ffffff);
}

.sidebar-link,
.mobile-menu-nav .sidebar-link {
    transition: background-color 220ms ease, color 220ms ease;
}

#student-sidebar [data-tab="notices"],
#student-mobile-menu [data-tab="notices"] {
    position: relative;
}

#student-sidebar [data-tab="notices"].has-unread::after,
#student-mobile-menu [data-tab="notices"].has-unread::after {
    position: static;
    flex: 0 0 0.5rem;
    width: 0.5rem;
    height: 0.5rem;
    margin-left: auto;
    border-radius: 50%;
    background: var(--bg-dc2626);
    content: '';
}

#student-notice-list .student-notice-card {
    display: block;
    width: 100%;
    border: 1px solid var(--bd-e2e8f0);
    color: inherit;
    font: inherit;
    text-align: left;
    transition:
        box-shadow 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
    #student-notice-list .student-notice-card:hover {
        box-shadow: var(--elev-2);
        translate: 0 -2px;
        border-color: var(--bd-dbe2ea);
    }
}

@media (hover: none) and (pointer: coarse) {
    #student-notice-list .student-notice-card.is-tap-raised {
        box-shadow: var(--elev-2);
        translate: 0 -2px;
        border-color: var(--bd-dbe2ea);
    }
}

#student-tab-notices > .page-header h2 {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 650;
}

#view-student .page-header h2,
#view-marks .page-header h2 {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1.35rem;
    font-weight: 650;
    transform: translateY(2px);
}

@media (max-width: 768px) {
    #view-student .page-header h2 {
        font-size: 1.4rem;
    }
}

.student-notice-card .notice-title-row {
    align-items: center;
}

.student-notice-detail-view {
    gap: 0.55rem;
}

@media (max-width: 640px) {
    .student-notice-detail-view .notice-detail-title {
        font-size: 1.4rem;
    }
}

.student-notice-detail-header {
    justify-content: flex-start;
    margin: 0;
}

.student-notice-detail-header .notice-detail-back {
    gap: 0.45rem;
    border: 0;
    background: transparent;
    color: var(--fg-475569);
    padding: 0.45rem 0.2rem;
    font-size: 0.88rem;
}

.student-notice-detail-header .notice-detail-back:hover {
    background: transparent;
    color: var(--fg-111318);
}

#student-notice-detail .notice-detail-card {
    width: 100%;
}

.notice-card {
    overflow: visible;
    transition:
        box-shadow 0.18s ease,
        border-color 0.18s ease,
        margin-top 0.24s ease,
        border-radius 0.24s ease;
}

.notice-card.has-flags {
    margin-top: 1.65rem;
    border-top-left-radius: 0;
}

#dashboard-panel-notices .notice-card.has-flags {
    border-top-left-radius: 0;
}

.notice-card-flags {
    position: absolute;
    top: -1.65rem;
    left: -1px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    width: fit-content;
    max-width: calc(100% - 1rem);
    height: 1.65rem;
    gap: 0.4rem;
    margin: 0;
    padding: 0.32rem 1rem;
    border: 1px solid var(--bd-e2e8f0);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: var(--bg-f8fafc);
    transition: border-color 180ms ease, opacity 180ms ease;
}

.notice-card-unread-dot {
    position: absolute;
    top: 0.8rem;
    right: 0.85rem;
    z-index: 1;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--bg-dc2626);
    pointer-events: none;
}

.notice-card:hover .notice-card-flags {
    border-color: var(--bd-dbe2ea);
    border-bottom: 0;
}

#dashboard-panel-notices .notice-card:hover .notice-card-flags {
    border-color: var(--notice-line);
    border-bottom: 0;
}

.notice-equation-guide {
    margin: -0.35rem 0 0.8rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    background: var(--bg-f8fafc);
    color: var(--fg-475569);
    font-size: 0.78rem;
}

.notice-equation-guide summary {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.75rem;
    color: var(--fg-334155);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.notice-equation-guide summary::-webkit-details-marker { display: none; }
.notice-equation-guide summary::after {
    content: '+';
    margin-left: auto;
    color: var(--fg-64748b);
    font-size: 1rem;
}
.notice-equation-guide[open] summary::after { content: '−'; }
.notice-equation-guide summary span { color: var(--fg-94a3b8); font-weight: 400; }
.notice-equation-guide-content {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border-top: 0 solid var(--bd-e2e8f0);
    transition: grid-template-rows 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease, border-top-width 280ms ease, visibility 280ms step-end;
}
.notice-equation-guide[open] > .notice-equation-guide-content {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    border-top-width: 1px;
    transition: grid-template-rows 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease, border-top-width 280ms ease, visibility 0s;
}
.notice-equation-guide-inner {
    min-height: 0;
    overflow: hidden;
    padding: 0 0.75rem;
    transition: padding-bottom 280ms ease;
}
.notice-equation-guide[open] .notice-equation-guide-inner {
    padding-bottom: 0.65rem;
}
.notice-equation-guide-content p { margin: 0.55rem 0 0; line-height: 1.5; }
.notice-equation-guide-content code {
    padding: 0.08rem 0.28rem;
    border-radius: 4px;
    background: var(--bg-e8eef8);
    color: var(--fg-1e293b);
    overflow-wrap: anywhere;
}
.notice-equation-snippet {
    display: grid;
    grid-template-columns: minmax(6.5rem, 0.3fr) 1fr;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.45rem;
    padding: 0.42rem 0.55rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 7px;
    background: var(--bg-ffffff);
}
.notice-equation-snippet > span { color: var(--fg-64748b); font-size: 0.72rem; }
.notice-equation-snippet code {
    display: inline-block;
    padding: 0.22rem 0.42rem;
    background: var(--bg-eef2ff);
    color: var(--fg-3730a3);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    user-select: all;
    -webkit-user-select: all;
}
.notice-equation-tip { color: var(--fg-64748b); font-size: 0.73rem; }
.equation-block,
.equation-edit-source {
    display: inline-block;
    max-width: 100%;
    min-width: 1.4em;
    padding: 0.05rem 0.22rem;
    border: 1px dashed var(--bd-94a3b8);
    border-radius: 5px;
    background: transparent;
    vertical-align: middle;
    cursor: text;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.equation-block mjx-container {
    margin: 0 !important;
}
.equation-edit-source { outline: none; }
#view-exam .equation-block {
    border: 0;
    padding: 0;
    cursor: inherit;
}

/* ---- Flowcharts (flow[...]) ---- */
.flow-block {
    display: block;
    max-width: 100%;
    margin: 0.5rem 0;
    padding: 0.55rem;
    border: 1px dashed var(--bd-94a3b8);
    border-radius: 8px;
    background: var(--bg-f8fafc);
    overflow-x: auto;
    cursor: text;
}
.flow-edit-source {
    display: block;
    padding: 0.15rem 0.35rem;
    border: 1px dashed var(--bd-94a3b8);
    border-radius: 5px;
    color: var(--fg-3730a3);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    outline: none;
}
.flow-canvas {
    position: relative;
    margin: 0 auto;
}
.flow-edges {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
}
.flow-edge {
    fill: none;
    stroke: var(--fg-64748b);
    stroke-width: 1.3;
    stroke-linejoin: round;
}
.flow-arrow-head { fill: var(--fg-64748b); }
.flow-edge-label {
    fill: var(--fg-475569);
    font-size: 10.5px;
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--bg-f8fafc);
    stroke-width: 3px;
    stroke-linejoin: round;
}
.flow-node {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.5rem;
    max-width: 200px;
    text-align: center;
    color: var(--fg-1e293b);
    font-size: 0.75rem;
    line-height: 1.28;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-cbd5e1);
    border-radius: 7px;
    overflow-wrap: anywhere;
}
.flow-node.is-terminal {
    border-radius: 999px;
    background: var(--bg-ffffff);
    font-weight: 600;
}
.flow-node.is-decision {
    padding: 0.3rem 1.35rem;
    background: var(--bg-eef2ff);
    color: var(--fg-3730a3);
    border: 0;
    clip-path: polygon(0 50%, 9% 0, 91% 0, 100% 50%, 91% 100%, 9% 100%);
}
#view-exam .flow-block {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: inherit;
}
#view-exam .flow-node {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Interactive builder — the drawing is edited in place, like a mind map */
.flow-block.is-flow-editing {
    border-color: #6366f1;
    border-style: solid;
    cursor: default;
}
.flow-toolbar {
    position: sticky;
    left: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.45rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--bd-e2e8f0, #e2e8f0);
    /* The canvas scrolls sideways; the hint and the buttons stay put while
       it does, so they are always under the pointer. */
    background: var(--bg-f8fafc);
}
.flow-toolbar-hint {
    margin-right: auto;
    color: var(--fg-94a3b8);
    font-size: 0.68rem;
}
.flow-toolbar-spacer { flex: 0 0 0; }
.flow-tool {
    padding: 0.18rem 0.5rem;
    border: 1px solid var(--bd-e2e8f0, #e2e8f0);
    border-radius: 999px;
    background: var(--bg-ffffff, #fff);
    color: var(--fg-334155, #334155);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
}
.flow-tool:hover { border-color: #6366f1; color: #4338ca; }
.flow-tool.is-primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
html[data-theme="dark"] .flow-tool {
    border-color: #334155;
    background: #1e293b;
    color: #e2e8f0;
}
html[data-theme="dark"] .flow-tool:hover { border-color: #818cf8; color: #c7d2fe; }
html[data-theme="dark"] .flow-tool.is-primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
/* The controls sit in small clusters around the selected step: a branch
   with its delete beside it, and a branch beside the "+" underneath. */
.flow-tools {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 6px;
}
.flow-tools.is-bottom { transform: translateX(-50%); }
.flow-tools.is-right { transform: translateY(-50%); }
.flow-tools.is-left { transform: translate(-100%, -50%); }
.flow-node-add,
.flow-node-branch,
.flow-node-delete {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-ffffff, #fff);
    font-size: 0.58rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
/* The "+" hangs under the step on a short line. */
.flow-node-add { border: 1px solid #c7d2fe; color: #4f46e5; }
.flow-tools.is-bottom::before {
    position: absolute;
    bottom: 100%;
    left: 50%;
    width: 1px;
    height: 14px;
    background: #c7d2fe;
    content: '';
}
.flow-node-add:hover { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.flow-node-branch { border: 1px solid #c7d2fe; color: #4f46e5; }
.flow-node-branch:hover { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.flow-node-delete { border: 1px solid #fecaca; color: #dc2626; }
.flow-node-delete:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
html[data-theme="dark"] .flow-start-add,
html[data-theme="dark"] .flow-node-add,
html[data-theme="dark"] .flow-node-branch,
html[data-theme="dark"] .flow-node-delete {
    border-color: #4338ca;
    background: #1e293b;
    color: #a5b4fc;
}
html[data-theme="dark"] .flow-node-delete { border-color: #7f1d1d; color: #fca5a5; }
html[data-theme="dark"] .flow-node-add:hover,
html[data-theme="dark"] .flow-node-branch:hover,
html[data-theme="dark"] .flow-start-add:hover { background: #4f46e5; border-color: #4f46e5; color: #fff; }
html[data-theme="dark"] .flow-node-delete:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
/* The blank canvas carries one lonely "+" in its middle. */
.flow-start-add {
    position: absolute;
    left: 50%;
    top: 50%;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px dashed #a5b4fc;
    border-radius: 50%;
    background: var(--bg-ffffff, #fff);
    color: #4f46e5;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.flow-start-add:hover { background: #eef2ff; border-color: #6366f1; }
.flow-node.is-selected {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.18);
}
/* A diamond is clipped, so its outline would be cut off: tint it instead. */
.flow-node.is-decision.is-selected {
    outline: none;
    background: #c7d2fe;
}
/* The step writes on its own surface: no field laid over the box, and no
   fixed width — the box grows with what is typed, up to its max-width. */
.flow-node.is-editing {
    cursor: text;
    min-width: 44px;
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
    user-select: text;
    -webkit-user-select: text;
}
.flow-node.is-decision.is-editing {
    outline: none;
    box-shadow: none;
    background: #c7d2fe;
}
/* Inline writer — the group-name look: quiet field, ring on focus. */
.flow-node-input {
    box-sizing: border-box;
    position: absolute;
    z-index: 3;
    padding: 0 0.45rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    background: var(--bg-ffffff, #fff);
    color: var(--fg-1e293b);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    outline: none;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
html[data-theme="dark"] .flow-node-input {
    border-color: #475569;
    background: #0f172a;
    color: #e2e8f0;
}
.flow-node-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18), 0 8px 20px rgba(15, 23, 42, 0.14);
}
.flow-edge-label { cursor: pointer; }
#view-exam .flow-toolbar,
#view-exam .flow-tools,
#view-exam .flow-start-add { display: none; }

.notice-flag {
    display: inline-flex;
    align-items: center;
    min-height: 1rem;
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    line-height: 1;
}

.notice-detail-body mjx-container[display="true"],
.notice-body mjx-container[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.35em 0;
}

.notice-flag-pinned {
    background: var(--bg-fef3c7);
    color: var(--fg-92400e);
}

.hamburger-toggle {
    position: relative;
    overflow: visible;
}

#student-hamburger-toggle.has-unread::after,
#student-hamburger-toggle-marks.has-unread::after {
    position: absolute;
    top: 5px;
    left: 27px;
    width: 0.58rem;
    height: 0.58rem;
    border-radius: 50%;
    background: var(--bg-dc2626);
    box-shadow: 0 1px 4px rgba(127, 29, 29, 0.25);
    content: '';
    transform: translate(-50%, -50%);
    transition: opacity 180ms ease;
    pointer-events: none;
}

#student-hamburger-toggle.rotated.has-unread::after,
#student-hamburger-toggle-marks.rotated.has-unread::after {
    opacity: 0;
}

.toast {
    width: max-content;
    max-width: 100%;
    min-width: 0;
    flex: 0 1 auto;
}

.toast .toast-text {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ============================================================ */
/*  NOTICE CARDS — no tap bump                            */
/*                                                              */
/*  Student notice cards are <button> elements, so they   */
/*  inherit the global `button:active { transform: scale(0.96) }` */
/*  rule. That fires the instant the finger touches down,       */
/*  producing a visible shrink-then-release yoyo. Lock it.      */
/* ============================================================ */
.notice-card:active,
.student-notice-card:active,
#dashboard-panel-notices .notice-card:active {
    transform: none !important;
    transition:
        box-shadow 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.32s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* ============================================================ */
/*  VISUAL TABLE EDITOR                                          */
/*                                                              */
/*  Modal-based grid editor for Markdown tables. Every cell is   */
/*  an <input>; Tab and Shift+Tab move between cells; Tab past   */
/*  the last cell appends a new row. The grid itself uses a 4px  */
/*  slate gutter between rounded white cells so the table reads   */
/*  as a spreadsheet, not a wall of bordered boxes.              */
/* ============================================================ */
.table-editor-box {
    max-width: 720px;
    padding: 0;
    max-height: min(85vh, 800px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.table-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--bd-eef2f6);
    flex-shrink: 0;
}
.table-editor-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.table-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--bd-f1f5f9);
    flex-shrink: 0;
}
.table-editor-toolbar .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.table-editor-info {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--fg-64748b);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.table-editor-grid-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.25rem;
    background: var(--bg-f8fafc);
}
.table-editor-grid {
    display: grid;
    gap: 4px;
    background: var(--bg-cbd5e1);
    padding: 4px;
    border-radius: 8px;
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
}
.table-editor-cell {
    background: var(--bg-ffffff);
    border: none;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    min-width: 90px;
    max-width: 220px;
    outline: none;
    font-family: inherit;
    color: var(--fg-1e293b);
    transition: background 0.12s ease, box-shadow 0.12s ease;
    border-radius: 4px;
    box-sizing: border-box;
}
.table-editor-cell:focus {
    background: var(--bg-eff6ff);
    box-shadow: inset 0 0 0 2px var(--fg-2563eb);
}
.table-editor-cell.header-cell {
    font-weight: 600;
    background: var(--bg-f1f5f9);
    color: var(--fg-334155);
}
.table-editor-cell.header-cell:focus {
    background: var(--bg-dbeafe);
}
.table-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem 1rem;
    border-top: 1px solid var(--bd-eef2f6);
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .table-editor-box { max-height: 92vh; }
    .table-editor-grid-wrap { padding: 0.75rem; }
    .table-editor-cell {
        min-width: 70px;
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }
    .table-editor-header { padding: 0.85rem 1rem 0.6rem; }
    .table-editor-toolbar { padding: 0.6rem 1rem; }
    .table-editor-actions { padding: 0.7rem 1rem 0.85rem; }
}

/* ============================================================ */
/*  WYSIWYG WRITE SURFACE                                        */
/*                                                              */
/*  A contenteditable div that mirrors the source markdown but   */
/*  renders it live. Same padding/line-height as the raw         */
/*  textarea so switching tabs doesn't shift the layout.         */
/*  Rich-text styling mirrors .editor-preview so what you type is    */
/*  what the reader will see.                                    */
/* ============================================================ */
.editor-surface {
    min-height: 240px;
    max-height: 60vh;
    padding: 0.85rem 1.1rem;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--fg-1e293b);
    overflow-y: auto;
    scrollbar-gutter: stable;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    caret-color: var(--fg-1e293b);
}
.editor-surface.is-empty::before {
    content: attr(data-placeholder);
    color: var(--fg-94a3b8);
    pointer-events: none;
    display: block;
}
.editor-surface:focus,
.editor-surface:focus-visible,
.editor-surface:focus-within,
[contenteditable]:focus,
[contenteditable]:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
}

/* Same rendered-content styles as .editor-preview so WYSIWYG looks  */
/* identical to preview and to the published notice.       */
.editor-surface h1,
.editor-surface h2,
.editor-surface h3,
.editor-surface h4,
.editor-surface h5,
.editor-surface h6 {
    margin: 1em 0 0.4em;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--fg-0f172a);
}
.editor-surface h1 { font-size: 1.25rem; }
.editor-surface h2 { font-size: 1.1rem; }
.editor-surface h3 { font-size: 0.98rem; }
.editor-surface h1:first-child,
.editor-surface h2:first-child,
.editor-surface h3:first-child { margin-top: 0; }
.editor-surface p { margin: 0.6em 0; }
.editor-surface p:first-child { margin-top: 0; }
.editor-surface p:last-child { margin-bottom: 0; }
.editor-surface [style*="text-align: center"] { text-align: center; }
.editor-surface [style*="text-align: right"]  { text-align: right; }
.editor-surface [style*="text-align: justify"]{ text-align: justify; text-justify: inter-word; }
.editor-surface ul,
.editor-surface ol {
    list-style-position: outside;
    padding-left: 1.5em;
    margin: 0.5em 0;
}
.editor-surface li { padding-left: 0.45em; margin: 0.15em 0; }
.editor-surface li > ul,
.editor-surface li > ol { margin: 0.15em 0 0.15em 1.15em; }
.editor-surface blockquote {
    margin: 0.6em 0;
    padding: 0.35rem 0.9rem;
    border-left: 3px solid var(--bd-cbd5e1);
    color: var(--fg-475569);
    background: var(--bg-f8fafc);
    border-radius: 0 6px 6px 0;
}
.editor-surface code {
    background: var(--bg-f1f5f9);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}
.editor-surface pre {
    background: var(--bg-1e293b);
    color: var(--fg-e2e8f0);
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.82em;
    margin: 0.6em 0;
}
.editor-surface pre code { background: transparent; color: inherit; padding: 0; }
.editor-surface a {
    color: var(--fg-2563eb);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.editor-surface hr {
    border: none;
    border-top: 1px solid var(--bd-e2e8f0);
    margin: 1em 0;
}
.editor-surface table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
    margin: 0.6em 0;
    font-size: 0.88em;
    border: 1px solid var(--bd-cbd5e1);
    border-radius: 6px;
    box-shadow: 0 0 0 1px var(--bd-cbd5e1);
}
.editor-surface th,
.editor-surface td {
    border: 1px solid var(--bd-d1d9e0);
    padding: 0.5rem 0.7rem;
    text-align: center;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    min-width: 0;
    max-width: 100%;
    height: 2.75rem;
    line-height: 1.5;
}
.editor-surface th > p,
.editor-surface td > p,
.editor-surface th > div,
.editor-surface td > div {
    margin: 0;
    min-height: 1.5em;
}
.editor-surface th:empty::before,
.editor-surface td:empty::before {
    content: '\00a0';
    display: inline-block;
    line-height: 1.5;
}
.editor-surface th {
    background: var(--bg-dbe3ec);
    font-weight: 800;
    color: var(--fg-0f172a);
    letter-spacing: 0.01em;
}
.editor-surface td {
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
}
.editor-surface img { max-width: 100%; height: auto; }
.editor-surface .bangla-text { font-family: 'SolaimanLipi', sans-serif; }

.editor-surface-wrapper { position: relative; }
.editor-cell-done-btn {
    position: absolute;
    top: 56px;
    right: 14px;
    z-index: 20;
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.9rem;
    background: var(--bg-17191d);
    color: var(--fg-ffffff);
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.35);
    transition: transform 0.12s ease, background 0.12s ease, opacity 0.18s ease;
    opacity: 0;
    pointer-events: none;
}
.editor-cell-done-btn.visible {
    display: inline-flex;
    opacity: 1;
    pointer-events: auto;
}
.editor-cell-done-btn:hover {
    background: var(--bg-0f1115);
    transform: translateY(-1px);
}
.editor-cell-done-btn:active {
    transform: translateY(0) scale(0.97);
}

.editor-surface td.is-cell-selected,
.editor-surface th.is-cell-selected {
    background: var(--bg-dbeafe) !important;
    box-shadow: inset 0 0 0 2px var(--fg-2563eb);
    user-select: none;
}
.editor-surface.is-cell-selecting,
.editor-surface.is-cell-selecting * {
    user-select: none !important;
    cursor: cell;
}
.editor-surface.is-tap-select-mode,
.editor-surface.is-tap-select-mode * {
    user-select: none !important;
    cursor: pointer;
}
.editor-surface-wrapper.ctrl-held .editor-surface td,
.editor-surface-wrapper.ctrl-held .editor-surface th {
    cursor: copy;
}

/* ============================================================ */
/*  EDITOR DEGRADED-MODE BANNER                                  */
/*                                                              */
/*  Shown when the Markdown renderer (marked + DOMPurify) can't   */
/*  be loaded — the Write tab is unusable until the page reloads. */
/*  Never let raw markdown leak into the contenteditable.         */
/* ============================================================ */
.editor-warning {
    display: none;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.6rem;
    background: var(--bg-fef3c7);
    border: 1px solid var(--bd-fcd34d);
    border-left: 3px solid var(--bd-d97706);
    border-radius: 8px;
    color: var(--fg-78350f);
    font-size: 0.82rem;
    line-height: 1.45;
    font-weight: 500;
}
.editor-warning i {
    color: var(--fg-d97706);
    font-size: 0.95rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
}
.editor-warning span { flex: 1; min-width: 0; }
.editor-surface.editor-surface-degraded {
    background: var(--bg-fafafa);
    min-height: 120px;
}
.editor-surface.editor-surface-degraded::before {
    content: 'Rich editor unavailable — switch to Raw to edit.';
    color: var(--fg-94a3b8);
    font-style: italic;
}

@media (max-width: 640px) {
    .editor-surface {
        min-height: 200px;
        padding: 0.7rem 0.85rem;
        font-size: 0.86rem;
    }
}

/* ============================================================ */
/*  CONFIGURATION TAB                                            */
/* ============================================================ */
.config-frame {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.7rem;
}
.config-frame-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
/* The header's action button is a label, not a paragraph: it keeps its
   own line instead of wrapping "Add sector" onto two lines when the
   title + help text beside it get long. */
.config-frame-header > .btn { flex: 0 0 auto; white-space: nowrap; }
.config-frame-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.config-frame-help {
    font-size: 0.78rem;
    color: var(--fg-64748b);
    margin-top: 0.3rem;
    line-height: 1.45;
}
.class-config-details,
.class-delete-frame {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.class-delete-frame {
    border-color: var(--bd-fecaca);
    background: var(--bg-fffafa);
}
.class-delete-btn {
    flex-shrink: 0;
}
.class-payment-details-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    background: var(--bg-f8fafc);
    color: var(--fg-475569);
    font-size: 0.86rem;
    line-height: 1.5;
}
.class-payment-details-hint > i {
    margin-top: 0.18rem;
    color: var(--fg-64748b);
}
.currency-symbol {
    font-family: 'SolaimanLipi', sans-serif;
    font-weight: 400;
}
.class-delete-warning {
    color: var(--fg-475569);
    line-height: 1.55;
    margin: 0 0 1rem;
}
.class-delete-checklist {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.class-delete-checklist label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    color: var(--fg-334155);
    font-size: 0.9rem;
    line-height: 1.45;
}
.class-delete-checklist input {
    flex: 0 0 auto;
    margin-top: 0.2rem;
}
.class-delete-checklist input[type="checkbox"] {
    appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--bd-64748b);
    border-radius: 3px;
    background: var(--bg-ffffff);
    cursor: pointer;
}
.class-delete-checklist input[type="checkbox"]:checked {
    border-color: var(--bd-111827);
    background-color: var(--bg-111827);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m3 8 3 3 7-7'/%3E%3C/svg%3E");
}
.class-delete-instruction {
    display: block;
    color: var(--fg-334155);
    font-size: 0.88rem;
    margin-bottom: 0.45rem;
}
#class-delete-confirm {
    opacity: 0.55;
}
#class-delete-confirm:not(:disabled) {
    opacity: 1;
}
@media (max-width: 600px) {
    .class-config-details,
    .class-delete-frame {
        align-items: stretch;
        flex-direction: column;
    }
    .class-delete-btn {
        width: 100%;
    }
}
.class-fee-footer,
.class-fee-save-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-top: 0.85rem;
}
.class-fee-save-row {
    justify-content: flex-end;
}
.class-fee-frame .fee-breakdown-row {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 160px) 32px;
}
.fee-breakdown-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) 32px;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
}
.fee-breakdown-row .input-field {
    min-width: 0;
    padding: 0.42rem 0.58rem;
    border-radius: 6px;
    font-size: 0.84rem;
}
.class-fee-frame .class-fee-saved-input {
    border-color: transparent;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.class-fee-frame .class-fee-saved-input:hover,
.class-fee-frame .class-fee-saved-input:focus {
    border-color: var(--bd-e2e8f0);
    background: var(--bg-ffffff);
}
.class-fee-frame .class-fee-saved-input:focus {
    border-color: var(--bd-1e293b);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
}
.fee-breakdown-value {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.fee-breakdown-value > i,
.fee-breakdown-total-value > i {
    color: var(--fg-64748b);
    font-size: 0.82rem;
    flex: 0 0 auto;
}
.fee-breakdown-value input {
    flex: 1;
    width: 0;
    min-width: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.fee-breakdown-remove {
    width: 32px;
    min-width: 32px;
    padding: 0.38rem 0;
}
.class-fee-total,
.fee-breakdown-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--bd-cbd5e1);
    font-variant-numeric: tabular-nums;
    color: var(--fg-334155);
    font-size: 0.9rem;
    font-weight: 600;
}
.class-fee-total strong {
    width: min(160px, calc(100% - 32px - 0.5rem));
    text-align: right;
    font-size: 0.88rem;
}
.fee-breakdown-total-value {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: min(160px, calc(100% - 32px - 0.5rem));
}
.fee-breakdown-total-value .input-field {
    flex: 1;
    width: 0;
    min-width: 0;
    padding: 0.4rem 0.58rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}
.fee-breakdown-total-value .input-field[readonly] {
    background: var(--bg-f1f5f9);
    color: var(--fg-475569);
}
.student-fee-editor {
    padding: 0.85rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    margin: 0.75rem 0 1rem;
}
.student-fee-mode {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.student-fee-mode-title {
    font-weight: 600;
    margin-right: auto;
}
.student-fee-mode label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--fg-475569);
    font-size: 0.9rem;
}
.student-fee-mode input {
    accent-color: var(--fg-111827);
}
.student-fee-breakdown-heading {
    color: var(--fg-475569);
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0.9rem 0 0.35rem;
}
.student-fee-breakdown input[readonly] {
    background: var(--bg-f8fafc);
    color: var(--fg-475569);
}
.student-fee-breakdown .fee-breakdown-row {
    grid-template-columns: minmax(120px, 1fr) minmax(110px, 145px);
}
.fee-breakdown-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    margin-top: 0.65rem;
    padding: 0.58rem 0.9rem;
    border: 1.5px dashed var(--bd-cbd5e1);
    border-radius: 9px;
    background: transparent;
    color: var(--fg-64748b);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.fee-breakdown-add:hover {
    border-color: var(--bd-94a3b8);
    background: var(--bg-f8fafc);
    color: var(--fg-1e293b);
}
.fee-breakdown-add:active {
    transform: scale(0.99);
}
.fee-breakdown-add:disabled {
    background: var(--bg-f8fafc);
    color: var(--fg-94a3b8);
    cursor: not-allowed;
    opacity: 0.72;
}
.fee-breakdown-add:disabled:hover {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-f8fafc);
    color: var(--fg-94a3b8);
}
.student-payment-card {
    cursor: pointer;
    transition: box-shadow 220ms ease, transform 220ms ease;
}
.student-payment-card:focus-visible {
    outline: 2px solid var(--bd-64748b);
    outline-offset: 2px;
}
.student-payment-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.payment-breakdown-panel {
    display: grid;
    grid-template-rows: minmax(0, 0fr);
    opacity: 0;
    overflow: hidden;
    transition:
        grid-template-rows 380ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 280ms ease,
        margin-top 380ms cubic-bezier(0.22, 1, 0.36, 1);
    margin-top: 0;
}
.payment-breakdown-inner {
    min-height: 0;
    overflow: hidden;
}
.student-payment-card.is-expanded .payment-breakdown-panel {
    grid-template-rows: minmax(0, 1fr);
    opacity: 1;
    margin-top: 0.8rem;
}
.student-payment-card,
#student-payment-list {
    overflow-anchor: none;
}
.payment-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0;
    color: var(--fg-475569);
    font-size: 0.9rem;
}
.payment-breakdown-row strong {
    min-width: 100px;
    text-align: right;
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
.payment-breakdown-rule {
    height: 1px;
    background: var(--bg-cbd5e1);
    margin: 0.35rem 0 0.6rem;
}
.payment-breakdown-total-slot {
    display: flex;
    justify-content: flex-end;
}
.payment-breakdown-total-slot .student-payment-total {
    transition: opacity 180ms ease, transform 180ms ease;
}
.student-payment-total.is-moving {
    opacity: 0.35;
    transform: translateY(3px);
}
.custom-select-option.keyboard-active {
    background: var(--bg-f1f5f9);
    color: var(--fg-0f172a);
}
@media (max-width: 520px) {
    .fee-breakdown-row {
        grid-template-columns: minmax(0, 1fr) minmax(95px, 125px) 30px;
        gap: 0.4rem;
    }
    .class-fee-frame .fee-breakdown-row {
        grid-template-columns: minmax(0, 1fr) minmax(95px, 125px) 30px;
    }
    .student-fee-breakdown .fee-breakdown-row {
        grid-template-columns: minmax(110px, 1fr) minmax(95px, 125px);
    }
    .fee-breakdown-total-value {
        width: min(130px, calc(100% - 30px - 0.4rem));
    }
    .class-fee-total strong {
        width: min(125px, calc(100% - 30px - 0.4rem));
    }
}
/* ============================================================ */
/*  DRAFT GROUP CARD                                             */
/*                                                              */
/*  An unnamed group lives only in this session — normalizeConfig */
/*  strips it from the DB payload, so it disappears on the next  */
/*  tab entry. A dashed border + reduced tint signals "not saved */
/*  yet" without blocking editing.                               */
/* ============================================================ */
.config-group-card--draft {
    border-style: dashed;
    background: var(--bg-fdfdfe);
}
.config-group-card--draft .config-group-name-input::placeholder {
    color: var(--fg-94a3b8);
}
.config-group-card {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.55rem;
}
.config-group-card:last-of-type {
    margin-bottom: 0.55rem;
}

.config-group-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

/* Editable name — looks like plain text until hover/focus */
.config-group-name-input {
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    min-width: 90px;
    max-width: 240px;
    flex: 1 1 140px;
    font-family: inherit;
    line-height: 1.3;
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.config-group-name-input:hover {
    border-color: var(--bd-e2e8f0);
    background: var(--bg-ffffff);
}
.config-group-name-input:focus {
    border-color: var(--bd-1e293b);
    background: var(--bg-ffffff);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
}
.config-group-name-input::placeholder {
    color: var(--fg-94a3b8);
    font-weight: 500;
}

.config-group-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.config-group-req {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    color: var(--fg-475569);
    font-weight: 500;
    user-select: none;
    /* Match the toggle-sm's 20px track height so the text baseline
       and the toggle centre land on the same axis. */
    line-height: 20px;
}
.config-group-req > span {
    line-height: 20px;
}
.config-group-req > span {
    line-height: 1;
}

/* Compact toggle — sibling of the base .toggle-switch rule.
   Inner slider dimensions are derived from the outer size so the
   circle never overflows the track. */
.toggle-switch.toggle-sm {
    width: 36px;
    height: 20px;
}
.toggle-switch.toggle-sm .toggle-slider {
    border-radius: 20px;
}
.toggle-switch.toggle-sm .toggle-slider::before {
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
}
.toggle-switch.toggle-sm input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Delete icon — same visual weight as the ⋮ it replaces */
.config-group-delete {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--fg-dc2626);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s ease, color 0.12s ease;
}
.config-group-delete:hover {
    background: var(--bg-fee2e2);
    color: var(--fg-b91c1c);
}
.config-group-delete i {
    font-size: 0.8rem;
    line-height: 1;
}

/* Options row — chips + inline add button + inline input all share
   the same flex track so they wrap together when width runs out. */
.config-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    min-height: 28px;
}

.config-option-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 22px;
    padding: 0 0.5rem 0 0.7rem;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}
.config-option-chip > span {
    display: inline-flex;
    align-items: center;
    height: 100%;
    line-height: 1;
}
/* display:grid + place-items:center centres the icon by geometry,
   not by baseline. line-height:0 kills the phantom line-box, so
   the × can never ride above or below the chip's vertical centre. */
.config-option-chip button {
    position: relative;
    display: grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    background: rgba(var(--surface-rgb), 0.14);
    color: var(--fg-ffffff);
    border: none;
    cursor: pointer;
    line-height: 0;
    flex-shrink: 0;
    transition: background 0.12s ease;
}
/* Expanded hit area — 44×44 around the 14px × */
.config-option-chip button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: auto;
}
.config-option-chip button:hover {
    background: rgba(var(--surface-rgb), 0.26);
}
/* ============================================================ */
/*  OPTION IN USE — dim the delete button                        */
/*                                                              */
/*  The × is replaced with a lock glyph in JS; here we soften   */
/*  the whole button so it reads as "you can hover, but you     */
/*  can't just delete this". Hovering lifts the dim and reveals */
/*  the tooltip with the usage counts.                          */
/* ============================================================ */
.config-option-chip.config-option-in-use button {
    background: rgba(var(--surface-rgb), 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: help;
}
.config-option-chip.config-option-in-use button:hover {
    background: rgba(var(--surface-rgb), 0.2);
    color: var(--fg-ffffff);
}
.config-option-chip.config-option-in-use button i {
    font-size: 7px;
}
.config-option-chip button i {
    display: block;
    font-size: 8px;
    line-height: 1;
    margin: 0;
}

.config-empty-hint {
    font-size: 0.72rem;
    color: var(--fg-94a3b8);
    font-style: italic;
    line-height: 1;
}

/* Inline add-option pill — matches chip height for a single row */
.config-add-option-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.75rem;
    height: 26px;
    background: transparent;
    border: 1.5px dashed var(--bd-cbd5e1);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-64748b);
    cursor: pointer;
    line-height: 1;
    transition: all 0.12s ease;
}
.config-add-option-btn:hover {
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
    background: var(--bg-ffffff);
}
.config-add-option-btn i {
    font-size: 0.62rem;
    line-height: 1;
}

/* Inline option input — same height as the chip so it never
   breaks the row rhythm */
.config-add-option-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 26px;
}
.config-add-option-input {
    width: 140px;
    padding: 0 0.7rem;
    height: 26px;
    border: 1px solid var(--bd-1e293b);
    border-radius: 999px;
    font-size: 0.78rem;
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
    font-family: inherit;
    background: var(--bg-ffffff);
}
.config-add-option-confirm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border: none;
    cursor: pointer;
    /* Grid + place-items:center instead of inline-flex. This is the
       most reliable cross-browser way to centre a single child in
       a fixed-size box — no baseline, no line-box quirks. */
    display: grid;
    place-items: center;
    padding: 0;
    margin: 0;
    /* Kill the button's own line box so it can't influence layout. */
    line-height: 0;
    flex-shrink: 0;
    transition: background 0.12s ease;
}
.config-add-option-confirm:hover {
    background: var(--bg-0f172a);
}
.config-add-option-confirm i {
    display: block;
    font-size: 0.68rem;
    line-height: 1;
    margin: 0;
    /* FA's checkmark glyph is top-heavy (tip sits at the baseline,
       visual mass above the em-box centre). A 0.5px downward nudge
       pulls the visible tick onto the button's true geometric
       centre. Increase to 1px if it still reads high on your system. */
    transform: translateY(0.5px);
}

/* Full-width dashed button beneath all group cards */
.config-add-group-btn {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin-top: 0.4rem;
    border: 1.5px dashed var(--bd-cbd5e1);
    border-radius: 10px;
    background: transparent;
    color: var(--fg-64748b);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
}
.config-add-group-btn:hover {
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
    background: var(--bg-f8fafc);
}
.config-add-group-btn i {
    font-size: 0.7rem;
    line-height: 1;
}

/* Online exam defaults panel — mirrors the modal's settings layout. */
.config-online-defaults {
    margin-top: 0.9rem;
    padding: 0.85rem 1rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
}

/* Same recessed treatment as the group cards: the defaults block is a
   well inside its raised frame, not another flat panel. */
.config-online-defaults {
    background: var(--surface-sunken);
    box-shadow: var(--well-shadow);
    border-left-color: var(--bd-e2e8f0);
    border-right-color: var(--bd-e2e8f0);
    border-top-color: var(--well-edge-top);
    border-bottom-color: var(--well-edge-bottom);
}
.config-defaults-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}
.config-defaults-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--fg-475569);
    margin-bottom: 0.3rem;
}
.config-defaults-field .input-field {
    height: 36px;
    font-size: 0.85rem;
}
.config-defaults-field .custom-select-wrapper { width: 100%; }
.config-defaults-field .custom-select-wrapper .input-field {
    padding-right: 2rem;
    cursor: pointer;
}
.config-defaults-toggles {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.15rem 0.85rem;
}
.config-defaults-toggles .online-toggle-row {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bd-eef2f6);
    text-align: left;
}
.config-defaults-toggles .online-toggle-row:last-child { border-bottom: none; }
.config-defaults-toggles .online-toggle-row > .online-toggle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
}
.config-defaults-toggles .online-toggle-title {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--fg-1e293b);
    line-height: 1.3;
}
.config-defaults-toggles .online-toggle-title i {
    color: var(--fg-64748b);
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.85em;
}
.config-defaults-toggles .online-toggle-hint {
    display: block;
    margin: 0.35rem 0 0 1.45rem;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--fg-94a3b8);
    text-align: left;
}
.config-defaults-toggles .toggle-switch { flex-shrink: 0; }

/* Fallback tag colour for custom group options that have no
   preset mapping in TAG_CLASSES. Keeps the chip readable instead
   of rendering as invisible text. */
.student-card-tag {
    background: var(--bg-f1f5f9);
    color: var(--fg-475569);
}

/* ============================================================ */
/*  SCROLLABLE MODAL — fixed header + actions, body scrolls     */
/* ============================================================ */
.modal-box.scroll-middle {
    display: flex;
    flex-direction: column;
    padding: 0;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}
.modal-box.scroll-middle > .modal-header-block {
    flex-shrink: 0;
    padding: 1.35rem 1.5rem 0.65rem;
    border-bottom: 1px solid var(--bd-f1f5f9);
}
.modal-box.scroll-middle > .modal-header-block h3 {
    margin: 0;
}
.modal-box.scroll-middle > .modal-header-block p {
    margin: 0.4rem 0 0;
    color: var(--fg-475569);
    line-height: 1.5;
    font-size: 0.9rem;
}
.modal-box.scroll-middle > .modal-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.9rem 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}
.modal-box.scroll-middle > .modal-scroll-body::-webkit-scrollbar {
    width: 6px;
}
.modal-box.scroll-middle > .modal-scroll-body::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
.modal-box.scroll-middle > .modal-actions {
    flex-shrink: 0;
    padding: 0.85rem 1.5rem 1.2rem;
    margin-top: 0;
    border-top: 1px solid var(--bd-eef2f6);
    background: var(--bg-ffffff);
}

/* ============================================================ */
/*  BASELINE NUDGE — Segoe UI offset                             */
/*                                                              */
/*  Segoe UI's line box places the visual text centre about 1px  */
/*  below the geometric centre. FA icons and geometric checkboxes */
/*  are centred by geometry, so the text ends up visibly lower.   */
/*  Translating the text (and FA glyphs inside circular buttons) */
/*  up by 1px brings the two axes into exact alignment.          */
/*                                                              */
/*  Every selector below targets a text or icon that sits beside */
/*  a geometrically-centred element.                             */
/* ============================================================ */
.config-option-chip > span,
.config-group-req > span,
.notice-creator-name {
    transform: translateY(-1px);
}
/* ============================================================ */
/*  ONLINE EXAMS — CONSOLIDATED (FINAL)                          */
/* ============================================================ */

/* ---- Exam view hides chrome ---- */
body:has(#view-exam.active-view) .mobile-menu,
body:has(#view-exam.active-view) .mobile-overlay,
body:has(#view-exam.active-view) #install-app-btn,
body:has(#view-exam.active-view) #global-app-header,
body:has(#view-exam.active-view) #student-app-header {
    display: none !important;
}

/* ============================================================ */
/*  EXAM HEADER                                                  */
/* ============================================================ */
#view-exam {
    background: var(--bg-f7f8fa);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#exam-app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-f6f8fa);
    border-bottom: 1px solid var(--header-hairline);
    padding: 0.7rem 1.5rem;
    margin: 0;
    border-radius: 0;
    will-change: top, width, margin, padding, border-radius, background, box-shadow, transform;
    transition:
        top 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        margin 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#exam-app-header .header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    width: 100%;
}

#exam-app-header.scrolled {
    top: 10px;
    width: calc(100% - 28px);
    max-width: calc(1200px + 24px);
    margin: 0 auto;
    padding: 0.55rem 1.5rem;
    border-radius: 22px;
    border-bottom: none;
    background: rgba(var(--surface-rgb), 0.6);
    backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    -webkit-backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    box-shadow: 0 6px 6px rgba(0, 0, 0, 0.12), 0 0 20px rgba(0, 0, 0, 0.06);
    min-height: 52px;
}

#exam-app-header.scrolled::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
    box-shadow:
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.55),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);
    background: linear-gradient(
        180deg,
        rgba(var(--surface-rgb), 0.22) 0%,
        rgba(var(--surface-rgb), 0) 40%,
        rgba(var(--surface-rgb), 0) 65%,
        rgba(var(--surface-rgb), 0.10) 100%
    );
    mix-blend-mode: overlay;
}

/* Detached hover bump — matches `/` app header */
@media (min-width: 769px) {
    #exam-app-header.scrolled:hover {
        transform: scale(1.015) translateY(-2px);
        box-shadow:
            0 10px 24px rgba(0, 0, 0, 0.16),
            0 0 32px rgba(0, 0, 0, 0.08);
    }
}

@supports not (backdrop-filter: url(#glass-distortion)) {
    #exam-app-header.scrolled {
        backdrop-filter: blur(20px) saturate(180%) contrast(108%);
        -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(108%);
    }
}

/* ---- Header timer / counter / home ---- */
.header-exam-timer,
.header-exam-counter {
    display: none;
    align-items: center;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    transition: background 0.3s, color 0.3s;
}
.header-exam-timer {
    font-family: 'League Spartan', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0.32rem 0.8rem;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.08);
    color: var(--fg-1e293b);
    letter-spacing: 0.02em;
}
.header-exam-timer.warning  { background: var(--bg-f59e0b); color: var(--fg-0f172a); }
.header-exam-timer.danger   { background: var(--bg-dc2626); color: var(--fg-ffffff); }
.header-exam-timer.critical {
    background: var(--bg-dc2626);
    color: var(--fg-ffffff);
    position: relative;
    isolation: isolate;
}
.header-exam-timer.critical::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    background: var(--bg-dc2626);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65);
    animation: timerPulseRing 1.6s ease-out infinite;
}
.header-exam-timer.critical .header-exam-timer-text {
    position: relative;
    z-index: 1;
}
.header-exam-counter {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-64748b);
    padding: 0.35rem 0.6rem;
    background: rgba(30, 41, 59, 0.06);
    border-radius: 6px;
}
.header-home-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.12s, border-color 0.12s;
}
.header-home-btn:hover { background: var(--bg-f1f5f9); border-color: var(--bd-cbd5e1); }
body:has(#view-exam.active-view) #header-exam-timer,
body:has(#view-exam.active-view) #header-exam-counter {
    display: inline-flex;
}
body:has(#view-exam.active-view) .hamburger-toggle,
body:has(#view-exam.active-view) .header-user-menu {
    display: none !important;
}
body.exam-result-mode #header-home-btn { display: inline-flex; }
body.exam-result-mode #header-exam-timer,
body.exam-result-mode #header-exam-counter {
    display: none !important;
}

@keyframes timerPulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65); }
    70%  { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ============================================================ */
/*  EXAM RUNNER LAYOUT                                           */
/* ============================================================ */
.exam-runner {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
}

.exam-runner-titlebar {
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
    padding: 2.5rem 2rem 1rem;
}
.exam-runner-title-text {
    font-family: 'League Spartan', sans-serif;
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--fg-0f172a);
    line-height: 1.2;
    letter-spacing: -0.025em;
    word-wrap: break-word;
}
.exam-runner-subject {
    font-size: 0.72rem;
    color: var(--fg-94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 0.5rem;
    font-weight: 600;
}

.exam-runner-questions {
    flex: 1;
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
    padding: 0.5rem 2rem 1.5rem;
    display: block;
    background: transparent;
}

/* The submit button belongs to the end of the paper, not to the
   viewport: it scrolls away with the last question instead of hovering
   over every line the student is reading. */
.exam-runner-footer {
    padding: 0.75rem 2rem 2.5rem;
    background: transparent;
}
.exam-runner-footer-inner {
    max-width: 1080px;
    margin: 0 auto;
}

/* ---- One question at a time ---------------------------------- */
.exam-runner.is-quiz .exam-runner-questions {
    max-width: 860px;
    padding-top: 0.35rem;
}
/* The quiz carries its own Next/Submit control at the end of the unit. */
.exam-runner.is-quiz .exam-runner-footer { display: none; }
.quiz-shell {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
}
.quiz-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--fg-64748b);
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}
.quiz-countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--bg-f1f5f9, #f1f5f9);
    color: var(--fg-334155, #334155);
    font-variant-numeric: tabular-nums;
}
.quiz-countdown.is-critical {
    background: #fee2e2;
    color: #b91c1c;
    animation: quiz-pulse 1s ease-in-out infinite;
}
@keyframes quiz-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.62; }
}
.quiz-unit { min-height: 12rem; }
.quiz-unit .paper-question:first-child,
.quiz-unit .paper-passage:first-child { border-top: 0; padding-top: 0.5rem; }
.quiz-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
}
.quiz-next-btn {
    width: auto;
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    font-weight: 600;
}
.quiz-next-btn.is-submit {
    background: var(--fg-16a34a);
    border-color: var(--fg-16a34a);
}
.quiz-hint {
    text-align: right;
    color: var(--fg-94a3b8);
    font-size: 0.72rem;
    line-height: 1.45;
    max-width: 26rem;
}
.quiz-empty {
    color: var(--fg-94a3b8);
    font-size: 0.9rem;
    padding: 2rem 0;
    text-align: center;
}
.online-timing-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
/* Sitting style — the same radio row as the rest of the modal, split
   into two even halves so the two choices sit left and right. */
.online-mode-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    min-height: 0;
    row-gap: 0.5rem;
}
.online-mode-group .radio-label {
    min-width: 0;
    line-height: 1.3;
    /* Only the circle and its own text are a click target. Stretched to
       the column width, the empty half of each grid cell used to select
       a style when it was clicked. */
    justify-self: start;
}
.online-mode-group .radio-label span {
    min-width: 0;
    overflow-wrap: anywhere;
}
@media (max-width: 520px) {
    .online-mode-group { grid-template-columns: 1fr; }
}
.online-quiz-total { margin: 0.15rem 0 0.75rem; color: var(--fg-64748b); }
/* The sitting style is a section of the form, not a field. It carries no
   extra padding of its own: the previous group's margin already gives it
   the same air every other title in the modal gets. */
.online-mode-field { padding-top: 0; }
/* Same label-to-control gap as every other field, so the two choices sit
   as close to "Sitting style" as an input sits to its own label. */
.online-mode-field > label {
    display: block;
    margin-bottom: 0.25rem;
}

/* ============================================================ */
/*  PAPER — questions, options, passages                         */
/* ============================================================ */
.paper-question {
    display: flex;
    gap: 1.25rem;
    padding: 1.75rem 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    align-items: flex-start;
}
.paper-question:first-child { border-top: none; padding-top: 0.5rem; }
.paper-question:last-child  { padding-bottom: 0.5rem; }

/* Question number — system font matching question text, same
   line-height so baselines align */
.paper-q-number {
    flex: 0 0 1.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--fg-94a3b8);
    line-height: 1.7;
    text-align: right;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border-radius: 0;
    width: auto;
    height: auto;
    margin-top: 0;
    padding-top: 0;
}

.paper-q-body { flex: 1; min-width: 0; }

.paper-q-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--fg-1e293b);
    font-weight: 500;
    margin-bottom: 1rem;
    text-align: left;
    white-space: pre-wrap;
}

/* Options — 2×2 grid */
.paper-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.paper-option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1.1rem;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e5e9ef);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.94rem;
    line-height: 1.5;
    color: var(--fg-1e293b);
    width: 100%;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: border-color 0.18s ease, box-shadow 0.18s ease,
                transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-tap-highlight-color: transparent;
}
.paper-option:active { transform: none !important; }
.paper-option:hover:not(:disabled):not(.selected):not(.is-correct):not(.is-wrong) {
    border-color: var(--bd-cbd5e1);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
}
.paper-option.selected {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-16a34a);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08),
                0 2px 8px rgba(22, 163, 74, 0.06);
}
.paper-option:disabled { cursor: not-allowed; opacity: 0.55; }
.paper-option.save-failed {
    background: var(--bg-fef2f2);
    border-color: var(--bd-dc2626);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

/* Option letter — system font + optical centering nudge */
.paper-option-letter {
    flex: 0 0 1.85rem;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bg-f1f5f9);
    color: var(--fg-64748b);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    padding: 0 0 0.5px 0;
    margin: 0;
    border: none;
    flex-shrink: 0;
    text-align: center;
    transition: background 0.18s ease, color 0.18s ease,
                box-shadow 0.25s ease,
                transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.paper-option:hover:not(:disabled):not(.selected):not(.is-correct):not(.is-wrong) .paper-option-letter {
    background: var(--bg-e2e8f0);
    color: var(--fg-334155);
}
.paper-option.selected .paper-option-letter {
    background: var(--bg-16a34a);
    color: var(--fg-ffffff);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
    transform: scale(1.05);
}

.paper-option-text {
    flex: 1;
    min-width: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    word-break: break-word;
}
.paper-option.selected .paper-option-text {
    color: var(--fg-15803d);
    font-weight: 500;
}

/* Passage */
.paper-passage {
    padding: 1.75rem 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.paper-passage:first-child { border-top: none; padding-top: 0.5rem; }
.paper-passage:last-child  { padding-bottom: 0.5rem; }

.paper-passage-instruction {
    display: block;
    padding: 0;
    margin: 0 0 0.9rem 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: var(--fg-475569);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0;
    text-align: left;
}
.paper-passage-instruction i { display: none; }

.paper-passage-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    font-size: 0.98rem;
    line-height: 1.8;
    color: var(--fg-334155);
    margin-bottom: 1.25rem;
    white-space: pre-wrap;
    text-align: left;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.paper-sub-question {
    padding: 1.25rem 0 0;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    margin-top: 1.25rem;
    border-bottom: none;
}
.paper-sub-question:first-of-type {
    padding-top: 1.25rem;
    margin-top: 1rem;
}

/* Review states */
.paper-option.is-correct {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-16a34a);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08),
                0 2px 8px rgba(22, 163, 74, 0.05);
}
.paper-option.is-correct .paper-option-letter {
    background: var(--bg-16a34a);
    color: var(--fg-ffffff);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
    transform: none;
}
.paper-option.is-correct .paper-option-text { color: var(--fg-15803d); font-weight: 500; }

.paper-option.is-wrong {
    background: var(--bg-fef2f2);
    border-color: var(--bd-dc2626);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08),
                0 2px 8px rgba(220, 38, 38, 0.05);
}
.paper-option.is-wrong .paper-option-letter {
    background: var(--bg-dc2626);
    color: var(--fg-ffffff);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
    transform: none;
}
.paper-option.is-wrong .paper-option-text { color: var(--fg-b91c1c); font-weight: 500; }

/* Tick / cross tag — geometric centering, no transforms, no optical
   nudges. `inline-grid + place-items: center` on the parent plus
   `display: grid; place-items: center` on the icon itself centers
   the glyph's bounding box exactly. `line-height: 1` kills the
   phantom line-box that otherwise offsets by fractionals. Nothing
   here reacts to parent transforms → zero scroll drift. */
.paper-option-tag {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.4rem;
    border-radius: 50%;
    align-self: center;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    font-size: 0;
}
.paper-option-tag i {
    display: grid;
    place-items: center;
    font-size: 0.55rem;
    line-height: 1;
    margin: 0;
    padding: 0;
    transform: none;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands', sans-serif;
}
.paper-option-tag--correct { background: var(--bg-16a34a); color: var(--fg-ffffff); }
.paper-option-tag--wrong   { background: var(--bg-dc2626); color: var(--fg-ffffff); }

.paper-verdict {
    margin-top: 0.85rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: right;
}
.paper-verdict.is-pass { color: var(--fg-15803d); }
.paper-verdict.is-fail { color: var(--fg-b91c1c); }

/* ============================================================ */
/*  REVIEW HERO — title+subject left, score badge right          */
/* ============================================================ */
.paper-review .review-hero {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0 1.5rem 0;
    margin-bottom: 0.75rem;
    /* No divider here — the first question's own top border is the one
       separator under the title. Having both read as a double rule. */
    border-bottom: none;
}

.paper-review .review-hero-info {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 130px);
}

.paper-review .review-hero-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--fg-0f172a);
    line-height: 1.3;
    letter-spacing: -0.01em;
    overflow-wrap: break-word;
}

.paper-review .review-hero-subject {
    font-size: 0.72rem;
    color: var(--fg-94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-top: 0.2rem;
}

.paper-review .review-hero-score-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-left: auto;
    line-height: 1;
    white-space: nowrap;
}
.paper-review .review-hero-score-badge.score-pass {
    background: var(--bg-f0fdf4);
    border-color: var(--bd-86efac);
}
.paper-review .review-hero-score-badge.score-pass .score-obtained { color: var(--fg-15803d); }

.paper-review .review-hero-score-badge.score-fail {
    background: var(--bg-fef2f2);
    border-color: var(--bd-fca5a5);
}
.paper-review .review-hero-score-badge.score-fail .score-obtained { color: var(--fg-b91c1c); }

.paper-review .review-hero-score-badge .score-obtained {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
}
.paper-review .review-hero-score-badge .score-sep {
    color: var(--fg-cbd5e1);
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1;
}
.paper-review .review-hero-score-badge .score-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-64748b);
    line-height: 1;
}

/* Kill any legacy markup that might still slip in */
.paper-review .review-hero-score,
.paper-review .review-hero-stats { display: none !important; }

/* Kill the double divider between hero and first question */
.review-hero + .paper-question,
.review-hero + .paper-passage {
    border-top: none !important;
}

/* Full-width review container */
.exam-result.paper-review-mode,
.exam-result:has(.paper-review) {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
    display: block;
}
.exam-runner-questions.paper-review {
    max-width: none;
    width: 100%;
    padding: 0;
}

/* Admin review modal — compact paper */
#admin-review-body .paper-question {
    padding: 1rem 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    border-bottom: none;
}
#admin-review-body .paper-question:first-child { padding-top: 0; border-top: none; }
#admin-review-body .paper-passage {
    padding: 1rem 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}
#admin-review-body .paper-passage:first-child { padding-top: 0; border-top: none; }
#admin-review-body .paper-passage-instruction { font-size: 0.85rem; margin-bottom: 0.75rem; }
#admin-review-body .paper-passage-body { font-size: 0.92rem; margin-bottom: 1rem; }
#admin-review-body .paper-q-text { font-size: 0.95rem; }
#admin-review-body .paper-options-grid { gap: 0.5rem; }
#admin-review-body .paper-option { padding: 0.7rem 0.85rem; font-size: 0.88rem; }
#admin-review-body .paper-option-letter { flex-basis: 1.6rem; width: 1.6rem; height: 1.6rem; font-size: 0.72rem; }
#admin-review-body .paper-sub-question { padding: 1rem 0 0; margin-top: 1rem; }
#admin-review-body .paper-verdict { display: none; }

/* ============================================================ */
/*  RESULT / TERMINATION CARDS                                   */
/* ============================================================ */
.exam-result {
    max-width: 620px;
    margin: 2rem auto;
    padding: 0 1.25rem 2rem;
    width: 100%;
}

.exam-result-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

/* Submitted card — big tick, heading, score body */
.exam-result-card.exam-result-card--submitted {
    padding: 2.25rem 1.75rem;
}
/* Post-submit interlude — full-screen centered tick that then
   cross-fades to the review or the result card. */
.exam-post-reveal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 60vh;
    text-align: center;
    padding: 2rem 1rem;
}

.exam-post-submit-tick {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 60vh;
    text-align: center;
    padding: 2rem 1rem;
}
.exam-post-submit-icon {
    font-size: 4rem;
    color: var(--fg-16a34a);
    line-height: 1;
    margin-bottom: 0.35rem;
}
.exam-post-submit-icon i {
    display: block;
    animation: examTickPop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes examTickPop {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.exam-post-submit-title {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg-15803d);
    letter-spacing: -0.02em;
}
.exam-post-submit-sub {
    font-size: 0.95rem;
    color: var(--fg-64748b);
    font-weight: 500;
    max-width: 320px;
    line-height: 1.4;
    word-break: break-word;
}

.exam-submitted-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(var(--surface-rgb), 0.84);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 350ms ease;
}
.exam-submitted-overlay[hidden] { display: none; }
.exam-submitted-overlay.is-visible { opacity: 1; }
.exam-submitted-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    padding: 1.5rem;
}
.exam-submitted-icon {
    display: grid;
    place-items: center;
    width: 5.5rem;
    height: 5.5rem;
    border: 4px solid var(--bd-22c55e);
    border-radius: 50%;
    background: var(--bg-f0fdf4);
    color: var(--fg-16a34a);
    font-size: 2.7rem;
    animation: examSubmittedTick 650ms cubic-bezier(0.2, 1.4, 0.5, 1) both;
}
.exam-submitted-content h2 {
    margin: 0;
    color: var(--fg-15803d);
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: clamp(1.7rem, 5vw, 2.3rem);
}
.exam-submitted-countdown {
    position: absolute;
    right: 1rem;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    left: 1rem;
    color: var(--fg-64748b);
    font-size: 0.95rem;
    text-align: center;
}
.exam-submitted-countdown strong {
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
@keyframes examSubmittedTick {
    from { transform: scale(0.25) rotate(-35deg); opacity: 0; }
    to { transform: scale(1) rotate(0); opacity: 1; }
}

.exam-result-tick {
    display: flex;
    justify-content: center;
    margin-bottom: 0.85rem;
}
.exam-result-tick i {
    font-size: 3.5rem;
    color: var(--fg-16a34a);
    line-height: 1;
}
.exam-result-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg-15803d);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
}
.exam-result-card.exam-result-card--submitted .exam-result-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    margin-bottom: 0.5rem;
    letter-spacing: 0;
}

.exam-result-body { margin-top: 0.5rem; }
.exam-result-body .exam-result-score {
    font-family: 'League Spartan', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    margin: 0.75rem 0 0.5rem;
    font-variant-numeric: tabular-nums;
}
.exam-result-body .exam-result-score.is-pass { color: var(--fg-15803d); }
.exam-result-body .exam-result-score.is-fail { color: var(--fg-b91c1c); }
.exam-result-body .exam-result-score .exam-result-score-total {
    font-size: 1.15rem;
    color: var(--fg-94a3b8);
    font-weight: 500;
}
.exam-result-body .exam-result-percent {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.exam-result-body .exam-result-percent.is-pass { color: var(--fg-15803d); }
.exam-result-body .exam-result-percent.is-fail { color: var(--fg-b91c1c); }
.exam-result-body .exam-result-pending {
    font-size: 0.95rem;
    color: var(--fg-64748b);
    line-height: 1.65;
    margin: 0.5rem 0 0;
    font-weight: 500;
}
.exam-result-body .exam-result-countdown {
    display: inline-flex;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0.75rem 1.15rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    margin: 0.75rem auto 0;
}
.exam-result-body .countdown-label {
    font-size: 0.82rem;
    color: var(--fg-64748b);
    font-weight: 500;
}
.exam-result-body .countdown-value {
    font-family: 'League Spartan', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.exam-result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Legacy status pill — no longer rendered */
.exam-result-status { display: none !important; }

/* Terminated card */
.exam-result-card.exam-terminated-card {
    border: 1px solid var(--bd-fecaca);
    background: linear-gradient(180deg, var(--bg-fef2f2) 0%, var(--bg-ffffff) 55%);
}
.exam-terminated-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg-fee2e2);
    color: var(--fg-b91c1c);
    font-size: 1.75rem;
    margin-bottom: 1.1rem;
}
.exam-terminated-title {
    font-family: 'League Spartan', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg-7f1d1d);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}
.exam-terminated-reason {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--fg-991b1b);
    background: var(--bg-fef2f2);
    border: 1px solid var(--bd-fecaca);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin: 0.75rem 0;
    text-align: left;
}
.exam-terminated-sub {
    font-size: 0.85rem;
    color: var(--fg-64748b);
    line-height: 1.55;
    margin: 0 0 1rem;
}
.exam-terminated-note {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}
.exam-terminated-note--ok {
    background: var(--bg-f0fdf4);
    color: var(--fg-15803d);
    border: 1px solid var(--bd-dcfce7);
}
.exam-terminated-note--locked {
    background: var(--bg-fef2f2);
    color: var(--fg-b91c1c);
    border: 1px solid var(--bd-fecaca);
}

/* ============================================================ */
/*  INFO MODAL                                                   */
/* ============================================================ */
.exam-info-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin: 0.5rem 0 1rem;
}
.exam-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--bd-f1f5f9);
    font-size: 0.88rem;
}
.exam-info-row:last-child { border-bottom: none; }
.exam-info-row-label { color: var(--fg-64748b); }
.exam-info-row-value { color: var(--fg-1e293b); font-weight: 600; text-align: right; }

.exam-info-bestnote {
    margin: 0.5rem 0 0.25rem;
    padding: 0.55rem 0.8rem;
    background: var(--bg-f0fdf4);
    border: 1px solid var(--bd-dcfce7);
    border-radius: 8px;
    color: var(--fg-15803d);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.exam-info-bestnote i { color: var(--fg-16a34a); }

/* ============================================================ */
/*  ONLINE EXAM ADMIN — LIST + STATUS                            */
/* ============================================================ */
.online-status-pill {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.6;
}
.online-status-open        { background: var(--bg-dcfce7); color: var(--fg-15803d); }
.online-status-scheduled   { background: var(--bg-fef3c7); color: var(--fg-92400e); }
.online-status-closed      { background: var(--bg-e2e8f0); color: var(--fg-475569); }
.online-status-draft       { background: var(--bg-f1f5f9); color: var(--fg-64748b); }
.online-status-in-progress { background: var(--bg-dbeafe); color: var(--fg-1e40af); }
.online-status-submitted   { background: var(--bg-dcfce7); color: var(--fg-15803d); }

.online-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-dcfce7);
    color: var(--fg-15803d);
    line-height: 1.6;
}

/* Admin exam-card countdown pill — "Opens in" / "Closes in" with a
   target date underneath. Amber surface, matches the original look
   before the markup was restructured to support live phase switch. */
.admin-countdown {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.7rem;
    border-radius: 999px;
    background: var(--bg-fef3c7);
    color: var(--fg-b45309);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-top: 0.15rem;
}
.admin-countdown > i {
    font-size: 0.62rem;
    opacity: 0.85;
    flex-shrink: 0;
    color: var(--fg-b45309);
}
.admin-countdown [data-countdown-label-text] {
    color: var(--fg-92400e);
    font-weight: 500;
}
.admin-countdown [data-countdown-value] {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--fg-b45309);
}
.admin-countdown .countdown-time {
    font-weight: 500;
    color: var(--fg-92400e);
    opacity: 0.75;
    font-size: 0.62rem;
}
.admin-countdown.is-closed {
    background: var(--bg-fee2e2);
    color: var(--fg-b91c1c);
}
.admin-countdown.is-closed > i,
.admin-countdown.is-closed [data-countdown-value],
.admin-countdown.is-closed .countdown-time {
    color: var(--fg-b91c1c);
}
.online-live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bg-16a34a);
    animation: onlineLivePulse 1.6s ease-out infinite;
    flex-shrink: 0;
}
@keyframes onlineLivePulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.65); }
    70%  { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.online-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: var(--fg-64748b);
}
.online-meta-row i { color: var(--fg-94a3b8); margin-right: 0.15rem; }

.admin-countdown {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--fg-b45309);
}
.admin-countdown > i {
    align-self: center;
    font-size: 0.7em;
    transform: translateY(-0.5px);
}
.admin-countdown .countdown-time {
    font-weight: 500;
    color: var(--fg-92400e);
    opacity: 0.75;
}
.admin-countdown.is-closed { color: var(--fg-dc2626); }
.admin-countdown.is-closed i { color: var(--fg-dc2626); }

/* ============================================================ */
/*  ONLINE EXAM EDITOR MODAL                                     */
/* ============================================================ */
#modal-online-exam input[type="text"],
#modal-online-exam textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
    text-align: left;
}

.online-schedule-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    /* Its own groups carry no bottom margin, so the row has to hold the
       gap to the next heading — otherwise showing a date field sat the
       following title flush against the inputs. Kept short: a full
       1rem stacked onto the radio row's own slack read as a hole before
       Passing. */
    margin-bottom: 0.6rem;
}
/* The radio rows here are as tall as their circles, not the generic
   38px, so the closes column does not trail empty space into that gap. */
.online-schedule-row .radio-group { min-height: 0; }
.online-schedule-row > .form-group {
    flex: 1 1 0;
    min-width: 0;
    margin-bottom: 0;
}
.online-schedule-row .online-schedule-input {
    width: 100%;
    max-width: 100%;
}

.online-passing-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 96px;
}
.online-passing-input-wrap .input-field {
    padding-right: 26px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.online-passing-input-wrap .input-field::-webkit-outer-spin-button,
.online-passing-input-wrap .input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.online-passing-suffix {
    position: absolute;
    right: 10px;
    color: var(--fg-64748b);
    font-weight: 600;
    font-size: 0.85rem;
    pointer-events: none;
}

.online-toggles {
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.15rem 0.85rem;
}
.online-toggle-row {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bd-eef2f6);
    text-align: left;
}
.online-toggle-row:last-child { border-bottom: none; }

.online-toggle-row > .online-toggle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
}
.online-toggle-row > .online-toggle-head > .online-toggle-title {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--fg-1e293b);
    line-height: 1.3;
}
.online-toggle-row > .online-toggle-head > .toggle-switch {
    flex-shrink: 0;
}

.online-toggle-row:not(:has(.online-toggle-head)) {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}
.online-toggle-row:not(:has(.online-toggle-head)) > span:first-child {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}
.online-toggle-row:not(:has(.online-toggle-head)) > .toggle-switch {
    flex-shrink: 0;
}

.online-toggle-title i {
    color: var(--fg-64748b);
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.85em;
}
.online-toggle-hint {
    display: block;
    margin: 0.35rem 0 0 1.45rem;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--fg-94a3b8);
    text-align: left;
}

.online-examinee-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: stretch;
}
.online-examinee-dim {
    flex: 1 1 200px;
    min-width: 0;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}
.online-examinee-dim-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-475569);
    margin-bottom: 0.4rem;
}
.online-examinee-dim-count {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--fg-94a3b8);
    letter-spacing: 0;
    text-transform: none;
    font-variant-numeric: tabular-nums;
}
.online-examinee-dim .exam-target-chips { gap: 0.35rem; }
.online-examinee-dim .group-chip {
    padding: 0.22rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 999px;
}

.online-questions-wrapper {
    position: relative;
    padding: 1rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    background: var(--bg-ffffff);
}
.online-questions-header-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 34px;
    padding: 0;
    margin: 0 0 0.4rem 0;
}
.online-questions-label {
    display: block;
    position: static;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--fg-475569);
    line-height: 1.2;
    text-align: left;
}
.online-questions-label span {
    font-family: inherit;
    font-weight: 700;
    color: var(--fg-1e293b);
    margin: 0.15rem;
}
.online-questions-content {
    position: relative;
}
.online-total-pill {
    position: sticky;
    top: 0.75rem;
    right: 0;
    bottom: auto;
    z-index: 20;
    width: max-content;
    display: flex;
    margin: 0 0 0.5rem auto;
    flex-shrink: 0;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(var(--surface-rgb), 0.72);
    backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    -webkit-backdrop-filter: url(#glass-distortion) blur(3px) saturate(180%) contrast(108%);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.12),
        0 0 20px rgba(0, 0, 0, 0.06),
        inset 2px 2px 1px 0 rgba(255, 255, 255, 0.5),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.04);
    font-family: 'League Spartan', sans-serif;
    white-space: nowrap;
}
.online-total-pill[hidden] { display: none; }
@supports not (backdrop-filter: url(#glass-distortion)) {
    .online-total-pill {
        backdrop-filter: blur(20px) saturate(180%) contrast(108%);
        -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(108%);
    }
}
.online-total-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.online-total-label {
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-64748b);
}

.online-add-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.65rem;
    flex-wrap: wrap;
}
.online-add-btn {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border: 1.5px dashed var(--bd-cbd5e1);
    border-radius: 10px;
    background: transparent;
    color: var(--fg-64748b);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
}
.online-add-btn:hover {
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
    background: var(--bg-f8fafc);
}

/* ---- Import panel — inline, no modal-on-modal ---- */
.online-import-panel {
    margin-top: 0.65rem;
    padding: 0.85rem 1rem 0.9rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    text-align: left;
}
.online-import-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.online-import-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.online-import-title i { color: var(--fg-64748b); font-size: 0.8rem; }
.online-import-close {
    border: none;
    background: transparent;
    color: var(--fg-64748b);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.12s ease, color 0.12s ease;
}
.online-import-close:hover { background: var(--bg-eef2f7); color: var(--fg-1e293b); }

.online-import-format {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}
.online-import-format > summary {
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--fg-475569);
    cursor: pointer;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.12s ease;
}
.online-import-format > summary::-webkit-details-marker { display: none; }
.online-import-format > summary::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.6rem;
    margin-left: auto;
    color: var(--fg-94a3b8);
    transition: transform 0.18s ease;
}
.online-import-format[open] > summary::after { transform: rotate(180deg); }
.online-import-format > summary:hover { background: var(--bg-f1f5f9); }
.online-import-format > summary i { color: var(--fg-94a3b8); font-size: 0.75rem; }

/* Body — light, no dark terminal. Two regions: code block with
   copy button, then the parameter list in prose. */
.online-import-format-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.7rem;
    border-top: 1px solid var(--bd-eef2f6);
    background: var(--bg-fafbfc);
}

/* --- Code surface --- */
.online-import-code {
    position: relative;
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    overflow: hidden;
}
.online-import-code pre {
    margin: 0;
    padding: 0.85rem 0.95rem 0.9rem;
    background: transparent;
    color: var(--fg-1e293b);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.6;
    /* Keep the box the height it is and let the example scroll inside. */
    max-height: 320px;
    overflow: auto;
    white-space: pre;
    tab-size: 2;
}
.online-import-code pre::-webkit-scrollbar { width: 6px; height: 6px; }
.online-import-code pre::-webkit-scrollbar-thumb {
    background: var(--bg-cbd5e1);
    border-radius: 8px;
}
.online-import-code pre::-webkit-scrollbar-track { background: transparent; }

/* Copy button — pinned to the code block's top-right corner. */
.online-import-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-475569);
    background: rgba(var(--surface-rgb), 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    z-index: 1;
}
.online-import-copy:hover {
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    border-color: var(--bd-cbd5e1);
}
.online-import-copy.is-copied {
    color: var(--fg-15803d);
    border-color: var(--bd-86efac);
    background: var(--bg-f0fdf4);
}
.online-import-copy i { font-size: 0.7rem; line-height: 1; }

/* Narrow screens — drop the "Copy" label, keep the icon. */
@media (max-width: 640px) {
    .online-import-copy {
        padding: 0.34rem;
        gap: 0;
        width: 28px;
        height: 28px;
        justify-content: center;
    }
    .online-import-copy .online-import-copy-label { display: none; }
    .online-import-code pre {
        padding-top: 2.4rem;   /* clear the copy button */
        font-size: 0.72rem;
    }
}

/* --- Parameters list --- */
.online-import-params-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-64748b);
    margin-bottom: 0.35rem;
}
.online-import-params ul {
    margin: 0;
    padding: 0 0 0 1.1rem;
    list-style: disc;
}
.online-import-params li {
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--fg-334155);
    margin: 0.15rem 0;
}
.online-import-params code {
    display: inline-block;
    padding: 0.02rem 0.32rem;
    background: var(--bg-eef2f7);
    color: var(--fg-1e293b);
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.4;
}

.online-import-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    min-height: 160px;
    resize: vertical;
    background: var(--bg-ffffff);
}

.online-import-error {
    border: 1px solid var(--bd-fecaca);
    background: var(--bg-fef2f2);
    color: var(--fg-991b1b);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.online-import-error-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}
.online-import-error-item i {
    color: var(--fg-dc2626);
    font-size: 0.72rem;
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.online-import-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.online-import-replace {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--fg-475569);
    cursor: pointer;
    user-select: none;
}
.online-import-replace input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--bd-94a3b8);
    border-radius: 4px;
    background-color: var(--bg-ffffff);
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    margin: 0;
    flex-shrink: 0;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.online-import-replace input[type="checkbox"]:checked {
    background-color: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3.5 8.5 6.5 11.5 12.5 4.5'%3E%3C/polyline%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 11px 11px;
}
.online-import-buttons {
    display: flex;
    gap: 0.4rem;
    margin-left: auto;
}

.online-question-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: visible;
}
.online-question-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative;
    text-align: left;
}
.online-question-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: var(--bd-dbe2ea);
}
.online-question-card.locked {
    background: var(--bg-f8fafc);
    border-style: dashed;
}
.online-question-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}
.online-question-index {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    background: var(--bg-f1f5f9);
    border-radius: 6px;
    flex-shrink: 0;
    line-height: 1;
}
.online-question-points {
    width: 52px;
    padding: 0.32rem 0.35rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 6px;
    font-size: 0.82rem;
    text-align: center;
    background: var(--bg-ffffff);
    font-weight: 600;
    color: var(--fg-1e293b);
    outline: none;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
.online-question-points:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
}
.online-question-points-label {
    font-size: 0.7rem;
    color: var(--fg-94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.online-question-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
}
.online-q-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    border-radius: 8px;
    color: var(--fg-475569);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.online-q-btn:hover:not(:disabled) {
    background: var(--bg-f1f5f9);
    color: var(--fg-1e293b);
    border-color: var(--bd-cbd5e1);
}
.online-q-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.online-q-delete:hover:not(:disabled) {
    color: var(--fg-dc2626);
    border-color: var(--bd-fca5a5);
    background: var(--bg-fef2f2);
}

.online-question-text {
    width: 100%;
    font-size: 0.9rem;
    margin-bottom: 0.65rem;
    min-height: 60px;
    line-height: 1.5;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    cursor: text;
}
.online-question-field-label {
    display: block;
    margin: 0 0 0.3rem;
    color: var(--fg-475569);
    font-size: 0.76rem;
    font-weight: 600;
    text-align: left;
}
.online-question-text:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
    outline: none;
}

.online-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.online-option {
    display: flex;
    align-items: stretch;
    padding: 0;
    border: 1.5px solid var(--bd-e2e8f0);
    border-radius: 10px;
    background: var(--bg-ffffff);
    overflow: hidden;
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
    min-height: 44px;
    text-align: left;
}
.online-option:hover { border-color: var(--bd-cbd5e1); }
.online-option.is-correct {
    border-color: var(--bd-16a34a);
    background: var(--bg-f0fdf4);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08);
}
.online-option-badge {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-right: 1.5px solid var(--bd-e2e8f0);
    background: var(--bg-f8fafc);
    color: var(--fg-64748b);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    text-align: center;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    align-self: stretch;
}
.online-option-badge:hover:not(:disabled) { background: var(--bg-f1f5f9); color: var(--fg-1e293b); }
.online-option-badge:disabled { cursor: not-allowed; opacity: 0.85; }
.online-option.is-correct .online-option-badge {
    background: var(--bg-16a34a);
    color: var(--fg-ffffff);
    border-right-color: var(--bd-16a34a);
}

/* Blank options keep their A/B/C/D labels visible before text is entered. */
.online-option-badge-spacer {
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    border-right: 1.5px solid var(--bd-eef2f6);
    background: var(--bg-f8fafc);
    color: var(--fg-64748b);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    text-align: center;
    align-self: stretch;
    display: grid;
    place-items: center;
}

/* Save/publish validation: red border on offending inputs. */
.online-option-text.input-error,
.online-question-text.input-error,
.online-passage-body.input-error,
.online-question-points.input-error {
    border-color: var(--bd-dc2626) !important;
    background-color: var(--bg-fef2f2) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

/* Question-level red frame — card or sub-card. */
.online-question-card.is-invalid,
.online-passage-card.is-invalid,
.online-sub-question.is-invalid {
    border-color: var(--bd-dc2626) !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

/* Narrower spacer on mobile so 4 rows still fit. */
@media (max-width: 640px) {
    .online-option-badge-spacer {
        flex-basis: 40px;
        width: 40px;
        min-height: 44px;
    }
}
.online-option-text {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.55rem 0.75rem;
    font-size: 0.86rem;
    border: none;
    background: transparent;
    color: var(--fg-1e293b);
    outline: none;
    line-height: 1.4;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    cursor: text;
}
.online-option-text:focus { background: rgba(var(--surface-rgb), 0.6); }

.online-passage-card {
    background: var(--bg-fafbfc);
    border: 1px solid var(--bd-e2e8f0);
    border-left: 3px solid var(--bd-6366f1);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    text-align: left;
}
.online-passage-card.locked {
    background: var(--bg-f8fafc);
    border-style: dashed;
}
.online-passage-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-6366f1);
    background: var(--bg-eef2ff);
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}
.online-passage-body {
    width: 100%;
    min-height: 90px;
    font-size: 0.9rem;
    line-height: 1.55;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--bd-d1d9e0);
    border-radius: 8px;
    margin-bottom: 0.65rem;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    cursor: text;
}
.online-passage-body:focus {
    border-color: var(--bd-1e293b);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.08);
    outline: none;
}
.equation-input[contenteditable="false"] { cursor: default; }
.equation-input:empty::before {
    content: attr(data-placeholder);
    color: var(--fg-64748b);
    pointer-events: none;
}
.online-equation-guide { margin: 0.4rem 0 0.75rem; }
.online-sub-question {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.5rem;
}
.online-sub-question:last-child { margin-bottom: 0.65rem; }
.online-sub-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.45rem;
}
.online-sub-index {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-64748b);
    padding: 0.15rem 0.5rem;
    background: var(--bg-f1f5f9);
    border-radius: 5px;
    line-height: 1.4;
}
.online-sub-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.9rem;
    border: 1.5px dashed var(--bd-cbd5e1);
    border-radius: 8px;
    background: transparent;
    color: var(--fg-64748b);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
}
.online-sub-add-btn:hover {
    border-color: var(--bd-94a3b8);
    color: var(--fg-1e293b);
    background: var(--bg-f8fafc);
}

/* ============================================================ */
/*  ATTENDANCE MODAL                                             */
/* ============================================================ */
.attendance-summary-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.attendance-live-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-15803d);
}

.attendance-summary-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-475569);
}
.attendance-summary-label i {
    font-size: 0.72rem;
    color: var(--fg-64748b);
}

.attendance-count-group {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--fg-475569);
    font-weight: 500;
    flex-wrap: wrap;
}
.attendance-count-group strong { color: var(--fg-1e293b); font-weight: 700; }
.attendance-count-group .is-taking    { color: var(--fg-15803d); }
.attendance-count-group .is-submitted { color: var(--fg-475569); }
.attendance-count-group .is-pending   { color: var(--fg-92400e); }
.attendance-count-group .is-terminated { color: var(--fg-b91c1c); }

.attendance-frame {
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    background: var(--bg-ffffff);
}
.attendance-frame:last-child { margin-bottom: 0; }

.attendance-frame-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-475569);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.12s;
}
.attendance-frame-title:hover { background: rgba(var(--ink-rgb), 0.02); }
.attendance-frame-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.attendance-frame-title .count {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    letter-spacing: 0;
    text-transform: none;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.attendance-frame-caret {
    font-size: 0.6rem;
    color: var(--fg-94a3b8);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.attendance-frame.collapsed .attendance-frame-title { border-bottom-color: transparent; }
.attendance-frame.collapsed .attendance-frame-caret { transform: rotate(-90deg); }

.attendance-frame-body {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
    padding: 0.35rem 0.55rem 0.5rem;
    transition: grid-template-rows 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                padding 0.28s ease;
}
.attendance-frame-body > .attendance-frame-body-inner {
    min-height: 0;
    overflow: hidden;
}
.attendance-frame.collapsed .attendance-frame-body {
    grid-template-rows: minmax(0, 0fr);
    padding-top: 0;
    padding-bottom: 0;
}
.attendance-frame-title:active,
.recipient-group-header:active,
.notice-class-header:active,
.notice-dim-header:active {
    transform: none !important;
    transition: background 0.12s ease !important;
}

.attendance-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.35rem;
    font-size: 0.85rem;
    margin: 0;
    border-radius: 6px;
    background: transparent;
    transition: background 0.12s;
}
.attendance-row + .attendance-row {
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}
.attendance-row:hover { background: rgba(var(--ink-rgb), 0.025); }
.attendance-frame--taking .attendance-row:hover     { background: rgba(22, 163, 74, 0.06); }
.attendance-frame--terminated .attendance-row:hover { background: rgba(220, 38, 38, 0.04); }

.attendance-name {
    color: var(--fg-1e293b);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attendance-timer {
    font-weight: 700;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    color: var(--fg-1e293b);
    min-width: 52px;
    text-align: right;
}
.attendance-timer.warning { color: var(--fg-b45309); }
.attendance-timer.danger  { color: var(--fg-b91c1c); }

.attendance-time {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    text-align: right;
    flex-shrink: 0;
    font-weight: 500;
}

.attendance-score {
    font-size: 0.82rem;
    color: var(--fg-475569);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    flex-shrink: 0;
}

.attendance-tab-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-fef3c7);
    color: var(--fg-92400e);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.attendance-tab-badge.zero { background: var(--bg-f1f5f9); color: var(--fg-94a3b8); }

.attendance-view-btn,
.attendance-note-btn {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-475569);
}

.attendance-terminate-btn {
    position: relative;
    width: auto;
    min-width: 30px;
    height: 20px;
    padding: 0 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    border: 1px solid var(--bd-fecaca);
    background: var(--bg-fef2f2);
    color: var(--fg-dc2626);
}
.attendance-terminate-btn:hover { background: var(--bg-fee2e2); border-color: var(--bd-fca5a5); }
.attendance-view-btn:hover { background: var(--bg-f1f5f9); border-color: var(--bd-cbd5e1); color: var(--fg-1e293b); }
.attendance-note-btn { border-color: var(--bd-e2e8f0); background: var(--bg-ffffff); color: var(--fg-64748b); }
.attendance-note-btn:hover { background: var(--bg-f1f5f9); color: var(--fg-1e293b); }

.attendance-retake-chip {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-dcfce7);
    color: var(--fg-15803d);
    white-space: nowrap;
    flex-shrink: 0;
}

.attendance-note-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 240px;
    padding: 0.45rem 0.7rem;
    background: var(--bg-1e293b);
    color: var(--fg-ffffff);
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-100%) scale(0.98);
    transition: opacity 0.14s ease, transform 0.14s ease;
    word-wrap: break-word;
}
.attendance-note-tooltip.show {
    opacity: 1;
    transform: translateY(-100%) scale(1);
}
.attendance-note-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--bg-1e293b);
    transform: translateX(-50%) rotate(45deg);
}

/* ============================================================ */
/*  INLINE ANSWERS VIEW — list + detail                          */
/* ============================================================ */
#online-answers-view .paper-verdict { display: none !important; }

.answers-view-wrap {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.24s ease;
}

/* ---------- List view ---------- */
.answers-list-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0;
}
.answers-list-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.answers-list-count {
    font-size: 0.78rem;
    color: var(--fg-94a3b8);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.answers-list-body {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.answers-examinee-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--bd-f1f5f9);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    width: 100%;
    transition: background 0.12s ease;
}
.answers-examinee-row:last-child { border-bottom: none; }
.answers-examinee-row:hover { background: var(--bg-f8fafc); }
.answers-examinee-row:active { transform: none !important; }

.answers-row-info {
    flex: 1 1 auto;
    min-width: 0;
}
.answers-row-name {
    font-size: 0.94rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.answers-row-meta {
    font-size: 0.75rem;
    color: var(--fg-64748b);
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.answers-row-score {
    flex: 0 0 auto;
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    line-height: 1.5;
    white-space: nowrap;
}
.answers-row-score.score-pass {
    background: var(--bg-f0fdf4);
    color: var(--fg-15803d);
    border: 1px solid var(--bd-86efac);
}
.answers-row-score.score-fail {
    background: var(--bg-fef2f2);
    color: var(--fg-b91c1c);
    border: 1px solid var(--bd-fca5a5);
}
.answers-row-score.score-na {
    background: var(--bg-f8fafc);
    color: var(--fg-94a3b8);
    border: 1px solid var(--bd-e2e8f0);
}
.answers-row-chevron {
    flex: 0 0 auto;
    color: var(--fg-cbd5e1);
    font-size: 0.85rem;
}

/* ---------- Detail view ---------- */
.answers-detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0;
}

/* Nav row — arrows span the full card-nav height, flush to the
   card's top corners. Inner blocks carry their own padding so
   the arrows can reach top:0 / bottom:0 without being clipped
   by the parent's padding. */
.answers-detail-card > .answers-detail-nav {
    position: relative;
    padding: 0;
    text-align: center;
    min-height: 84px;   /* reserves height when content is short */
}
.answers-detail-card > .answers-detail-nav > .answers-nav-position-text,
.answers-detail-card > .answers-detail-nav > .answers-nav-name,
.answers-detail-card > .answers-detail-nav > .answers-nav-attempts {
    padding-left: 3.5rem;
    padding-right: 3.5rem;
}
.answers-detail-card > .answers-detail-nav > .answers-nav-position-text {
    padding-top: 1rem;
}
.answers-detail-card > .answers-detail-nav > .answers-nav-attempts:last-child,
.answers-detail-card > .answers-detail-nav > .answers-nav-name:last-child {
    padding-bottom: 1rem;
}

.answers-nav-arrow--edge {
    position: absolute;
    top: 0;
    bottom: 0;
    left: auto;
    right: auto;
    width: 44px;
    /* Stretch from top:0 to bottom:0 only — no min-height, no
       border on any edge (the nav's own bottom border handles
       the divider line). */
    height: auto;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--fg-94a3b8);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0;
    transition: background 0.15s, color 0.15s, opacity 0.18s ease;
    z-index: 1;
}
.answers-nav-arrow--edge:hover:not(:disabled) {
    background: var(--bg-f1f5f9);
    color: var(--fg-1e293b);
}
.answers-nav-arrow--edge:active:not(:disabled) {
    transform: none !important;
}
/* Left arrow — flush to the card's top-left and bottom-left edges.
   Its bottom-left is NOT rounded (nav sits above the divider, so the
   card's outer radius only applies to the top-left corner here). */
.answers-nav-arrow--edge#answers-prev-btn {
    left: 0;
    border-radius: 12px 0 0 0;
}
/* Right arrow — mirror. */
.answers-nav-arrow--edge#answers-next-btn {
    right: 0;
    border-radius: 0 12px 0 0;
}
.answers-nav-arrow--edge.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.answers-nav-position-text {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--fg-94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
}
.answers-detail-card > .answers-detail-nav .answers-nav-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    word-break: break-word;
    margin: 0 auto;
    max-width: 100%;
}

.answers-nav-attempts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.6rem;
}
.answers-attempt-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-475569);
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.answers-attempt-pill:hover {
    background: var(--bg-f1f5f9);
    border-color: var(--bd-cbd5e1);
    color: var(--fg-1e293b);
}
.answers-attempt-pill.is-current {
    background: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
    color: var(--fg-ffffff);
    cursor: default;
}
.answers-attempt-pill:active {
    transform: none !important;
}
.answers-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-475569);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.answers-detail-back:hover {
    background: var(--bg-f8fafc);
    border-color: var(--bd-cbd5e1);
    color: var(--fg-1e293b);
}
.answers-detail-back:active { transform: none !important; }

.answers-detail-card {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.answers-detail-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.1rem 1.25rem;
}
.answers-detail-divider {
    height: 1px;
    background: var(--bg-eef2f6);
    margin: 0;
}
.answers-detail-body {
    padding: 1.25rem;
}
.answers-detail-body .paper-review { padding-bottom: 0; }

/* Position row — arrows absolute so their height doesn't create
   a gap between "1 of N" and the name below */
.answers-nav-position {
    position: relative;
    display: inline-block;
    padding: 0 30px;
    margin-bottom: 0.15rem;
    line-height: 1.5;
}
.answers-nav-position .answers-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
.answers-nav-position .answers-nav-arrow:active:not(:disabled) {
    transform: translateY(-50%);
}
.answers-nav-position #answers-prev-btn { left: 0; }
.answers-nav-position #answers-next-btn { right: 0; }
.answers-nav-position-text {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
}

/* Small circular arrows — secondary */
.answers-nav-arrow {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-ffffff);
    color: var(--fg-64748b);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    padding: 0;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.answers-nav-arrow:hover:not(:disabled) {
    background: var(--bg-f1f5f9);
    border-color: var(--bd-cbd5e1);
    color: var(--fg-1e293b);
}
.answers-nav-arrow:active:not(:disabled) {
    transform: none !important;
}
.answers-nav-arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.answers-nav-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    line-height: 1.3;
    text-align: center;
    width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Summary wrap — centered, content-sized card */
.answers-summary-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

/* Info card — two auto columns, no stretching */
.answers-nav-info {
    display: grid;
    grid-template-columns: auto auto;
    padding: 0;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 12px;
    max-width: 100%;
    overflow: hidden;
}

/* Each column — label column sized to widest label, value to widest
   value; nothing stretches to fill */
.answers-nav-col {
    display: grid;
    grid-template-columns: max-content minmax(0, auto);
    column-gap: 0.9rem;
    row-gap: 0.5rem;
    align-items: baseline;
    padding: 0.85rem 1.1rem;
    min-width: 0;
}
.answers-nav-col + .answers-nav-col {
    border-left: 1px solid var(--bd-e2e8f0);
}

/* Stat row uses display:contents so its label/value become direct
   grid children — that's what makes all labels align and all values
   align, with zero leftover whitespace */
.answers-nav-stat {
    display: contents;
}
.answers-nav-stat .label {
    color: var(--fg-94a3b8);
    font-weight: 500;
    font-size: 0.74rem;
    white-space: nowrap;
}
.answers-nav-stat .value {
    color: var(--fg-1e293b);
    font-weight: 600;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: left;
}
.answers-nav-stat .value.score-pass { color: var(--fg-15803d); }
.answers-nav-stat .value.score-fail { color: var(--fg-b91c1c); }
.answers-nav-stat .value.score-na   { color: var(--fg-94a3b8); }

/* ============================================================ */
/*  MARKSHEET BADGE + online-exam student card integration       */
/* ============================================================ */
.marks-mode-badge {
    display: inline-block;
    padding: 0.08rem 0.55rem;
    margin-left: 0.35rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--bg-dbeafe);
    color: var(--fg-1e40af);
    vertical-align: middle;
    line-height: 1.6;
}

.marks-table .marks-time {
    color: var(--fg-64748b);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    white-space: nowrap;
    text-align: center;
}

.online-exam-card-student .student-exam-header { align-items: center; }
.online-exam-card-student .online-meta-row { display: none; }
.online-exam-card-student .online-status-pill { display: none; }

.online-action-muted {
    font-size: 0.82rem;
    color: var(--fg-94a3b8);
    font-weight: 500;
}
.online-action-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}
.online-score-display {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
    font-variant-numeric: tabular-nums;
}
.online-score-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
.online-score-total {
    font-size: 0.9rem;
    color: var(--fg-94a3b8);
    font-weight: 500;
}

.online-countdown-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.7rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--fg-b45309);
    background: var(--bg-fef3c7);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.online-countdown-tag i {
    font-size: 0.6rem;
    opacity: 0.85;
    flex-shrink: 0;
    color: var(--fg-b45309);
}
.online-countdown-tag .online-countdown-tag-label {
    color: var(--fg-92400e);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}
.online-countdown-tag [data-countdown-value] {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    color: var(--fg-b45309);
    letter-spacing: 0.01em;
}
.online-countdown-tag .countdown-time {
    font-weight: 500;
    color: var(--fg-92400e);
    opacity: 0.75;
}

/* ------------------------------------------------------------ */
/*  COUNTDOWN GROUP — plain text, stacked. Label on top,         */
/*  value below. No background, no border, no pill. Used on the  */
/*  student exam card for STARTING IN / CLOSES IN / RESULT IN.   */
/*  Right-aligned in the action column; the outer flex row       */
/*  centres it vertically against the card header.               */
/* ------------------------------------------------------------ */
.exam-countdown-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
    padding: 0;
    background: transparent;
    border: none;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}
.exam-countdown-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-94a3b8);
    line-height: 1.2;
}
.exam-countdown-value {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--fg-b45309);
    letter-spacing: 0.01em;
    line-height: 1.05;
}
.exam-countdown-pill.is-past .exam-countdown-label { color: var(--fg-cbd5e1); }
.exam-countdown-pill.is-past .exam-countdown-value { color: var(--fg-94a3b8); }

/* Solo variant — countdown stands alone (no retake link below it).
   Larger, muted slate — reads as information, not an alert. */
.exam-countdown-pill--solo .exam-countdown-value {
    font-size: 1.18rem;
    color: var(--fg-475569);
    font-weight: 700;
}

/* Non-solo (has retake link below) — same neutral slate tone,
   slightly smaller so it doesn't compete with the retake link. */
.exam-countdown-pill:not(.exam-countdown-pill--solo) .exam-countdown-value {
    font-size: 1rem;
    color: var(--fg-475569);
    font-weight: 700;
}
.exam-countdown-pill--solo .exam-countdown-label {
    color: var(--fg-94a3b8);
    font-size: 0.56rem;
}

/* Retake — plain text link with a right chevron that slides on
   hover. Replaces the outlined button. */
.exam-retake-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0;
    background: transparent;
    border: none;
    color: var(--fg-b45309);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: color 0.15s ease;
}
.exam-retake-link span {
    line-height: 1;
    padding-right: 2px;
}
.exam-retake-link i {
    font-size: 0.6rem;
    line-height: 1;
    transition: transform 0.15s ease;
}
.exam-retake-link:hover {
    color: var(--fg-92400e);
}
.exam-retake-link:hover i {
    transform: translateX(2px);
}
.exam-retake-link:active {
    transform: none !important;
}

/* Vertically centre the action column's contents against the
   card header. Applies to the plain countdown group and to any
   button that shares the row. */
.online-exam-card-student .student-exam-header {
    align-items: center;
}
.online-exam-card-student .student-exam-marks {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 100%;
}

/* Right-aligned stack on the card action column. */
.online-action-group {
    align-items: flex-end;
    gap: 0.35rem;
}
.online-result-stack {
    align-items: flex-end;
    gap: 0.35rem;
}

.online-result-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}
.online-result-score {
    display: inline-flex;
    align-items: baseline;
    gap: 0.2rem;
    /* Match .student-exam-marks typography on offline cards. */
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 600;
}
.online-result-score .student-mark {
    font-size: 1.2rem;
    font-weight: 600;
}
.online-result-score .total-marks {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--fg-94a3b8);
}
.online-countdown-line {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--fg-64748b);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.online-countdown-line i { color: var(--fg-94a3b8); font-size: 0.65rem; }
.online-countdown-line.is-past { color: var(--fg-94a3b8); }

/* Student card — compact attempts row under the title. */
.student-card-attempts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.35rem;
}
.student-card-attempt-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--fg-475569);
    background: var(--bg-f1f5f9);
    border: 1px solid var(--bd-e2e8f0);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.online-terminated-label {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-fef2f2);
    color: var(--fg-b91c1c);
    border: 1px solid var(--bd-fecaca);
    white-space: nowrap;
}

.online-terminated-note {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--bg-fef2f2);
    border: 1px solid var(--bd-fecaca);
    border-left: 3px solid var(--bd-dc2626);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--fg-7f1d1d);
}
.online-terminated-note > i {
    color: var(--fg-b91c1c);
    font-size: 0.95rem;
    margin-top: 0.15rem;
    flex-shrink: 0;
}
.online-terminated-note-title {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--fg-991b1b);
    margin-bottom: 0.15rem;
}
.online-terminated-note-reason {
    font-weight: 400;
    line-height: 1.45;
    color: var(--fg-7f1d1d);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SolaimanLipi', sans-serif;
}

/* ============================================================ */
/*  MOBILE                                                       */
/* ============================================================ */

/* Exam header + runner */
@media (max-width: 768px) {
    #exam-app-header { padding: 0.6rem 1rem; }
    #exam-app-header.scrolled {
        top: 8px;
        width: calc(100% - 16px);
        margin: 0 8px;
        padding: 0.5rem 1rem;
        border-radius: 18px;
        min-height: 48px;
    }
    .header-exam-timer { font-size: 0.98rem; padding: 0.28rem 0.6rem; }
    .header-exam-counter { font-size: 0.66rem; }
    .header-home-btn { width: 44px; height: 44px; }

    .exam-runner-titlebar { padding: 1.5rem 1rem 0.5rem; }
    .exam-runner-title-text { font-size: 1.25rem; }
    .exam-runner-subject { font-size: 0.66rem; margin-top: 0.35rem; }
    .exam-runner-questions { padding: 0 1rem 6rem; }

    .paper-question { gap: 0.75rem; padding: 1.25rem 0; }
    .paper-q-number { flex-basis: 1.5rem; font-size: 0.95rem; line-height: 1.7; }
    .paper-q-text { font-size: 0.96rem; margin-bottom: 0.85rem; }

    .paper-option { padding: 0.75rem 0.85rem; font-size: 0.9rem; gap: 0.6rem; }
    .paper-option-letter { flex-basis: 1.65rem; width: 1.65rem; height: 1.65rem; font-size: 0.72rem; }

    .paper-passage-instruction { font-size: 0.9rem; margin-bottom: 0.75rem; }
    .paper-passage-body { font-size: 0.93rem; margin-bottom: 1rem; }

    .paper-sub-question { padding: 1rem 0 0; margin-top: 1rem; }
    .paper-sub-question:first-of-type { padding-top: 1rem; margin-top: 0.85rem; }

    .review-hero-title { font-size: 1.05rem; }
    .exam-result:has(.paper-review) { padding: 1rem 1rem 3rem; }

    .online-q-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
    .online-examinee-grid { flex-direction: column !important; }
    .online-examinee-dim { flex: 1 1 auto; }
    .online-add-buttons { flex-direction: column; }
    .online-add-btn { flex: 1 1 100%; }
    .online-total-pill { padding: 0.4rem 0.8rem; }
    .online-total-value { font-size: 1.05rem; }
}

/* Very narrow screens — stack the review hero */
@media (max-width: 480px) {
    .paper-review .review-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }
    .paper-review .review-hero-info { max-width: 100%; }
    .paper-review .review-hero-score-badge { margin-left: 0; }
    .review-hero-score-col {
        align-items: flex-start;
        margin-left: 0;
    }
}

@media (max-width: 640px) {
    .paper-options-grid { grid-template-columns: 1fr; gap: 0.55rem; }

    .online-schedule-row { flex-direction: column; gap: 0; }
    .online-schedule-row > .form-group { margin-bottom: 1rem; }
    .online-options-grid { grid-template-columns: 1fr; }

    /* Answers list */
    .answers-examinee-row { padding: 0.75rem 0.85rem; gap: 0.55rem; }
    .answers-row-name { font-size: 0.88rem; }
    .answers-row-meta { font-size: 0.7rem; }
    .answers-row-score { font-size: 0.8rem; padding: 0.15rem 0.55rem; }

    /* Answers detail header */
    .answers-detail-nav { padding: 0.9rem 1rem; }
    .answers-summary-wrap { margin-bottom: 1rem; }
    .answers-nav-name { font-size: 0.98rem; }
    .answers-nav-position { padding: 0 26px; }
    .answers-nav-arrow {
        flex-basis: 20px;
        width: 20px;
        height: 20px;
        font-size: 0.52rem;
    }
    .answers-nav-position-text { font-size: 0.68rem; }

    /* Info card — stack columns vertically */
    .answers-nav-info {
        grid-template-columns: 1fr;
        width: 100%;
    }
    .answers-nav-col + .answers-nav-col {
        border-left: none;
        border-top: 1px solid var(--bd-e2e8f0);
    }
    .answers-nav-col {
        padding: 0.75rem 1rem;
        column-gap: 1rem;
        row-gap: 0.4rem;
    }
    .answers-nav-stat .label { font-size: 0.72rem; }
    .answers-nav-stat .value { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
    .online-live-dot { animation: none; }
    .header-exam-timer.critical::after { animation: none; box-shadow: none; }
    .paper-option,
    .paper-option-letter { transition: none !important; }
}


/* ============================================================ */
/*  STUDENT EXAM SURFACES — CONTENT FADES                        */
/*  The runner, the result card and the review paper mount via    */
/*  direct DOM writes, so they never got a view transition. These */
/*  classes give them the same fade the rest of the app uses.     */
/* ============================================================ */
@keyframes cbsFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
@keyframes cbsFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
.cbs-fade-in {
    animation: cbsFadeIn 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Full-page views fade opacity only — a translate on a whole page reads
   as a jolt rather than a fade. */
@keyframes cbsViewFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.view.cbs-fade-in {
    animation: cbsViewFadeIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cbs-fade-out {
    animation: cbsFadeOut 0.18s ease-in both;
    pointer-events: none;
}

/* ---------- Exit confirmation overlay ---------- */
.exam-exit-overlay {
    position: fixed;
    inset: 0;
    z-index: 100500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.16s ease;
}
.exam-exit-overlay.is-open { opacity: 1; }

.exam-exit-card {
    width: min(420px, 100%);
    background: var(--bg-ffffff);
    border-radius: 16px;
    padding: 1.5rem 1.35rem 1.25rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    text-align: center;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.exam-exit-overlay.is-open .exam-exit-card { transform: none; }

.exam-exit-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-fef2f2);
    color: var(--fg-dc2626);
    font-size: 1.15rem;
}
.exam-exit-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fg-1e293b);
}
.exam-exit-text {
    margin: 0.4rem 0 1.25rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--fg-64748b);
}
.exam-exit-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
}
.exam-exit-actions .btn { min-width: 96px; }

/* ---------- Review: tab-switch pill + termination ---------- */
/* Mark + tab-switch tally stack directly under one another on the
   right edge of the review hero. */
.review-hero-score-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
    margin-left: auto;
    flex-shrink: 0;
}
.review-tab-switch-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--bg-f1f5f9);
    color: var(--fg-475569);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.review-tab-switch-pill[hidden] { display: none !important; }
.review-tab-switch-pill.is-warning {
    background: var(--bg-fff7ed);
    color: var(--fg-b45309);
}

.review-hero-score-badge.is-terminated {
    background: var(--bg-f8fafc);
    color: var(--fg-64748b);
    border: 1px solid var(--bd-e2e8f0);
}
.review-hero-score-badge .score-term {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.review-terminated-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0.25rem 0.9rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: var(--bg-fef2f2);
    border: 1px solid var(--bd-fecaca);
    color: var(--fg-b91c1c);
    font-size: 0.82rem;
    line-height: 1.45;
}
.review-terminated-retake {
    margin-left: auto;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-dcfce7);
    color: var(--fg-15803d);
    font-size: 0.7rem;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .cbs-fade-in,
    .cbs-fade-out,
    .exam-exit-overlay,
    .exam-exit-card {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================================ */
/*  THEME SWITCHER (inside the account / profile menu)           */
/*  Same segmented-pill language as the dashboard tab switcher.  */
/* ============================================================ */
#cbs-theme-fade {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    pointer-events: none;
    opacity: 0;
    will-change: opacity;
}

.user-menu-dropdown,
.mobile-profile-dropdown {
    min-width: 236px;
}
.user-menu-dropdown.show {
    max-height: 320px;
}

.profile-theme-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.15rem 0 0.35rem;
    padding: 0.5rem 0.3rem 0.55rem;
    border-bottom: 1px solid var(--bd-e2e8f0);
}

.profile-theme-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    padding-left: 0.1rem;
}

.theme-switcher {
    display: flex;
    gap: 0.15rem;
    padding: 0.2rem;
    border-radius: 999px;
    background: var(--bg-f1f5f9);
    border: 1px solid var(--bd-e2e8f0);
}

.theme-switch-btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.32rem;
    padding: 0.36rem 0.5rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--fg-64748b);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: none;
}

.theme-switch-btn i {
    font-size: 0.68rem;
}

.theme-switch-btn:hover {
    color: var(--fg-1e293b);
}

.theme-switch-btn:focus-visible {
    outline: 2px solid var(--fg-2563eb);
    outline-offset: 1px;
}

.theme-switch-btn.is-active {
    background: var(--bg-ffffff);
    color: var(--fg-1e293b);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.12),
        0 4px 10px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] .theme-switch-btn.is-active {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.55),
        0 4px 10px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    .theme-switch-btn { transition: none; }
}

/* ---- Dark-mode leftovers -------------------------------------
   Literal colours that are not part of the token families, plus a
   few places where a light colour is supplied by JS/canvas. ---- */
html[data-theme="dark"] {
    --notice-ink: #e9e9e9;
    --notice-muted: #9b9b9b;
    --notice-accent: #8ba0ff;
    --surface-rgb: 37, 37, 37;
    --ink-rgb: 0, 0, 0;
    accent-color: #d4d4d4;
    scrollbar-color: #3d3d3d transparent;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb,
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #3d3d3d;
}
/* Dark mode keeps the shimmer: the light surface sweep is invisible on a
   near-black card, so the blocks carry the animated gradient itself. */
html[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #232323 25%, #3a3a3a 37%, #232323 63%);
    background-size: 200% 100%;
    animation: cbsShimmer 1.6s linear infinite;
}
html[data-theme="dark"] .skeleton-card::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: cbsShimmer 1.6s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
    html[data-theme="dark"] .skeleton {
        animation: none;
        background: #232323;
    }
    html[data-theme="dark"] .skeleton-card::before { animation: none; opacity: 0; }
}
html[data-theme="dark"] img {
    color-scheme: dark;
}

/* ============================================================ */
/*  DARK GLASS FIXES                                            */
/*                                                              */
/*  The light theme fakes glass with bright inset highlights     */
/*  and page-white translucency. On a dark surface those read    */
/*  as white rims and milky panels, so they are re-cast here     */
/*  instead of being globally inverted.                          */
/* ============================================================ */
html[data-theme="dark"] .app-header.scrolled::before,
html[data-theme="dark"] #exam-app-header.scrolled::before {
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.05),
        inset -1px -1px 0 rgba(0, 0, 0, 0.45);
}

/* #install-app-btn is deliberately absent here: it carries the nav pill's
   full slab shadow in the DESIGN PASS section, light or dark. */
html[data-theme="dark"] .toast,
html[data-theme="dark"] .online-total-pill,
html[data-theme="dark"] #modal-notice-recipients .recipients-box {
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 10px 30px rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .toast.toast-online { border-color: rgba(74, 222, 128, 0.35); }
html[data-theme="dark"] .toast.toast-offline { border-color: rgba(248, 113, 113, 0.35); }

/* The other two notice boxes carried the same bright 72% hairline but
   were missing from the list above, so they kept a white ring. */
html[data-theme="dark"] #modal-notice-editor .notice-editor-box,
html[data-theme="dark"] #modal-notice-targeting .recipients-box {
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62);
}

html[data-theme="dark"] .user-menu-dropdown,
html[data-theme="dark"] .mobile-profile-dropdown,
html[data-theme="dark"] .mobile-menu-footer .mobile-profile-dropdown {
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow:
        0 16px 32px -12px rgba(0, 0, 0, 0.85),
        0 4px 12px -4px rgba(0, 0, 0, 0.65);
}

html[data-theme="dark"] .mobile-menu {
    box-shadow: -6px 0 28px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .mobile-profile-trigger,
html[data-theme="dark"] .mobile-menu-footer .mobile-profile-trigger {
    border-color: rgba(255, 255, 255, 0.10);
}
html[data-theme="dark"] .mobile-menu-footer .mobile-profile-trigger.is-closing {
    border-bottom-color: transparent;
}
html[data-theme="dark"] .mobile-overlay {
    background: rgba(0, 0, 0, 0.55);
}

html:not([data-theme="dark"]) .toast,
html:not([data-theme="dark"]) .online-total-pill,
html:not([data-theme="dark"]) #modal-notice-recipients .recipients-box {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 8px 18px rgba(15, 23, 42, 0.1);
}

html:not([data-theme="dark"]) .mobile-menu {
    box-shadow: -6px 0 28px rgba(15, 23, 42, 0.14);
}

/* Notice surfaces carry their own ink variables on the panel, which
   would otherwise override the inherited dark values. */
html[data-theme="dark"] #dashboard-panel-notices {
    --notice-ink: #e9e9e9;
    --notice-muted: #9b9b9b;
    --notice-line: rgba(255, 255, 255, 0.10);
    --notice-accent: #8ba0ff;
}

/* Hairline hovers that relied on a black tint need the opposite. */
html[data-theme="dark"] .attendance-frame-title:hover { background: rgba(255, 255, 255, 0.04); }
html[data-theme="dark"] .attendance-row:hover { background: rgba(255, 255, 255, 0.05); }

/* ============================================================ */
/*  ELEVATION — one depth scale, light and dark alike           */
/*  Cards sit at 1, floating menus at 2, modals at 3.           */
/* ============================================================ */
.login-card,
.student-exam-item {
    box-shadow: var(--elev-1);
}

.online-summary-message {
    margin: 0;
    padding: 0.65rem 0.75rem;
    color: var(--fg-64748b);
    font-size: 0.85rem;
    text-align: center;
}

.exam-card-item,
.class-card-item,
.student-card-item,
.student-exam-item,
.teacher-card,
.payment-month-card,
.config-group-card,
.reports-filters,
.student-selector-card,
.marks-table {
    box-shadow: var(--elev-1);
}

.exam-card-item,
.class-card-item,
.student-card-item,
.student-exam-item,
.teacher-card,
.payment-month-card,
.config-group-card {
    transition: box-shadow 0.2s ease, translate 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

/* Lift only where a real pointer exists. On touch screens the emulated
   :hover sticks after a tap, so a tapped exam card stayed floated even
   once its details were closed again. */
@media (hover: hover) and (pointer: fine) {
    .exam-card-item:hover,
    .class-card-item:hover,
    .student-card-item:hover,
    .student-exam-item:hover,
    .teacher-card:hover,
    .payment-month-card:hover {
        box-shadow: var(--elev-2);
        translate: 0 -2px;
    }
}

/* Pressing a card lifts it too, on any pointer. */
.exam-card-item:active,
.class-card-item:active,
.student-card-item:active,
.student-exam-item:active,
.teacher-card:active,
.payment-month-card:active {
    box-shadow: var(--elev-2);
    translate: 0 -2px;
}

.exam-card-item:hover,
.class-card-item:hover,
.student-card-item:hover,
.teacher-card:hover,
.payment-month-card:hover,
.config-group-card:hover,
.exam-card-item:active,
.class-card-item:active,
.student-card-item:active,
.teacher-card:active,
.payment-month-card:active,
.config-group-card:active {
    background: var(--bg-ffffff);
}

.payment-month-card.highlight-month {
    box-shadow: var(--elev-1), 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.payment-month-card.highlight-month:hover {
    box-shadow: var(--elev-2), 0 0 0 3px rgba(37, 99, 235, 0.12);
}

@media (prefers-reduced-motion: reduce) {
    .exam-card-item,
    .class-card-item,
    .student-card-item,
    .student-exam-item,
    .teacher-card,
    .payment-month-card,
    .config-group-card {
        transition: none;
    }
}

.custom-select-menu,
.dropdown-menu,
.split-action-menu,
.split-dropdown-menu {
    box-shadow: var(--elev-2);
}

.modal-box {
    box-shadow: var(--elev-3);
}

/* ============================================================ */
/*  MODAL SCROLL LOCK — the page behind must not move           */
/* ============================================================ */
body.modal-open {
    overflow: hidden;
}

/* ============================================================ */
/*  FILTER MENU — expanding a class must not jump the panel     */
/* ============================================================ */
.custom-select-menu {
    max-height: min(70vh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-anchor: none;
}

/* Selected class row + its independent fold control */
.flt-tree-head {
    cursor: pointer;
}

.flt-tree-box {
    display: inline-flex;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bd-cbd5e1);
    border-radius: 4px;
    background: var(--bg-ffffff);
    color: transparent;
    font-size: 0.55rem;
}

.flt-tree.is-selected .flt-tree-box {
    border-color: var(--bg-2563eb);
    background: var(--bg-2563eb);
    color: var(--fg-ffffff);
}

.flt-tree-fold {
    display: inline-flex;
    margin-left: auto;
    padding: 0.2rem;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--fg-94a3b8);
    cursor: pointer;
}

.flt-tree-fold:hover {
    background: var(--bg-f1f5f9);
    color: var(--fg-1e293b);
}

.flt-tree-count {
    margin-left: auto;
}

/* ============================================================ */
/*  SETTINGS SURFACES — cards read as cards, nesting as nesting  */
/* ============================================================ */
.settings-frame {
    background: var(--surface-raised);
    box-shadow: var(--elev-1);
}

.settings-frame:hover {
    box-shadow: var(--elev-2);
}

/* The nested Prepaid / Student Alert block belongs to the Payments
   card, so it is recessed: no shadow, one step darker than its parent. */
.settings-subframe,
.settings-subframe.expanded {
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    padding-inline: 0;
}

.settings-subframe.expanded {
    border-top-color: transparent;
}

/* ============================================================ */
/*  TOGGLE SWITCH — off/on must be unmistakable in both themes   */
/* ============================================================ */
.toggle-slider {
    background: var(--toggle-off);
    box-shadow:
        inset 0 0 0 1px rgba(var(--ink-rgb), 0.06),
        inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.toggle-slider::before {
    background: var(--toggle-knob);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--toggle-on);
    box-shadow:
        inset 0 0 0 1px rgba(var(--ink-rgb), 0.10),
        0 0 10px -2px rgba(0, 0, 0, 0.35);
}

.toggle-switch input:checked + .toggle-slider::before {
    background: var(--toggle-knob-on);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* ============================================================ */
/*  ONE CHECKBOX EVERYWHERE                                     */
/*                                                              */
/*  The students-tab filter tick, applied to every real          */
/*  checkbox in both portals: 1.5px neutral border, rounded      */
/*  square, solid fill with a white tick when checked.           */
/* ============================================================ */
input[type="checkbox"],
.student-chip input[type="checkbox"],
.select-all-toggle input[type="checkbox"],
.payment-select-all input[type="checkbox"],
.payment-student-checkbox {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 15px;
    height: 15px;
    min-width: 15px;
    margin: 0;
    padding: 0;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    background-color: var(--bg-ffffff);
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px 10px;
    box-sizing: border-box;
    vertical-align: middle;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

input[type="checkbox"]:hover:not(:disabled),
.student-chip input[type="checkbox"]:hover:not(:disabled) {
    border-color: var(--bd-94a3b8);
}

input[type="checkbox"]:checked,
.student-chip input[type="checkbox"]:checked,
.select-all-toggle input[type="checkbox"]:checked,
.payment-select-all input[type="checkbox"]:checked,
.payment-student-checkbox:checked {
    background-color: var(--bg-1e293b);
    border-color: var(--bd-1e293b);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='2.4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='3.5%208.4%206.6%2011.5%2012.5%204.6'/%3E%3C/svg%3E");
    background-size: 10px 10px;
}

/* The old hand-rolled ticks would double up with the SVG one. */
.student-chip input[type="checkbox"]:checked::before,
.select-all-toggle input[type="checkbox"]:checked::before,
.payment-select-all input[type="checkbox"]:checked::before,
.payment-student-checkbox:checked::before {
    content: none;
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--fg-2563eb);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* The toggle switch keeps its own invisible input. */
.toggle-switch input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    width: 0;
    height: 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    opacity: 0;
    pointer-events: none;
}

/* ============================================================ */
/*  Tick boxes drawn as spans (subject tree, notice targets)     */
/*  must look exactly like every real checkbox.                  */
/* ============================================================ */
.tree-subject-box,
.notice-option-box {
    display: inline-flex;
    width: 15px;
    height: 15px;
    margin-top: 1px;
    border: 1.5px solid var(--bd-cbd5e1);
    border-radius: 4px;
    background-color: var(--bg-ffffff);
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px 10px;
    flex-shrink: 0;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

/* The old hand-drawn ticks would double up with the shared one. */
.tree-subject-box::after,
.notice-option-box::after {
    content: none;
}

.tree-subject:hover .tree-subject-box,
.notice-option:hover .notice-option-box {
    border-color: var(--bd-94a3b8);
}

.tree-subject.checked .tree-subject-box,
.notice-option.checked .notice-option-box {
    border-color: var(--bd-1e293b);
    background-color: var(--bg-1e293b);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='2.4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='3.5%208.4%206.6%2011.5%2012.5%204.6'/%3E%3C/svg%3E");
}

/* ============================================================ */
/*  CHECKBOX VISIBILITY — one border/fill for every tick box     */
/*  (inputs, subject tree, notice targets, students filter)      */
/* ============================================================ */
input[type="checkbox"],
.tree-subject-box,
.notice-option-box,
.report-filter-check {
    border-color: var(--check-border);
}

input[type="checkbox"]:hover:not(:disabled),
.student-chip input[type="checkbox"]:hover:not(:disabled),
.tree-subject:hover .tree-subject-box,
.notice-option:hover .notice-option-box {
    border-color: var(--check-border-hover);
}

input[type="checkbox"]:checked,
.student-chip input[type="checkbox"]:checked,
.select-all-toggle input[type="checkbox"]:checked,
.payment-select-all input[type="checkbox"]:checked,
.payment-student-checkbox:checked,
.tree-subject.checked .tree-subject-box,
.notice-option.checked .notice-option-box,
.report-filter-option.active .report-filter-check {
    border-color: var(--check-fill);
    background-color: var(--check-fill);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='2.4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='3.5%208.4%206.6%2011.5%2012.5%204.6'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px 10px;
}

.report-filter-check {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 9px 9px;
}

.report-filter-check i {
    display: none;
}

/* ============================================================ */
/*  ONE TICK — leftovers that still draw their own checkmark     */
/* ============================================================ */
.class-admin-checkbox input:checked::after {
    content: none;
}

/* Class root row in the notice target picker */
.notice-class-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--check-border);
    border-radius: 4px;
    background-color: var(--bg-ffffff);
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px 10px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.notice-class-check:hover {
    border-color: var(--check-border-hover);
}

.notice-class-check.full {
    border-color: var(--check-fill);
    background-color: var(--check-fill);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='2.4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpolyline%20points='3.5%208.4%206.6%2011.5%2012.5%204.6'/%3E%3C/svg%3E");
}

.notice-class-check.partial {
    border-color: var(--check-fill);
    background-color: var(--check-fill);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23fff'%20stroke-width='2.4'%20stroke-linecap='round'%3E%3Cline%20x1='3.5'%20y1='8'%20x2='12.5'%20y2='8'/%3E%3C/svg%3E");
}

.notice-class-check.partial::after,
.notice-class-check.full::after {
    content: none;
}

/* ============================================================ */
/*  THEME SWAP — freeze every transition for one frame           */
/*                                                              */
/*  Otherwise each component eases to its new colour at its own  */
/*  speed (0.08s cards, 0.2s buttons, 0.3s toggles...), which is */
/*  exactly what reads as "the page is catching up".             */
/* ============================================================ */
html.cbs-theme-swapping,
html.cbs-theme-swapping *,
html.cbs-theme-swapping *::before,
html.cbs-theme-swapping *::after {
    transition: none !important;
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
}

/* ============================================================ */
/*  CARD BEVEL — one lit top edge, one shaded bottom edge        */
/*                                                              */
/*  The highlight is the border itself, not an extra inset line, */
/*  so a card's top is 1px like every other side. That removes  */
/*  the doubled white+dark top line in light mode and the        */
/*  "fatter" top edge in dark mode, while keeping the 3D read.   */
/* ============================================================ */
.exam-card-item,
.class-card-item,
.student-card-item,
.student-exam-item,
.teacher-card,
.payment-month-card,
.config-frame,
.config-group-card,
.reports-filters,
.student-selector-card,
.marks-table {
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
}

/* Hovers that repaint all four borders must keep the lit top. */
.student-card-item:hover,
.teacher-card:hover {
    border-top-color: var(--card-edge-top-hover);
    border-bottom-color: var(--card-edge-bottom);
}

/* ============================================================ */
/*  CONFIGURATION TAB — raised outer frames, recessed groups    */
/*  Without two distinct levels the tab reads flat next to the   */
/*  rest of the portal, which already has the bevel.             */
/* ============================================================ */
.config-frame {
    background: var(--surface-raised);
    border-radius: 14px;
    box-shadow: var(--elev-1);
}

.config-group-card,
.config-group-card--draft {
    background: var(--surface-sunken);
    box-shadow: var(--well-shadow);
    translate: 0;
    /* A well catches light at the bottom and is shadowed at the top,
       which is the opposite of the raised cards above. */
    border-top-color: var(--well-edge-top);
    border-bottom-color: var(--well-edge-bottom);
}

.config-group-card:hover,
.config-group-card--draft:hover {
    background: var(--surface-sunken);
    box-shadow: var(--well-shadow);
    translate: 0;
    border-left-color: var(--bd-e2e8f0);
    border-right-color: var(--bd-e2e8f0);
    border-top-color: var(--well-edge-top);
    border-bottom-color: var(--well-edge-bottom);
}

/* ============================================================ */
/*  NOTICE META — DRAFT takes its own line before the date and   */
/*  author get squeezed. The three never split 2 + 1 (which read */
/*  as a broken row on a narrow card).                            */
/* ============================================================ */
.notice-meta {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

/* The card is the query container, so the wrap keys off the card's own
   inline size — a narrow desktop column behaves exactly like a phone. */
.notice-card {
    container-type: inline-size;
}

@container (max-width: 340px) {
    /* Two columns on the second line: DRAFT claims the whole first row,
       then the date and author split the space underneath instead of
       leaving the author stranded on its own line. */
    .notice-meta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, auto));
        justify-content: start;
        align-items: center;
        column-gap: 0.5rem;
    }
    .notice-meta .notice-draft-chip {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

/* ============================================================ */
/*  NOTICE CARDS — same bevel as every other card                */
/*  They carried a flat 1px shadow and never joined the scale.   */
/* ============================================================ */
.notice-card,
.notice-detail-card {
    box-shadow: var(--elev-1);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
}

.notice-card:hover {
    box-shadow: var(--elev-2);
    border-top-color: var(--card-edge-top-hover);
    border-bottom-color: var(--card-edge-bottom);
}

/* The dashboard notice panel paints its own border colour, so the
   bevel has to be re-stated at the same specificity. */
#dashboard-panel-notices .notice-card,
#dashboard-panel-notices .notice-detail-card {
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
}

#dashboard-panel-notices .notice-card:hover {
    border-top-color: var(--card-edge-top-hover);
    border-bottom-color: var(--card-edge-bottom);
}

/* ============================================================ */
/*  FLOATING MENUS — same lit top edge as the cards              */
/*  (the three-dot menu also sets its borders inline in JS)      */
/* ============================================================ */
.custom-select-menu,
.split-action-menu,
.split-dropdown-menu,
.dropdown-menu {
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
}

/* ============================================================ */
/*  BUTTONS — bevelled, same light direction as the cards        */
/*  The bevel is the 1px border itself (lit top, shaded bottom)  */
/*  plus one soft contact shadow, exactly like a card. A solid   */
/*  fill carries the same ring in its own tint so the edge is    */
/*  visible at any size, in both themes.                         */
/* ============================================================ */
.btn {
    border-color: var(--btn-line);
    border-top-color: var(--btn-line-top);
    border-bottom-color: var(--btn-line-bottom);
    box-shadow: var(--elev-1);
}

/* Filled variants: ring in the fill's own tint (light on top, dark
   underneath) so the button reads raised on any surface. */
.btn-primary,
.btn-success,
.btn-danger {
    border-color: var(--btn-solid-line);
    border-top-color: var(--btn-solid-line-top);
    border-bottom-color: var(--btn-solid-line-bottom);
    box-shadow: var(--elev-1);
}

.btn:active {
    box-shadow:
        inset 0 1px 2px rgba(15, 23, 42, 0.16),
        0 1px 2px rgba(15, 23, 42, 0.08);
}

.btn-primary:active,
.btn-success:active,
.btn-danger:active {
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.28),
        0 1px 2px rgba(15, 23, 42, 0.08);
}

/* A button already sitting on an elevated surface must not be elevated
   again — it would read as a card on a card. Independent actions (page
   headers, dashboard tabs) keep the bevel below. */
:is(.modal-box, .notice-card, .notice-detail-card, .config-frame,
    .config-group-card, .config-online-defaults, .exam-card-item,
    .class-card-item, .student-card-item, .student-exam-item,
    .teacher-card, .payment-month-card, .student-selector-card,
    .reports-filters, .marks-table) .btn,
:is(.modal-box, .notice-card, .notice-detail-card, .config-frame,
    .config-group-card, .config-online-defaults, .exam-card-item,
    .class-card-item, .student-card-item, .student-exam-item,
    .teacher-card, .payment-month-card, .student-selector-card,
    .reports-filters, .marks-table) .btn:active {
    box-shadow: none;
}

:is(.modal-box, .notice-card, .notice-detail-card, .config-frame,
    .config-group-card, .config-online-defaults, .exam-card-item,
    .class-card-item, .student-card-item, .student-exam-item,
    .teacher-card, .payment-month-card, .student-selector-card,
    .reports-filters, .marks-table) .btn-outline {
    border-top-color: var(--bd-d1d9e0);
    border-bottom-color: var(--bd-e2e8f0);
}

/* Outline buttons have a real border, so the bevel rides on it, and they
   get a faint face gradient so an unfilled button still reads as a
   surface rather than a hole punched in the page. */
.btn-outline {
    border-color: var(--bd-d1d9e0);
    border-top-color: var(--btn-line-top);
    border-bottom-color: var(--btn-line-bottom);
    background: linear-gradient(180deg, var(--btn-face-top), var(--btn-face-bottom));
    box-shadow: var(--elev-1);
}

.btn-outline:hover {
    border-color: var(--bd-cbd5e1);
    border-top-color: var(--btn-line-top);
    border-bottom-color: var(--btn-line-bottom);
    background: var(--bg-f1f5f9);
}

/* ============================================================ */
/*  REPORTS — subject / type now use the shared custom select    */
/* ============================================================ */
.reports-filters .custom-select-wrapper.report-select-wrapper {
    display: block;
    width: 100%;
    min-width: 0;
}

/* The fade is a single Web Animation started by JS (see
   syncSearchEmptyState in utils.js) so both tabs animate identically.
   A CSS keyframe here would run a second animation on the same element
   and fight the JS one — that is the pop-then-drop this replaced. */

.custom-select-option.is-disabled {
    cursor: default;
    opacity: 0.6;
    pointer-events: none;
}

/* ============================================================ */
/*  REPORT PREVIEW — the frame is 3D, its controls are not      */
/*  Zoom / paging buttons sit on the preview surface, so they    */
/*  stay flat while the preview itself carries the elevation.    */
/* ============================================================ */
#report-preview {
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 14px;
    background: var(--surface-raised);
    box-shadow: var(--elev-1);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
}

#report-preview .btn,
#report-preview .btn:active {
    box-shadow: none;
}

#report-preview .btn-outline {
    border-top-color: var(--bd-d1d9e0);
    border-bottom-color: var(--bd-e2e8f0);
}

/* ============================================================ */
/*  DASHBOARD — "New …" actions and the tab switcher            */
/* ============================================================ */
.dashboard-action-btn {
    box-shadow: var(--elev-1);
}

.dashboard-action-btn:active {
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.24),
        0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Raised, not recessed: the switcher sits ON the page like the cards
   rather than being cut into it. The active pill still sits proud of
   it, so the pair reads outside-in instead of inside-out. */
.dashboard-tabs {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-e2e8f0);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    box-shadow: var(--elev-1);
}

.dashboard-tab.active {
    box-shadow:
        inset 0 1px 0 var(--card-edge-top),
        inset 0 -1px 0 rgba(15, 23, 42, 0.05),
        0 2px 4px rgba(15, 23, 42, 0.10),
        0 8px 16px -10px rgba(15, 23, 42, 0.22);
}

/* ============================================================ */
/*  DELETE CLASS — danger frame: red on every side              */
/*  Must outrank the generic .config-frame bevel.                */
/* ============================================================ */
.config-frame.class-delete-frame {
    border-color: var(--bd-fecaca);
    box-shadow: var(--elev-1), 0 0 0 1px rgba(220, 38, 38, 0.08);
}

/* ------------------------------------------------------------------
   Expanded cards stay lifted.
   An open exam card used to drop back to the flat elevation the moment
   the pointer left it — and on touch it never lifted at all, because
   the hover lift is gated on a fine pointer. Opening a card now adds
   .is-expanded, which holds the raised state until it is closed again.
   ------------------------------------------------------------------ */
.exam-card-item.is-expanded,
.student-exam-item.is-expanded {
    box-shadow: var(--elev-2),
        inset 0 1px 0 var(--card-edge-top),
        inset 0 -1px 0 var(--card-edge-bottom);
    translate: 0 -2px;
    border-color: var(--bd-dbe2ea);
    z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
    .exam-card-item.is-expanded,
    .student-exam-item.is-expanded { translate: none; }
}

/* ============================================================ */
/*  SPLIT-ACTION MENU — same size as every other dropdown        */
/*  The item is a bare <button>, so it inherited the body font   */
/*  and stood a size taller than the options in the other menus. */
/* ============================================================ */
.split-action-menu button {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.2;
}

.split-action-menu button i {
    font-size: 0.78rem;
    width: 1em;
    text-align: center;
}

/* ============================================================ */
/*  SEARCH EMPTY STATE — fade in after the list has finished     */
/*  leaving, instead of popping in on the frame the last card    */
/*  disappears.                                                  */
/* ============================================================ */
/* The fade itself is a Web Animation started by JS the moment the
   message is shown, so it can never be clipped by a frame that never
   painted the opacity-0 state. */
.student-search-empty,
.reports-search-empty {
    will-change: opacity, transform;
}

/* ============================================================ */
/*  ADMIN HEADER — dashboard vs class                            */
/*  On the dashboard there is no class nav, so the mobile drawer */
/*  would open empty. There the header shows the same avatar     */
/*  menu as desktop; inside a class the hamburger comes back.    */
/* ============================================================ */
@media (max-width: 768px) {
    body:has(#view-dashboard.active-view) #global-app-header .hamburger-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    body:has(#view-dashboard.active-view) #global-app-header .header-user-menu {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body:has(#view-dashboard.active-view) #global-app-header .user-menu-trigger {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Inside a class the drawer has the class nav (and its own profile
   block), so the header goes back to the hamburger only. */
@media (max-width: 768px) {
    body:has(#view-class.active-view) #global-app-header .header-user-menu,
    body:has(#view-class.active-view) #global-app-header .user-menu-trigger {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    body:has(#view-class.active-view) #global-app-header .hamburger-toggle {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* ============================================================ */
/*  OUTLINED BUTTONS — readable edges in both themes             */
/*  The old #d1d9e0 line on white (and #373737 on dark) was too  */
/*  faint to read as a button: Edit class, Add subject and the   */
/*  online-exam modal buttons looked borderless.                 */
/* ============================================================ */
.btn-outline {
    border-color: var(--outline-btn-line);
    border-top-color: var(--outline-btn-line-top);
    border-bottom-color: var(--outline-btn-line-bottom);
}

/* ============================================================ */
/*  PAYMENT DETAIL — the card carries the depth, not the button  */
/*  Back / Mark Selected sit inside .payment-detail-header and   */
/*  .payment-detail-actions. Only the header is a surface — it   */
/*  has its own white card. The actions row is a transparent flex */
/*  strip between the header and the table, so it takes no shadow */
/*  at all: a shadow on an empty box reads as a floating strip.   */
/*  A bevelled button inside a bevelled card reads as noise.     */
/* ============================================================ */
.payment-detail-header {
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    box-shadow: var(--elev-1);
}

.payment-detail-header .btn,
.payment-detail-actions .btn {
    box-shadow: none;
}

.payment-detail-header .btn:active,
.payment-detail-actions .btn:active {
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.14);
}

/* ============================================================ */
/*  PROFILE DROPDOWN — who you are, above the theme row          */
/*  The header keeps only the avatar; the name moves here so the */
/*  nav stops competing with the menu.                           */
/* ============================================================ */
.user-menu-identity {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem 0.65rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px solid var(--bd-e2e8f0);
}

.user-menu-identity .user-avatar {
    flex: 0 0 auto;
}

.user-menu-identity-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    max-width: 12rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 768px) {
    /* Dashboard header: avatar only — no name, no caret. */
    body:has(#view-dashboard.active-view) #global-app-header .user-menu-trigger {
        gap: 0;
        padding: 3px;
    }

    body:has(#view-dashboard.active-view) #global-app-header .user-menu-trigger .user-name,
    body:has(#view-dashboard.active-view) #global-app-header .user-menu-trigger .user-menu-caret {
        display: none !important;
    }
}

/* ============================================================ */
/*  ONE RULE FOR "BUTTON INSIDE A RAISED SURFACE"                */
/*  Any button that already sits on a card, frame, modal or      */
/*  panel must not be raised again — the surface carries the     */
/*  depth. This list is the single place to add a new surface:   */
/*  it covers every raised container in the app, so screens do   */
/*  not need fixing one at a time.                               */
/*  Independent buttons (page headers, tab bars, toolbars that   */
/*  are not inside a card) keep their bevel below.               */
/* ============================================================ */
:is(.modal-box, .settings-modal-box, .settings-frame, .settings-subframe,
    .notice-card, .notice-detail-card,
    .config-frame, .config-group-card, .config-online-defaults,
    .exam-card-item, .class-card-item, .student-card-item, .student-exam-item,
    .student-exam-card, .teacher-card, .payment-month-card, .payment-summary-card,
    .payment-detail-header, .payment-detail-actions, .exam-result-card,
    .student-selector-card, .reports-filters, .reports-panel,
    .attendance-frame, .marks-table, .online-import-panel) .btn:not(.view-marks-btn) {
    box-shadow: none;
}

:is(.modal-box, .settings-modal-box, .settings-frame, .settings-subframe,
    .notice-card, .notice-detail-card,
    .config-frame, .config-group-card, .config-online-defaults,
    .exam-card-item, .class-card-item, .student-card-item, .student-exam-item,
    .student-exam-card, .teacher-card, .payment-month-card, .payment-summary-card,
    .payment-detail-header, .payment-detail-actions, .exam-result-card,
    .student-selector-card, .reports-filters, .reports-panel,
    .attendance-frame, .marks-table, .online-import-panel) .btn:not(.view-marks-btn):active {
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.14);
}

/* Flat inside a card also means a flat outline: no lit/shaded pair,
   just the ordinary border. */
:is(.modal-box, .settings-modal-box, .settings-frame, .settings-subframe,
    .notice-card, .notice-detail-card,
    .config-frame, .config-group-card, .config-online-defaults,
    .exam-card-item, .class-card-item, .student-card-item, .student-exam-item,
    .student-exam-card, .teacher-card, .payment-month-card, .payment-summary-card,
    .payment-detail-header, .payment-detail-actions, .exam-result-card,
    .student-selector-card, .reports-filters, .reports-panel,
    .attendance-frame, .marks-table, .online-import-panel) .btn-outline {
    border-top-color: var(--outline-btn-line);
    border-bottom-color: var(--outline-btn-line);
}


/* ============================================================ */
/*  CARDS THAT STAY RAISED                                      */
/*                                                              */
/*  Hover is desktop-only, so a card used to drop back to the   */
/*  flat elevation the moment the pointer left it — and on      */
/*  touch it never lifted at all. A card now holds the lift     */
/*  for as long as it is opened (.is-expanded, set by the       */
/*  exam-card code) or picked (.is-raised, set by a click on    */
/*  the student cards, which have nothing to expand).           */
/* ============================================================ */
.student-card-item,
.student-exam-card,
.student-payment-card {
    transition:
        box-shadow 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        background 0.32s ease,
        border-color 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
    .student-card-item:hover,
    .student-exam-card:hover,
    .student-payment-card:hover {
        box-shadow: var(--elev-2);
        translate: 0 -2px;
        border-color: var(--bd-dbe2ea);
    }
}

.student-card-item.is-raised,
.student-exam-card.is-expanded,
.student-payment-card.is-expanded {
    box-shadow: var(--elev-2);
    translate: 0 -2px;
    border-color: var(--bd-dbe2ea);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    background: var(--bg-ffffff);
    z-index: 2;
}

/* Only a desktop pointer lifts them, same as every other card. */
@media (hover: hover) and (pointer: fine) {
    .student-card-item.is-raised:hover,
    .student-exam-card.is-expanded:hover,
    .student-payment-card.is-expanded:hover {
        box-shadow: var(--elev-2);
    }
}

@media (prefers-reduced-motion: reduce) {
    .student-card-item.is-raised,
    .student-exam-card.is-expanded,
    .student-payment-card.is-expanded {
        translate: none;
    }
}

/* ============================================================ */
/*  SETTINGS — STORAGE PANE                                     */
/*                                                              */
/*  Every other settings pane is a stack of raised frames, so   */
/*  the storage pane read as a flat slab next to them. Its      */
/*  summary becomes a raised frame and each table row a well    */
/*  inside it, matching Configuration's frames → groups.        */
/* ============================================================ */
.storage-overview {
    background: var(--surface-raised);
    border: 1px solid var(--bd-e2e8f0);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    box-shadow: var(--elev-1);
}

.storage-row {
    background: var(--surface-sunken);
    border-top-color: var(--well-edge-top);
    border-bottom-color: var(--well-edge-bottom);
    box-shadow: var(--well-shadow);
}

/* ============================================================ */
/*  MOBILE DRAWER — the page behind it moves                    */
/*                                                              */
/*  Opening the drawer nudges the page a little to the left so  */
/*  the drawer reads as pressing on top of it. Closing it (or   */
/*  Back) puts the page straight back.                          */
/* ============================================================ */
@media (max-width: 768px) {
    .view.active-view {
        transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
            opacity 0.2s ease;
        will-change: transform;
    }

    body.mobile-menu-open {
        overflow-x: hidden;
    }

    /* Push: the page drifts straight left with the drawer — horizontal
       only, no scaling, so nothing moves on the y axis. */
    body.mobile-menu-open .view.active-view {
        transform: translateX(-12%);
    }

    /* Admin only: its bar is a sibling of the views, so it has to be
       moved explicitly. In the student portal the bar lives INSIDE the
       view (index.html: view > header), so it already travels with the
       page — moving it again put the nav twice as far left as the
       content. */
    body.mobile-menu-open #global-app-header {
        transform: translateX(-12%);
    }

    /* The student header moves with its view, but keep the toggle's
       position fixed while its icon rotates just like the admin toggle. */
    body.mobile-menu-open #view-student.active-view .hamburger-toggle.rotated,
    body.mobile-menu-open #view-marks.active-view .hamburger-toggle.rotated {
        transform: translateX(12vw) rotate(180deg);
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .view.active-view {
        transition: opacity 0.2s ease;
    }

    body.mobile-menu-open .view.active-view,
    body.mobile-menu-open #global-app-header {
        transform: none;
    }

    body.mobile-menu-open #view-student.active-view .hamburger-toggle.rotated,
    body.mobile-menu-open #view-marks.active-view .hamburger-toggle.rotated {
        transform: rotate(180deg);
    }
}


/* ============================================================ */
/*  NOTICE CARDS — hover lift                                    */
/*                                                              */
/*  They deepened their shadow on hover but never moved, so they */
/*  read flat next to the exam/student/class cards. Same 2px     */
/*  lift, same desktop-only gate as everything else.             */
/* ============================================================ */
.notice-card {
    transition:
        box-shadow 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        margin-top 0.24s ease, border-radius 0.24s ease;
}

@media (hover: hover) and (pointer: fine) {
    .notice-card:hover {
        translate: 0 -2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .notice-card:hover {
        translate: none;
    }
}

/* ============================================================ */
/*  PROFILE DROPDOWN — identity block is for phones only         */
/*                                                              */
/*  On desktop the header already shows the avatar AND the name, */
/*  so printing them again above the theme row was a duplicate.  */
/*  On a phone the header keeps only the avatar, which is        */
/*  exactly why the block exists there.                          */
/* ============================================================ */
.user-menu-identity {
    display: none;
}

@media (max-width: 768px) {
    .user-menu-identity {
        display: flex;
    }
}


/* ============================================================ */
/*  DASHBOARD ACTIONS — real 3D, not a flat gradient chip        */
/*                                                              */
/*  The panel-header rule set its own drop shadow at id          */
/*  specificity, which replaced the button's inset edges — the   */
/*  button ended up a painted rectangle with no lit top or       */
/*  shaded bottom. These restate the full bevel at the same      */
/*  id level, so the button reads raised like every other        */
/*  primary action.                                              */
/* ============================================================ */
#view-dashboard .dashboard-panel .page-header > .dashboard-action-btn {
    box-shadow:
        inset 0 1px 0 var(--btn-solid-lip),
        inset 0 -1px 0 var(--btn-solid-shade),
        inset 0 -3px 6px -4px var(--btn-solid-shade),
        0 2px 0 var(--btn-solid-base),
        0 6px 14px -7px var(--btn-drop);
}

#view-dashboard .dashboard-panel .page-header > .dashboard-action-btn:hover {
    box-shadow:
        inset 0 1px 0 var(--btn-solid-lip),
        inset 0 -1px 0 var(--btn-solid-shade),
        inset 0 -3px 6px -4px var(--btn-solid-shade),
        0 2px 0 var(--btn-solid-base),
        0 10px 20px -8px var(--btn-drop);
}

#view-dashboard .dashboard-panel .page-header > .dashboard-action-btn:active {
    box-shadow:
        inset 0 2px 4px var(--btn-solid-shade),
        0 1px 0 var(--btn-solid-base);
}

/* ============================================================ */
/*  DETACHED NAV — 3D GLASS (dark)                              */
/*                                                              */
/*  Same slab treatment as light, but the lips invert: a thin    */
/*  top highlight and a shaded bottom edge, since a white lip    */
/*  on a dark surface just looks like a seam. The refraction     */
/*  and glass distortion above are untouched.                    */
/* ============================================================ */
html[data-theme="dark"] .app-header.scrolled {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        inset 0 -1px 0 rgba(0, 0, 0, 0.6),
        0 1px 0 rgba(255, 255, 255, 0.04),
        0 2px 0 -1px rgba(0, 0, 0, 0.5),
        0 10px 18px -10px rgba(0, 0, 0, 0.75),
        0 22px 46px -22px rgba(0, 0, 0, 0.8);
}

@media (min-width: 769px) {
    html[data-theme="dark"] .app-header.scrolled:hover {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.12),
            inset 0 -1px 0 rgba(0, 0, 0, 0.6),
            0 1px 0 rgba(255, 255, 255, 0.05),
            0 3px 0 -1px rgba(0, 0, 0, 0.55),
            0 16px 28px -12px rgba(0, 0, 0, 0.8),
            0 30px 60px -28px rgba(0, 0, 0, 0.85);
    }
}

/* ============================================================ */
/*  STUDENT PORTAL — 3D CARD SURFACES                           */
/*                                                              */
/*  The admin dashboard reads as stacked physical cards (lit top */
/*  lip, shaded bottom, two-step drop). Student cards were a flat */
/*  rectangle with a 1px shadow, so the two portals felt like     */
/*  different products. Same recipe here, at stable elevation so */
/*  the hover/pick lift still owns the movement.                 */
/* ============================================================ */
.student-exam-card,
.student-payment-card,
.student-card-item,
#student-notice-list .student-notice-card {
    transition:
        box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        translate 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.24s ease,
        background 0.24s ease;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(15, 23, 42, 0.05),
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 6px 14px -9px rgba(15, 23, 42, 0.15);
}

@media (hover: hover) and (pointer: fine) {
    .student-exam-card:hover,
    .student-payment-card:hover,
    .student-card-item:hover,
    #student-notice-list .student-notice-card:hover {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            inset 0 -1px 0 rgba(15, 23, 42, 0.06),
            0 2px 4px rgba(15, 23, 42, 0.07),
            0 12px 24px -14px rgba(15, 23, 42, 0.19);
    }
}

/* Held open / picked on touch — same raised surface, no hover needed. */
.student-exam-card.is-expanded,
.student-payment-card.is-expanded,
.student-card-item.is-raised,
#student-notice-list .student-notice-card.is-tap-raised {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -1px 0 rgba(15, 23, 42, 0.06),
        0 2px 4px rgba(15, 23, 42, 0.07),
        0 12px 24px -14px rgba(15, 23, 42, 0.19);
}

/* Pressing a card lifts it, exactly like the admin cards do — student
   cards used to just open with no lift at all, so the same gesture read
   as two different products. */
.student-exam-card:active,
.student-payment-card:active,
.student-card-item:active,
#student-notice-list .student-notice-card:active {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -1px 0 rgba(15, 23, 42, 0.06),
        0 2px 4px rgba(15, 23, 42, 0.07),
        0 12px 24px -14px rgba(15, 23, 42, 0.19);
    translate: 0 -2px;
}

html[data-theme="dark"] .student-exam-card,
html[data-theme="dark"] .student-payment-card,
html[data-theme="dark"] .student-card-item,
html[data-theme="dark"] #student-notice-list .student-notice-card {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        inset 0 -1px 0 rgba(0, 0, 0, 0.32),
        var(--elev-1);
}

@media (hover: hover) and (pointer: fine) {
    html[data-theme="dark"] .student-exam-card:hover,
    html[data-theme="dark"] .student-payment-card:hover,
    html[data-theme="dark"] .student-card-item:hover,
    html[data-theme="dark"] #student-notice-list .student-notice-card:hover {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.1),
            inset 0 -1px 0 rgba(0, 0, 0, 0.36),
            var(--elev-2);
    }
}

html[data-theme="dark"] .student-exam-card.is-expanded,
html[data-theme="dark"] .student-payment-card.is-expanded,
html[data-theme="dark"] .student-card-item.is-raised,
html[data-theme="dark"] #student-notice-list .student-notice-card.is-tap-raised {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.36),
        var(--elev-2);
}

html[data-theme="dark"] .student-exam-card:active,
html[data-theme="dark"] .student-payment-card:active,
html[data-theme="dark"] .student-card-item:active,
html[data-theme="dark"] #student-notice-list .student-notice-card:active {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.36),
        var(--elev-2);
    translate: 0 -2px;
}


/* ============================================================ */
/*  EXAM FILTER BAR — 3D (admin + student)                       */
/*                                                              */
/*  A flat white strip with a hairline border sat on top of 3D   */
/*  cards and killed the depth. It is a raised tray now: lit top */
/*  lip, shaded bottom, contact shadow, and its controls are     */
/*  dimples inside it.                                           */
/* ============================================================ */
.exam-filters,
.student-exam-filters {
    border-color: var(--card-edge-top);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.07),
        var(--elev-1);
}

html[data-theme="dark"] .exam-filters,
html[data-theme="dark"] .student-exam-filters {
    border-color: var(--card-edge-top);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.32),
        var(--elev-1);
}

/* ============================================================ */
/*  CACHED-DATA HINT                                             */
/*  Shown above notice / payment lists that come from storage.   */
/* ============================================================ */
.cache-mode-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.7rem;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    border: 1px dashed rgba(217, 119, 6, 0.45);
    background: rgba(245, 158, 11, 0.12);
    color: #8a5a00;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
}

.cache-mode-hint i {
    font-size: 0.85rem;
    color: #b45309;
    flex: 0 0 auto;
}

html[data-theme="dark"] .cache-mode-hint {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.14);
    color: #f0c67a;
}

html[data-theme="dark"] .cache-mode-hint i {
    color: #f0c67a;
}


/* ============================================================ */
/*  DROPDOWN MENUS — 3D PANELS                                   */
/*                                                              */
/*  The filter tray and its wrapper are raised; the menu that     */
/*  drops out of them should read as a card lifted off the page, */
/*  not a flat sheet. The control inside the tray stays flat.    */
/* ============================================================ */
.custom-select-menu,
.user-menu-dropdown,
.mobile-profile-dropdown {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.06),
        0 2px 4px rgba(15, 23, 42, 0.08),
        0 16px 34px -16px rgba(15, 23, 42, 0.34);
}

html[data-theme="dark"] .custom-select-menu,
html[data-theme="dark"] .user-menu-dropdown,
html[data-theme="dark"] .mobile-profile-dropdown {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.55),
        0 3px 6px rgba(0, 0, 0, 0.5),
        0 18px 38px -18px rgba(0, 0, 0, 0.9);
}

/* ============================================================ */
/*  FRAME SURFACES — raised content frames and tables            */
/* ============================================================ */
.analytics-summary-card,
.payment-summary-card,
.config-group-card,
.reports-filters,
.student-selector-card,
.settings-frame,
.marks-table,
.class-table,
.student-table {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.06),
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 12px 26px -16px rgba(15, 23, 42, 0.28);
}

html[data-theme="dark"] .analytics-summary-card,
html[data-theme="dark"] .payment-summary-card,
html[data-theme="dark"] .config-group-card,
html[data-theme="dark"] .reports-filters,
html[data-theme="dark"] .student-selector-card,
html[data-theme="dark"] .settings-frame,
html[data-theme="dark"] .marks-table,
html[data-theme="dark"] .class-table,
html[data-theme="dark"] .student-table {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        inset 0 -1px 0 rgba(0, 0, 0, 0.55),
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 14px 30px -18px rgba(0, 0, 0, 0.85);
}


/* ============================================================ */
/*  TOUCH-RAISED EXAM CARDS                                      */
/*                                                              */
/*  No hover on touch, so a tapped non-expandable exam card      */
/*  holds the raised surface until the student taps elsewhere.    */
/*  Values mirror .is-expanded so both paths look identical.     */
/* ============================================================ */
@media (hover: none) and (pointer: coarse) {
    .student-exam-card.is-tap-raised {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset 0 -1px 0 rgba(15, 23, 42, 0.08),
            0 2px 4px rgba(15, 23, 42, 0.1),
            0 18px 34px -14px rgba(15, 23, 42, 0.34);
        translate: 0 -2px;
        border-color: var(--bd-dbe2ea);
    }

    html[data-theme="dark"] .student-exam-card.is-tap-raised {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.1),
            inset 0 -1px 0 rgba(0, 0, 0, 0.55),
            0 3px 6px rgba(0, 0, 0, 0.55),
            0 18px 34px -16px rgba(0, 0, 0, 0.9);
        translate: 0 -2px;
    }
}


/* ============================================================ */
/*  ANALYTICS DEPTH — the cards lift, not their wrapper          */
/*                                                              */
/*  The plates (filter bar, sections) used to carry the drop     */
/*  shadow while the metric and summary cards inside them were   */
/*  flat, so the wrapper read as the raised thing and its cards  */
/*  looked pressed into it. The plates are plain sheets now and  */
/*  every card carries the lift instead.                         */
/* ============================================================ */
.analytics-filters,
.analytics-section {
    box-shadow: none;
}

.analytics-metric,
.analytics-summary-card,
.analytics-highlight {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.06),
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 8px 18px -14px rgba(15, 23, 42, 0.24);
}

html[data-theme="dark"] .analytics-metric,
html[data-theme="dark"] .analytics-summary-card,
html[data-theme="dark"] .analytics-highlight {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(0, 0, 0, 0.45),
        0 10px 22px -16px rgba(0, 0, 0, 0.8);
}


/* ============================================================ */
/*  MOBILE PROFILE DROPDOWN — smoother open / close              */
/*                                                              */
/*  scaleY squashed the text while it moved and the overshoot    */
/*  curve snapped at the end. It slides and fades on one soft    */
/*  curve now, and stays out of the hit-testing layer when shut. */
/* ============================================================ */
.mobile-profile-dropdown {
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
        max-height 0.52s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.52s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.34s ease;
    will-change: transform, opacity, max-height;
}

.mobile-profile-dropdown.show {
    max-height: 240px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .mobile-profile-dropdown {
        transition: max-height 0.01s linear, opacity 0.01s linear;
        transform: none;
    }
    .mobile-profile-dropdown.show { transform: none; }
    .notice-card,
    #dashboard-panel-notices .notice-card,
    .student-exam-card,
    .student-payment-card,
    .student-card-item,
    #student-notice-list .student-notice-card {
        transition: none;
    }
}

/* Sign-in surfaces use the same lit edge, shaded bottom and contact
   shadow as every portal card — no extruded slab underneath, which is
   what made the bottom edge read thick and pixelated. */
.login-card {
    background: linear-gradient(145deg, var(--surface-raised), var(--bg-ffffff));
    border: 1px solid var(--card-edge-bottom);
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    box-shadow: var(--elev-2);
}

html[data-theme="dark"] .login-card {
    background: linear-gradient(145deg, #2d2d2d, #222222);
    border-color: #1a1a1a;
    border-top-color: var(--card-edge-top);
    border-bottom-color: var(--card-edge-bottom);
    box-shadow: var(--elev-2);
}

#login-form .input-field {
    color: var(--fg-1e293b);
    caret-color: var(--fg-1e293b);
}



html:not([data-theme="dark"]) #login-form > .btn-primary {
    border: 1px solid rgba(15, 23, 42, 0.18);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        inset 0 -1px 0 rgba(0, 0, 0, 0.28),
        0 1px 2px rgba(15, 23, 42, 0.16),
        0 5px 12px -7px rgba(15, 23, 42, 0.42);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    html:not([data-theme="dark"]) #login-form > .btn-primary:hover {
        transform: translateY(-1px);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.34),
            inset 0 -1px 0 rgba(0, 0, 0, 0.28),
            0 2px 4px rgba(15, 23, 42, 0.18),
            0 9px 18px -9px rgba(15, 23, 42, 0.48);
    }
}

html:not([data-theme="dark"]) #login-form > .btn-primary:active {
    transform: translateY(0);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.32),
        inset 0 -1px 0 rgba(255, 255, 255, 0.12);
}

/* ============================================================ */
/*  COMBINED (MCQ + CQ) EXAMS — config, rows, segment colours    */
/* ============================================================ */
.exam-marks-config[hidden],
.exam-marks-config [hidden] {
    display: none !important;
}
.exam-segment-editor,
.exam-pass-editor {
    padding: 0.85rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    margin: 0.15rem 0 0.9rem;
}
.exam-segment-row {
    grid-template-columns: minmax(64px, 92px) minmax(0, 1fr);
    gap: 0.6rem;
}
.exam-segment-row .input-field {
    width: 100%;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.exam-segment-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--fg-334155);
}
.exam-segment-editor .fee-breakdown-total {
    margin-top: 0.6rem;
}
.exam-pass-mode {
    display: grid;
    gap: 0.5rem;
}
.exam-pass-option {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 9px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.exam-pass-option:hover {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-f8fafc);
}
.exam-pass-option.is-selected {
    border-color: var(--bd-94a3b8);
    background: var(--bg-f8fafc);
}
.exam-pass-option input {
    margin-top: 0.2rem;
    accent-color: var(--fg-111827);
}
.exam-pass-option-body {
    display: grid;
    gap: 0.15rem;
}
.exam-pass-option-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fg-1e293b);
}
.exam-pass-option-desc {
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--fg-64748b);
}
.exam-pass-individual .exam-segment-row {
    margin-top: 0.5rem;
}

/* ---- Marksheet / marks table: segmented columns ---- */
.marks-table-combined th:nth-child(n + 3),
.marks-table-combined td:nth-child(n + 3) {
    width: 1%;
    text-align: center;
    white-space: nowrap;
}
.marks-table .mark-seg {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
/* An unevaluated segment shows the same dash as any other exam row:
   inherited ink, not the muted grey the old rule used. */
.marks-table .mark-seg.is-empty {
    color: var(--fg-94a3b8);
    font-weight: 500;
}

/* One ink for "nothing to show" in BOTH table shapes: a plain exam's
   "Abst." and a combined exam's segment dashes + "Abst." total must read
   identically — never heavier in one and lighter in the other. */
.marks-table td.mark-absent,
.marks-table .mark-total.mark-absent,
.marks-table .mark-pct.mark-absent {
    color: var(--fg-94a3b8);
    font-weight: 600;
}

/* Termination is a fail verdict: it stays red in the total and percentage. */
.marks-table td.mark-terminated,
.marks-table .mark-total.mark-terminated,
.marks-table .mark-pct.mark-terminated {
    color: var(--fg-dc2626);
    font-weight: 700;
}
/* Edit mode: a terminated row stays editable, but is visibly flagged so
   the admin knows saving a change will re-grade it. */
.marks-table tr.marks-row-terminated td {
    background: rgba(220, 38, 38, 0.035);
}
.marks-table tr.marks-row-terminated td:nth-child(2) strong::after {
    content: 'Term.';
    margin-left: 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--fg-dc2626);
    vertical-align: middle;
}
.marks-table .mark-total {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--fg-1e293b);
}
.marks-table .mark-total.mark-fail,
.marks-table .mark-pct.mark-fail {
    color: var(--fg-dc2626);
}
.marks-table .mark-pct {
    font-variant-numeric: tabular-nums;
}
.marks-table-edit .marks-edit-seg-cell .mark-input {
    width: 68px;
    min-width: 68px;
}
.marks-seg-note {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin: 0 0 0.85rem;
    padding: 0.6rem 0.75rem;
    border: 1px dashed var(--bd-cbd5e1);
    border-radius: 9px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--fg-64748b);
}
.marks-seg-note i {
    margin-top: 0.15rem;
    color: var(--fg-94a3b8);
}

/* ---- Student exam card: segmented result stack ---- */
.student-mark-stack {
    display: grid;
    gap: 0.2rem;
    justify-items: end;
}
.student-mark-seg {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--fg-64748b);
    white-space: nowrap;
}
.student-mark-seg .seg-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--fg-94a3b8);
}
.student-mark-seg strong {
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}
.student-mark-total-row {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.student-mark-total-row .total-marks {
    color: var(--fg-64748b);
}

/* ---- Analytics: one row per segment ---- */
.analytics-seg-row td.col-exam .seg-pill {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--fg-64748b);
}
.student-mark-seg strong.is-empty {
    color: var(--fg-94a3b8);
    font-weight: 500;
}

/* ============================================================ */
/*  MARKSHEET — horizontal scroll instead of squeezing           */
/*                                                              */
/*  Under the mobile breakpoint the table keeps its natural      */
/*  column widths and the wrapper is what scrolls. The name      */
/*  column is shrink-to-fit, so the marks sit immediately after  */
/*  the name instead of being pushed aside by empty space.       */
/* ============================================================ */
.marks-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    scrollbar-width: thin;
}

@media (max-width: 768px) {
    .marks-table-scroll .marks-table {
        width: max-content;
        min-width: 100%;
    }

    .marks-table-scroll .marks-table th:nth-child(2),
    .marks-table-scroll .marks-table td:nth-child(2) {
        width: 1%;
        white-space: nowrap;
    }
}

/* ============================================================ */
/*  MARKSHEET — a segment that has no results yet                */
/*  One merged cell spans the column's body height, text kept    */
/*  horizontal, so the column reads "not evaluated" instead of   */
/*  a strip of em dashes.                                        */
/* ============================================================ */
/* A merged CQ cell with no results yet: the label runs vertically so
   the column stays as narrow as a single mark. Short merges fall back
   to "N/E" (see renderMarksTable). */
.marks-table .mark-seg-vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    width: 1.9rem;
    padding: 0.4rem 0.25rem;
    letter-spacing: 0.02em;
}

.marks-table .mark-seg-pending {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    font-style: italic;
    font-weight: 500;
    color: var(--fg-94a3b8);
}

/* ============================================================ */
/*  EXAM MODAL — the total decides pass, segments only colour   */
/* ============================================================ */
.exam-pass-note {
    margin: 0.45rem 0 0;
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--fg-64748b);
}
.exam-pass-note strong {
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}

/* ============================================================ */
/*  MARKS SAVE CHECK MODALS — partial rows + blank students      */
/* ============================================================ */
.marks-check-box {
    max-width: 540px;
}
.marks-check-lead {
    margin: 0.35rem 0 0.85rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--fg-64748b);
}
.marks-check-list {
    display: grid;
    gap: 0.35rem;
    max-height: 38vh;
    overflow-y: auto;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.85rem;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    scrollbar-width: thin;
}
.marks-check-list:empty {
    display: none;
}
.marks-check-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    font-size: 0.86rem;
    line-height: 1.4;
}
.marks-check-name {
    font-weight: 600;
    color: var(--fg-1e293b);
}
.marks-check-missing {
    color: var(--fg-64748b);
}
.marks-check-missing strong,
.marks-check-red {
    color: var(--fg-dc2626);
    font-weight: 700;
}
.marks-check-choices {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.marks-check-choice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.marks-check-choice:hover {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-f8fafc);
}
.marks-check-choice input {
    margin-top: 0.2rem;
    accent-color: var(--fg-111827);
    flex-shrink: 0;
}
/* Direct child only — an inner span (the highlighted "0" / "Abst.")
   must stay inline instead of becoming its own grid row. */
.marks-check-choice > span {
    display: grid;
    gap: 0.15rem;
}
.marks-check-choice span.marks-check-red {
    display: inline;
}
.marks-check-choice strong {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fg-1e293b);
}
.marks-check-choice small {
    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--fg-64748b);
}
.marks-check-choice-single {
    margin-bottom: 1rem;
}

/* ---- "not evaluated" text wherever a segment has no result ---- */
.mark-seg-pending,
.mark-pending-text {
    color: var(--fg-94a3b8);
    font-style: italic;
    font-weight: 600;
    white-space: nowrap;
}

/* ========================================================================== */
/*  DESIGN PASS                                                               */
/*  1. Semantic text roles (contrast-safe muted ink)                          */
/*  2. Micro-labels (uppercase, tracked)                                     */
/*  3. Liquid glass on the install button (small-radius variant)              */
/*  4. Analytics: metrics, insights, score distribution                       */
/*  5. Analytics tables as cards on phones                                    */
/* ========================================================================== */

/* ---- 1. SEMANTIC TEXT ROLES ---- */
:root {
    --text-strong: var(--fg-1e293b);
    --text-body: var(--fg-334155);
    --text-muted: #5f7086;   /* 5.0:1 on white — the old #94a3b8 was 2.6:1 */
    --text-subtle: #6b7c90;  /* 4.5:1 on white */
}
html[data-theme="dark"] {
    --text-muted: #9fabb9;
    --text-subtle: #93a0ae;
}

/* ---- 2. MICRO-LABELS ---- */
.analytics-card-label {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.analytics-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-strong);
}
.analytics-section-title i { color: var(--text-muted); }
.analytics-filter-label {
    text-transform: none;
    letter-spacing: 0.01em;
    font-weight: 600;
    color: var(--text-muted);
}
.exam-list-table thead th {
    text-transform: none;
    letter-spacing: 0.01em;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.analytics-empty { color: var(--text-muted); }

/* ---- 3. INSTALL BADGE — the nav pill's exact refraction + slab lighting ---- */
#install-app-btn,
#install-app-btn.btn-outline,
#install-app-btn.expanded {
    background: rgba(var(--surface-rgb), 0.6) !important;
    backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);
    -webkit-backdrop-filter: blur(1px) url(#glass-distortion) blur(3px) saturate(180%) contrast(106%);

    /* The nav's slab: lit top lip, shaded bottom lip, a crisp plinth line
       where it meets the page, then a soft drop below. */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(15, 23, 42, 0.09),
        0 1px 0 rgba(255, 255, 255, 0.65),
        0 2px 0 -1px rgba(15, 23, 42, 0.1),
        0 10px 16px -8px rgba(15, 23, 42, 0.26),
        0 22px 46px -22px rgba(15, 23, 42, 0.22);
}
@supports not (backdrop-filter: url(#glass-distortion)) {
    #install-app-btn,
    #install-app-btn.btn-outline {
        backdrop-filter: blur(20px) saturate(180%) contrast(108%);
        -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(108%);
    }
}
/* The nav's rim and slab are lit for a light bar. On the dark page the
   same values read as a bright white outline around the badge, so the
   badge keeps its shape and depth but derives them from the dark theme. */
html[data-theme="dark"] #install-app-btn,
html[data-theme="dark"] #install-app-btn.btn-outline,
html[data-theme="dark"] #install-app-btn.expanded {
    border-color: rgba(255, 255, 255, 0.10) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5),
        0 1px 0 rgba(255, 255, 255, 0.05),
        0 2px 0 -1px rgba(0, 0, 0, 0.5),
        0 10px 16px -8px rgba(0, 0, 0, 0.6),
        0 22px 46px -22px rgba(0, 0, 0, 0.55);
}

/* ---- 3b. LOGIN — brand face on the title ---- */
/* The sign-in card is the only place the brand face never reached —
   body copy stays on the system stack for Bangla/Latin legibility. */
body.login-page .login-title {
    font-family: 'League Spartan', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.01em;
}

/* ---- 4. ANALYTICS METRICS ---- */
.analytics-metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 0.55rem;
}
.analytics-metric {
    background: var(--bg-ffffff);
    border: 1px solid var(--bd-eef2f6);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
}
.analytics-metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}
.analytics-metric-value {
    font-size: 1.18rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.analytics-metric-value i { font-size: 0.85rem; }
.analytics-metric-hint {
    font-size: 0.7rem;
    line-height: 1.35;
    color: var(--text-subtle);
}
.analytics-metric.is-up .analytics-metric-value,
.analytics-metric.is-up .analytics-metric-value i { color: var(--fg-15803d); }
.analytics-metric.is-down .analytics-metric-value,
.analytics-metric.is-down .analytics-metric-value i { color: var(--fg-b91c1c); }

/* ---- 4b. INSIGHTS ---- */
.analytics-glossary {
    margin: 0.75rem 0 0;
    padding-top: 0.65rem;
    border-top: 1px dashed var(--bd-e2e8f0);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.analytics-glossary p {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.analytics-glossary strong { color: var(--text-strong); }
.analytics-insights {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.analytics-insight {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-body);
}
.analytics-insight i {
    font-size: 0.8rem;
    margin-top: 0.22rem;
    flex-shrink: 0;
    color: var(--fg-2563eb);
}
.analytics-insight.is-good i  { color: var(--fg-16a34a); }
.analytics-insight.is-warn i  { color: #b45309; }
.analytics-insight strong { color: var(--text-strong); font-weight: 600; }

/* ---- 4c. SCORE DISTRIBUTION — one horizontal bar per mark range ---- */
.analytics-dist {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
}
.analytics-dist-row {
    display: grid;
    grid-template-columns: 4.6rem minmax(0, 1fr) 4.2rem;
    align-items: center;
    gap: 0.6rem;
}
.analytics-dist-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.analytics-dist-track {
    width: 100%;
    height: 11px;
    background: var(--bg-f8fafc);
    border-radius: 999px;
    overflow: hidden;
}
.analytics-dist-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}
.analytics-dist-row.is-empty .analytics-dist-bar {
    width: 3px !important;
    background: var(--bd-eef2f6) !important;
}
.analytics-dist-value {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.analytics-dist-share {
    margin-left: 0.25rem;
    font-weight: 500;
    color: var(--text-subtle);
}

/* Class-average series in the trend chart */
.legend-dashed-slate {
    height: 0;
    border-top: 2px dashed var(--fg-94a3b8);
    background: transparent;
    border-radius: 0;
}
.legend-dashed-violet {
    height: 0;
    border-top: 2px dashed #7c3aed;
    background: transparent;
    border-radius: 0;
}

/* ---- 5. ANALYTICS TABLES AS CARDS ON PHONES ---- */
@media (max-width: 640px) {
    .exam-list-table-wrap {
        overflow-x: visible;
        padding: 0.15rem 0;
    }
    .exam-list-table,
    .exam-list-table tbody,
    .exam-list-table tr,
    .exam-list-table td {
        display: block;
        width: auto;
    }
    .exam-list-table thead { display: none; }
    /* Three tight lines per exam instead of six stacked ones:
       date · merit · %   /   title   /   obt · high · total. The title
       gets a full line of its own so a long paper name stays readable. */
    .exam-list-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 0.5rem;
        row-gap: 0.06rem;
        border: 1px solid var(--bd-e2e8f0);
        border-radius: 10px;
        background: var(--bg-ffffff);
        padding: 0.42rem 0.6rem;
        margin-bottom: 0.35rem;
    }
    /* Zero-height flex item: forces the stat strip onto its own line. */
    .exam-list-table tbody tr::before {
        content: '';
        order: 6;
        flex: 0 0 100%;
        height: 0;
    }
    /* The same trick after the first line: the title starts a new row. */
    .exam-list-table tbody tr::after {
        content: '';
        order: 4;
        flex: 0 0 100%;
        height: 0;
    }
    .exam-list-table tbody tr:last-child { margin-bottom: 0; }
    .exam-list-table tbody tr:hover { background: var(--bg-ffffff); }
    .exam-list-table tbody td {
        display: inline-flex;
        align-items: baseline;
        gap: 0.2rem;
        border: none;
        padding: 0;
        text-align: left;
        white-space: nowrap;
        font-size: 0.74rem;
        width: auto;
        min-width: 0;
    }
    /* The desktop columns are sized with width:1% so they hug their text;
       inside flex lines that collapsed them to nothing. */
    .exam-list-table tbody td.col-date,
    .exam-list-table tbody td.col-merit,
    .exam-list-table tbody td.col-obt,
    .exam-list-table tbody td.col-high,
    .exam-list-table tbody td.col-total,
    .exam-list-table tbody td.col-pct { width: auto; }
    .exam-list-table .col-date { order: 1; font-size: 0.66rem; }
    /* Merit shares the first line with the date and the percentage. */
    .exam-list-table .col-merit { order: 2; font-size: 0.66rem; }
    .exam-list-table .col-exam {
        order: 5;
        display: block;
        /* Alone on its line, the title has the whole width — so it wraps
           instead of being cut off with an ellipsis. */
        flex: 1 1 100%;
        font-weight: 600;
        line-height: 1.3;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }
    .exam-list-table .col-date,
    .exam-list-table .col-merit,
    .exam-list-table .col-pct,
    .exam-list-table .col-obt,
    .exam-list-table .col-high,
    .exam-list-table .col-total { flex: 0 0 auto; }
    .exam-list-table .col-pct {
        order: 3;
        margin-left: auto;
        font-size: 0.95rem;
        font-weight: 800;
        letter-spacing: -0.01em;
    }
    .exam-list-table .col-obt { order: 7; }
    .exam-list-table .col-high { order: 8; color: var(--text-muted); }
    .exam-list-table .col-total { order: 9; margin-left: auto; color: var(--text-muted); }
    /* Short inline labels keep the stat strip readable without a header;
       the full words would not fit three-across on a phone. */
    .exam-list-table .col-obt::before,
    .exam-list-table .col-high::before,
    .exam-list-table .col-total::before {
        font-size: 0.6rem;
        font-weight: 700;
        color: var(--text-muted);
        letter-spacing: 0.03em;
        text-transform: uppercase;
        flex-shrink: 0;
    }
    .exam-list-table .col-obt::before { content: 'Obt'; }
    .exam-list-table .col-high::before { content: 'High'; }
    .exam-list-table .col-total::before { content: 'Total'; }
    /* Clip rather than spill across the next value. */
    .exam-list-table .col-obt,
    .exam-list-table .col-high,
    .exam-list-table .col-total { overflow: hidden; }
}


/* ---- 6. TEACHER PROFILE ENTRY ------------------------------ */
/* Everyone else opens Settings; a teacher's only pane is
   Change Password, so the menu says exactly that. */
.profile-entry-icon-teacher,
.profile-entry-label-teacher { display: none; }
body.role-teacher .profile-entry-icon-admin,
body.role-teacher .profile-entry-label-admin { display: none; }
body.role-teacher .profile-entry-icon-teacher,
body.role-teacher .profile-entry-label-teacher { display: inline-block; }


/* ============================================================ */
/*  STUDENT REPORT MODAL (Students tab)                          */
/* ============================================================ */
/* The card opens this student's report now, so its header row reads
   as a clickable strip rather than a static tile. The report that
   unfolds underneath is a reading surface — dial, filters, figures —
   so it keeps the plain arrow, and only its own controls show a hand. */
.student-card-item { cursor: default; }

/* ============================================================ */
/*  STUDENT REPORT — inline expansion inside the student card    */
/* ============================================================ */
.student-card-item > .student-card-avatar,
.student-card-item > .student-card-info,
.student-card-item > .student-card-mobile { cursor: pointer; }
.student-stats-inline { cursor: default; }

/* The card keeps wrapping while the panel is animating out, so the
   report does not jump into the header row on its last frames. */
.student-card-item.is-stats-open,
.student-card-item.is-stats-closing {
    flex-wrap: wrap;
}
/* Wrapping is only there to give the report its own line. A long phone
   number yields instead of pushing the ⋮ button down to that line. */
.student-card-item.is-stats-open > .student-card-mobile,
.student-card-item.is-stats-closing > .student-card-mobile {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Height is driven by JS: 0 on open, the measured content height while
   the report loads, then auto. Overflow hides whatever sits outside. */
.student-stats-inline {
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    order: 9;
    height: 0;
    overflow: hidden;
}

.student-stats-inner {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--bd-e2e8f0);
    animation: studentStatsOpen 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---- Timeframe bar ---- */
.student-stats-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
    margin-bottom: 0.8rem;
}
.student-stats-filters-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.student-stats-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.student-stats-presets .preset-btn {
    padding: 0.18rem 0.5rem;
    font-size: 0.7rem;
}
.student-stats-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}
.student-stats-range[hidden] { display: none; }
.student-stats-range .input-field {
    height: 32px;
    max-width: 148px;
    font-size: 0.78rem;
}
.student-stats-range-sep {
    font-size: 0.72rem;
    color: var(--text-subtle);
}

/* ---- Counts line ---- */
.student-stats-tally {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.9rem;
    margin-bottom: 0.7rem;
    font-size: 0.72rem;
    color: var(--text-subtle);
}
.student-stats-tally strong {
    font-weight: 700;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

/* ---- Plain-words notes under the rings ---- */
.student-stats-glossary {
    margin: 0;
    padding: 0.6rem 0.7rem;
    border-radius: 10px;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-f1f5f9);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.student-stats-glossary p {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.student-stats-glossary strong { color: var(--text-strong); }

.student-stats-empty {
    padding: 0.6rem 0;
}

@keyframes studentStatsOpen {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

.student-report {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* ---- Stat rings ---- */
/* The three dials share one flat row on the report's own surface — no
   per-ring card, so the numbers read as one line, not three boxes. */
.student-report-rings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    align-items: center;
}

.student-ring {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
    min-width: 0;
    text-align: center;
}

.student-ring-dial {
    position: relative;
    width: 100%;
    max-width: 96px;
    aspect-ratio: 1;
}
.student-ring-svg {
    width: 100%;
    height: 100%;
    display: block;
    transform: rotate(-90deg);
}
.student-ring-track {
    fill: none;
    stroke: var(--bd-e2e8f0);
    stroke-width: 9;
}
.student-ring-progress {
    fill: none;
    stroke: #2563eb;
    stroke-width: 9;
    stroke-linecap: round;
}
.student-ring.is-good .student-ring-progress { stroke: var(--bg-16a34a); }
.student-ring.is-warn .student-ring-progress { stroke: #f59e0b; }
.student-ring.is-bad  .student-ring-progress { stroke: var(--bg-dc2626); }

.student-ring-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
.student-ring-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1.25;
}
.student-ring-hint {
    font-size: 0.68rem;
    line-height: 1.25;
    color: var(--text-subtle);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Trend ---- */
.student-trend-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}
.student-trend-dot {
    stroke: var(--bg-ffffff);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
    animation: studentDotPop 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.student-trend-dot.is-good { fill: var(--bg-16a34a); }
.student-trend-dot.is-warn { fill: #f59e0b; }
.student-trend-dot.is-bad  { fill: var(--bg-dc2626); }
.student-trend-dot.is-absent { fill: var(--fg-94a3b8); }
.student-trend-dot.is-terminated { fill: var(--bg-dc2626); }

@keyframes studentDotPop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.student-trend-foot {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.1rem;
    font-size: 0.68rem;
    color: var(--text-subtle);
}

.student-trend-delta {
    margin-left: auto;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-eef2f6);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.student-trend-delta.is-up   { color: var(--fg-15803d); }
.student-trend-delta.is-down { color: var(--fg-b91c1c); }

/* ---- Sections ---- */
.student-stats-section { margin-top: 0; }
.student-stats-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.student-stats-subject {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 3.2rem;
    align-items: center;
    gap: 0.3rem 0.6rem;
    margin-bottom: 0.55rem;
}
.student-stats-subject:last-child { margin-bottom: 0; }
.student-stats-subject-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.student-stats-subject-value {
    font-size: 0.78rem;
    font-weight: 700;
    text-align: right;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
.student-stats-subject-track {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-f1f5f9);
    overflow: hidden;
}
.student-stats-subject-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--bg-2563eb);
    transition: width 0.45s ease;
}

.student-stats-exams {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.student-stats-exam-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-f1f5f9);
}
.student-stats-exam-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.student-stats-exam-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.student-stats-exam-sub {
    font-size: 0.7rem;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.student-stats-exam-score {
    flex-shrink: 0;
    font-size: 0.94rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-strong);
}
.student-stats-exam-score.is-good { color: var(--fg-15803d); }
.student-stats-exam-score.is-warn { color: #b45309; }
.student-stats-exam-score.is-bad  { color: var(--fg-b91c1c); }
.student-stats-exam-score.is-muted { color: var(--text-subtle); font-weight: 600; }
.student-stats-exam-score-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
}
.student-stats-exam-split {
    font-size: 0.66rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-subtle);
}
/* Marks read the same way on every exam row: mark / total, then the
   percentage, both coloured by the verdict. */
.student-stats-exam-marks {
    font-size: 0.74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-strong);
    white-space: nowrap;
}
.student-stats-exam-marks .is-good { color: var(--fg-16a34a); }
.student-stats-exam-marks .is-bad  { color: var(--fg-dc2626); }
.student-stats-exam-marks .is-muted,
.student-stats-exam-marks.is-muted {
    color: var(--text-subtle);
    font-weight: 600;
}
.student-stats-marks-of {
    color: var(--text-subtle);
    font-weight: 600;
}
.student-stats-seg-op {
    color: inherit;
    font-weight: 500;
    margin: 0 1px;
}
/* The merit chip sits to the left of every exam name */
.student-stats-exam-merit {
    flex: 0 0 auto;
    min-width: 2rem;
    text-align: center;
    padding: 0.1rem 0.34rem;
    border-radius: 6px;
    background: var(--bg-eef2ff, #eef2ff);
    color: var(--fg-2563eb);
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.student-stats-exam-merit.is-blank {
    background: transparent;
    color: var(--text-subtle);
    font-weight: 600;
}
/* Rank #1 matches the gold of a topped exam card, in both themes. */
.student-stats-exam-merit.is-top {
    background: #f1dc94;
    color: #6b500e;
    border: 1px solid rgba(184, 146, 40, 0.38);
    box-shadow: none;
}
html[data-theme="dark"] .student-stats-exam-merit.is-top {
    background: #d9b646;
    color: #1a1405;
    border-color: rgba(212, 175, 55, 0.45);
}
.student-stats-count {
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--bg-f1f5f9);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
}

.student-stats-note {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-subtle);
}

/* ---- Loader ---- */
.student-stats-skeleton-rings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.85rem;
}
.student-stats-skeleton-ring {
    width: 100%;
    max-width: 84px;
    aspect-ratio: 1;
    border-radius: 50%;
    margin: 0.55rem auto;
}
.student-stats-skeleton-line {
    display: block;
    height: 13px;
    border-radius: 6px;
    margin-bottom: 0.55rem;
}
.student-stats-skeleton-line.short { width: 62%; }

/* The card avatar and menu are absolutely placed inside the card at
   phone widths; once the card grows an inline report they must stay
   pinned to the header row instead of centring on the whole panel. */
@media (max-width: 640px) {
    .student-card-item.is-stats-open .student-stats-inline,
    .student-card-item.is-stats-closing .student-stats-inline {
        margin-left: calc(-1 * (0.85rem + 38px + 0.55rem));
        margin-right: -2.4rem;
    }
    .student-card-item.is-stats-open .student-stats-inner,
    .student-card-item.is-stats-closing .student-stats-inner {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
    .student-report-rings { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .student-ring-dial { max-width: 74px; }
}

@media (prefers-reduced-motion: reduce) {
    .student-stats-inner,
    .student-trend-dot,
    .student-card-avatar,
    .student-card-actions {
        animation: none;
        transition: none;
    }
}



/* ============================================================ */
/*  MARKSHEET — exam analysis strip under the toolbar            */
/* ============================================================ */
.marks-analysis {
    margin-bottom: 1rem;
}
.marks-analysis-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.7rem 1rem;
}

/* ---- One chart: present / absent, pass / fail and the score bands are
   all read off the same dial, with the legend beside it ---- */
.marks-analysis-radial {
    width: 100%;
    /* The dial is one block on a sheet of other cards, not the page's
       headline: it sits close to the size of the text around it, and the
       drawing scales down with it on every width. */
    max-width: 430px;
    min-width: 214px;
    margin: 0 auto;
}
.marks-radial-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}
.marks-radial-track { stroke: var(--bg-eef2f7); }
.marks-radial-seg {
    cursor: pointer;
    /* Slices arrive with a zero-length dash and are grown to their real
       length by marks.js, so the chart draws itself in one smooth sweep.
       Only the sweep is staggered: each slice carries its own delay and
       duration as custom properties, while opacity — the click dimming —
       is pinned to 0 ms so every ring steps back at the same instant. */
    transition: opacity 0.16s ease 0ms,
                stroke-dasharray var(--sweep-dur, 0.75s) cubic-bezier(0.22, 1, 0.36, 1) var(--sweep-delay, 0ms);
}
/* Flat, not raised: the ring sits on the panel with no shadow under it. */
.marks-radial-dial {
    filter: none;
}
.marks-radial-seg:focus { outline: none; }
/* Every ring sits at full colour until a slice is read; reading one — by
   pointing at it, tapping it, or tapping its legend entry — steps the
   rest back, so the chosen band is the only one still carrying its own
   tone. A hover lets go again; a tap holds it. */
.marks-radial-seg.is-band { opacity: 1; }
.marks-analysis-radial.is-picked .marks-radial-seg:not(.is-hot) { opacity: 0.28; }
/* The frame around the slice being read. Ink in light, paper in dark —
   two thin lines, one just outside the stroke and one just inside, so
   the slice keeps its own colour between them. */
.marks-radial-outline {
    fill: none;
    stroke: #0f172a;
    opacity: 0;
    pointer-events: none;
    /* One closed path, drawn from the picked slice's own geometry, so all
       four sides are the same weight and the corners are joined by the
       stroke itself. Only the fade is animated; the path snaps. */
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: opacity 0.18s ease;
}
html[data-theme="dark"] .marks-radial-outline { stroke: #f8fafc; }
.marks-radial-outline.is-on { opacity: 1; }
.marks-radial-leader {
    fill: none;
    stroke: var(--text-subtle);
    stroke-width: 1.2;
    opacity: 0;
    transition: opacity 0.16s ease;
}
.marks-radial-leader.is-hot {
    /* Dimmed on purpose: a full-strength hairline reads as a white scratch
       over the card, so the connector sits just under the bracket ink. */
    opacity: 0.72;
    stroke: var(--text-muted);
    stroke-width: 1.2;
}
html[data-theme="dark"] .marks-radial-leader.is-hot {
    opacity: 0.5;
    stroke: var(--text-muted);
}
/* ---- Legend: one column, right of the dial ---- */
.marks-radial-legend-swatch {
    pointer-events: all;
    cursor: pointer;
    transition: opacity 0.16s ease;
}
.marks-radial-legend-label {
    fill: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    pointer-events: all;
    cursor: pointer;
    transition: fill 0.16s ease, opacity 0.16s ease;
}
.marks-radial-legend-value {
    fill: var(--text-strong);
    font-size: 13.5px;
    /* The ring's own reading is already the loud one; the row count only
       has to be a little firmer than its label, not bold. */
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
/* The band the class average falls in is tagged, so the caret on the
   ring has a word to go with it. */
.marks-radial-legend-avg {
    fill: var(--text-subtle);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.marks-radial-legend-label.is-hot { fill: var(--text-strong); }
.marks-analysis-radial.is-picked .marks-radial-legend-label:not(.is-hot) { opacity: 0.45; }
.marks-analysis-radial.is-picked .marks-radial-legend-swatch:not(.is-hot) { opacity: 0.35; }
/* The caret over the average's category — it reads like any other slice:
   point at it and the middle states the average. */
.marks-radial-avg { fill: #0f172a; pointer-events: all; cursor: pointer; }
.marks-radial-avg:focus { outline: none; }
html[data-theme="dark"] .marks-radial-avg { fill: #f8fafc; }
/* Thin printed brackets group the legend: one per Passed / Failed / Present
   block, and one large brace around the whole column. */
.marks-radial-group-bracket {
    fill: none;
    stroke: var(--bd-cbd5e1);
    stroke-width: 1.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.marks-radial-group-bracket.is-legend {
    stroke: var(--text-subtle);
    opacity: 0.7;
}
.marks-radial-center-value {
    text-anchor: middle;
    fill: var(--text-strong);
    font-size: 25px;
    font-weight: 700;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
.marks-radial-center-label {
    text-anchor: middle;
    fill: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
/* The average lives on the big legend brace, not in the middle of the
   dial; hovering the caret reads it out like any other slice. */
.marks-analysis-skeleton {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: var(--bg-f8fafc);
    border: 1px solid var(--bd-e2e8f0);
    margin-bottom: 1rem;
}
.marks-analysis-skeleton-dial {
    position: relative;
    flex: 0 0 auto;
    width: 170px;
    height: 170px;
    margin: 0 auto;
}
/* A ring, not a disc: the real dial is a donut, so the placeholder is
   masked to the same band. */
.marks-analysis-skeleton-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    -webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63%);
    mask: radial-gradient(closest-side, transparent 62%, #000 63%);
}
/* Only painted when the marksheet will carry the pass / fail ring. */
.marks-analysis-skeleton-ring-inner {
    position: absolute;
    inset: 26%;
    border-radius: 50%;
    border: 9px solid var(--bd-e2e8f0);
    opacity: 0.75;
}

/* ============================================================ */
/*  EXAMS IN THIS TIMEFRAME — scrolls after ~6 rows              */
/*  A long timeframe used to stretch the student card for every  */
/*  sitting. The list now keeps a fixed window and scrolls, so   */
/*  the analytics card stays a card.                             */
/* ============================================================ */
.student-stats-exams {
    max-height: 16rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
    scrollbar-gutter: stable;
    padding-right: 0.3rem;
}
.student-stats-exams::-webkit-scrollbar { width: 7px; }
.student-stats-exams::-webkit-scrollbar-track { background: transparent; }
.student-stats-exams::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 8px;
}

/* ============================================================ */
/*  PRIMARY ACTIONS — REAL 3D FACE, LIGHT MODE ONLY              */
/*                                                              */
/*  Dark mode is deliberately untouched: none of these rules    */
/*  match there, so every button keeps the face it already had. */
/*                                                              */
/*  In light mode every filled action button — dashboard New    */
/*  Class / Notice / Teacher, the tab-header Create Exam / New   */
/*  Online Exam / Add Student, Generate Report, the marksheet   */
/*  Edit and every other primary / success / danger button —    */
/*  wears the marksheet Edit button's raised face, built with   */
/*  the same bevel as the dashboard actions: a lit top lip, a   */
/*  shaded bottom, a short extruded base and one soft contact   */
/*  shadow.                                                     */
/* ============================================================ */
html[data-theme="light"] .btn-primary,
html[data-theme="light"] .btn-success,
html[data-theme="light"] .btn-danger,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-primary,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-success,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-danger {
    background-color: var(--bg-1e293b);
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.06) 46%,
        rgba(0, 0, 0, 0.10) 100%);
    background-repeat: no-repeat;
    border: 1px solid var(--btn-solid-line);
    border-top-color: var(--btn-solid-line-top);
    /* The bottom edge used to be a hard dark band plus a solid extruded
       base. That read as a black line under every button, so the base is
       gone and the bottom is a soft shade instead. */
    border-bottom-color: rgba(15, 23, 42, 0.14);
    box-shadow:
        inset 0 1px 0 var(--btn-solid-lip),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05),
        0 1px 2px rgba(15, 23, 42, 0.12),
        0 8px 16px -10px var(--btn-drop);
    color: #ffffff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
    transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

html[data-theme="light"] .btn-success { background-color: var(--bg-16a34a); }
html[data-theme="light"] .btn-danger  { background-color: var(--bg-dc2626); }
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-success { background-color: var(--bg-16a34a); }
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-danger  { background-color: var(--bg-dc2626); }

html[data-theme="light"] .btn-primary:hover,
html[data-theme="light"] .btn-success:hover,
html[data-theme="light"] .btn-danger:hover,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-primary:hover,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-success:hover,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-danger:hover {
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.28) 0%,
        rgba(255, 255, 255, 0.08) 46%,
        rgba(0, 0, 0, 0.10) 100%);
    border-top-color: rgba(255, 255, 255, 0.42);
    border-bottom-color: rgba(15, 23, 42, 0.18);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.34),
        0 2px 4px rgba(15, 23, 42, 0.14),
        0 10px 20px -10px var(--btn-drop);
    filter: brightness(1.04);
    transform: translateY(-1px);
}

html[data-theme="light"] .btn-primary:hover { background-color: var(--bg-0f172a); }
html[data-theme="light"] .btn-success:hover { background-color: var(--bg-15803d); }
html[data-theme="light"] .btn-danger:hover  { background-color: var(--bg-b91c1c); }
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-primary:hover { background-color: var(--bg-0f172a); }
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-success:hover { background-color: var(--bg-15803d); }
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-danger:hover  { background-color: var(--bg-b91c1c); }

html[data-theme="light"] .btn-primary:active,
html[data-theme="light"] .btn-success:active,
html[data-theme="light"] .btn-danger:active,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-primary:active,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-success:active,
html[data-theme="light"] #view-dashboard .dashboard-panel .page-header > .btn.btn-danger:active {
    background-image: linear-gradient(180deg,
        rgba(0, 0, 0, 0.14) 0%,
        rgba(0, 0, 0, 0.02) 100%);
    box-shadow:
        inset 0 2px 4px var(--btn-solid-shade),
        0 1px 0 rgba(15, 23, 42, 0.12);
    filter: none;
    transform: translateY(1px);
}

/* A button that already sits on a raised card / frame / modal stays
   flat in light mode too — the surface carries the depth there, as
   it always has. The list mirrors the shared "button inside a raised
   surface" rule above; this copy is scoped to light mode only. */
html[data-theme="light"] :is(.modal-box, .settings-modal-box, .settings-frame, .settings-subframe,
    .notice-card, .notice-detail-card,
    .config-frame, .config-group-card, .config-online-defaults,
    .exam-card-item, .class-card-item, .student-card-item, .student-exam-item,
    .student-exam-card, .teacher-card, .payment-month-card, .payment-summary-card,
    .payment-detail-header, .payment-detail-actions, .exam-result-card,
    .student-selector-card, .reports-filters, .reports-panel,
    .attendance-frame, .marks-table, .online-import-panel, #report-preview) :is(.btn-primary, .btn-success, .btn-danger):not(.view-marks-btn):not(.online-start-btn):not(.online-resume-btn) {
    box-shadow: none;
    filter: none;
    transform: none;
}

/* ---- Radial callouts: a legend row is part of its slice ---- */
.marks-radial-seg { stroke-linecap: butt; }
.marks-radial-leader {
    /* Drawn, never aimed at: the connector only appears for the slice
       being read, and an invisible one still catches the pointer where
       its stroke would run — so the line never steals the reading from
       the ring or the row it belongs to. */
    pointer-events: none;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* ============================================================ */
/*  TOPPER CARD — RANK #1 ON AN EXAM                            */
/*                                                              */
/*  Taking first place on a paper is the one result a student   */
/*  keeps. The award lives in the badge alone: the card keeps    */
/*  the same surface and shadow as every other card and gains    */
/*  only a thin gold edge — no wash, no glow, no sheen.          */
/* ============================================================ */
.student-exam-card.is-top-rank {
    position: relative;
    border-color: rgba(212, 175, 55, 0.45);
}

/* Hover, pressed and open: only the edge warms up. */
.student-exam-card.is-top-rank:hover,
.student-exam-card.is-top-rank:active,
.student-exam-card.is-top-rank.is-expanded,
.student-exam-card.is-top-rank.is-raised {
    border-color: rgba(191, 155, 40, 0.55);
}

/* The gold ribbon that says why the card is marked — flat, one
   colour, no metallic gradient and no highlight. */
.student-exam-card .exam-tag.topper-tag {
    background: #f1dc94;
    color: #4a3a10;
    border: 1px solid rgba(148, 118, 30, 0.4);
    font-weight: 700;
    box-shadow: none;
}
.student-exam-card .exam-tag.topper-tag i { margin-right: 0.25rem; color: #7c5c12; }

html[data-theme="dark"] .student-exam-card.is-top-rank {
    border-color: rgba(212, 175, 55, 0.34);
}
html[data-theme="dark"] .student-exam-card .exam-tag.topper-tag {
    background: #d9b646;
    color: #1a1405;
    border-color: rgba(212, 175, 55, 0.45);
}

/* ============================================================ */
/*  ROLLING DIGITS (odometer stats)                              */
/*                                                              */
/*  Same mechanic as the maintenance countdown: each digit is a  */
/*  clipped column holding a 0…9 strip that slides to the value. */
/*  The strip's height is 1em, so a cell never grows the card.   */
/* ============================================================ */
.odo {
    display: inline-flex;
    align-items: baseline;
    gap: 0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.odo-digits { display: inline-flex; align-items: baseline; }
.odo-cell {
    position: relative;
    display: inline-block;
    width: 0.58em;
    height: 1em;
    overflow: hidden;
}
.odo-strip {
    display: flex;
    flex-direction: column;
    transform: translateY(calc(var(--d, 0) * -1em));
    transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.odo-strip > span {
    display: block;
    height: 1em;
    line-height: 1;
    text-align: center;
}
/* No transition on the first frame: the strips must start on 0 silently
   and only then roll. */
.odo-hold .odo-strip { transition: none; }
.odo-sep {
    display: inline-block;
    line-height: 1;
    padding: 0 0.02em;
}
.odo-blank { color: var(--fg-94a3b8); }
@media (prefers-reduced-motion: reduce) {
    .odo-strip { transition: none; }
}

/* ============================================================ */
/*  SCORE DISTRIBUTION RADIAL                                    */
/*                                                              */
/*  Flat ring, one arc per mark range, the range written beside   */
/*  its arc. Selecting an arc frames it in ink (paper in dark)    */
/*  and draws the leader out to that range's row.                 */
/* ============================================================ */
.dist-radial {
    position: relative;
    width: 100%;
    max-width: 330px;
    margin: 0.15rem auto 0;
}
/* On a phone the card is the full width, so the dial does not need to fill
   it to stay legible: it steps back to the size of the text around it. */
@media (max-width: 560px) {
    .marks-analysis-radial { max-width: 300px; }
    .dist-radial { max-width: 280px; }
}
.dist-radial-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}
.dist-track { stroke: var(--bg-eef2f7); }
.dist-arc {
    fill: none;
    stroke-linecap: butt;
    /* Each arc arrives empty and is grown to its length by
       wireDistributionRadial, so the ring sweeps in clockwise. Only the
       sweep is timed from the markup (--sweep-*), so picking a range still
       dims and lifts the other arcs at their own pace. */
    transition: opacity 0.24s ease,
                filter 0.24s ease,
                stroke-dasharray var(--sweep-dur, 0.82s) cubic-bezier(0.22, 1, 0.36, 1) var(--sweep-delay, 0ms);
}
.dist-slice { cursor: pointer; }
.dist-slice:focus { outline: none; }
.dist-outline {
    fill: none;
    stroke: #0f172a;
    opacity: 0;
    pointer-events: none;
    /* One closed path around the slice — both rims and both end walls —
       so the inner and outer edges meet instead of floating apart. It
       inks itself in with the dimming instead of blinking on. */
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: opacity 0.2s ease;
}
html[data-theme="dark"] .dist-outline { stroke: #f8fafc; }
.dist-slice.is-hot .dist-outline { opacity: 1; }
/* Picking a range — by tapping its arc or its legend row — lowers the
   light on the rest and lifts it on the one being read, so the dimming
   and the highlight arrive together. Hovering alone does nothing. */
.dist-slice.is-hot .dist-arc { filter: brightness(1.07) saturate(1.06); }
.dist-radial.is-picked .dist-slice:not(.is-hot) .dist-arc {
    opacity: 0.24;
    filter: saturate(0.55) brightness(1.02);
}
/* Same ink as the marksheet's connectors, so both charts read as one
   drawn language: a hairline just under the bracket colour, not a rule. */
.dist-leader {
    fill: none;
    stroke: var(--text-subtle);
    stroke-width: 1.2;
    stroke-linejoin: round;
    stroke-linecap: round;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease;
}
.dist-leader.is-hot {
    opacity: 0.72;
    stroke: var(--text-muted);
}
html[data-theme="dark"] .dist-leader.is-hot {
    opacity: 0.5;
    stroke: var(--text-muted);
}
.dist-row-label {
    font-size: 10px;
    font-weight: 600;
    fill: var(--fg-475569);
    cursor: pointer;
    transition: opacity 0.16s ease;
}
.dist-row-value {
    font-size: 9.5px;
    font-weight: 700;
    fill: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: opacity 0.16s ease;
}
.dist-row-label.is-hot,
.dist-row-value.is-hot { fill: var(--text-strong); }
.dist-radial.is-picked .dist-row-label:not(.is-hot),
.dist-radial.is-picked .dist-row-value:not(.is-hot) { opacity: 0.4; }
.dist-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.12rem;
    text-align: center;
    pointer-events: none;
}
.dist-center-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-strong);
}
.dist-center-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-94a3b8);
    max-width: 96px;
    line-height: 1.2;
}
/* A range nobody scored in still states its place, quietly. */
.dist-row-label[data-count="0"],
.dist-row-value[data-count="0"] { opacity: 0.62; }

/* ---- Legend: one column right of the ring, every row joined to its own
   arc by a connector — the same reading as the marksheet's chart. SVG
   text cannot wrap, so a range label never breaks onto a second line. ---- */
.dist-legend-row { cursor: pointer; transition: opacity 0.16s ease; }
.dist-legend-swatch { pointer-events: none; }
.dist-legend-label {
    font-size: 10.5px;
    font-weight: 600;
    fill: var(--fg-475569);
    white-space: nowrap;
    transition: fill 0.16s ease, opacity 0.16s ease;
}
.dist-legend-value {
    font-size: 10.5px;
    /* The strong ink is what sets the count apart; at this size a bold
       weight only made it look chunky. */
    font-weight: 600;
    fill: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
.dist-legend-row.is-hot .dist-legend-label,
.dist-legend-row.is-hot .dist-legend-value { fill: var(--text-strong); }
.dist-radial.is-picked .dist-legend-row:not(.is-hot) { opacity: 0.4; }
/* The middle of the ring states the total, then the range being read. The
   total is an HTML odometer inside a foreignObject, so it rolls up like
   every other stat while still scaling with the drawing. */
.dist-center-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.dist-center-odo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
/* The class rule outranks [hidden], so the swap needs its own rule. */
.dist-center-odo[hidden],
.dist-center-read[hidden] { display: none; }
/* Reading a range: its own average, flagged with the range's colour. */
.dist-center-read {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
.dist-center-dot {
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
}
.dist-center-value {
    font-size: 17px;
    font-weight: 700;
    fill: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
.dist-center-label {
    font-size: 7.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    fill: var(--fg-94a3b8);
}

/*  Date inputs print their own text in the browser's UI locale, which the
    page cannot change, so they are left exactly as the browser draws them
    (month / day / year on an en-US Chrome). Everything that pins a date
    back onto a card still writes DD/MM/YYYY. */
.date-range input[type="date"],
.date-range input[type="datetime-local"] { flex: 1 1 0; min-width: 0; }
.analytics-custom-range input[type="date"] { max-width: 160px; }
.student-stats-range input[type="date"] { max-width: 148px; }

@media (max-width: 640px) {
    .analytics-custom-range input[type="date"] { max-width: 100%; flex: 1 1 100px; }
}

/* ============================================================ */
/*  Dated fee sectors                                            */
/*                                                              */
/*  The list is a ledger: a live sector prices the months it      */
/*  covers, an expired one stays as history that still prices     */
/*  its own months, and deleting a row removes it for good.       */
/* ============================================================ */
.fee-schedule-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.35rem;
}
.class-fee-frame .fee-schedule-row {
    grid-template-columns: minmax(0, 1fr) auto auto 32px 32px;
    gap: 0.45rem;
    margin-top: 0;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 9px;
    background: var(--bg-ffffff);
}
.fee-schedule-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-wrap: wrap;
}
.fee-schedule-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fee-schedule-chip {
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--bd-e2e8f0);
    background: var(--bg-f8fafc);
    color: var(--fg-64748b);
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}
.fee-schedule-row.is-active .fee-schedule-chip {
    border-color: rgba(22, 163, 74, 0.35);
    background: var(--bg-f0fdf4);
    color: var(--fg-15803d);
}
.fee-schedule-row.is-upcoming .fee-schedule-chip {
    border-color: var(--bd-cbd5e1);
    background: var(--bg-f8fafc);
    color: var(--fg-475569);
}
.fee-schedule-row.is-expired .fee-schedule-chip {
    border-color: var(--bd-e2e8f0);
    background: var(--bg-f8fafc);
    color: var(--fg-94a3b8);
}
/* Expired rows stay readable but recede: they still price the months
   they covered, they just no longer price a new month. */
.fee-schedule-row.is-expired .fee-schedule-name,
.fee-schedule-row.is-expired .fee-schedule-amount {
    color: var(--fg-94a3b8);
}
.fee-schedule-range {
    font-size: 0.72rem;
    color: var(--fg-64748b);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.fee-schedule-row.is-expired .fee-schedule-range {
    color: var(--fg-94a3b8);
}
/* ---- Collapsible sections --------------------------------------
   The payment breakdown, its history shelf and the 12-month preview
   are one component. A 0fr → 1fr grid row animates to the content's
   own height, so nothing has to be measured in JS. */
.fee-collapse {
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 10px;
    background: var(--bg-ffffff);
    overflow: hidden;
}
.fee-collapse + .fee-collapse {
    margin-top: 0.45rem;
}
.fee-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 0;
    background: var(--bg-f8fafc);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    color: var(--fg-64748b);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.fee-collapse-header:hover {
    color: var(--fg-1e293b);
}
/* It is a disclosure, not a button: the global press-scale would make the
   whole section jump every time it opened. */
.fee-collapse-header:active {
    transform: none !important;
}
.fee-collapse-title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}
.fee-collapse-arrow {
    font-size: 0.66rem;
    transform: rotate(-90deg);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.fee-collapse.is-open > .fee-collapse-header .fee-collapse-arrow {
    transform: rotate(0deg);
}
.fee-collapse-note {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--fg-94a3b8);
    text-align: right;
}
.fee-collapse-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.fee-collapse.is-open > .fee-collapse-body {
    grid-template-rows: 1fr;
}
.fee-collapse-inner {
    min-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.26s ease;
}
.fee-collapse.is-open > .fee-collapse-body > .fee-collapse-inner {
    opacity: 1;
}
.fee-collapse .fee-schedule-list {
    margin-top: 0;
    padding: 0.45rem 0.55rem 0.55rem;
}
.fee-collapse .fee-schedule-empty {
    margin: 0;
    padding: 0.55rem 0.7rem 0.7rem;
}
.fee-preview-collapse {
    margin-top: 0.85rem;
}
.fee-history-collapse:not(:empty) {
    margin-top: 0.45rem;
}
.fee-preview-collapse .fee-collapse-inner > .fee-preview-table {
    border-top: 1px solid var(--bd-e2e8f0);
}
.fee-schedule-amount {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--fg-1e293b);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fee-schedule-edit,
.fee-schedule-remove {
    padding: 0.28rem 0;
    min-width: 32px;
}
.fee-schedule-empty {
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--fg-64748b);
}
.fee-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
}
.fee-preview-table td {
    padding: 0.32rem 0.8rem;
    border-top: 1px solid var(--bd-e2e8f0);
    color: var(--fg-475569);
    white-space: nowrap;
}
.fee-preview-amount {
    text-align: right;
    font-weight: 600;
    color: var(--fg-1e293b);
    font-variant-numeric: tabular-nums;
}
.fee-preview-parts {
    text-align: right;
    font-size: 0.7rem;
    color: var(--fg-94a3b8);
    white-space: normal;
}
.fee-sector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.fee-sector-sentence {
    margin: 0.35rem 0 0.9rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--bd-e2e8f0);
    border-radius: 8px;
    background: var(--bg-f8fafc);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--fg-475569);
}
.fee-sector-sentence.is-warning {
    border-color: rgba(185, 28, 28, 0.35);
    background: #fef2f2;
    color: #b91c1c;
}
.fee-sector-range-field > label {
    display: block;
    margin-bottom: 0.5rem;
}
.radio-group.fee-sector-range-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 0;
}
.fee-sector-range-group .radio-label {
    min-width: 0;
    line-height: 1.3;
}
.fee-sector-range-group .radio-label span {
    min-width: 0;
    overflow-wrap: anywhere;
}
/* The add-sector modal is one form, so its gaps match the rest of the
   config screen: a title that clears the first field, labels that sit
   off their inputs, and radio rows with room to breathe. */
.fee-sector-modal > h3 {
    margin-bottom: 1.2rem;
}
.fee-sector-modal .form-group > label {
    margin-bottom: 0.4rem;
}
.fee-sector-modal .fee-sector-range-field > label {
    margin-bottom: 0.65rem;
}
.fee-sector-modal .radio-group.fee-sector-range-group {
    row-gap: 0.6rem;
    padding-block: 0.1rem;
}
.fee-sector-modal-note {
    margin: 0 0 0.9rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #b45309;
}

/* ---- Payments: month progress + that month's own rates -------- */
.payment-month-percent {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--fg-64748b);
    font-variant-numeric: tabular-nums;
}
.payment-month-progress {
    height: 4px;
    margin-top: 0.55rem;
    border-radius: 999px;
    background: var(--bd-e2e8f0);
    overflow: hidden;
}
.payment-month-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--fg-16a34a);
    transition: width 0.35s ease;
}
.payment-rate-note {
    margin: -0.2rem 0 0.85rem;
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--fg-64748b);
}

@media (max-width: 560px) {
    .fee-sector-grid { grid-template-columns: 1fr; }
    .radio-group.fee-sector-range-group { grid-template-columns: 1fr; }
    .class-fee-frame .fee-schedule-row { grid-template-columns: minmax(0, 1fr) auto 30px 30px; }
    .class-fee-frame .fee-schedule-range { display: none; }
    .fee-collapse-note { display: none; }
}

/* ============================================================ */
/*  Fee groups — separately collected sectors                    */
/*                                                              */
/*  A sector can be billed with the tuition or collected on its  */
/*  own. The payments screen switches between those groups with  */
/*  the tab row below, and a student's month card lists every    */
/*  group with its own state.                                    */
/* ============================================================ */
/* Violet, not the blue of a neutral info chip: a separate tag is a
   property of the sector, and it has to read as one at a glance next to
   the green Active chip on the same row. */
.fee-schedule-row .fee-schedule-chip.is-separate,
.fee-schedule-row.is-active .fee-schedule-chip.is-separate,
.fee-schedule-row.is-upcoming .fee-schedule-chip.is-separate,
.fee-schedule-row.is-expired .fee-schedule-chip.is-separate {
    border-color: rgba(126, 34, 206, 0.30);
    background: var(--bg-f3e8ff, #f3e8ff);
    color: var(--fg-7e22ce, #7e22ce);
}

/* Same pill switcher as the dashboard tabs: one rounded track, the
   selected group is the dark full-height pill with white text. */
.payment-group-tabs {
    display: flex;
    justify-content: center;
    justify-content: safe center;
    gap: 0.25rem;
    position: relative;
    isolation: isolate;
    width: fit-content;
    max-width: 100%;
    padding: 0.3rem;
    margin: 0.7rem auto 0.9rem;
    border-radius: 999px;
    background: var(--bg-f1f5f9);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: 0.9rem;
}
.payment-group-tabs::-webkit-scrollbar { display: none; }

/* The selected group is one full-height pill that slides between the
   tabs — the dashboard's switcher. The track keeps its own horizontal
   scroll, so more groups pan instead of squeezing. */
.payment-group-tabs::before {
    position: absolute;
    z-index: 0;
    inset: 0.3rem auto 0.3rem 0;
    width: var(--pay-tab-indicator-width, 0px);
    border-radius: 999px;
    background: var(--bg-17191d);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.18),
        0 4px 12px rgba(15, 23, 42, 0.10);
    content: "";
    transform: translate3d(var(--pay-tab-indicator-x, 0px), 0, 0);
    transition:
        transform var(--pay-tab-indicator-duration, 320ms) cubic-bezier(0.22, 1, 0.36, 1),
        width var(--pay-tab-indicator-duration, 320ms) cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

/* Until the pill has been measured, the selected tab paints its own
   dark background so its white label is never invisible. */
.payment-group-tabs:not([data-indicator-ready]) .payment-group-tab.is-active {
    background: var(--bg-17191d);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.18),
        0 4px 12px rgba(15, 23, 42, 0.10);
}

@media (prefers-reduced-motion: reduce) {
    .payment-group-tabs::before { transition-duration: 1ms; }
}

.payment-group-tab {
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    padding: 0.5rem 1.05rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--fg-64748b);
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.15;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 160ms ease;
}
.payment-group-tab:hover { color: var(--fg-1e293b); }
.payment-group-tab:active { transform: none; }
.payment-group-tab:focus-visible { outline: 2px solid var(--bg-17191d); outline-offset: 2px; }
.payment-group-tab.is-active {
    background: transparent;
    color: var(--fg-ffffff);
    box-shadow: none;
}
.payment-group-tab.is-active:hover { color: var(--fg-ffffff); }

.payment-group-tab-name { font-weight: 600; }
.payment-group-tab-amount { font-size: 0.72rem; opacity: 0.78; }
.payment-group-tab .currency-symbol { font-size: 0.85em; }

.payment-status.status-partial { background: var(--bg-fef3c7, #fef3c7); color: var(--fg-b45309, #b45309); }

.payment-group-state {
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: var(--bg-f1f5f9);
    color: var(--fg-64748b);
}
.payment-group-state.is-due    { background: var(--bg-fee2e2); color: var(--fg-b91c1c); }

/* Odometer summary values: a digit that changes rolls out and its
   replacement rolls in from above, in place, so a card's value updates
   without the card being rebuilt. Digits are tabular and a rolling cell
   is one character wide, so the "(৳ 3,000)" beside the count never
   slides sideways while the number rolls. */
.payment-summary-card .card-value {
    font-variant-numeric: tabular-nums;
    /* One roller cell tall: the cell and the plain text around it then
       share the same line box, so nothing sits a pixel lower while a
       number rolls and nothing moves when it lands. */
    line-height: 1.25em;
}
.card-value .odo-cell.is-rolling {
    width: 1ch;
    min-width: 1ch;
}
.card-value .odo-cell {
    display: inline-block;
    height: 1.25em;
    line-height: 1.25em;
    overflow: hidden;
    vertical-align: top;
}
.card-value .odo-stack {
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.card-value .odo-stack > i {
    display: block;
    height: 1.25em;
    line-height: 1.25em;
    font-style: normal;
    text-align: center;
}
.card-value .odo-roll .odo-cell.is-rolling .odo-stack {
    transform: translateY(-1.25em);
}
.payment-summary-card.is-card-new { will-change: opacity, transform; }

@media (prefers-reduced-motion: reduce) {
    .card-value .odo-stack { transition-duration: 1ms; }
}
