/* ==========================================================================
   SmartSchool — Design System
   RTL · Persian · Dark-first with light theme · Glassmorphism · 3D depth
   ========================================================================== */

/* ------------------------------------------------------------------ Fonts */
/* Vazirmatn — SIL Open Font License 1.1 (wwwroot/fonts/Vazirmatn-OFL.txt).
   Self-hosted so the UI and the PDF renderer use the exact same Persian face,
   with no dependency on a CDN or on fonts installed on the visitor's machine. */
@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ------------------------------------------------------------ Fonts/Reset */
:root {
    --font-fa: "Vazirmatn", "IRANSansX", "IRANSans", "Segoe UI", Tahoma, "Arial", sans-serif;
    --font-mono: "Cascadia Code", "Consolas", monospace;

    /* Brand */
    --brand-1: #6366f1;
    --brand-2: #8b5cf6;
    --brand-3: #06b6d4;
    --brand-4: #ec4899;
    --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #06b6d4 100%);
    --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,.22), rgba(6,182,212,.16));

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --excellent: #10b981;
    --good: #22c55e;
    --average: #f59e0b;
    --weak: #ef4444;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --shadow-1: 0 1px 2px rgba(0,0,0,.16), 0 1px 3px rgba(0,0,0,.12);
    --shadow-2: 0 4px 16px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.14);
    --shadow-3: 0 18px 48px rgba(0,0,0,.34), 0 6px 16px rgba(0,0,0,.2);
    --shadow-glow: 0 0 0 1px rgba(139,92,246,.28), 0 18px 60px -18px rgba(99,102,241,.6);

    --ease: cubic-bezier(.22, 1, .36, 1);
    --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
    --dur: .38s;

    --sidebar-w: 268px;
    --topbar-h: 68px;
}

html[data-theme="dark"] {
    --bg-0: #06070f;
    --bg-1: #0b0d1a;
    --bg-2: #11142270;
    --surface: rgba(20, 23, 42, .72);
    --surface-2: rgba(28, 32, 55, .82);
    --surface-solid: #141728;
    --surface-hover: rgba(139, 92, 246, .1);
    --border: rgba(148, 163, 184, .14);
    --border-strong: rgba(148, 163, 184, .26);
    --text: #eef1f8;
    --text-2: #b9c0d4;
    --text-3: #7c85a0;
    --grid-line: rgba(148,163,184,.1);
    --overlay: rgba(4,6,14,.72);
}

html[data-theme="light"] {
    --bg-0: #f5f7fc;
    --bg-1: #eef1f9;
    --bg-2: #ffffff;
    --surface: rgba(255,255,255,.86);
    --surface-2: rgba(255,255,255,.95);
    --surface-solid: #ffffff;
    --surface-hover: rgba(99,102,241,.07);
    --border: rgba(15,23,42,.09);
    --border-strong: rgba(15,23,42,.18);
    --text: #131a2e;
    --text-2: #4a5470;
    --text-3: #7b849b;
    --grid-line: rgba(15,23,42,.07);
    --overlay: rgba(15,23,42,.42);
    --shadow-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --shadow-2: 0 4px 16px rgba(15,23,42,.09);
    --shadow-3: 0 18px 48px rgba(15,23,42,.13);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-fa);
    background: var(--bg-0);
    color: var(--text);
    line-height: 1.85;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(900px 600px at 88% -8%, rgba(99,102,241,.28), transparent 62%),
        radial-gradient(760px 520px at 6% 4%, rgba(6,182,212,.22), transparent 60%),
        radial-gradient(900px 700px at 50% 112%, rgba(236,72,153,.16), transparent 62%),
        var(--bg-1);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 58px 58px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 78%);
}

h1, h2, h3, h4, h5 { margin: 0 0 .5rem; font-weight: 800; line-height: 1.5; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.22rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; color: var(--text-2); }
a { color: var(--brand-2); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--brand-3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,.34); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,.62); background-clip: content-box; }

::selection { background: rgba(139,92,246,.36); color: #fff; }

/* ------------------------------------------------------------------ Utils */
.gradient-text {
    background: var(--brand-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: .6rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; text-align: left; }
.mono { font-family: var(--font-mono); }
.fs-sm { font-size: .82rem; } .fs-xs { font-size: .74rem; }
.fs-lg { font-size: 1.05rem; }

/* ------------------------------------------------------------------ Cards */
.card {
    position: relative;
    background: var(--surface);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-1);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.card.hoverable:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-3);
    border-color: var(--border-strong);
}

.card.glow::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: var(--brand-grad);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: .45;
    pointer-events: none;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}

.card-head h3, .card-head h4 { margin: 0; }
.card-title { display: flex; align-items: center; gap: .55rem; font-weight: 800; }

/* 3D tilt container */
.tilt-scene { perspective: 1000px; }
.tilt {
    transform-style: preserve-3d;
    transition: transform .5s var(--ease), box-shadow .5s var(--ease);
    will-change: transform;
}
.tilt-layer { transform: translateZ(38px); }

/* ------------------------------------------------------------- Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.stat {
    position: relative;
    overflow: hidden;
    padding: 1.15rem 1.25rem;
}

.stat::after {
    content: "";
    position: absolute;
    width: 150px; height: 150px;
    left: -46px; top: -66px;
    border-radius: 50%;
    background: var(--brand-grad-soft);
    filter: blur(22px);
    opacity: .8;
    transition: transform .7s var(--ease);
}

.stat:hover::after { transform: scale(1.35) translateY(12px); }

.stat-label { font-size: .8rem; color: var(--text-3); font-weight: 600; margin-bottom: .3rem; }
.stat-value {
    font-size: 1.95rem;
    font-weight: 900;
    letter-spacing: -.02em;
    line-height: 1.3;
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-hint { font-size: .76rem; color: var(--text-3); margin-top: .2rem; }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 13px;
    display: grid; place-items: center;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border);
    color: var(--brand-2);
    flex: none;
}

/* ------------------------------------------- کارت آماری کلیک‌پذیر (لینک) */
/* چرا <a> و نه onclick روی div؟ چون لینک با کلیک میانی/کنترل، باز شدن در تب
   جدید، و مسیر کیبورد (Tab + Enter) کار می‌کند و صفحه‌خوان آن را «پیوند»
   اعلام می‌کند. یک div با onclick هیچ‌کدام را ندارد. */
a.stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

a.stat-link:focus-visible {
    outline: 2px solid var(--brand-2);
    outline-offset: 3px;
}

/* نشانگر «برو» — کم‌رنگ در حالت عادی، پررنگ با هاور، تا کارت شلوغ نشود. */
.stat-go {
    position: absolute;
    left: .7rem;
    bottom: .55rem;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border);
    color: var(--brand-2);
    opacity: .35;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    pointer-events: none;
}

a.stat-link:hover .stat-go,
a.stat-link:focus-visible .stat-go {
    opacity: 1;
    transform: translateX(-3px);
}

/* ---------------------------------------- ورودی سال تایپی (تاریخ تولد) */
/* سال در حالت تایپی هم‌عرض لیست کشویی قبلی است تا چیدمان سه‌ستونی
   سال/ماه/روز به‌هم نریزد. */
.jalali .input.jalali-y {
    flex: 1;
    min-width: 92px;
    text-align: center;
    font-weight: 700;
    letter-spacing: .06em;
}

.jalali .input.jalali-y.is-invalid {
    border-color: var(--danger, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

/* پیام بازهٔ سال — تمام‌عرضِ ردیف، چون .jalali فلکس با wrap است. */
.jalali-hint {
    flex: 1 1 100%;
    font-size: .74rem;
    color: var(--text-3);
    line-height: 1.5;
}

.jalali-hint.is-error { color: var(--danger, #ef4444); font-weight: 600; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .62rem 1.15rem;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: transform .22s var(--ease), box-shadow .22s var(--ease), background .22s var(--ease), border-color .22s var(--ease), color .22s var(--ease);
    white-space: nowrap;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--brand-2); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 26px -12px rgba(99,102,241,.9);
}
.btn-primary:hover { box-shadow: 0 16px 38px -12px rgba(99,102,241,1); color: #fff; }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }

.btn-danger { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.24); border-color: var(--danger); color: #fff; }

.btn-success { background: rgba(16,185,129,.14); border-color: rgba(16,185,129,.42); color: #6ee7b7; }
.btn-success:hover { background: rgba(16,185,129,.26); color: #fff; }

.btn-sm { padding: .38rem .7rem; font-size: .78rem; border-radius: 10px; }
.btn-lg { padding: .85rem 1.7rem; font-size: 1rem; border-radius: 14px; }
.btn-icon { padding: .45rem; width: 36px; height: 36px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .32rem;
    padding: .2rem .62rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-brand { background: rgba(99,102,241,.16); color: #a5b4fc; border-color: rgba(99,102,241,.34); }
.badge-success { background: rgba(16,185,129,.16); color: #6ee7b7; border-color: rgba(16,185,129,.34); }
.badge-warning { background: rgba(245,158,11,.16); color: #fcd34d; border-color: rgba(245,158,11,.34); }
.badge-danger { background: rgba(239,68,68,.16); color: #fca5a5; border-color: rgba(239,68,68,.34); }
.badge-info { background: rgba(14,165,233,.16); color: #7dd3fc; border-color: rgba(14,165,233,.34); }
.badge-muted { background: rgba(148,163,184,.14); color: var(--text-2); border-color: var(--border); }
.badge-lg { padding: .34rem .9rem; font-size: .82rem; }

html[data-theme="light"] .badge-brand { color: #4338ca; }
html[data-theme="light"] .badge-success { color: #047857; }
html[data-theme="light"] .badge-warning { color: #b45309; }
html[data-theme="light"] .badge-danger { color: #b91c1c; }
html[data-theme="light"] .badge-info { color: #0369a1; }

/* ------------------------------------------------------------------ Chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .34rem .78rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .8rem;
    cursor: pointer;
    transition: all .22s var(--ease);
    user-select: none;
}
.chip:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.chip.active { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 8px 20px -10px rgba(99,102,241,.9); }

/* ------------------------------------------------------------------ Forms */
.field { margin-bottom: 1rem; }
.field > label, .label {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: .38rem;
}
.label .req { color: var(--danger); margin-inline-start: .2rem; }

.input, .select, .textarea {
    width: 100%;
    padding: .62rem .85rem;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.7;
    transition: border-color .22s var(--ease), box-shadow .22s var(--ease), background .22s var(--ease);
    outline: none;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-2);
    box-shadow: 0 0 0 4px rgba(139,92,246,.16);
    background: var(--surface-solid);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 96px; }
.select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(0% + 14px) calc(50% + 2px), calc(0% + 19px) calc(50% + 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-inline-start: 2.1rem; }
.select option { background: var(--surface-solid); color: var(--text); }

.input-group { display: flex; gap: .5rem; }
.input-group .input { flex: 1; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1rem; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .86rem; user-select: none; }
.check input[type="checkbox"], .check input[type="radio"] {
    appearance: none;
    width: 19px; height: 19px;
    border-radius: 6px;
    border: 1.6px solid var(--border-strong);
    background: var(--surface-2);
    cursor: pointer;
    position: relative;
    transition: all .2s var(--ease);
    flex: none;
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--brand-grad); border-color: transparent; }
.check input:checked::after {
    content: "";
    position: absolute;
    left: 6px; top: 2px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.check input[type="radio"]:checked::after { left: 5px; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: #fff; border: 0; transform: none; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background .3s var(--ease);
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 20px; width: 20px;
    right: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s var(--ease-bounce);
    box-shadow: var(--shadow-1);
}
.switch input:checked + .slider { background: var(--brand-grad); }
.switch input:checked + .slider::before { transform: translateX(-20px); }

.validation-message { color: #fca5a5; font-size: .78rem; margin-top: .25rem; display: block; }
html[data-theme="light"] .validation-message { color: #dc2626; }

.invalid { border-color: var(--danger) !important; }

/* ------------------------------------------------------------------ Tables */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .86rem;
}
table.data thead th {
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 800;
    font-size: .78rem;
    text-align: right;
    padding: .8rem .9rem;
    border-bottom: 1px solid var(--border-strong);
    position: sticky; top: 0;
    white-space: nowrap;
    z-index: 2;
}
table.data tbody td {
    padding: .72rem .9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr { transition: background .2s var(--ease); }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { padding: .7rem .9rem; font-weight: 700; background: var(--surface-2); }

/* ---------------------------------------------------------------- Avatar */
.avatar {
    width: 40px; height: 40px;
    border-radius: 13px;
    display: grid; place-items: center;
    background: var(--brand-grad);
    color: #fff;
    font-weight: 800;
    font-size: .85rem;
    flex: none;
    box-shadow: 0 6px 18px -8px rgba(99,102,241,.9);
}
.avatar-sm { width: 30px; height: 30px; border-radius: 10px; font-size: .7rem; }
.avatar-lg { width: 58px; height: 58px; border-radius: 18px; font-size: 1.15rem; }

/* ------------------------------------------------------------------ Modal */
.modal-backdrop {
    position: fixed; inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    animation: fadeIn .26s var(--ease);
    overflow-y: auto;
}
.modal {
    width: min(760px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    animation: modalIn .42s var(--ease-bounce);
}
.modal.modal-lg { width: min(1080px, 100%); }
.modal.modal-sm { width: min(460px, 100%); }
.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    background: var(--surface-solid);
    z-index: 3;
}
.modal-body { padding: 1.4rem; }
.modal-foot {
    display: flex; justify-content: flex-start; gap: .6rem; flex-wrap: wrap;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    position: sticky; bottom: 0;
    background: var(--surface-solid);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(28px) scale(.96); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Toasts */
.toast-stack {
    position: fixed;
    top: 1.1rem; left: 1.1rem;
    z-index: 2000;
    display: flex; flex-direction: column; gap: .6rem;
    max-width: 380px;
}
.toast {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .8rem 1rem;
    border-radius: 14px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-3);
    animation: toastIn .4s var(--ease-bounce);
    font-size: .87rem;
    font-weight: 600;
    cursor: pointer;
}
.toast.success { border-inline-start: 3px solid var(--success); }
.toast.error { border-inline-start: 3px solid var(--danger); }
.toast.warning { border-inline-start: 3px solid var(--warning); }
.toast.info { border-inline-start: 3px solid var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-36px) scale(.94); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Alerts */
.alert {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .85rem 1.05rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .87rem;
    margin-bottom: 1rem;
}
.alert-info { border-color: rgba(14,165,233,.34); background: rgba(14,165,233,.09); }
.alert-success { border-color: rgba(16,185,129,.34); background: rgba(16,185,129,.09); }
.alert-warning { border-color: rgba(245,158,11,.34); background: rgba(245,158,11,.09); }
.alert-danger { border-color: rgba(239,68,68,.34); background: rgba(239,68,68,.09); }

/* ------------------------------------------------------------------ Tabs */
.tabs {
    display: flex; gap: .3rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: .7rem 1.05rem;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-family: inherit;
    font-weight: 700;
    font-size: .87rem;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color .25s var(--ease);
    display: inline-flex; align-items: center; gap: .4rem;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
    content: "";
    position: absolute;
    inset-inline: .5rem;
    bottom: -1px;
    height: 2.5px;
    border-radius: 3px;
    background: var(--brand-grad);
    animation: tabIn .34s var(--ease);
}
@keyframes tabIn { from { transform: scaleX(.2); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

/* --------------------------------------------------------------- Progress */
.progress {
    height: 9px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--brand-grad);
    transition: width .9s var(--ease);
}
.progress.thin { height: 6px; }
.progress.excellent > span { background: linear-gradient(90deg, #10b981, #34d399); }
.progress.good > span { background: linear-gradient(90deg, #22c55e, #84cc16); }
.progress.average > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.weak > span { background: linear-gradient(90deg, #ef4444, #f97316); }

.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-value {
    position: absolute;
    font-weight: 900;
    font-size: .95rem;
    letter-spacing: -.02em;
}
.ring circle { fill: none; stroke-linecap: round; }
.ring .track { stroke: var(--border); }
.ring .bar { transition: stroke-dashoffset 1.1s var(--ease); }

/* -------------------------------------------------------------- Empty state */
.empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-3);
}
.empty .empty-icon {
    width: 74px; height: 74px;
    margin: 0 auto 1rem;
    border-radius: 22px;
    display: grid; place-items: center;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border);
    color: var(--brand-2);
    animation: floatY 4.4s ease-in-out infinite;
}
.empty h4 { color: var(--text-2); margin-bottom: .35rem; }
.empty p { max-width: 420px; margin: 0 auto 1.1rem; font-size: .87rem; }

@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ---------------------------------------------------------------- Spinner */
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--brand-2);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex: none;
}
.spinner.lg { width: 38px; height: 38px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------- App shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-inline-start: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 60;
    transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.sidebar.collapsed { width: 82px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .sidebar-foot-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding-inline: 0; }

.brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.15rem 1.15rem .9rem;
    border-bottom: 1px solid var(--border);
}
.brand-mark {
    width: 42px; height: 42px;
    border-radius: 14px;
    display: grid; place-items: center;
    background: var(--brand-grad);
    color: #fff;
    flex: none;
    box-shadow: 0 10px 26px -12px rgba(99,102,241,1);
    animation: brandPulse 5s ease-in-out infinite;
}
@keyframes brandPulse {
    0%,100% { box-shadow: 0 10px 26px -12px rgba(99,102,241,.9); }
    50% { box-shadow: 0 14px 36px -10px rgba(6,182,212,.95); }
}
.brand-text { line-height: 1.35; flex: 1; min-width: 0; }
.brand-text strong { display: block; font-size: 1.02rem; font-weight: 900; }
.brand-text span { font-size: .7rem; color: var(--text-3); }

/* ------------------------------------------------ انتخابگر مدرسهٔ فعال (مدیر کل) */
.school-switch { position: relative; }
.school-switch > summary {
    display: flex; align-items: center; gap: .3rem;
    font-size: .7rem; color: var(--text-2);
    cursor: pointer; list-style: none;
    padding: .12rem .3rem; margin: 0 -.3rem;
    border-radius: 7px;
    max-width: 100%;
    transition: background .15s, color .15s;
}
.school-switch > summary::-webkit-details-marker { display: none; }
.school-switch > summary:hover { background: var(--surface-hover); color: var(--text); }
.school-switch > summary span { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.school-switch > summary .icon { flex: none; opacity: .75; }

.school-menu {
    position: absolute; top: calc(100% + .35rem); inset-inline-start: 0; z-index: 60;
    min-width: 13rem; max-height: 17rem; overflow-y: auto;
    /* سطح ثابت (نه شیشه‌ای) چون روی محتوای صفحه می‌افتد و از لبهٔ نوار کناری بیرون می‌زند */
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-3);
    padding: .3rem;
    display: flex; flex-direction: column; gap: .1rem;
}
.school-opt {
    display: flex; align-items: center; gap: .45rem;
    padding: .45rem .55rem;
    font-size: .78rem; color: var(--text-2);
    text-decoration: none;
    border-radius: 8px;
    transition: background .12s, color .12s;
}
.school-opt > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.school-opt:hover { background: var(--surface-hover); color: var(--text); }
.school-opt.is-active { color: var(--text); font-weight: 700; background: var(--surface-hover); }
.school-opt .tag { flex: none; font-size: .62rem; padding: .08rem .3rem; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.school-opt-global { border-top: 1px solid var(--border); margin-top: .15rem; padding-top: .5rem; border-radius: 0 0 8px 8px; }
.school-opt-global .icon { flex: none; opacity: .7; }

/* ---------------------------------- دروازهٔ مدرسه: حالت سراسری روی /school */
.school-gate {
    max-width: 34rem; margin: 2.5rem auto;
    padding: 2.2rem 1.8rem; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: .7rem;
}
.school-gate-icon {
    width: 62px; height: 62px; border-radius: 18px;
    display: grid; place-items: center;
    background: var(--brand-grad); color: #fff;
    box-shadow: 0 12px 30px -12px rgba(99,102,241,1);
}
.school-gate h3 { margin: .2rem 0 0; font-size: 1.15rem; font-weight: 900; }
.school-gate p { margin: 0; color: var(--text-2); font-size: .88rem; line-height: 1.75; }
.school-gate code {
    font-size: .82em; padding: .1rem .35rem; border-radius: 5px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.school-gate-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-top: .5rem; }

.nav { flex: 1; overflow-y: auto; padding: .85rem .7rem 1.5rem; }
.nav-group-title {
    font-size: .68rem;
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .09em;
    padding: .9rem .6rem .4rem;
}
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .62rem .72rem;
    border-radius: 12px;
    color: var(--text-2);
    font-size: .875rem;
    font-weight: 650;
    margin-bottom: .18rem;
    transition: all .24s var(--ease);
    position: relative;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); transform: translateX(-3px); }
.nav-item.active {
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 10px 26px -14px rgba(99,102,241,1);
    border-color: transparent;
}
.nav-item.active .nav-icon { color: #fff; }
.nav-icon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; color: var(--brand-2); }
.nav-item .nav-badge {
    margin-inline-start: auto;
    background: rgba(239,68,68,.9);
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    padding: .05rem .42rem;
    border-radius: 999px;
}

.sidebar-foot { padding: .85rem; border-top: 1px solid var(--border); }
.user-card {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: .8rem;
    padding: 0 1.4rem;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    z-index: 50;
}
.topbar h2 { font-size: 1.06rem; margin: 0; }
.topbar .crumb { font-size: .74rem; color: var(--text-3); }

.page { padding: 1.5rem 1.4rem 3.5rem; flex: 1; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.7rem; margin-bottom: .25rem; }

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    transition: all .22s var(--ease);
    position: relative;
    flex: none;
}
.icon-btn:hover { border-color: var(--brand-2); color: var(--text); transform: translateY(-2px); }
.icon-btn .dot {
    position: absolute; top: 7px; inset-inline-end: 7px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--surface-2);
}

/* ------------------------------------------------------------- AI chat UI */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h) - 3.4rem);
    min-height: 460px;
}
.chat-scroll { flex: 1; overflow-y: auto; padding: 1rem .35rem; display: flex; flex-direction: column; gap: .9rem; }
.bubble {
    max-width: 84%;
    padding: .85rem 1.05rem;
    border-radius: 18px;
    font-size: .89rem;
    line-height: 1.9;
    animation: bubbleIn .4s var(--ease);
    position: relative;
    word-break: break-word;
}
.bubble.user {
    align-self: flex-start;
    background: var(--brand-grad);
    color: #fff;
    border-end-start-radius: 6px;
    box-shadow: 0 12px 30px -16px rgba(99,102,241,1);
}
.bubble.assistant {
    align-self: flex-end;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-end-end-radius: 6px;
}
.bubble.blocked { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.08); }
.bubble .bubble-meta { font-size: .68rem; opacity: .68; margin-top: .45rem; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

.chat-composer {
    display: flex; gap: .6rem; align-items: flex-end;
    padding: .8rem;
    border-radius: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
}
.chat-composer .textarea { border: 0; background: transparent; min-height: 46px; max-height: 170px; padding: .4rem .3rem; }
.chat-composer .textarea:focus { box-shadow: none; background: transparent; }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--brand-2);
    animation: typingBounce 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* --------------------------------------------------------------- Markdown */
.md h1, .md h2, .md h3 { margin-top: 1rem; margin-bottom: .45rem; }
.md h1 { font-size: 1.28rem; } .md h2 { font-size: 1.13rem; } .md h3 { font-size: 1rem; }
.md ul, .md ol { margin: .4rem 0 .8rem; padding-inline-start: 1.4rem; }
.md li { margin-bottom: .3rem; color: var(--text-2); }
.md p { margin-bottom: .7rem; }
.md code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: .1rem .35rem;
    border-radius: 6px;
    font-size: .84em;
    direction: ltr;
    display: inline-block;
}
.md pre {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .85rem 1rem;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    margin-bottom: .9rem;
}
.md pre code { background: none; border: 0; padding: 0; }
.md strong { color: var(--text); font-weight: 800; }
.md blockquote {
    border-inline-start: 3px solid var(--brand-2);
    margin: .6rem 0;
    padding: .3rem .9rem;
    color: var(--text-2);
    background: var(--surface-hover);
    border-radius: 0 10px 10px 0;
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.md table { width: 100%; border-collapse: collapse; margin-bottom: .9rem; font-size: .85rem; }
.md th, .md td { border: 1px solid var(--border); padding: .45rem .65rem; text-align: right; }
.md th { background: var(--surface-2); font-weight: 800; }

/* ------------------------------------------------------------ Exam taking */
.exam-shell { min-height: 100vh; display: flex; flex-direction: column; }
.exam-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 1.3rem;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 40;
}
.timer {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 800;
    padding: .4rem .95rem;
    border-radius: 12px;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border-strong);
    direction: ltr;
}
.timer.warning { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.5); color: #fcd34d; animation: pulseWarn 1.4s infinite; }
.timer.danger { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.55); color: #fca5a5; animation: pulseWarn .9s infinite; }
@keyframes pulseWarn { 0%,100% { transform: scale(1); } 50% { transform: scale(1.045); } }

.q-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    background: var(--surface);
    margin-bottom: 1rem;
    transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.q-card.answered { border-color: rgba(16,185,129,.45); }
.q-card.current { border-color: var(--brand-2); box-shadow: var(--shadow-glow); }
.q-num {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px;
    border-radius: 10px;
    background: var(--brand-grad);
    color: #fff;
    font-weight: 800;
    font-size: .82rem;
    flex: none;
}
.q-text { font-size: .96rem; font-weight: 650; line-height: 2; margin-bottom: .9rem; white-space: pre-wrap; }

.opt {
    display: flex; align-items: center; gap: .7rem;
    padding: .68rem .9rem;
    border-radius: 13px;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    margin-bottom: .5rem;
    transition: all .22s var(--ease);
    font-size: .89rem;
}
.opt:hover { border-color: var(--brand-2); transform: translateX(-4px); }
.opt.selected { border-color: var(--brand-2); background: rgba(139,92,246,.14); box-shadow: 0 8px 22px -14px rgba(99,102,241,1); }
.opt .marker {
    width: 24px; height: 24px; border-radius: 8px;
    border: 1.6px solid var(--border-strong);
    display: grid; place-items: center;
    font-size: .72rem; font-weight: 800;
    flex: none;
    transition: all .2s var(--ease);
}
.opt.selected .marker { background: var(--brand-grad); border-color: transparent; color: #fff; }
.opt.correct { border-color: rgba(16,185,129,.6); background: rgba(16,185,129,.1); }
.opt.wrong { border-color: rgba(239,68,68,.6); background: rgba(239,68,68,.1); }

.q-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: .4rem;
}
.q-nav button {
    aspect-ratio: 1;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 700;
    font-size: .8rem;
    cursor: pointer;
    transition: all .2s var(--ease);
    font-family: inherit;
}
.q-nav button:hover { border-color: var(--brand-2); }
.q-nav button.answered { background: rgba(16,185,129,.2); border-color: rgba(16,185,129,.5); color: #6ee7b7; }
.q-nav button.current { background: var(--brand-grad); color: #fff; border-color: transparent; }

/* ---------------------------------------------------------------- Charts */
.chart-box { width: 100%; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .7rem; font-size: .78rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-2); }
.chart-legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }

.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; font-size: .82rem; }
.bar-row .bar-label { width: 118px; flex: none; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width 1s var(--ease); }
.bar-row .bar-value { width: 52px; text-align: left; font-weight: 700; font-size: .78rem; direction: ltr; }

/* --------------------------------------------------------------- Reveal */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.reveal.visible { opacity: 1; transform: none; }

/* ============================================================ Mobile nav */
/* روی موبایل، منوی کشویی کناری کاملاً بازنشسته شده است.
   دلیل: هر بار که با position:fixed + transform ساخته شد، ترکیب RTL و
   viewport واقعی گوشی (نه شبیه‌سازی عرض مرورگر) منو را نیمه‌باز روی محتوا
   می‌گذاشت. الگوی جایگزین، تست‌پذیرتر و مدرن‌تر است:
     ۱) نوار پایین ثابت (thumb-reachable) با ۴ مقصد اصلی + «همه»
     ۲) شیت تمام‌صفحه با همهٔ گروه‌ها، انتخاب مدرسه و خروج
   هیچ transform و هیچ عرض محاسبه‌شده‌ای در کار نیست؛ فقط inset. */

.mnav,
.msheet { display: none; }

/* ------------------------------------------------------- نوار پایین (mnav) */
.mnav {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 80;
    align-items: stretch;
    justify-content: center;
    gap: .1rem;
    padding: .3rem .35rem calc(.3rem + env(safe-area-inset-bottom));
    background: var(--surface);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .55);
}

.mnav-item {
    position: relative;
    flex: 1 1 0;
    max-width: 108px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .12rem;
    padding: .34rem .1rem .26rem;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font: inherit;
    font-size: .64rem;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
    border-radius: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s var(--ease), background .2s var(--ease);
}
.mnav-item > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mnav-item > svg { flex: none; transition: transform .24s var(--ease-bounce); }
.mnav-item:hover { color: var(--text-2); }
.mnav-item.active { color: var(--brand-2); }
.mnav-item.active > svg { transform: translateY(-1px) scale(1.08); }
/* نشانگر بالای آیتم فعال — با left:50% و translateX(-50%) در هر دو جهت وسط می‌ماند. */
.mnav-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 30px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--brand-grad);
    box-shadow: 0 0 14px rgba(139, 92, 246, .85);
    transform: translateX(-50%);
}
.mnav-dot {
    position: absolute;
    top: .3rem;
    inset-inline-start: calc(50% + 7px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--bg-1);
}

/* ------------------------------------------- شیت تمام‌صفحه (همهٔ منوها) */
.msheet {
    position: fixed;
    inset: 0;
    height: 100dvh;
    z-index: 900;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 55%);
    animation: sheetUp .3s var(--ease) both;
}
@keyframes sheetUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

.msheet-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: calc(env(safe-area-inset-top) + .9rem) 1rem .85rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.msheet-title { font-size: 1.02rem; font-weight: 900; }
.msheet-sub { margin-top: .1rem; font-size: .72rem; color: var(--text-3); }

.msheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: .2rem .85rem calc(1.4rem + env(safe-area-inset-bottom));
}

.msheet-group {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .95rem .35rem .45rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    color: var(--text-3);
}
.msheet-group::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.msheet-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-2);
    box-shadow: var(--shadow-1);
}

.msheet-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 52px;
    padding: .6rem .75rem;
    color: var(--text-2);
    font-size: .89rem;
    font-weight: 650;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s;
}
.msheet-item + .msheet-item { border-top: 1px solid var(--border); }
.msheet-item:active { background: var(--surface-hover); }
.msheet-item.active { color: var(--text); background: var(--surface-hover); }
.msheet-item.active .msheet-ico {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px -12px rgba(99, 102, 241, 1);
}
.msheet-item > svg { flex: none; opacity: .45; }

.msheet-ico {
    flex: none;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--brand-2);
}
.msheet-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msheet-item .nav-badge {
    flex: none;
    padding: .05rem .42rem;
    border-radius: 999px;
    background: rgba(239, 68, 68, .9);
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
}

.msheet-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .1rem .05rem;
}
.msheet-chip {
    padding: .42rem .8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.msheet-chip.active {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px -12px rgba(99, 102, 241, 1);
}

.msheet-logout {
    margin-top: 1rem;
    border: 1px solid rgba(239, 68, 68, .26);
    border-radius: 16px;
    background: rgba(239, 68, 68, .08);
    color: #f87171;
}
.msheet-logout .msheet-ico {
    border-color: rgba(239, 68, 68, .3);
    background: rgba(239, 68, 68, .12);
    color: #f87171;
}

/* ============================================================== Homework */
/* نوار پیشرفت تحویل در جدول معلم */
.hw-progress { display: flex; align-items: center; gap: .5rem; }
.hw-progress-track {
    flex: 1; min-width: 56px; height: 8px; border-radius: 999px;
    background: var(--border); overflow: hidden;
}
.hw-progress-fill {
    height: 100%; border-radius: 999px; background: var(--brand-grad);
    transition: width .8s var(--ease);
}
.hw-progress-num { font-size: .72rem; font-weight: 700; color: var(--text-2); direction: ltr; }

/* کارت‌های خلاصهٔ صفحهٔ تصحیح */
.hw-ring-card { display: flex; align-items: center; gap: 1rem; }
.hw-big {
    font-size: 1.9rem; font-weight: 900; letter-spacing: -.02em;
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ردیف دانش‌آموز در صفحهٔ تصحیح */
.hw-student { padding: .9rem 1rem; }
.hw-student.is-missing { border-inline-start: 3px solid var(--warning); }
.hw-student-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.hw-student-head .avatar { width: 38px; height: 38px; border-radius: 12px; flex: none; }
.hw-score-chip {
    display: inline-flex; align-items: baseline; gap: .15rem;
    padding: .2rem .55rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface-2);
    font-weight: 800; font-size: .82rem;
}
.hw-score-chip.is-graded { border-color: rgba(16,185,129,.45); background: rgba(16,185,129,.12); color: #6ee7b7; }
.hw-grade-panel { margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.hw-answer {
    padding: .7rem .85rem; margin-bottom: .7rem;
    border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2);
}

/* تصاویر تحویل */
.hw-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.hw-thumb {
    position: relative; width: 86px; height: 86px; padding: 0;
    border-radius: 12px; overflow: hidden; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-2);
}
.hw-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .35s var(--ease);
}
.hw-thumb:hover img { transform: scale(1.07); }
.hw-thumb-zoom {
    position: absolute; inset-inline-end: 4px; bottom: 4px;
    width: 22px; height: 22px; border-radius: 8px;
    display: grid; place-items: center;
    background: rgba(0,0,0,.55); color: #fff;
}
.hw-thumb-del {
    position: absolute; top: 4px; inset-inline-start: 4px;
    width: 22px; height: 22px; border: 0; border-radius: 50%;
    display: grid; place-items: center; cursor: pointer;
    background: rgba(239,68,68,.92); color: #fff;
}
.hw-thumb-del:hover { background: var(--danger); }
.hw-thumb-size {
    position: absolute; inset-inline: 0; bottom: 0;
    padding: .1rem .25rem; font-size: .58rem; text-align: center;
    color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.72));
}
.hw-thumb-own { cursor: default; }

/* انتخاب و ارسال تصویر */
.hw-pick-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.hw-uploading {
    display: flex; align-items: center; gap: .5rem;
    margin-top: .6rem; font-size: .8rem; color: var(--text-2);
}

/* نمایش تمام‌صفحهٔ تصویر */
.hw-lightbox {
    position: fixed; inset: 0; z-index: 3000;
    display: grid; place-items: center; padding: 1rem;
    background: rgba(2, 4, 12, .93);
    cursor: zoom-out;
    animation: fadeIn .18s var(--ease);
}
.hw-lightbox img {
    max-width: 100%; max-height: 100%;
    border-radius: 14px; box-shadow: var(--shadow-3);
    cursor: default;
}
.hw-lightbox-x {
    position: absolute; top: 1rem; inset-inline-end: 1rem;
    width: 42px; height: 42px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text);
    font-size: 1.4rem; line-height: 1;
}

/* ------------------------------------------------------------- Responsive */
@media (max-width: 1024px) {
    /* منوی کناری در موبایل کاملاً حذف می‌شود — نه پنهان‌شده با transform.
       اگر فقط بیرون از کادر می‌رفت، در بعضی مرورگرهای موبایل با نوار آدرس
       دینامیک دوباره سر جای خودش می‌آمد و روی محتوا می‌نشست. */
    .sidebar { display: none; }
    /* «جمع کردن منو» فقط برای منوی کناری دسکتاپ است. */
    .topbar-btn-collapse { display: none; }

    .mnav { display: flex; }
    .msheet { display: flex; }

    /* نوار پایین نباید انتهای صفحه را بپوشاند. */
    .page { padding: 1.1rem .9rem calc(84px + env(safe-area-inset-bottom)); }
    .topbar { padding: 0 .9rem; }

    /* وقتی شیت باز است، صفحهٔ زیرین اسکرول نشود. */
    body:has(.msheet) { overflow: hidden; }

    /* صفحهٔ گفتگو ارتفاع ثابت دارد؛ با نوار پایین باید کوتاه‌تر شود. */
    .chat-wrap {
        height: calc(100dvh - var(--topbar-h) - 3.4rem - 72px - env(safe-area-inset-bottom));
        min-height: 320px;
    }
}

@media (max-width: 640px) {
    body { font-size: 14px; }
    h1 { font-size: 1.55rem; }
    .page-head h1 { font-size: 1.35rem; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .stat-value { font-size: 1.5rem; }
    .modal-body, .modal-head, .modal-foot { padding-inline: 1rem; }
    .bubble { max-width: 94%; }
    .toast-stack { left: .6rem; right: .6rem; max-width: none; }

    /* تکالیف: تصاویر و ردیف‌ها در عرض کم جا شوند */
    .hw-thumb { width: 72px; height: 72px; }
    .hw-student { padding: .8rem .75rem; }
    .hw-student-head { gap: .5rem; }
    .hw-ring-card { gap: .7rem; }
    .hw-big { font-size: 1.5rem; }

    /* جدول تکالیف معلم روی گوشی: هر ردیف یک کارت.
       هفت ستون با اسکرول افقی روی گوشی عملاً خوانده نمی‌شد؛ اینجا ردیف
       به یک کارت تبدیل می‌شود و برچسب هر مقدار از data-label می‌آید.
       سلکتورها با «tbody» نوشته شده‌اند تا specificity با قاعدهٔ
       table.data tbody td برابر شود و ترتیب (قرارگیری بعدتر) برنده باشد. */
    .hw-table-wrap { border: 0; background: transparent; overflow: visible; }
    table.hw-table thead { display: none; }
    table.hw-table tbody tr {
        display: flex; flex-wrap: wrap; align-items: center;
        gap: .4rem .85rem;
        padding: .8rem .85rem;
        margin-bottom: .55rem;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--surface-2);
    }
    table.hw-table tbody tr:last-child { margin-bottom: 0; }
    table.hw-table tbody tr:hover { background: var(--surface-hover); }
    table.hw-table tbody td {
        display: flex; align-items: center; gap: .35rem;
        padding: 0; border: 0; min-width: 0;
    }
    /* برچسب کوچک قبل از مقدار */
    table.hw-table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: .68rem; font-weight: 700; color: var(--text-3);
        white-space: nowrap;
    }
    table.hw-table tbody td.hw-t-title {
        flex: 1 1 100%;
        display: block;
        font-size: .92rem;
    }
    table.hw-table tbody td.hw-t-title::before { content: none; }
    table.hw-table tbody td.hw-t-progress { flex: 1 1 100%; }
    table.hw-table tbody td.hw-t-actions {
        flex: 1 1 100%; justify-content: flex-end; padding-top: .15rem;
    }
    table.hw-table tbody td.hw-t-actions::before { content: none; }
    /* نوار پیشرفت در کارت تمام‌عرض شود */
    table.hw-table .hw-progress { width: 100%; }
    table.hw-table .hw-progress-num { min-width: 3.2rem; text-align: end; }
}

@media print {
    .sidebar, .topbar, .no-print, .toast-stack { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border-color: #ddd; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ============================================================ Chart extras */
.col-chart {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
    /* ارتفاع باید «قطعی» باشد، نه فقط min-height: ستون‌ها height:100% دارند و
       درصد ارتفاع فقط وقتی حل می‌شود که والد ارتفاع قطعی داشته باشد. با
       min-height، ارتفاع .col-item برابر محتوای خودش می‌شد و .col-track
       (flex:1) به صفر می‌رسید — یعنی میله‌ها دیده نمی‌شدند. */
    height: 190px;
    padding-top: 1.4rem;
}
.col-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    position: relative;
    height: 100%;
}
.col-value {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-3);
    margin-bottom: .3rem;
    white-space: nowrap;
}
.col-track {
    flex: 1;
    width: 100%;
    max-width: 46px;
    display: flex;
    align-items: flex-end;
    background: var(--border);
    border-radius: 10px 10px 4px 4px;
    overflow: hidden;
    position: relative;
}
.col-bar {
    width: 100%;
    border-radius: 10px 10px 4px 4px;
    background: var(--brand-grad);
    transition: height 1s var(--ease);
    position: relative;
}
.col-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.28), transparent 55%);
}
.col-item:hover .col-bar { filter: brightness(1.18); }
.col-label {
    margin-top: .45rem;
    font-size: .66rem;
    color: var(--text-3);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.line-labels {
    display: flex;
    justify-content: space-between;
    gap: .2rem;
    margin-top: .45rem;
    font-size: .68rem;
    color: var(--text-3);
}
.line-labels span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }

.donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    flex-wrap: wrap;
    justify-content: center;
}
.donut { position: relative; width: 158px; height: 158px; flex: none; }
.donut-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    line-height: 1.35;
}
.donut-center strong {
    font-size: 1.35rem;
    font-weight: 900;
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.donut-center span { font-size: .7rem; color: var(--text-3); }
.donut-legend { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: .45rem; }

.radar-wrap {
    display: flex;
    align-items: center;
    gap: 1.3rem;
    flex-wrap: wrap;
    justify-content: center;
}
.radar-legend { flex: 1; min-width: 175px; display: flex; flex-direction: column; gap: .4rem; }

.jalali { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.jalali .select { flex: 1; min-width: 92px; padding-inline-start: 1.9rem; }
/* ساعت و دقیقه باریک‌تر از سال/ماه/روز تا پنج فیلد در یک ستون جا شوند. */
.jalali .select.jalali-t { flex: .72; min-width: 72px; }

/* روی گوشی پنج لیست کشویی آن‌قدر باریک می‌شدند که «اردیبهشت» و «ساعت» با
   سه‌نقطه بریده می‌شدند (اندازه‌گیری: متن ۶۱px در فضای ۴۸px). حالا سه‌تا در
   ردیف اول و ساعت/دقیقه در ردیف دوم. این بلوک عمداً بعد از قواعد .jalali آمده؛
   اگر داخل بلوک عمومی ۶۴۰px (بالاتر در فایل) بگذارد، همان specificity ولی
   ترتیبِ بعدیِ .jalali .select آن را خنثی می‌کند. */
@media (max-width: 640px) {
    .jalali { gap: .35rem; }
    .jalali .select { flex: 1 1 30%; min-width: 0; padding-inline-start: 1.5rem; }
    .jalali .select.jalali-t { flex: 1 1 40%; }
}

/* ------------------------------------------------------- Score pills */
.score-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .18rem .6rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: .78rem;
    direction: ltr;
}
.score-pill.excellent { background: rgba(16,185,129,.16); color: #6ee7b7; }
.score-pill.good { background: rgba(34,197,94,.16); color: #86efac; }
.score-pill.average { background: rgba(245,158,11,.16); color: #fcd34d; }
.score-pill.weak { background: rgba(239,68,68,.16); color: #fca5a5; }
html[data-theme="light"] .score-pill.excellent { color: #047857; }
html[data-theme="light"] .score-pill.good { color: #15803d; }
html[data-theme="light"] .score-pill.average { color: #b45309; }
html[data-theme="light"] .score-pill.weak { color: #b91c1c; }

/* --------------------------------------------------- Segmented control */
.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    gap: 3px;
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-family: inherit;
    font-size: .8rem;
    font-weight: 700;
    padding: .38rem .85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all .24s var(--ease);
    white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px -8px rgba(99,102,241,.9); }

/* ------------------------------------------------------- List utilities */
.list { display: flex; flex-direction: column; gap: .6rem; }
.list-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .85rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: all .24s var(--ease);
}
.list-item:hover { border-color: var(--brand-2); transform: translateX(-4px); }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: .75rem; color: var(--text-3); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.timeline { position: relative; padding-inline-start: 1.4rem; }
.timeline::before {
    content: "";
    position: absolute;
    inset-block: .4rem;
    inset-inline-start: .34rem;
    width: 2px;
    background: linear-gradient(180deg, var(--brand-2), transparent);
    border-radius: 2px;
}
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-item::before {
    content: "";
    position: absolute;
    inset-inline-start: -1.4rem;
    top: .45rem;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--brand-grad);
    box-shadow: 0 0 0 3px var(--bg-1);
}

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); font-size: .85rem; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-3); }
.kv span:last-child { font-weight: 700; }

.tag { display:inline-block; padding:.15rem .55rem; border-radius:8px; background:var(--surface-2); border:1px solid var(--border); font-size:.72rem; color:var(--text-2); }

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 2rem 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: all .3s var(--ease);
    background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag {
    border-color: var(--brand-2);
    background: var(--surface-hover);
    transform: translateY(-2px);
}
.dropzone .dz-icon {
    width: 64px; height: 64px;
    margin: 0 auto .8rem;
    border-radius: 20px;
    display: grid; place-items: center;
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 16px 34px -16px rgba(99,102,241,1);
}

/* ==========================================================================
   Login / Public auth screens
   ========================================================================== */

.login-wrap {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 1.4rem;
    width: min(1120px, 100%);
    margin: 0 auto;
    align-items: stretch;
    animation: ssFadeUp .6s var(--ease) both;
}

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

.login-aside {
    position: relative;
    overflow: hidden;
    padding: 2.4rem 2.1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: linear-gradient(160deg, rgba(99,102,241,.16), rgba(6,182,212,.09) 55%, transparent);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--shadow-3);
}

.login-aside h1 { margin: 0 0 1rem; font-weight: 800; letter-spacing: -.01em; }
.login-aside p { color: var(--text-2); font-size: .95rem; }

.login-points {
    display: grid;
    gap: .55rem;
    margin-top: 1.8rem;
}

.login-points .lp {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .85rem;
    color: var(--text-2);
    transition: transform .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease);
}

.login-points .lp:hover {
    transform: translateX(-4px);
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--text);
}

.login-points .lp svg { color: var(--brand-2); flex: none; }

.login-card {
    padding: 2.1rem 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-3);
    animation: ssFadeUp .7s .08s var(--ease) both;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .55rem;
}
/* هر دکمهٔ ورود نمونه یک فرم POST مستقل است — پس نباید خودش کارت باشد. */
.demo-form { display: block; margin: 0; }
.demo-form .demo-btn { width: 100%; text-align: start; }

.demo-btn {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: transform .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
}

.demo-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--brand-2);
    background: var(--surface-hover);
    box-shadow: var(--shadow-2);
}

.demo-btn:disabled { opacity: .55; cursor: not-allowed; }

.demo-btn .demo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.4;
}

.demo-btn .demo-text strong { font-size: .84rem; font-weight: 700; }
.demo-btn .demo-text .mono { font-size: .68rem; color: var(--text-3); }

@media (max-width: 900px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-aside { order: 2; padding: 1.8rem 1.4rem; }
    .login-card { order: 1; padding: 1.6rem 1.3rem; }
    .login-points { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .login-points { grid-template-columns: 1fr; }
    .demo-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Small utility helpers used across pages
   ========================================================================== */

.table-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.divider { height: 1px; background: var(--border); margin: 1.1rem 0; border: 0; }
.kpi-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: .55rem; }
.flex-1 { flex: 1; min-width: 0; }
.text-center { text-align: center; }
.text-end { text-align: end; }
.fw-700 { font-weight: 700; }
.fs-xs { font-size: .72rem; }
.gap-1 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-0 { padding: 0; }
.p-2 { padding: 1.1rem; }
.w-100 { width: 100%; }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.border-top { border-top: 1px solid var(--border); }
.rounded { border-radius: var(--radius); }
.surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.soft { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.nowrap-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-plain { list-style: none; margin: 0; padding: 0; }

/* Exam taking shell helpers */
.exam-shell .q-card { scroll-margin-top: 90px; }
.q-option {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    transition: all .25s var(--ease);
}
.q-option:hover { border-color: var(--brand-2); background: var(--surface-hover); }
.q-option.selected { border-color: var(--brand-2); background: var(--brand-grad-soft); box-shadow: inset 0 0 0 1px var(--brand-2); }

/* Print-friendly */
@media print {
    .sidebar, .topbar, .toast-stack, .no-print { display: none !important; }
    .main { margin: 0 !important; }
    .page { padding: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* ============================================ کارت «AI در حال فکر کردن» */
.ai-think {
    position: relative;
    overflow: hidden;
    margin-top: 1rem;
    padding: 1.5rem 1.25rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 24px);
    background:
        radial-gradient(120% 140% at 12% 0%, rgba(139,92,246,.16), transparent 60%),
        radial-gradient(120% 140% at 92% 110%, rgba(6,182,212,.14), transparent 60%),
        var(--surface, rgba(20,23,42,.72));
    animation: ssFadeUp .45s var(--ease) both;
}
/* هالهٔ پشت شخصیت — همان زبان بصری landing */
.ai-think-glow {
    position: absolute;
    inset-inline-end: -6%;
    top: -55%;
    width: 46%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--brand-grad);
    filter: blur(46px);
    opacity: .22;
    animation: aiGlowPulse 4.5s var(--ease) infinite;
    pointer-events: none;
}
@keyframes aiGlowPulse {
    0%, 100% { opacity: .18; transform: scale(1); }
    50%      { opacity: .38; transform: scale(1.08); }
}
.ai-think-stage {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.15rem;
    flex-wrap: wrap;
}
.ai-think .ai-owl {
    width: 128px;
    height: auto;
    flex: none;
    filter: drop-shadow(0 14px 24px rgba(99,102,241,.32));
    animation: floatY 4.2s var(--ease) infinite;
}
.ai-think-text { min-width: 0; flex: 1; }
.ai-think-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--text);
}
.ai-think-spark {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 10px;
    background: var(--brand-grad);
    color: #fff;
    flex: none;
    animation: pulseWarn 2.4s var(--ease) infinite;
}
.ai-think-sub { margin-top: .3rem; font-size: .82rem; color: var(--text-2); line-height: 1.7; }

/* مراحل کار — به‌جای اسپینر بی‌پایان، کاربر می‌بیند کجای کار است */
.ai-think-steps {
    list-style: none;
    margin: .85rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .55rem;
}
.ai-think-steps li {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .22rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .72rem;
    color: var(--text-3);
    transition: all .3s var(--ease);
}
.ai-think-steps li .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border-strong, #64748b);
    flex: none;
}
.ai-think-steps li.is-active {
    color: var(--text);
    border-color: rgba(139,92,246,.55);
    background: rgba(139,92,246,.14);
    font-weight: 700;
}
.ai-think-steps li.is-active .dot {
    background: var(--brand-2, #8b5cf6);
    box-shadow: 0 0 0 3px rgba(139,92,246,.22);
    animation: aiStepPulse 1.4s var(--ease) infinite;
}
.ai-think-steps li.is-done {
    color: var(--text-2);
    border-color: rgba(16,185,129,.4);
    background: rgba(16,185,129,.1);
}
.ai-think-steps li.is-done .dot { background: #10b981; }
@keyframes aiStepPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(139,92,246,.22); }
    50%      { box-shadow: 0 0 0 6px rgba(139,92,246,.06); }
}

.ai-think-meta {
    margin-top: .6rem;
    font-size: .72rem;
    color: var(--text-3);
}
.ai-think-slow { color: var(--warning, #f59e0b); }

/* روی گوشی جغد کوچک‌تر می‌شود تا متن پیام و مراحل جا شود.
   این بلوک عمداً بعد از قواعد .ai-think آمده؛ اگر داخل @media بالای فایل
   بگذارد، قاعدهٔ بعدیِ .ai-think .ai-owl با specificity برابر آن را خنثی می‌کند. */
@media (max-width: 640px) {
    .ai-think { padding: 1.15rem 1rem 1rem; }
    .ai-think-stage { gap: .75rem; }
    .ai-think .ai-owl { width: 88px; }
    .ai-think-title { font-size: .94rem; }
    .ai-think-sub { font-size: .78rem; }
    .ai-think-steps { gap: .28rem .38rem; margin-top: .7rem; }
    .ai-think-steps li { font-size: .67rem; padding: .18rem .45rem; }
}

/* نوار پیشرفت نامعین — نشان می‌دهد کار ادامه دارد */
.ai-think-bar {
    position: relative;
    height: 5px;
    margin-top: 1.1rem;
    border-radius: 999px;
    background: rgba(148,163,184,.2);
    overflow: hidden;
}
.ai-think-bar span {
    position: absolute;
    inset-block: 0;
    width: 38%;
    border-radius: 999px;
    background: var(--brand-grad);
    animation: aiThinkSlide 1.6s var(--ease) infinite;
}
@keyframes aiThinkSlide {
    0%   { transform: translateX(120%); }
    100% { transform: translateX(-320%); }
}

/* -------------------------------------------- حرکت اجزای جغد */
.owl-pupil { animation: owlLook 5.2s var(--ease) infinite; }
.owl-pupil-r { animation-delay: .12s; }
@keyframes owlLook {
    0%, 22%, 46%, 72%, 100% { transform: translateX(0); }
    10%, 34%                 { transform: translateX(3.4px); }
    58%, 84%                 { transform: translateX(-3.4px); }
}
.owl-shine { animation: owlBlink 5.2s var(--ease) infinite; }
@keyframes owlBlink {
    0%, 92%, 100% { opacity: 1; }
    95%           { opacity: .25; }
}
/* پلک: بیشترِ زمان بالا جمع است، گاهی پایین می‌آید */
.owl-lid { transform-origin: center; animation: owlLid 5.2s var(--ease) infinite; }
@keyframes owlLid {
    0%, 86%, 100% { transform: scaleY(0); }
    90%, 94%      { transform: scaleY(1); }
}
.owl-bubble { animation: bubbleIn .5s var(--ease) .5s both; }
.owl-dot { animation: typingBounce 1.25s var(--ease) infinite; }
.owl-dot.d2 { animation-delay: .16s; }
.owl-dot.d3 { animation-delay: .32s; }
/* ذرات حباب بالا می‌آیند */
.owl-bubble circle { animation: owlPuff 3s var(--ease) infinite; }
@keyframes owlPuff {
    0%, 100% { opacity: .55; transform: translateY(0); }
    50%      { opacity: 1;   transform: translateY(-3px); }
}

/* احترام به تنظیم «کاهش حرکت» */
@media (prefers-reduced-motion: reduce) {
    .ai-think, .ai-think .ai-owl, .ai-think-glow, .ai-think-spark,
    .ai-think-bar span, .owl-pupil, .owl-shine, .owl-lid, .owl-bubble circle,
    .owl-dot {
        animation: none !important;
    }
    .owl-lid { transform: scaleY(0); }
    .owl-dot { opacity: 1; }
}

/* ---------------------------------- انتخاب مسیر: AI یا ساخت دستی */
.path-card {
    display: flex;
    align-items: center;
    gap: .8rem;
    width: 100%;
    padding: .95rem 1rem;
    text-align: start;
    border: 1px solid var(--border);
    border-radius: var(--radius, 16px);
    background: var(--surface, rgba(20,23,42,.72));
    color: var(--text);
    cursor: pointer;
    transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.path-card:hover {
    border-color: rgba(139,92,246,.55);
    box-shadow: var(--shadow-2, 0 4px 16px rgba(0,0,0,.22));
    transform: translateY(-2px);
}
.path-card:active { transform: translateY(0); }
.path-icon {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: 14px;
    color: #fff;
    flex: none;
}
.path-body { flex: 1; min-width: 0; display: block; }
.path-body strong { display: block; font-size: .94rem; font-weight: 800; margin-bottom: .15rem; }
.path-body .fs-sm { display: block; line-height: 1.65; }

/* ==========================================================================
   انتقاد و پیشنهاد (Feedback)
   ========================================================================== */

/* جداکنندهٔ بخش در فرم‌ها — «اطلاعات دانش‌آموز» / «حساب والدین».
   از <hr> استفاده نکردم چون در گرید فرم، فاصلهٔ عمودی‌اش قابل کنترل نیست. */
.form-sep {
    display: flex;
    align-items: center;
    gap: .5rem;
    grid-column: 1 / -1;
    margin: .4rem 0 .2rem;
    padding-top: .8rem;
    border-top: 1px dashed var(--border-strong);
    font-size: .82rem;
    font-weight: 800;
    color: var(--text-2);
}

.fb-subject {
    margin: 0;
    font-size: .98rem;
    font-weight: 800;
    line-height: 1.5;
}

.fb-body {
    margin: .7rem 0 0;
    white-space: pre-wrap;
    line-height: 1.85;
    font-size: .9rem;
}

/* کارت «جدید» یک نوار رنگی سمت شروع می‌گیرد تا در فهرست بلند دیده شود. */
.fb-card.is-new {
    border-inline-start: 3px solid var(--brand-2);
}

.fb-anon {
    display: inline-block;
    margin-inline-start: .3rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .7rem;
    color: var(--text-3);
}

/* ---------------------------------------------------------- شمارنده‌ها */
.fb-counts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: .6rem;
    margin-bottom: 1rem;
}

.fb-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: .7rem .5rem;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.fb-count.is-hot {
    border-color: var(--brand-2);
    background: var(--brand-grad-soft);
}

.fb-count-num {
    font-size: 1.3rem;
    font-weight: 900;
    line-height: 1.2;
}

.fb-count-lbl { font-size: .74rem; color: var(--text-3); font-weight: 600; }

/* -------------------------------------------------------------- پاسخ */
.fb-reply {
    margin-top: .8rem;
    padding: .7rem .85rem;
    border-radius: 12px;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border);
}

.fb-reply-head {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .76rem;
    font-weight: 700;
    color: var(--brand-2);
    margin-bottom: .3rem;
}

.fb-reply-body {
    font-size: .87rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.fb-reply-form {
    margin-top: .8rem;
    padding-top: .8rem;
    border-top: 1px dashed var(--border-strong);
    display: grid;
    gap: .5rem;
}

/* ---------------------------------------------------------- ستاره‌ها */
.fb-stars {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
    margin-top: .5rem;
    color: var(--border-strong);
}

.fb-stars span.on, .fb-stars button.on { color: #f59e0b; }

.fb-stars-input button {
    background: none;
    border: 0;
    padding: .1rem;
    cursor: pointer;
    color: var(--border-strong);
    line-height: 0;
    transition: transform .15s var(--ease), color .15s var(--ease);
}

.fb-stars-input button:hover { transform: scale(1.15); }
.fb-stars-input button.on { color: #f59e0b; }

/* ------------------------------------------------------ نکته‌های راهنما */
.fb-tip {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}

.fb-tip-ico {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 10px;
    background: var(--brand-grad-soft);
    border: 1px solid var(--border);
    color: var(--brand-2);
    flex: none;
}

.fb-sec-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .95rem;
    margin: 1.4rem 0 .8rem;
}

.fb-inbox > .fb-sec-title:first-child { margin-top: 0; }

/* ==========================================================================
   بخش‌ها (کلاس‌ها) و زنگ‌بانی هفتگی
   --------------------------------------------------------------------------
   تا پیش از این، «کلاس دهم-۱» وجود نداشت: جدول Courses هم کلاس دانش‌آموزان بود
   هم درس با معلم. dbo.Sections آن مفهوم را اضافه کرد و این‌ها ظاهر آن‌اند.
   ========================================================================== */

.fw-600 { font-weight: 600; }
.fw-800 { font-weight: 800; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.form-row {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    flex-wrap: wrap;
    padding: .9rem 1rem 0;
}

.input-sm {
    padding: .3rem .55rem;
    font-size: .8rem;
    border-radius: 8px;
    max-width: 200px;
}

.btn-xs {
    padding: .2rem .45rem;
    font-size: .72rem;
    border-radius: 7px;
    line-height: 1.2;
}

.chk {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    cursor: pointer;
    font-size: .88rem;
}

/* --------------------------------------------------------------- زنگ‌بندی */

table.tt {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}

table.tt thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    backdrop-filter: blur(8px);
    text-align: center;
    padding: .55rem .5rem;
    min-width: 118px;
}

.tt-day {
    text-align: start !important;
    white-space: nowrap;
    min-width: 92px !important;
    font-weight: 700;
    background: var(--surface-2);
}

.tt-cell {
    height: 88px;
    vertical-align: top;
    padding: .35rem !important;
    border: 1px solid var(--grid-line);
}

.tt-cell.is-empty {
    background:
        repeating-linear-gradient(135deg,
            transparent 0 8px,
            var(--surface-hover) 8px 16px);
}

.tt-fill {
    width: 100%;
    height: 100%;
    min-height: 62px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}

.tt-fill:hover {
    border-color: var(--brand-1);
    color: var(--brand-1);
    background: var(--surface-hover);
}

.tt-t {
    font-weight: 700;
    font-size: .86rem;
    line-height: 1.35;
}

.tt-s {
    font-size: .72rem;
    color: var(--text-3);
    margin-top: .1rem;
}

.tt-a {
    display: flex;
    gap: .15rem;
    justify-content: flex-end;
    margin-top: .2rem;
    opacity: .55;
    transition: opacity var(--dur) var(--ease);
}

.tt-cell:hover .tt-a { opacity: 1; }

/* --------------------------------------------------------- فهرست دانش‌آموز */

.roster {
    border-top: 1px solid var(--border);
    background: var(--surface-hover);
}

.roster-head {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .6rem 1rem;
}

.roster .table-wrap { max-height: 340px; overflow: auto; }

/* ------------------------------------------------- برنامه هفتگی: خانهٔ کم‌رنگ */

/* خانهٔ بقیهٔ معلم‌ها/کلاس‌ها: دیده می‌شود ولی تعاملی نیست. «کم‌رنگ» با
   pointer-events پیاده شده، نه فقط opacity — وگرنه کلیک اتفاقی باز هم
   کنترل را باز می‌کرد و کاربر در حالت فقط‌مشاهده چیزی را عوض می‌کرد. */
.tt-cell.is-dim { opacity: .38; pointer-events: none; }

/* رنگ خانه از style درون‌خطی می‌آید (رنگ درس)؛ این‌ها فقط قالب بیرونی‌اند. */
.tt-cell { transition: opacity var(--dur) var(--ease); }
.tt-cell:hover { opacity: 1; }
.tt-cell.is-empty:hover { opacity: 1; }

.tt-t { text-shadow: 0 0 1px currentColor; }

@media (max-width: 720px) {
    .tt-cell { height: 78px; }
    .tt-s { font-size: .68rem; }
}

/* ------------------------------------------------- فهرست کار دانش‌آموز (مشترک) */

.hw-card.is-readonly { border-inline-start-style: dashed; opacity: .95; }

/* کارت آزمون در حالت فقط‌مشاهده (پنل والدین): حاشیهٔ خط‌چین همان زبانهٔ
   «این کارت دکمهٔ کاری ندارد» است تا کاربر دنبال دکمه نگردد. */
.card.is-readonly { border-inline-start-style: dashed; }
