/* =========================================================
           School Portal Login UI
           Shared design system with the staff login (index.php).
           Brand: Navy #1a2a6c · Crimson #b21f1f
           ========================================================= */
        :root {
            --brand-navy: #1a2a6c;
            --brand-navy-deep: #111c52;
            --brand-navy-soft: #2a3d8f;
            --brand-crimson: #b21f1f;
            --brand-crimson-soft: #d94a4a;
            --accent: #fdbb2d;

            --ink-900: #0f172a;
            --ink-700: #334155;
            --ink-500: #64748b;
            --ink-400: #94a3b8;
            --line: #e6e8ef;
            --line-strong: #d4d8e3;
            --surface: #ffffff;
            --surface-muted: #f7f8fb;

            --success: #138a5a;
            --warning: #c2570a;
            --danger:  #c81e1e;

            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;

            --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04),
                           0 10px 30px rgba(15, 23, 42, 0.10),
                           0 30px 60px -20px rgba(26, 42, 108, 0.35);
            --shadow-toast: 0 12px 40px rgba(15, 23, 42, 0.18),
                            0 2px 6px rgba(15, 23, 42, 0.06);
            --ring: 0 0 0 4px rgba(26, 42, 108, 0.15);

            /* ----- Spacing tokens (compactness) ----- */
            --login-card-pad:        1.75rem 2rem 1.5rem;
            --login-logo-top:        0.25rem;
            --login-logo-bottom:     0.9rem;
            --login-heading-bottom:  0.45rem;
            --login-subtitle-bottom: 1.35rem;
            --login-form-gap:        1.05rem;
            --login-label-bottom:    0.45rem;
            --login-input-pad:       0.78rem 0.95rem;
            --login-btn-pad:         0.85rem 1rem;
            --login-btn-top:         0.5rem;
            --login-error-bottom:    1.1rem;
            --login-error-pad:       0.85rem 1rem;
            --login-footer-top:      1.1rem;
            --login-staff-top:       1.25rem;
            --login-staff-pad-top:   1.0rem;

            /* legacy aliases preserved so any existing rules keep working */
            --primary: var(--brand-navy);
            --secondary: var(--brand-crimson);
        }

        *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
        html { -webkit-text-size-adjust: 100%; }

        body {
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            color: var(--ink-900);
            min-height: 100vh;
            min-height: 100dvh;
            /* top padding leaves room for the fixed theme-toggle */
            padding: 56px 20px 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow-x: hidden;

            background-color: #0e1742;
            background-image:
                radial-gradient(1100px 700px at 12% -10%, rgba(178, 31, 31, 0.28), transparent 60%),
                radial-gradient(900px 600px at 100% 110%, rgba(42, 61, 143, 0.55), transparent 60%),
                radial-gradient(700px 500px at 50% 50%, rgba(255, 255, 255, 0.05), transparent 70%),
                linear-gradient(135deg, #0d1640 0%, #1a2a6c 55%, #2a1a4a 100%);
        }

        body::before {
            content: "";
            position: fixed;
            inset: 0;
            pointer-events: none;
            background-image:
                linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
            background-size: 44px 44px;
            mask-image: radial-gradient(ellipse at center, #000 40%, transparent 80%);
            -webkit-mask-image: radial-gradient(ellipse at center, #000 40%, transparent 80%);
        }

        /* ========== Card ========== */
        .login-card {
            position: relative;
            background: var(--surface);
            width: 100%;
            max-width: 410px;
            padding: var(--login-card-pad);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-card);
            margin: auto;
            border: 1px solid rgba(255, 255, 255, 0.6);
            text-align: center;
            animation: card-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
        }
        @keyframes card-in {
            from { opacity: 0; transform: translateY(10px) scale(0.985); }
            to   { opacity: 1; transform: translateY(0)    scale(1); }
        }
        .login-card::before {
            content: "";
            position: absolute;
            top: 0; left: 24px; right: 24px;
            height: 3px;
            border-radius: 0 0 6px 6px;
            background: linear-gradient(90deg, var(--brand-navy), var(--brand-crimson));
            opacity: 0.9;
        }

        /* ========== Logo / header ========== */
        .logo {
            width: 68px;
            height: 68px;
            margin: var(--login-logo-top) auto var(--login-logo-bottom);
            border-radius: 50%;
            background: linear-gradient(135deg, var(--brand-navy), var(--brand-crimson));
            color: #fff;
            font-size: 1.85rem;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow:
                0 0 0 3px #fff,
                0 0 0 4px rgba(26, 42, 108, 0.15),
                0 6px 16px -8px rgba(26, 42, 108, 0.45);
        }

        h2 {
            color: var(--ink-900);
            font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
            font-size: 1.2rem;
            font-weight: 700;
            letter-spacing: -0.01em;
            margin-bottom: var(--login-heading-bottom);
        }
        p.subtitle {
            color: var(--ink-500);
            font-size: 0.86rem;
            line-height: 1.5;
            margin-bottom: var(--login-subtitle-bottom);
        }

        /* ========== Form ========== */
        .form-group {
            text-align: left;
            margin-bottom: var(--login-form-gap);
        }
        label {
            display: block;
            margin-bottom: var(--login-label-bottom);
            font-weight: 600;
            font-size: 0.82rem;
            color: var(--ink-700);
            letter-spacing: 0.02em;
        }
        input {
            width: 100%;
            padding: var(--login-input-pad);
            border: 1.5px solid var(--line-strong);
            border-radius: var(--radius-md);
            font-size: 0.93rem;
            font-family: inherit;
            color: var(--ink-900);
            background: var(--surface-muted);
            transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
        }
        input::placeholder { color: var(--ink-400); }
        input:hover { border-color: #c2c8d6; }
        input:focus {
            outline: none;
            background: #fff;
            border-color: var(--brand-navy);
            box-shadow: var(--ring);
        }


        /* ========== PIN visibility toggle ========== */
        .password-wrapper { position: relative; }
        .password-wrapper input { padding-right: 2.9rem; }
        .toggle-password {
            position: absolute;
            right: 0.6rem;
            top: 50%;
            transform: translateY(-50%);
            cursor: pointer;
            color: var(--ink-400);
            font-size: 0.95rem;
            background: none;
            border: none;
            padding: 0.4rem;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color 0.2s, background 0.2s;
        }
        .toggle-password:hover {
            color: var(--brand-navy);
            background: rgba(26, 42, 108, 0.08);
        }
        :root[data-theme="dark"] .toggle-password:hover {
            color: var(--brand-navy);
            background: rgba(108, 132, 230, 0.12);
        }

        .btn-login {
            width: 100%;
            padding: var(--login-btn-pad);
            background: linear-gradient(180deg, var(--brand-navy) 0%, var(--brand-navy-deep) 100%);
            color: #fff;
            border: none;
            border-radius: var(--radius-md);
            font-size: 0.95rem;
            font-weight: 600;
            font-family: inherit;
            letter-spacing: 0.02em;
            cursor: pointer;
            margin-top: var(--login-btn-top);
            box-shadow:
                0 1px 0 rgba(255, 255, 255, 0.12) inset,
                0 6px 16px -6px rgba(26, 42, 108, 0.55);
            transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
        }
        .btn-login:hover {
            filter: brightness(1.06);
            transform: translateY(-1px);
            box-shadow:
                0 1px 0 rgba(255, 255, 255, 0.15) inset,
                0 10px 22px -8px rgba(26, 42, 108, 0.65);
        }
        .btn-login:focus-visible {
            outline: none;
            box-shadow:
                0 0 0 4px rgba(26, 42, 108, 0.22),
                0 6px 16px -6px rgba(26, 42, 108, 0.55);
        }
        .btn-login:active { transform: translateY(0); filter: brightness(0.98); }
        .btn-login:disabled { opacity: 0.75; cursor: not-allowed; transform: none; }

        /* ========== Error ========== */
        #error_msg {
            color: #8a1313;
            text-align: left;
            margin-bottom: var(--login-error-bottom);
            font-weight: 500;
            font-size: 0.88rem;
            padding: var(--login-error-pad);
            background-color: #fdecec;
            border-radius: var(--radius-sm);
            border-left: 4px solid var(--danger);
            display: none;
        }

        /* ========== Footer ========== */
        .footer-note {
            margin-top: var(--login-footer-top);
            font-size: 0.85rem;
            color: var(--ink-500);
        }
        .footer-note a {
            color: var(--brand-navy);
            text-decoration: none;
            font-weight: 600;
            transition: color 0.2s;
        }
        .footer-note a:hover {
            color: var(--brand-crimson);
            text-decoration: underline;
            text-underline-offset: 3px;
        }

        .staff-link-section {
            margin-top: var(--login-staff-top);
            padding-top: var(--login-staff-pad-top);
            border-top: 1px solid var(--line);
        }
        .staff-link-section p {
            font-size: 0.82rem;
            color: var(--ink-500);
            margin-bottom: 0.5rem;
        }
        .staff-link-section a {
            color: var(--brand-navy);
            text-decoration: none;
            font-size: 0.84rem;
            font-weight: 600;
            transition: color 0.2s;
        }
        .staff-link-section a:hover { color: var(--brand-crimson); }

        /* ========== Flash toast ========== */
        .flash-toast {
            position: fixed;
            top: 1.5rem;
            left: 50%;
            transform: translateX(-50%) translateY(-140px);
            z-index: 999;
            min-width: 0;
            max-width: min(480px, calc(100vw - 96px));
            width: calc(100% - 96px);
            background: #fff;
            border-radius: var(--radius-md);
            padding: 1rem 1.1rem 1.1rem;
            display: flex;
            align-items: flex-start;
            gap: 0.85rem;
            box-shadow: var(--shadow-toast);
            border: 1px solid var(--line);
            opacity: 0;
            overflow: hidden;
            transition: transform 0.45s cubic-bezier(0.34, 1.45, 0.64, 1), opacity 0.35s ease;
        }
        .flash-toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
        .flash-toast.logout  { border-left: 4px solid var(--brand-navy); }
        .flash-toast.timeout { border-left: 4px solid var(--warning); }

        .flash-icon {
            flex-shrink: 0;
            width: 38px; height: 38px;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 1rem; color: #fff;
        }
        .flash-toast.logout  .flash-icon { background: var(--brand-navy); }
        .flash-toast.timeout .flash-icon { background: var(--warning); }

        .flash-body { flex: 1; min-width: 0; }
        .flash-body strong {
            display: block;
            font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
            font-size: 0.95rem; font-weight: 700;
            margin-bottom: 0.2rem;
            color: var(--ink-900);
        }
        .flash-body span {
            font-size: 0.85rem;
            color: var(--ink-500);
            line-height: 1.45;
        }
        .flash-close {
            flex-shrink: 0;
            background: none; border: none; cursor: pointer;
            color: var(--ink-400);
            font-size: 0.95rem;
            padding: 4px;
            border-radius: 6px;
            line-height: 1;
            transition: color 0.2s, background 0.2s;
        }
        .flash-close:hover { color: var(--ink-700); background: var(--surface-muted); }

        /* ========== Responsive ========== */
        @media (max-width: 768px) {
            body { padding: 64px 16px 16px; }
            .login-card { padding: 1.25rem 1.4rem 1.1rem; }
            .logo { width: 58px; height: 58px; font-size: 1.65rem; }
            h2 { font-size: 1.1rem; }
            .flash-toast {
                top: 1rem;
                width: calc(100% - 88px);
                max-width: calc(100vw - 88px);
            }
        }

        @media (max-width: 576px) {
            body { padding: 60px 14px 20px; align-items: flex-start; }
            .login-card { padding: 1.1rem 1.05rem; border-radius: 14px; }
            .logo { width: 54px; height: 54px; font-size: 1.55rem; }
            h2 { font-size: 1.05rem; }
            p.subtitle { font-size: 0.8rem; }
            input { padding: 0.55rem 0.8rem; font-size: 0.88rem; }
            .btn-login { padding: 0.65rem; font-size: 0.92rem; }
            .flash-toast {
                padding: 0.85rem 0.9rem;
                top: 0.75rem;
                width: calc(100% - 80px);
                max-width: calc(100vw - 80px);
            }
            .flash-body strong { font-size: 0.9rem; }
            .flash-body span { font-size: 0.8rem; }
            .theme-toggle { top: 12px; right: 12px; gap: 6px; padding: 5px 11px 5px 7px; font-size: 0.76rem; }
        }

        @media (max-width: 400px) {
            body { padding: 56px 10px 16px; }
            .login-card { padding: 1rem 0.9rem; border-radius: 12px; }
            .logo { width: 48px; height: 48px; font-size: 1.4rem; }
            h2 { font-size: 1rem; }
            input { padding: 0.55rem 0.75rem; font-size: 0.88rem; }
            .btn-login { padding: 0.6rem; font-size: 0.9rem; }
            .footer-note { font-size: 0.78rem; }
            .flash-toast {
                width: calc(100% - 72px);
                max-width: calc(100vw - 72px);
                gap: 0.6rem;
                padding: 0.75rem 0.8rem;
            }
            .flash-icon { width: 34px; height: 34px; font-size: 0.9rem; }
        }

        @media (max-height: 640px) {
            body { align-items: flex-start; padding-top: 56px; padding-bottom: 24px; }
            .logo { width: 52px; height: 52px; font-size: 1.45rem; }
            .form-group { margin-bottom: 0.55rem; }
        }

        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.001ms !important;
                transition-duration: 0.001ms !important;
            }
        }

        /* =========================================================
           Dark theme
           ========================================================= */
        :root[data-theme="dark"] {
            --brand-navy:        #6c84e6;
            --brand-navy-deep:   #4f68c9;
            --brand-navy-soft:   #8aa0ee;
            --brand-crimson:     #ef6464;
            --brand-crimson-soft:#f48a8a;

            --ink-900: #e6ecf5;
            --ink-700: #c2cad8;
            --ink-500: #94a3b8;
            --ink-400: #6b7790;

            --line:        #2a3146;
            --line-strong: #394260;
            --surface:        #1e2533;
            --surface-muted:  #161b27;

            --success: #34d399;
            --warning: #fbbf24;
            --danger:  #f87171;

            --shadow-card:  0 1px 2px rgba(0, 0, 0, 0.35),
                            0 12px 32px rgba(0, 0, 0, 0.45),
                            0 30px 60px -20px rgba(0, 0, 0, 0.6);
            --shadow-toast: 0 14px 44px rgba(0, 0, 0, 0.55),
                            0 2px 6px rgba(0, 0, 0, 0.3);
            --ring: 0 0 0 4px rgba(108, 132, 230, 0.28);
        }

        :root[data-theme="dark"] body {
            background-color: #07091a;
            background-image:
                radial-gradient(1100px 700px at 12% -10%, rgba(178, 31, 31, 0.20), transparent 60%),
                radial-gradient(900px 600px at 100% 110%, rgba(42, 61, 143, 0.45), transparent 60%),
                radial-gradient(700px 500px at 50% 50%, rgba(255, 255, 255, 0.025), transparent 70%),
                linear-gradient(135deg, #05071a 0%, #0c1340 55%, #160d2a 100%);
            color: var(--ink-900);
        }
        :root[data-theme="dark"] body::before {
            background-image:
                linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
        }
        :root[data-theme="dark"] .login-card {
            background: var(--surface);
            border-color: rgba(255, 255, 255, 0.06);
        }
        :root[data-theme="dark"] h2 { color: var(--ink-900); }
        :root[data-theme="dark"] input:hover { border-color: #4a5475; }
        :root[data-theme="dark"] input:focus { background: #0f1422; }
        :root[data-theme="dark"] .btn-login {
            background: linear-gradient(180deg, #3b51a8 0%, #2a3d8f 100%);
            box-shadow:
                0 1px 0 rgba(255, 255, 255, 0.08) inset,
                0 6px 18px -6px rgba(0, 0, 0, 0.7);
        }
        :root[data-theme="dark"] #error_msg {
            color: #fecaca;
            background-color: rgba(248, 113, 113, 0.12);
        }
        :root[data-theme="dark"] .flash-toast {
            background: #1e2533;
            border-color: rgba(255, 255, 255, 0.06);
        }
        :root[data-theme="dark"] .flash-body strong { color: var(--ink-900); }
        :root[data-theme="dark"] .flash-body span,
        :root[data-theme="dark"] .flash-close       { color: var(--ink-500); }
        :root[data-theme="dark"] .flash-close:hover { color: var(--ink-700); background: var(--surface-muted); }
        :root[data-theme="dark"] .staff-link-section { border-top-color: var(--line); }
        :root[data-theme="dark"] .staff-link-section p,
        :root[data-theme="dark"] .footer-note        { color: var(--ink-500); }

        /* =========================================================
           Theme toggle (injected at runtime — matches admin_dashboard pill)
           ========================================================= */
        .theme-toggle {
            position: fixed;
            top: 16px; right: 16px;
            z-index: 1000;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: none;
            border: 1.5px solid rgba(255, 255, 255, 0.45);
            border-radius: 50px;
            padding: 6px 14px 6px 8px;
            cursor: pointer;
            font-size: 0.82rem;
            font-weight: 600;
            color: #fff;
            transition: all 0.25s ease;
            white-space: nowrap;
            letter-spacing: 0.2px;
            flex-shrink: 0;
            user-select: none;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.45);
        }
        .theme-toggle:hover {
            border-color: rgba(255, 255, 255, 0.7);
            background: rgba(255, 255, 255, 0.12);
            transform: translateY(-1px);
        }
        .theme-toggle:focus-visible {
            outline: none;
            box-shadow: 0 0 0 4px rgba(108, 132, 230, 0.45);
        }
        .theme-toggle .toggle-track {
            width: 34px;
            height: 18px;
            background: rgba(255, 255, 255, 0.35);
            border-radius: 50px;
            position: relative;
            transition: background 0.25s;
            flex-shrink: 0;
        }
        .theme-toggle .toggle-thumb {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
            transition: transform 0.25s ease;
        }
        .theme-toggle .toggle-icon {
            font-size: 0.9rem;
            transition: transform 0.4s ease;
            display: flex;
            align-items: center;
        }
        :root[data-theme="dark"] .theme-toggle {
            border-color: rgba(147, 197, 253, 0.4);
            color: #93c5fd;
            background: rgba(59, 130, 246, 0.1);
        }
        :root[data-theme="dark"] .theme-toggle:hover {
            background: rgba(59, 130, 246, 0.2);
            border-color: #93c5fd;
            color: #bfdbfe;
        }
        :root[data-theme="dark"] .theme-toggle .toggle-track {
            background: #3b82f6;
        }
        :root[data-theme="dark"] .theme-toggle .toggle-thumb {
            transform: translateX(16px);
        }
        :root[data-theme="dark"] .theme-toggle .toggle-icon {
            transform: rotate(360deg);
        }