/* Raparin Group Timetable — application styles (RTL-first, light/dark). */

:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2456a6;
    --brand-strong: #1c4488;
    --brand-soft: #e8effa;
    --accent: #d97706;
    --ok: #16a34a;
    --ok-soft: #e7f6ec;
    --warn: #d97706;
    --warn-soft: #fdf1e0;
    --danger: #dc2626;
    --danger-soft: #fdeaea;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
    --radius: 12px;
    --radius-sm: 8px;
    --topbar-h: 58px;
    --sidebar-w: 240px;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --panel: #121a2b;
    --panel-2: #182338;
    --text: #e6ecf5;
    --muted: #8fa0b8;
    --line: #24304a;
    --brand: #5b8fe0;
    --brand-strong: #7ba6ea;
    --brand-soft: #1a2b47;
    --ok: #34c46b;
    --ok-soft: #10281a;
    --warn: #e79a2e;
    --warn-soft: #2d2110;
    --danger: #ef5350;
    --danger-soft: #331313;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: 'Vazirmatn', 'Noto Sans Arabic', 'Noto Sans', Tahoma, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.35; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.fw-bold { font-weight: 700; }
.mt-4 { margin-block-start: 1.25rem; }
.hide-sm { display: inline; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: .5rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: transparent;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { color: var(--text); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.btn-outline { border-color: var(--line); background: var(--panel); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-title { font-size: 1.25rem; margin: 0; }
.form-subtitle { margin-block-end: .25rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-weight: 600; font-size: .9rem; }
.field-error { color: var(--danger); font-size: .82rem; }

.input, select.input, textarea.input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-inline-end: 2.6rem; }
.input-affix {
    position: absolute;
    inset-inline-end: .35rem;
    inset-block-start: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: .35rem;
    border-radius: 6px;
}
.input-affix:hover { color: var(--text); }
.password-row { display: flex; align-items: stretch; gap: .5rem; }
.password-row .input { min-width: 0; flex: 1; }
.password-toggle { flex: none; width: 42px; padding: .5rem; }

/* ---------- Cards / alerts ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card-title { font-size: 1.05rem; }
.card-narrow { max-width: 460px; }

.alert {
    border-radius: var(--radius-sm);
    padding: .7rem 1rem;
    margin-block-end: 1rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border-radius: 999px;
    padding: .15rem .7rem;
    font-size: .8rem;
    font-weight: 700;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--panel-2); color: var(--muted); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    inset-inline-start: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: .35rem;
    display: none;
    z-index: 60;
}
.dropdown-end .dropdown-menu { inset-inline-start: auto; inset-inline-end: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: start;
    background: transparent;
    border: 0;
    font: inherit;
    color: var(--text);
    padding: .5rem .7rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--brand-soft); color: var(--brand); }
.dropdown-item.is-active { font-weight: 700; color: var(--brand); }
.dropdown-item-danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-header { padding: .5rem .7rem; border-block-end: 1px solid var(--line); margin-block-end: .35rem; }

/* ---------- Plain (login/activation) layout ---------- */
.page-plain { min-height: 100vh; display: flex; flex-direction: column; }
.plain-topbar {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.25rem;
}
.plain-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1rem;
}
.plain-card { width: 100%; max-width: 430px; padding: 2rem; }
.plain-footer { font-size: .8rem; }

.brand-block { text-align: center; margin-block-end: 1.5rem; }
.brand-mark { width: 52px; height: 52px; }
.brand-name { font-size: 1.2rem; margin: .6rem 0 .2rem; }
.brand-tagline { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---------- App shell ---------- */
.page-app { min-height: 100vh; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: .5rem;
    height: var(--topbar-h);
    padding-inline: .75rem;
    background: var(--panel);
    border-block-end: 1px solid var(--line);
}
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    min-width: 0; /* allow the brand to shrink on narrow screens instead of overflowing the topbar */
}
.topbar-brand .brand-mark { width: 30px; height: 30px; }
.topbar-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-spacer { flex: 1; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
}

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--panel);
    border-inline-end: 1px solid var(--line);
    padding: .9rem .6rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .8rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.sidebar-link:hover { background: var(--brand-soft); color: var(--brand); }
.sidebar-link.is-active { background: var(--brand); color: #fff; }
.sidebar-toggle { display: none; }

.content { flex: 1; padding: 1.5rem; min-width: 0; }

.page-head { margin-block-end: 1.25rem; }
.page-title { font-size: 1.35rem; margin: 0 0 .25rem; }

/* ---------- Grid / stats ---------- */
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.stat-card { display: flex; flex-direction: column; gap: .35rem; }
.stat-label { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; display: flex; align-items: center; gap: .4rem; }
.stat-ok { color: var(--ok); }
.stat-warn { color: var(--warn); font-size: 1.05rem; }
.stat-foot { font-size: .8rem; }

/* ---------- Tables (used across modules) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; border-block-end: 1px solid var(--line); text-align: start; }
.table th { color: var(--muted); font-size: .82rem; font-weight: 700; }
.table tbody tr:hover { background: var(--panel-2); }

/* ---------- Theme toggle icons ---------- */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        inset-block: var(--topbar-h) 0;
        inset-inline-start: 0;
        transform: translateX(calc(var(--rtl-flip, 1) * -100%));
        transition: transform .2s ease;
        z-index: 55;
    }
    [dir="rtl"] .sidebar { --rtl-flip: -1; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .hide-sm { display: none; }
    .content { padding: 1rem; }
}

/* ---- Module utilities: toolbars, chips, pagination, timelines, lists ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-block-end: 16px; }
.toolbar .input { max-width: 320px; }
.select-auto { width: auto; }
.code-chip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: .92em; letter-spacing: .04em; }
.code-chip-lg { font-size: 1.15rem; padding: 6px 12px; }
.empty-note { padding: 24px 0; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-block-start: 16px; }
.is-disabled { pointer-events: none; opacity: .45; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row form { display: inline-flex; margin: 0; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { filter: brightness(.92); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.92); }
.badge-info { background: var(--brand-soft); color: var(--brand); }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2col { grid-template-columns: 1fr; } }
.divider { border: 0; border-block-start: 1px solid var(--line); margin-block: 20px; }
.hint { color: var(--muted); font-size: .85rem; margin-block-start: 6px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; }
.ta-end { text-align: end; }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { position: relative; padding-inline-start: 22px; padding-block-end: 14px; }
.timeline-item::before { content: ""; position: absolute; inset-inline-start: 5px; inset-block-start: 14px; inset-block-end: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; inset-inline-start: 0; inset-block-start: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.is-copied { outline: 2px solid var(--ok); }

/* ---- License lock screen & status ---- */
.license-lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(3, 7, 18, .88);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}
.license-lock {
    width: min(100%, 460px);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: #fff;
}
.lock-icon { color: var(--danger); display: flex; justify-content: center; }
.lock-title { font-size: 1.55rem; margin: 0; }
.lock-reason { margin: 0; }
.lock-message {
    background: rgba(15, 23, 42, .94);
    border: 1px solid rgba(239, 68, 68, .65);
    border-radius: 18px;
    padding: 24px;
    line-height: 2;
    font-weight: 600;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.lock-message p { margin: 0; }
.lock-owner { font-size: 1.25rem; font-weight: 800; }
.lock-phone {
    display: inline-block;
    margin-block-start: 10px;
    padding: 8px 22px;
    border-radius: 999px;
    background: #16a34a;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    text-decoration: none;
    direction: ltr;
}
.lock-phone:hover { background: #15803d; }
.lock-device { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.lock-device .code-chip { max-width: 100%; overflow-wrap: anywhere; }
.lock-actions { display: flex; justify-content: center; gap: 10px; }
.lock-actions form { margin: 0; }
.input-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .12em; text-align: center; }
.kv-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 16px; }
.kv-list dt { color: var(--muted); }
.kv-list dd { margin: 0; overflow-wrap: anywhere; }
.link-plain { color: inherit; text-decoration: none; }
.link-plain:hover { text-decoration: underline; }

/* ---- academic structure additions ---- */
.inline-form { display: inline-flex; vertical-align: middle; }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.sidebar-heading { margin: 16px 14px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .05em; opacity: .55; text-transform: uppercase; }
.form-inset { border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); margin-top: 14px; padding-top: 14px; }
.trash-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }
.trash-list li { display: flex; align-items: center; gap: 10px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; margin-inline-end: 18px; cursor: pointer; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); vertical-align: middle; }

/* ---- teacher availability grid ---- */
.avail-grid { border-collapse: collapse; margin: 6px 0; }
.avail-grid th, .avail-grid td { border: 1px solid color-mix(in srgb, currentColor 14%, transparent); padding: 3px 6px; text-align: center; font-size: .85rem; }
.avail-btn { width: 34px; height: 30px; border: 0; background: transparent; cursor: pointer; border-radius: 6px; font-size: .95rem; color: inherit; }
.avail-btn:hover { outline: 2px solid color-mix(in srgb, currentColor 25%, transparent); }
.avail-btn.is-pref { background: var(--ok); color: #fff; }
.avail-btn.is-unav { background: var(--danger); color: #fff; }
.text-sm { font-size: .85rem; }

/* Audit log details */
.audit-details { margin-top: 8px; padding: 10px; background: var(--surface-2, rgba(128,128,128,.08)); border-radius: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-all; max-width: 480px; overflow: auto; }

/* ---- Institution branding (logo in topbar, plain layout and settings) ---- */
.topbar-logo { height: 30px; width: auto; max-width: 150px; object-fit: contain; border-radius: 6px; }
.brand-logo { display: block; height: 56px; width: auto; max-width: 200px; object-fit: contain; border-radius: 8px; margin-inline: auto; margin-block-end: 8px; }
.logo-preview-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-block-end: 8px; }
.logo-preview { height: 56px; width: auto; max-width: 200px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); padding: 4px; }
.field-hint { margin: 4px 0 0; }

/* ---- Subject color palette (aSc-style; the timetable grid reuses it) ---- */
:root {
    --subj-1: #e11d48;
    --subj-2: #ea580c;
    --subj-3: #d97706;
    --subj-4: #65a30d;
    --subj-5: #16a34a;
    --subj-6: #0d9488;
    --subj-7: #0284c7;
    --subj-8: #4f46e5;
    --subj-9: #7c3aed;
    --subj-10: #c026d3;
    --subj-11: #db2777;
    --subj-12: #475569;
}
.subj-c1 { --chip: var(--subj-1); }
.subj-c2 { --chip: var(--subj-2); }
.subj-c3 { --chip: var(--subj-3); }
.subj-c4 { --chip: var(--subj-4); }
.subj-c5 { --chip: var(--subj-5); }
.subj-c6 { --chip: var(--subj-6); }
.subj-c7 { --chip: var(--subj-7); }
.subj-c8 { --chip: var(--subj-8); }
.subj-c9 { --chip: var(--subj-9); }
.subj-c10 { --chip: var(--subj-10); }
.subj-c11 { --chip: var(--subj-11); }
.subj-c12 { --chip: var(--subj-12); }

.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-block-start: .5rem; }
.subject-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 700;
    padding: .18rem .65rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chip, var(--brand)) 15%, transparent);
    color: color-mix(in srgb, var(--chip, var(--brand)) 72%, var(--text));
}
.subject-chip::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chip, var(--brand));
    flex: none;
}

/* ---- Guided setup path (aSc-style dashboard) ---- */
.setup-path { padding: 1.5rem; }
.setup-head {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-block-end: 1.25rem;
}
.setup-title { font-size: 1.3rem; margin: 0 0 .25rem; }
.setup-head p { margin: 0; }
.setup-progress { flex: 0 1 260px; min-width: 210px; display: flex; flex-direction: column; gap: .4rem; }
.setup-progress-label { font-size: .85rem; font-weight: 700; color: var(--brand); }
.progress { height: 10px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--ok)); transition: width .4s ease; }

.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .65rem; }
.step-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: .9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .85rem 1.1rem;
    background: var(--panel);
    transition: border-color .15s, box-shadow .15s;
}
.step-card:not(.is-coming):hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: var(--shadow); }
.step-card.is-current { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.step-card.is-coming { opacity: .62; background: var(--panel-2); }

.step-num {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background: var(--brand-soft);
    color: var(--brand);
    flex: none;
}
.is-done .step-num { background: var(--ok); color: #fff; }
.is-current .step-num { background: var(--brand); color: #fff; }

.step-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--step-c, var(--brand)) 13%, transparent);
    color: var(--step-c, var(--brand));
}
.step-icon-wrap .icon { width: 1.45em; height: 1.45em; }
.step-card[data-c="1"] { --step-c: var(--subj-7); }
.step-card[data-c="2"] { --step-c: var(--subj-3); }
.step-card[data-c="3"] { --step-c: var(--subj-9); }
.step-card[data-c="4"] { --step-c: var(--subj-5); }
.step-card[data-c="5"] { --step-c: var(--subj-1); }
.step-card[data-c="6"] { --step-c: var(--subj-6); }
.step-card[data-c="7"] { --step-c: var(--subj-8); }
.step-card[data-c="8"] { --step-c: var(--subj-2); }

.step-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.step-title { font-weight: 700; font-size: 1rem; }
.step-title a:hover { text-decoration: underline; }
.step-hint { font-size: .84rem; }
.step-meta { display: flex; align-items: center; gap: .6rem; justify-self: end; }
[dir="rtl"] .step-cta-arrow { transform: scaleX(-1); }

.btn-hero {
    padding: .6rem 1.4rem;
    font-size: 1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), #7c3aed);
    color: #fff;
}

@media (max-width: 700px) {
    .step-card { grid-template-columns: auto 1fr; }
    .step-icon-wrap { display: none; }
    .step-meta { grid-column: 1 / -1; justify-self: start; }
}

/* ---- Sidebar collapsible groups (quiet menus) ---- */
.sidebar-group { margin-block-start: .9rem; }
.sidebar-group > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin: 0 14px 4px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    opacity: .55;
    text-transform: uppercase;
    user-select: none;
}
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary:hover { opacity: .85; }
.group-chevron { width: .95em; height: .95em; transition: transform .15s; }
.sidebar-group[open] .group-chevron { transform: rotate(180deg); }
.sidebar-group-items { display: flex; flex-direction: column; gap: .15rem; }

/* ---- Auth Layout additions ---- */
.auth-wrapper {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-header {
    text-align: center;
    margin-block-end: 3rem;
    animation: authFadeIn 0.6s ease-out;
}

.auth-main-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-block-end: 0.5rem;
    color: var(--text);
}

.auth-subtitle {
    font-size: 1.05rem;
    margin: 0;
}

.inst-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    width: 100%;
    animation: authFadeUp 0.6s ease-out 0.1s both;
}

.inst-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.inst-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--inst-accent) 12%, transparent) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.inst-card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--inst-accent) 40%, var(--line));
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 0 0 1px color-mix(in srgb, var(--inst-accent) 20%, transparent);
}

.inst-card:hover::before {
    opacity: 1;
}

.inst-logo-wrap {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    padding: 4px;
    background: var(--panel);
    border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.inst-card:hover .inst-logo-wrap {
    transform: scale(1.05) rotate(-2deg);
    border-color: var(--inst-accent);
}

.inst-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.inst-info {
    flex: 1;
    z-index: 1;
}

.inst-name {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.inst-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.inst-arrow {
    color: var(--muted);
    transition: all 0.3s ease;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inst-card:hover .inst-arrow {
    color: var(--inst-accent);
    transform: translateX(calc(var(--rtl-flip, 1) * 6px));
}

[dir="rtl"] .inst-arrow svg {
    transform: scaleX(-1);
}

[dir="rtl"] .inst-card {
    --rtl-flip: -1;
}

/* Login Form specific */
.auth-login-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    animation: authFadeUp 0.5s ease-out;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    margin-block-end: 1.5rem;
    transition: color 0.2s ease;
}

.auth-back-link:hover {
    color: var(--text);
}

[dir="rtl"] .auth-back-link svg {
    transform: scaleX(-1);
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01), 0 0 0 1px color-mix(in srgb, var(--inst-accent) 15%, transparent);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 5px;
    background: var(--inst-accent);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-block-end: 2rem;
}

.auth-brand .inst-logo-wrap {
    width: 96px;
    height: 96px;
    margin-block-end: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.auth-inst-name {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 0.35rem;
    color: var(--text);
}

.auth-inst-label {
    font-size: 0.95rem;
    color: var(--muted);
    margin: 0;
    font-weight: 600;
}

.auth-form .field {
    gap: 0.5rem;
    margin-block-end: 1.25rem;
}

.auth-form .field-label {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

.auth-input {
    border-radius: 12px;
    padding: 0.75rem 1rem;
    background: var(--panel-2);
    border: 1px solid var(--line);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.auth-input:focus {
    background: var(--panel);
    border-color: var(--inst-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--inst-accent) 20%, transparent);
}

.password-row .password-toggle {
    border-radius: 12px;
    border-color: var(--line);
    background: var(--panel-2);
}

.password-row .password-toggle:hover {
    background: var(--panel);
    border-color: var(--inst-accent);
    color: var(--inst-accent);
}

.auth-submit-btn {
    margin-block-start: 0.5rem;
    padding: 0.85rem;
    font-size: 1.05rem;
    border-radius: 12px;
    background: var(--inst-accent);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--inst-accent) 30%, transparent);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--inst-accent) 40%, transparent);
    filter: brightness(1.08);
}

.auth-submit-btn:active {
    transform: translateY(0);
}

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

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

@media (max-width: 600px) {
    .auth-card {
        padding: 2rem 1.25rem;
        border-radius: 20px;
    }
    
    .inst-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-main-title {
        font-size: 1.5rem;
    }
}
