/* ==========================================================================
   Skip to Secure | Defense Training — shared theme
   One stylesheet for the landing page, student app, teacher app and sign-in
   screens. No external requests: fonts are self-hosted in /shared/fonts.

   Contents
     1. Fonts            7. Tabs                 13. Logs
     2. Tokens           8. Cards & sections     14. Teacher dashboard
     3. Base             9. Tables               15. Modal
     4. Buttons         10. Forms & toggles      16. Toasts & inline messages
     5. Auth screens    11. Pills & badges       17. States (empty/loading/error)
     6. Top bar/header  12. Routing / VLAN / UTM 18. Responsive & motion
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/shared/fonts/inter-latin-var.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/shared/fonts/jetbrains-mono-latin-var.woff2') format('woff2');
}

/* 2. Tokens --------------------------------------------------------------- */
:root {
    color-scheme: dark;

    /* Surfaces: layered slate, darkest at the back */
    --bg: #0a0e13;
    --bg-raised: #0e1319;
    --surface: #121821;
    --surface-2: #18202b;
    --surface-3: #1e2835;
    --surface-inset: #0c1117;
    --border: #232d3a;
    --border-strong: #324154;
    --overlay: rgba(4, 7, 11, 0.72);

    /* Text (all >= 4.5:1 on --surface; see e2e contrast check) */
    --text: #e7ecf2;
    --text-muted: #a6b1c0;
    --text-subtle: #8a97a8;
    --text-on-accent: #17120a;

    /* One accent: refined amber (from the original #ffd700, desaturated) */
    --accent: #e2b04a;
    --accent-hover: #ecc066;
    --accent-text: #ecc36b;
    --accent-soft: rgba(226, 176, 74, 0.13);
    --accent-ring: rgba(226, 176, 74, 0.55);

    /* Semantic colours: only for meaning */
    --allow: #4cc38a;
    --allow-soft: rgba(76, 195, 138, 0.13);
    --deny: #f0736b;
    --deny-strong: #b8433c;
    --deny-soft: rgba(240, 115, 107, 0.13);
    --warn: #e9a83b;
    --warn-soft: rgba(233, 168, 59, 0.13);
    --info: #6ea9ef;
    --info-soft: rgba(110, 169, 239, 0.13);

    /* Spacing: 4px scale */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.5);

    --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;

    --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 26px;

    --control-h: 36px;
    --control-h-sm: 30px;
    --topbar-h: 56px;
    --ease: 120ms ease;
}

/* 3. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.25; color: var(--text); letter-spacing: -0.01em; }

a { color: var(--accent-text); }

code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon, .tab svg, .section-icon svg, .btn-icon svg {
    width: 16px; height: 16px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* Scrollbars (Chromium) */
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }

/* 4. Buttons -------------------------------------------------------------- */
.btn-primary, .btn-secondary, .btn-small, .btn-reset, .btn-lock, .btn-cancel,
.btn-confirm-reset, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    height: var(--control-h);
    padding: 0 var(--s-4);
    border-radius: var(--radius);
    border: 1px solid transparent;
    font: inherit; font-size: var(--fs-sm); font-weight: 550;
    line-height: 1; white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
    user-select: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: #d5a23d; }

.btn-secondary, .btn-cancel, .btn-lock {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover, .btn-cancel:hover, .btn-lock:hover { background: var(--surface-3); border-color: #3e4f65; }

.btn-small {
    height: var(--control-h-sm);
    padding: 0 var(--s-3);
    font-size: var(--fs-xs);
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-small:hover { background: var(--surface-3); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    height: var(--control-h-sm);
    padding: 0 var(--s-3);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

/* Danger: delete, clear, reset, remove */
.btn-danger, .btn-reset, .btn-danger-outline {
    color: var(--deny) !important;
    background: transparent;
    border-color: rgba(240, 115, 107, 0.45) !important;
}
.btn-danger:hover, .btn-reset:hover, .btn-danger-outline:hover {
    background: var(--deny-soft) !important;
    border-color: var(--deny) !important;
}
.btn-confirm-reset {
    background: var(--deny-strong);
    color: #fff;
}
.btn-confirm-reset:hover { background: #a83a34; }

/* Lock toggle shows state */
.btn-lock { color: var(--allow); border-color: rgba(76, 195, 138, 0.45); }
.btn-lock::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}
.btn-lock.locked { color: var(--warn); border-color: rgba(233, 168, 59, 0.5); }

button:disabled, .btn-primary:disabled, .btn-secondary:disabled, .btn-small:disabled {
    opacity: 0.5; cursor: not-allowed; box-shadow: none;
}

.btn-block { width: 100%; }

/* Loading state (teacher sign-in) */
.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(23, 18, 10, 0.35); border-top-color: var(--text-on-accent);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 5. Auth screens: landing, student join, teacher sign-in ----------------- */
.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(380px, 46%) 1fr;
    background: var(--bg);
}

.auth-brand {
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: var(--s-10) var(--s-12);
    background:
        radial-gradient(1200px 500px at 0% 0%, rgba(226, 176, 74, 0.07), transparent 60%),
        linear-gradient(160deg, #0f151d 0%, #0b1016 100%);
    border-right: 1px solid var(--border);
}
/* Subtle network grid */
.auth-brand::before {
    content: '';
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(148, 170, 196, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 170, 196, 0.06) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
    pointer-events: none;
}
.auth-brand > * { position: relative; }

.brand-network {
    position: absolute !important; right: -40px; bottom: 40px;
    width: 420px; max-width: 80%; height: auto;
    opacity: 0.55;
    pointer-events: none;
}
.brand-network line { stroke: rgba(148, 170, 196, 0.22); stroke-width: 1; }
.brand-network circle { fill: #18202b; stroke: rgba(148, 170, 196, 0.45); stroke-width: 1.2; }
.brand-network circle.hub { stroke: var(--accent); fill: rgba(226, 176, 74, 0.12); }

.brand-lockup { display: flex; align-items: center; gap: var(--s-3); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.brand-name { font-weight: 700; font-size: var(--fs-md); letter-spacing: -0.01em; color: var(--text); }
.brand-divider { color: var(--border-strong); font-weight: 300; }
.brand-product { font-weight: 500; font-size: var(--fs-md); color: var(--text-muted); }

.brand-body { max-width: 440px; margin: var(--s-12) 0; }
.brand-headline { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: var(--s-4); }
.brand-copy { color: var(--text-muted); font-size: var(--fs-md); line-height: 1.6; }

.brand-points { list-style: none; display: grid; gap: var(--s-2); color: var(--text-muted); font-size: var(--fs-sm); }
.brand-points li { display: flex; align-items: center; gap: var(--s-2); }
.brand-points li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.8; }

.auth-main {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: var(--s-10) var(--s-6);
    gap: var(--s-6);
}

.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--s-8);
    box-shadow: var(--shadow-2);
}
.auth-eyebrow {
    display: inline-flex; align-items: center; gap: var(--s-2);
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--accent-text);
    margin-bottom: var(--s-2);
}
.auth-title { font-size: var(--fs-xl); margin-bottom: var(--s-2); }
.auth-subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--s-6); }
.auth-field { margin-bottom: var(--s-4); }
.auth-field label, .auth-card .form-label {
    display: block; font-size: var(--fs-sm); font-weight: 550; color: var(--text); margin-bottom: var(--s-2);
}
.auth-card input[type="text"], .auth-card input[type="password"], .auth-card .form-input-inline {
    width: 100%; height: 40px;
    padding: 0 var(--s-3);
    background: var(--surface-inset);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit; font-size: var(--fs-md);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-card input[readonly] { color: var(--text-muted); background: var(--surface-2); cursor: default; }
.auth-card input[readonly]:focus { box-shadow: none; border-color: var(--border-strong); }
.auth-card .btn-primary, .login-card button[type="submit"] { width: 100%; height: 40px; font-size: var(--fs-base); margin-top: var(--s-2); }
.field-hint { margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-subtle); }
.code-input { font-family: var(--font-mono) !important; letter-spacing: 0.25em; text-transform: uppercase; }

.password-field { position: relative; }
.password-field input { padding-right: 44px !important; }
.password-toggle {
    position: absolute; right: 4px; top: 4px; width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: var(--radius-sm);
    color: var(--text-subtle); cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-2); }
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-off { display: none; }
.password-toggle.is-revealed .eye-on { display: none; }
.password-toggle.is-revealed .eye-off { display: block; }

.auth-error, .login-error {
    min-height: 20px; margin-top: var(--s-3);
    font-size: var(--fs-sm); color: var(--deny);
}
.auth-error:not(:empty), .login-error:not(:empty) {
    display: flex; gap: var(--s-2); align-items: flex-start;
    padding: var(--s-2) var(--s-3);
    background: var(--deny-soft);
    border: 1px solid rgba(240, 115, 107, 0.35);
    border-radius: var(--radius);
}
.auth-note { font-size: var(--fs-sm); color: var(--text-muted); text-align: center; margin-top: var(--s-5); }
.auth-footer { font-size: var(--fs-xs); color: var(--text-subtle); letter-spacing: 0.02em; display: flex; align-items: center; gap: var(--s-2); }
.auth-footer svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* Teacher sign-in overlay keeps its id/class; lay it out as the auth screen */
.login-overlay { position: fixed; inset: 0; z-index: 2000; background: var(--bg); overflow-y: auto; }
.login-overlay .auth-layout { min-height: 100%; }
.login-card { max-width: 400px; }
.login-card h2 { font-size: var(--fs-xl); margin-bottom: var(--s-2); }

/* Student join screen: shown until signed in */
.app-student #joinScreen { display: grid; }
.app-student.is-signed-in #joinScreen { display: none; }
.app-student:not(.is-signed-in) .topbar,
.app-student:not(.is-signed-in) > .container { display: none; }

.class-info {
    display: flex; align-items: center; gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    margin-bottom: var(--s-5);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--fs-sm); color: var(--text-muted);
}
.class-info:empty { display: none; }
.class-info::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none;
}

.auth-card .student-info .form-row { display: grid; gap: var(--s-2); }
.auth-card .form-group-inline { display: block; }

.session-status { min-height: 20px; margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--text-muted); }
.session-status.error {
    color: var(--deny);
    padding: var(--s-2) var(--s-3);
    background: var(--deny-soft);
    border: 1px solid rgba(240, 115, 107, 0.35);
    border-radius: var(--radius);
}
.session-status.warning { color: var(--warn); }
.session-status.success { color: var(--allow); }

/* 6. Top bar & page header ------------------------------------------------ */
.topbar {
    position: sticky; top: 0; z-index: 900;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--s-4);
    padding: 0 var(--s-6);
    background: rgba(14, 19, 25, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar .brand-lockup { gap: var(--s-2); }
.topbar .brand-mark { width: 22px; height: 22px; }
.topbar .brand-name, .topbar .brand-product { font-size: var(--fs-sm); }
.topbar-sep { width: 1px; height: 24px; background: var(--border); }
.topbar-class {
    font-size: var(--fs-sm); font-weight: 550; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.topbar-nick { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.role-badge {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    padding: 3px var(--s-2); border-radius: var(--radius-pill);
    color: var(--accent-text); background: var(--accent-soft); border: 1px solid rgba(226, 176, 74, 0.3);
}

.container { max-width: 1320px; margin: 0 auto; padding: var(--s-6); }

.header {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
    margin-bottom: var(--s-5);
}
.header h1 { font-size: var(--fs-xl); }
.header > p { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--s-1); max-width: 760px; }
.page-title-group { min-width: 0; }

/* Teacher class toolbar */
.teacher-info { width: 100%; }
.teacher-controls {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.scenario-info { flex: 1; min-width: 260px; display: grid; gap: 2px; }
.scenario-title { font-weight: 600; font-size: var(--fs-md); }
.scenario-details { font-size: var(--fs-sm); color: var(--text-muted); }
.class-meta { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--s-1); display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.class-meta code {
    color: var(--accent-text); background: var(--surface-inset); border: 1px solid var(--border);
    padding: 2px var(--s-2); border-radius: var(--radius-sm); user-select: all;
}

/* Exercise file bar (export / import / template library), second row of the toolbar */
.exercise-bar {
    flex-basis: 100%;
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
    margin-top: var(--s-2); padding-top: var(--s-3);
    border-top: 1px solid var(--border);
}
.exercise-bar-label {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-subtle); margin-right: var(--s-1);
}
.exercise-bar .btn-secondary { display: inline-flex; align-items: center; gap: 6px; }
.exercise-bar .btn-secondary svg {
    width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
.exercise-bar .exercise-template-select { flex: 0 0 auto; width: auto; min-width: 210px; max-width: 320px; height: var(--control-h); }
.loaded-exercise {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
    margin-left: var(--s-1); padding: 4px var(--s-3);
    font-size: var(--fs-sm); color: var(--text-muted);
    background: var(--allow-soft); border: 1px solid rgba(76, 195, 138, 0.35); border-radius: var(--radius-pill);
}
.loaded-exercise[hidden] { display: none; }
.loaded-exercise strong {
    color: var(--text); font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px;
}
.loaded-exercise svg { flex: none; width: 14px; height: 14px; fill: none; stroke: var(--allow); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Footer privacy link (sign-in screens and the bottom of the apps) */
.auth-footer .footer-link, .app-footer a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.auth-footer .footer-link:hover, .app-footer a:hover { color: var(--text); }
.auth-footer .footer-sep { color: var(--border-strong); }
.app-footer {
    margin-top: var(--s-8); padding: var(--s-4) 0 var(--s-6);
    border-top: 1px solid var(--border);
    font-size: var(--fs-xs); color: var(--text-subtle); text-align: center;
}
.student-number-input { font-family: var(--font-mono); letter-spacing: 0.06em; }

/* Privacy page */
.brand-link { text-decoration: none; color: inherit; }
.privacy-page {
    max-width: 720px; margin: 0 auto; padding: var(--s-10) var(--s-5) var(--s-12);
    color: var(--text-muted); font-size: var(--fs-md); line-height: 1.65;
}
.privacy-page h1 { font-size: var(--fs-2xl); color: var(--text); margin-bottom: var(--s-3); }
.privacy-page .privacy-lede { font-size: var(--fs-lg); color: var(--text); margin-bottom: var(--s-8); }
.privacy-page section {
    margin-bottom: var(--s-5); padding: var(--s-5) var(--s-6);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.privacy-page h2 { font-size: var(--fs-lg); color: var(--text); margin-bottom: var(--s-3); }
.privacy-page ul { margin-left: var(--s-5); display: grid; gap: var(--s-2); }
.privacy-page strong { color: var(--text); }
.privacy-page a { color: var(--accent-text); }
.privacy-page .privacy-footer { margin-top: var(--s-6); font-size: var(--fs-sm); }
@media (max-width: 600px) { .privacy-page { padding: var(--s-6) var(--s-4) var(--s-10); } .privacy-page section { padding: var(--s-4); } }

/* 7. Tabs: segmented nav ---------------------------------------------------- */
.tabs {
    display: flex; gap: 2px;
    padding: 3px;
    margin-bottom: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}
.tab {
    position: relative;
    flex: 1 1 0; min-width: max-content;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    height: 38px; padding: 0 var(--s-4);
    background: transparent; border: 0; border-radius: 7px;
    color: var(--text-muted);
    font: inherit; font-size: var(--fs-sm); font-weight: 550;
    cursor: pointer;
    transition: background-color var(--ease), color var(--ease);
}
.tab svg { pointer-events: none; opacity: 0.85; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-3); box-shadow: var(--shadow-1); }
.tab.active::after {
    content: ''; position: absolute; left: 22%; right: 22%; bottom: 3px; height: 2px;
    border-radius: 2px; background: var(--accent);
}
.tab.active svg { color: var(--accent); opacity: 1; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* 8. Cards & sections ------------------------------------------------------- */
.rules-list, .rule-builder, .routing-section, .utm-section, .log-content, .log-form, .student-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--s-5);
    margin-bottom: var(--s-5);
}
.routing-section .rules-list { padding: 0; border: 0; margin: 0; background: transparent; }

.rules-header, .log-form-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
    padding-bottom: var(--s-4); margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}
.rules-header > div:last-child, .log-form-header > div:last-child { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.rules-title { font-size: var(--fs-md); font-weight: 600; }

.section-header { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); }
.log-form-header .section-header { margin-bottom: 0; }
.section-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius);
    background: var(--accent-soft); color: var(--accent-text);
}
.section-title { font-size: var(--fs-md); font-weight: 600; }

.rule-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.rule-section {
    padding: var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.routing-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.routing-sections .routing-section { margin-bottom: 0; }
.routing-sections + .rules-list { margin-top: var(--s-5); }

.help-text, .utm-help-text {
    padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4);
    background: var(--info-soft); border: 1px solid rgba(110, 169, 239, 0.3); border-left: 3px solid var(--info);
    border-radius: var(--radius); color: var(--text); font-size: var(--fs-sm); line-height: 1.6;
}
.warning-text, .utm-warning-text {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
    padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4);
    background: var(--warn-soft); border: 1px solid rgba(233, 168, 59, 0.3); border-left: 3px solid var(--warn);
    border-radius: var(--radius); color: var(--text); font-size: var(--fs-sm); line-height: 1.6;
}
.warning-text .btn-secondary { height: var(--control-h-sm); font-size: var(--fs-xs); }
.section-footer { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin-top: var(--s-5); }
.section-spacer { margin-top: var(--s-6); }

/* 9. Tables (div grids for rules/routes, real table for UTM) ---------------- */
.rules-table-header, .rule-grid {
    display: grid;
    grid-template-columns: 104px minmax(130px, 1.35fr) minmax(130px, 1.35fr) minmax(84px, 0.8fr) minmax(90px, 0.85fr) minmax(76px, 0.7fr) 150px;
    align-items: center;
    column-gap: var(--s-3);
}
.route-table-header, .route-item {
    display: grid;
    grid-template-columns: minmax(130px, 1.4fr) minmax(120px, 1.2fr) minmax(80px, 0.8fr) 104px 140px;
    align-items: center;
    column-gap: var(--s-3);
}
.rules-table-header, .route-table-header {
    position: sticky; top: var(--topbar-h); z-index: 5;
    padding: 0 var(--s-4);
    height: 36px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}
.header-cell {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-subtle);
}

#rulesContainer, #answerKeyContainer, #routesContainer, #answerRouteContainer {
    border: 1px solid var(--border); border-top: 0;
    min-width: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}
#rulesContainer:empty, #answerKeyContainer:empty, #routesContainer:empty, #answerRouteContainer:empty { display: none; }

.rule-item {
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
    transition: background-color var(--ease);
}
.rule-item:first-child { border-top: 0; }
.rule-item:hover, .route-item:hover { background: rgba(255, 255, 255, 0.022); }
.rule-item.default-rule { background: var(--surface-inset); }
.rule-cell { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.actions-col { justify-content: flex-end; }
.actions-col .btn-secondary { height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-xs); }
.cell-content { flex: 1; min-width: 0; }
.primary-text { font-size: var(--fs-sm); font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.secondary-text { font-size: var(--fs-xs); color: var(--text-subtle); }
.source-col .primary-text, .dest-col .primary-text, .port-col .primary-text, .interface-col .primary-text {
    font-family: var(--font-mono); font-size: 12.5px; font-weight: 450;
}
.rule-description {
    margin-top: var(--s-2); padding-left: 116px;
    font-size: var(--fs-sm); color: var(--text-muted);
}
.default-rule-description { color: var(--text-subtle); font-style: italic; }

.route-item { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); }
.route-item:first-child { border-top: 0; }
.route-cell { font-size: var(--fs-sm); min-width: 0; overflow-wrap: anywhere; }
.route-cell:nth-child(1), .route-cell:nth-child(2) { font-family: var(--font-mono); font-size: 12.5px; }
.route-cell:last-child { display: flex; gap: var(--s-2); justify-content: flex-end; }

/* UTM matrix */
.assignment-matrix, .utm-matrix-table { overflow-x: auto; border-radius: var(--radius); }
.matrix-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.matrix-header th {
    position: sticky; top: 0; z-index: 2;
    padding: var(--s-3);
    background: var(--surface-2);
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-subtle); text-align: center; white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.matrix-header th:first-child { text-align: left; min-width: 220px; }
.matrix-table td { padding: var(--s-3); border-top: 1px solid var(--border); text-align: center; vertical-align: middle; }
.matrix-table tbody tr:first-child td { border-top: 0; }
.matrix-table td:first-child { text-align: left; }
.matrix-row:hover td { background: rgba(255, 255, 255, 0.022); }
.utm-policy-checkbox, .policy-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.target-info { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.target-icon:empty { display: none; }
.target-name { font-weight: 550; font-size: var(--fs-sm); }
.target-details { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: 2px; }
.utm-summary { display: flex; gap: var(--s-6); flex-wrap: wrap; margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--text-muted); }

/* 10. Forms & toggles -------------------------------------------------------- */
.form-group { margin-bottom: var(--s-4); }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: var(--fs-sm); font-weight: 550; color: var(--text); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea, .form-input-inline {
    width: 100%; height: var(--control-h);
    padding: 0 var(--s-3);
    background: var(--surface-inset);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit; font-size: var(--fs-base);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.form-input::placeholder, .form-textarea::placeholder, .form-input-inline::placeholder, .auth-card input::placeholder { color: #8190a5; }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: #3e4f65; }
.form-input:focus, .form-select:focus, .form-textarea:focus, .form-input-inline:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-select {
    appearance: none; -webkit-appearance: none;
    padding-right: 32px;
    background-image: url('/shared/img/chevron-down.svg'); /* a file, not data:, so CSP img-src can be 'self' */
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.form-select option { background: var(--surface); color: var(--text); }
.form-textarea {
    height: auto; min-height: 260px; padding: var(--s-3);
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; resize: vertical;
}
.form-input.mono { font-family: var(--font-mono); font-size: 13px; }
.subnet-hint { margin-top: 6px; font-size: var(--fs-xs); color: var(--text-subtle); }

.form-row { display: flex; gap: var(--s-3); align-items: flex-end; }
.form-group-inline { flex: 1; }
.form-group-inline:last-child { flex: 0 0 auto; }

/* Segmented choice buttons (Allow/Deny, direction) */
.action-buttons, .direction-buttons {
    display: flex; gap: 2px; padding: 3px;
    background: var(--surface-inset); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.action-btn, .direction-btn {
    flex: 1; height: 30px;
    background: transparent; border: 1px solid transparent; border-radius: 4px;
    color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: 550;
    cursor: pointer; transition: background-color var(--ease), color var(--ease);
}
.action-btn:hover, .direction-btn:hover { color: var(--text); background: var(--surface-2); }
.direction-btn.active { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.action-btn.allow.active { background: var(--allow-soft); color: var(--allow); border-color: rgba(76, 195, 138, 0.45); }
.action-btn.deny.active { background: var(--deny-soft); color: var(--deny); border-color: rgba(240, 115, 107, 0.45); }

/* Switches */
.toggle-switch, .toggle-switch-small { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.toggle-switch .form-label { margin-bottom: 0; }
.toggle, .toggle-small {
    position: relative; flex: none;
    width: 40px; height: 22px; border-radius: var(--radius-pill);
    background: var(--surface-3); border: 1px solid var(--border-strong);
    cursor: pointer; transition: background-color var(--ease), border-color var(--ease);
}
.toggle::after, .toggle-small::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #c3ccd8; box-shadow: var(--shadow-1);
    transition: transform var(--ease), background-color var(--ease);
}
.toggle.active, .toggle-small.active { background: var(--accent); border-color: var(--accent); }
.toggle.active::after, .toggle-small.active::after { transform: translateX(18px); background: #fff; }
.toggle-small { width: 34px; height: 20px; }
.toggle-small::after { width: 14px; height: 14px; }
.toggle-small.active::after { transform: translateX(14px); }

/* 11. Pills & badges ----------------------------------------------------------- */
.action-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 56px; height: 22px; padding: 0 var(--s-2);
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.04em;
    border: 1px solid transparent;
}
.action-badge.allow { color: var(--allow); background: var(--allow-soft); border-color: rgba(76, 195, 138, 0.35); }
.action-badge.deny { color: var(--deny); background: var(--deny-soft); border-color: rgba(240, 115, 107, 0.35); }
.action-badge.disabled { color: var(--text-subtle); background: transparent; border-color: var(--border-strong); text-decoration: line-through; }

.status-indicator { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-enabled { background: var(--allow); box-shadow: 0 0 0 3px var(--allow-soft); }
.status-disabled { background: #5b6878; }

.route-type, .interface-type, .rejoin-badge, .policy-count {
    display: inline-flex; align-items: center; height: 20px; padding: 0 var(--s-2);
    border-radius: var(--radius-pill);
    font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
    border: 1px solid var(--border-strong); color: var(--text-muted); background: var(--surface-2);
}
.route-type.default { color: var(--accent-text); border-color: rgba(226, 176, 74, 0.4); background: var(--accent-soft); }
.route-type.static { color: var(--info); border-color: rgba(110, 169, 239, 0.4); background: var(--info-soft); }
.interface-type.type-vlan { color: var(--info); border-color: rgba(110, 169, 239, 0.4); background: var(--info-soft); }
.policy-count { min-width: 22px; justify-content: center; color: var(--text); text-transform: none; }
.rejoin-badge.signed-out-badge { color: var(--text-muted); border-color: var(--border-strong); background: var(--surface-3); }
.rejoin-badge { color: var(--warn); border-color: rgba(233, 168, 59, 0.45); background: var(--warn-soft); text-transform: none; letter-spacing: 0; }

/* 12. Routing / VLANs ------------------------------------------------------------ */
.vlan-list {
    max-height: 260px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface-inset);
}
.vlan-item {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3);
    border-top: 1px solid var(--border);
}
.vlan-item:first-child { border-top: 0; }
.vlan-item:hover { background: rgba(255, 255, 255, 0.022); }
.vlan-info { flex: 1; min-width: 0; }
.vlan-name { font-size: var(--fs-sm); font-weight: 550; }
.vlan-details { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.dhcp-toggle { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.dhcp-checkbox { width: 16px; height: 16px; accent-color: var(--accent); }
.vlan-actions { display: flex; gap: var(--s-2); }
.routing-section > .btn-primary { margin-top: var(--s-1); }

/* 13. Logs ----------------------------------------------------------------------- */
.log-viewer { max-height: min(72vh, 760px); overflow-y: auto; }
.logs-header {
    display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3);
    padding-bottom: var(--s-4); margin-bottom: var(--s-4); border-bottom: 1px solid var(--border);
}
.logs-header h2 { font-size: var(--fs-md); flex: 1; }
.logs-header p { width: 100%; order: 3; font-size: var(--fs-sm); color: var(--text-muted); }
.logs-controls { display: flex; gap: var(--s-2); }
.logs-controls .btn-secondary { height: var(--control-h-sm); font-size: var(--fs-xs); }
.logs-list { display: grid; gap: var(--s-4); }
.log-entry { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-inset); }
.log-entry .log-header, .log-item .log-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.log-title-section { flex: 1; min-width: 0; }
.log-title { font-size: var(--fs-md); font-weight: 600; }
.log-meta { display: flex; flex-wrap: wrap; gap: var(--s-3); font-size: var(--fs-xs); color: var(--text-subtle); margin-top: 2px; }
.log-actions { display: flex; gap: var(--s-2); }
.log-actions .btn-secondary { height: var(--control-h-sm); font-size: var(--fs-xs); }
.log-content-container { max-height: 420px; overflow: auto; padding: var(--s-2) 0; }
.log-line {
    position: relative;
    display: block;
    padding: 0 var(--s-4) 0 56px;
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7;
    color: #c9d2de;
    border-left: 2px solid transparent;
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.log-line::before {
    content: attr(data-line);
    position: absolute; left: 0; top: 0; width: 42px;
    color: #8190a5; text-align: right;
    user-select: none;
}
.log-line:hover { background: rgba(255, 255, 255, 0.025); }
.log-blocked { border-left-color: rgba(240, 115, 107, 0.55); }
.log-allowed { border-left-color: rgba(76, 195, 138, 0.5); }
.log-alert, .log-ids { border-left-color: rgba(233, 168, 59, 0.55); }
.log-error { border-left-color: var(--deny); }
.log-warning { border-left-color: rgba(233, 168, 59, 0.4); }
.kw { font-weight: 650; border-radius: 3px; padding: 0 2px; }
.kw-block { color: #ff8f88; background: rgba(240, 115, 107, 0.12); }
.kw-allow { color: #6fd6a3; background: rgba(76, 195, 138, 0.12); }
.kw-alert { color: #f2bf63; background: rgba(233, 168, 59, 0.12); }
.kw-warn { color: #f2bf63; }
/* Expand/collapse: the JS swaps an emoji; show a chevron instead */
.toggle-icon { font-size: 0; display: inline-flex; width: 14px; height: 14px; align-items: center; justify-content: center; }
.toggle-icon::before {
    content: ''; width: 7px; height: 7px;
    border-right: 1.75px solid var(--text-muted); border-bottom: 1.75px solid var(--text-muted);
    transform: rotate(45deg) translate(-1px, -1px);
    transition: transform var(--ease);
}
.log-entry:has(> .log-content-container[style*="none"]) .toggle-icon::before { transform: rotate(-45deg); }

/* Teacher log editor list */
#scenarioLogsContainer { display: grid; gap: var(--s-3); }
.log-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-inset); }
.log-item .log-meta { display: block; }
.log-preview { padding: var(--s-3) var(--s-4); }
.log-content-preview {
    max-height: 60px; overflow: hidden;
    font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: pre-wrap;
}
.auto-save-indicator { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: var(--s-2); }

/* 14. Teacher dashboard ---------------------------------------------------------- */
#studentsContainer { display: grid; gap: var(--s-3); }
.student-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px auto;
    align-items: center; gap: var(--s-5);
    padding: var(--s-4) var(--s-5);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--ease);
}
.student-item:hover { border-color: var(--border-strong); }
.student-item .student-info { min-width: 0; }
.student-name { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; font-size: var(--fs-md); }
.student-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: 2px; font-size: var(--fs-xs); }
.summary-correct { color: var(--allow); }
.summary-missing { color: var(--deny); }
.summary-extra { color: var(--warn); }
.summary-activity { color: var(--text-subtle); }
.summary-breakdown { color: var(--text-subtle); }
.student-progress {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2) var(--s-4);
    margin-top: var(--s-3); max-width: 640px;
}
.progress-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px var(--s-2); }
.progress-label { grid-row: 1; grid-column: 1; font-size: var(--fs-xs); color: var(--text-muted); }
.progress-value { grid-row: 1; grid-column: 2; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.progress-track { grid-row: 2; grid-column: 1 / -1; height: 5px; border-radius: var(--radius-pill); background: var(--surface-inset); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 150ms ease; }

.student-score { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.student-score-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.student-score-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); }
.score-high .student-score-value { color: var(--allow); }
.score-mid .student-score-value { color: var(--warn); }
.score-low .student-score-value { color: var(--text); }
.student-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.student-actions .btn-secondary { height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-xs); }

.activity-indicator { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.activity-active { background: var(--allow); box-shadow: 0 0 0 3px var(--allow-soft); }
.activity-recent { background: var(--warn); }
.activity-idle { background: #5b6878; }

/* Student details modal */
.details-body { max-height: 74vh; overflow-y: auto; padding-right: var(--s-2); }
.details-title { font-size: var(--fs-lg); margin-bottom: var(--s-4); }
.details-title-sub { font-size: var(--fs-sm); font-weight: 500; color: var(--text-subtle); margin-left: var(--s-2); }
.details-summary {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4);
    padding: var(--s-4); margin-bottom: var(--s-5);
    background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--radius);
    font-size: var(--fs-sm);
}
.details-breakdown { width: 100%; color: var(--text-subtle); font-size: var(--fs-xs); }
.details-section-title {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-subtle); margin: var(--s-5) 0 var(--s-2);
}
.details-card {
    padding: var(--s-3) var(--s-4); margin-bottom: var(--s-2);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.details-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: 4px; }
.details-card-title { font-size: var(--fs-sm); font-weight: 600; }
.details-card-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.match-status { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.match-good { color: var(--allow); }
.match-poor { color: var(--deny); }
.details-empty { padding: var(--s-4); text-align: center; color: var(--text-subtle); font-size: var(--fs-sm); }
.details-error, .details-missing { color: var(--deny); }
.details-missing { font-size: var(--fs-sm); margin: var(--s-3) 0 var(--s-2); }

/* 15. Modal -------------------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1500;
    display: none; align-items: center; justify-content: center;
    padding: var(--s-6);
    background: var(--overlay);
    backdrop-filter: blur(2px);
}
.modal {
    width: 100%; max-width: 520px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: var(--s-6);
    box-shadow: var(--shadow-3);
}
.modal.modal-wide { max-width: 1040px; }
.modal-header { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--s-4); }
.modal-header .modal-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%; background: var(--deny-soft); color: var(--deny);
}
.modal-header .modal-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.modal-content { color: var(--text-muted); font-size: var(--fs-base); }
.modal-content p { margin-bottom: var(--s-3); }
.modal-content strong { color: var(--text); }
.warning-list { margin: 0 0 var(--s-3) var(--s-5); display: grid; gap: var(--s-1); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-6); }

/* Exercise dialogs */
.modal-header .modal-icon.modal-icon-info { background: var(--accent-soft); color: var(--accent-text); }
.modal .optional { font-weight: 400; color: var(--text-subtle); }
.form-textarea.form-textarea-short { min-height: 88px; font-family: var(--font-ui); font-size: var(--fs-base); }
.form-error { min-height: 0; color: var(--deny); font-size: var(--fs-sm); }
.form-error:empty { display: none; }
.modal-note { font-size: var(--fs-sm); color: var(--text-subtle); }
.exercise-summary {
    margin-bottom: var(--s-4); padding: var(--s-4);
    background: var(--surface-inset); border: 1px solid var(--border); border-radius: var(--radius);
}
.exercise-summary-title { color: var(--text); font-weight: 600; font-size: var(--fs-md); overflow-wrap: anywhere; }
.exercise-summary-author { font-size: var(--fs-sm); color: var(--text-subtle); margin-top: 2px; }
.exercise-summary-author:empty { display: none; }
.modal-content .exercise-summary-description {
    margin: var(--s-2) 0 0; white-space: pre-line; overflow-wrap: anywhere;
    max-height: 120px; overflow-y: auto; font-size: var(--fs-sm);
}
.exercise-summary-description:empty { display: none; }
.exercise-counts {
    list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3);
}
.exercise-counts li {
    font-size: var(--fs-sm); color: var(--text-muted);
    padding: 2px var(--s-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.exercise-counts li strong { font-family: var(--font-mono); color: var(--text); margin-right: 4px; }
.checkbox-row {
    display: flex; align-items: center; gap: var(--s-2); cursor: pointer;
    color: var(--text); font-size: var(--fs-base); margin-bottom: var(--s-2);
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--deny); flex: none; }
.problem-list {
    list-style: none; display: grid; gap: var(--s-1); margin: 0 0 var(--s-3);
    max-height: 300px; overflow-y: auto;
}
.problem-list li {
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--text);
    padding: 6px var(--s-3); background: var(--deny-soft); border-left: 2px solid var(--deny); border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}
.problem-list.is-warning li { background: var(--warn-soft); border-left-color: var(--warn); }
.problem-list.is-examples li { background: var(--surface-inset); border-left-color: var(--accent); white-space: pre; }

/* 16. Toasts & inline messages ------------------------------------------------- */
.toast-region {
    /* Bottom-right, and below modals (z 1500) so they never cover dialog buttons */
    position: fixed; z-index: 1400;
    right: var(--s-5); bottom: var(--s-5);
    display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2);
    pointer-events: none;
    max-width: min(420px, calc(100vw - 32px));
}
.toast {
    pointer-events: auto;
    display: grid; grid-template-columns: 20px 1fr 24px; align-items: start; gap: var(--s-3);
    width: 100%;
    padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--info);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-sm); color: var(--text);
    animation: toast-in 150ms ease-out;
}
.toast-leaving { opacity: 0; transform: translateY(4px); transition: opacity 150ms ease, transform 150ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast-icon { width: 18px; height: 18px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast-text { line-height: 1.45; overflow-wrap: anywhere; }
.toast-close {
    width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: var(--radius-sm); color: var(--text-subtle); cursor: pointer;
}
.toast-close:hover { background: var(--surface-3); color: var(--text); }
.toast-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toast-success { border-left-color: var(--allow); } .toast-success .toast-icon { color: var(--allow); }
.toast-error { border-left-color: var(--deny); }     .toast-error .toast-icon { color: var(--deny); }
.toast-warning { border-left-color: var(--warn); }   .toast-warning .toast-icon { color: var(--warn); }
.toast-info { border-left-color: var(--info); }      .toast-info .toast-icon { color: var(--info); }

/* Old in-page message containers (fallback if toast.js failed to load) */
.success-message, .error-message, .info-message, .warning-message {
    padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3);
    border-radius: var(--radius); font-size: var(--fs-sm);
    border: 1px solid var(--border-strong); background: var(--surface-2);
}
.success-message { border-left: 3px solid var(--allow); }
.error-message { border-left: 3px solid var(--deny); }
.info-message { border-left: 3px solid var(--info); }
.warning-message { border-left: 3px solid var(--warn); }
.log-viewer .error-message, .error-state .error-message { border: 0; background: none; padding: 0; color: var(--deny); }

/* 17. States ------------------------------------------------------------------- */
.empty-message, #noRulesMessage, #noVlansMessage, #noRoutesMessage, #noAnswerKeyMessage, #noLogsMessage {
    padding: var(--s-6); text-align: center; font-size: var(--fs-sm); color: var(--text-subtle);
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
#noRulesMessage, #noRoutesMessage, #noAnswerKeyMessage { border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.empty-state, .loading-state, .no-logs-message, .no-session-state, .error-state, .utm-error, .utm-no-targets, .utm-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
    padding: var(--s-10) var(--s-6);
    text-align: center; color: var(--text-muted); font-size: var(--fs-sm);
}
.empty-state h3, .loading-state h3, .error-state h3, .utm-error h3, .utm-no-targets h3, .utm-loading h3 { font-size: var(--fs-md); color: var(--text); }
.no-logs-message .empty-state, .no-session-state .empty-state { padding: 0; }
.empty-state-icon { width: 32px; height: 32px; fill: none; stroke: var(--text-subtle); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: var(--s-1); }
.empty-state-link {
    padding: var(--s-2) var(--s-3); border-radius: var(--radius);
    background: var(--surface-inset); border: 1px solid var(--border); color: var(--accent-text); user-select: all;
}
.empty-icon, .error-icon, .loading-spinner { display: none; }
.loading-state::before, .utm-loading::before {
    content: ''; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
#studentsContainer > .loading-state.empty-state::before { display: none; }
.loading-dots { display: none; }
.error-details { font-size: var(--fs-xs); color: var(--text-subtle); text-align: left; }
.error-details ul { margin: var(--s-1) 0 0 var(--s-5); }
.error-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-2); }
.empty-content { color: var(--text-subtle); padding: var(--s-3) var(--s-4); }
.utm-loading-inline { color: var(--text-subtle); padding: var(--s-5); text-align: center; font-size: var(--fs-sm); }

.temporary-notification { display: none; }

/* 18. Responsive & motion ------------------------------------------------------ */
@media (max-width: 1180px) {
    .student-item { grid-template-columns: minmax(0, 1fr) 88px; }
    .student-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}
@media (max-width: 1100px) {
    .rules-table-header, .rule-grid { grid-template-columns: 96px minmax(110px, 1fr) minmax(110px, 1fr) 72px 80px 70px 136px; }
    .rule-description { padding-left: 108px; }
}
@media (max-width: 960px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-brand { padding: var(--s-6); border-right: 0; border-bottom: 1px solid var(--border); }
    .brand-body { margin: var(--s-5) 0 0; }
    .brand-headline { font-size: 22px; }
    .brand-points, .brand-network { display: none; }
    .rule-sections, .routing-sections { grid-template-columns: 1fr; }
    .topbar .brand-product, .topbar .brand-divider { display: none; }
}
@media (max-width: 860px) {
    .rules-table-header, .route-table-header { display: none; }
    .rule-grid, .route-item { grid-template-columns: 1fr 1fr; row-gap: var(--s-2); }
    .actions-col, .route-cell:last-child { grid-column: 1 / -1; justify-content: flex-start; }
    .rule-description { padding-left: 0; }
    .student-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .container { padding: var(--s-4); }
    .topbar { padding: 0 var(--s-4); }
}
@media (min-width: 1700px) {
    .container { max-width: 1480px; }
    body { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
        animation-iteration-count: 1 !important;
    }
    .is-loading::after, .loading-state::before, .utm-loading::before { animation: spin 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
@media (forced-colors: active) {
    .tab.active { outline: 2px solid CanvasText; }
    .toggle.active, .toggle-small.active { background: Highlight; }
}

/* Teacher: class name lives in the top bar */
.topbar .topbar-class.scenario-title { font-size: var(--fs-sm); font-weight: 550; }

/* UTM tab: the matrix renders its own help + strategy text; hide the static
   duplicates once it has (the teacher's template buttons are never hidden). */
.app-student #utm-tab:has(.utm-help-text) > .help-text { display: none; }
.app-student .utm-section:has(.utm-warning-text) > .warning-text { display: none; }

/* Teacher route answer key sits in a half-width column: let its table scroll */
.routing-section .rules-list { overflow-x: auto; }
