/* ============ Токены ============ */
:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e3e8ef;
    --text: #1b2533;
    --muted: #64748b;
    --primary: #2457d6;
    --primary-hover: #1c47b3;
    --primary-soft: #e8eefc;
    --success: #15803d;
    --success-soft: #e7f6ec;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --warning: #b45309;
    --warning-soft: #fdf3e2;
    --sidebar-bg: #14213d;
    --sidebar-text: #c9d3e6;
    --sidebar-active: #2b3d63;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 20px 40px rgba(16, 24, 40, .18);

    /* цвета видов занятий */
    --lt-lecture: #2457d6;
    --lt-practice: #0f8a6a;
    --lt-lab: #7c3aed;
    --lt-seminar: #0e7490;
    --lt-consultation: #b45309;
    --lt-credit: #c2410c;
    --lt-exam: #c62828;
    --lt-coursework: #4d7c0f;
    --lt-internship: #be185d;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h1:focus { outline: none; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.icon { flex-shrink: 0; vertical-align: middle; }

/* ============ Каркас ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1rem .75rem;
}

.brand {
    display: flex; align-items: center; gap: .6rem;
    padding: .25rem .5rem 1rem;
    color: #fff;
    text-decoration: none !important;
}
.brand-logo {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.brand-sub { font-size: .75rem; opacity: .7; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    color: #8a98b5;
    padding: 1rem .75rem .35rem;
}
.nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none !important;
    font-size: .93rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0 .45rem;
    line-height: 1.5;
}
.tab .nav-badge { margin-left: .4rem; }

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

.topbar {
    display: flex; align-items: center; gap: .75rem;
    height: 60px;
    padding: 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar-spacer, .toolbar-spacer { flex: 1; }
.burger { display: none; cursor: pointer; color: var(--text); }
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

.user-chip {
    display: flex; align-items: center; gap: .55rem;
    color: var(--text);
    text-decoration: none !important;
    padding: .25rem .5rem;
    border-radius: 8px;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip-name { font-weight: 600; font-size: .9rem; }
.user-chip-role { font-size: .75rem; color: var(--muted); }
.inline-form { display: inline; margin: 0; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; }

/* ============ Компоненты ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.table-card { padding: 0; overflow: hidden; }
.pad { padding: 1.25rem; }

.page-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-header p { margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit;
    font-weight: 500;
    padding: .55rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .87rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #cfd6e0; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.link-btn {
    background: none; border: none; padding: 0;
    color: var(--primary); cursor: pointer; font: inherit; font-size: .85rem;
}

/* формы */
.field { margin-bottom: .9rem; }
.field label, .field > label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.input {
    width: 100%;
    font: inherit;
    padding: .5rem .7rem;
    border: 1px solid #cfd6e0;
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
/* Выпадающие списки: своя стрелка с отступом от края вместо системной */
select.input:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .85rem center;
    background-size: 16px;
    cursor: pointer;
}
select.input:disabled { cursor: not-allowed; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input-auto { width: auto; min-width: 200px; }
textarea.input { resize: vertical; }
.input-group { display: flex; gap: .5rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.hint-inline { font-weight: 400; color: var(--muted); font-size: .78rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .4rem 0 .8rem; cursor: pointer; font-size: .92rem; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.validation-message { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.invalid { border-color: var(--danger) !important; }

.grid-2, .grid-3 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.checklist {
    max-height: 190px;
    overflow-y: auto;
    border: 1px solid #cfd6e0;
    border-radius: 8px;
    padding: .25rem .75rem;
}
.checklist .check { margin: .35rem 0; }

/* оповещения */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: .93rem;
}
.alert-row { display: flex; align-items: center; gap: .75rem; }
.alert-row > span { flex: 1; }
.alert-error { background: var(--danger-soft); color: #8f1d1d; border-color: #f6caca; }
.alert-success { background: var(--success-soft); color: #14532d; border-color: #bfe5cb; }
.alert-info { background: var(--primary-soft); color: #1e3a8a; border-color: #cbd8f7; }
.conflicts { margin: .5rem 0 0; padding-left: 1.2rem; }

/* метки */
.tag {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    vertical-align: middle;
}
.tag-accent { background: var(--primary-soft); color: var(--primary); }
.status { font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.status-active { background: var(--success-soft); color: var(--success); }
.status-pending { background: var(--warning-soft); color: var(--warning); }
.status-blocked { background: var(--danger-soft); color: var(--danger); }
.status-rejected { background: #eef0f3; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--primary-soft); color: var(--primary); padding: .25rem .7rem; border-radius: 999px; font-size: .87rem; font-weight: 500; }

/* таблицы */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfd; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: .8rem; color: var(--muted); }
.actions-col { width: 1%; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: .25rem; justify-content: flex-end; }

/* панель инструментов, вкладки */
.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .75rem 1rem; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.1rem; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.segmented button {
    border: none; background: transparent; font: inherit; font-size: .9rem;
    padding: .35rem .85rem; border-radius: 6px; cursor: pointer; color: var(--muted);
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 500; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab {
    border: none; background: none; font: inherit; cursor: pointer;
    padding: .6rem 1rem; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-flex; align-items: center;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state p { margin: .5rem 0 0; }

.list { margin: 0; padding-left: 1.2rem; }
.list li { margin: .3rem 0; }

/* модальные окна */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; }
.modal {
    position: fixed; z-index: 101;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.modal-wide { width: min(820px, calc(100vw - 2rem)); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }

/* ============ Гостевой режим (не вошёл в систему) ============ */
.guest { min-height: 100vh; display: flex; flex-direction: column; }
.guest-header {
    display: flex; align-items: center; gap: .6rem;
    height: 60px; padding: 0 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand-dark { color: var(--text); padding: 0; }
.guest-content { margin: 0 auto; }

/* ============ Авторизация ============ */
.auth-page { display: flex; justify-content: center; padding: 2rem 0; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.auth-card-wide { max-width: 720px; }
.auth-card h1 { margin-bottom: .4rem; }
.auth-card > p.muted { margin-top: 0; margin-bottom: 1.25rem; }
.auth-footer { text-align: center; margin: 1.25rem 0 0; font-size: .92rem; color: var(--muted); }

/* ============ Главная ============ */
.hero {
    background: linear-gradient(135deg, #1d3e9e, #2457d6 60%, #3b82f6);
    color: #fff;
    border-radius: 14px;
    padding: 2rem;
    margin-bottom: 1.25rem;
}
.hero h1 { font-size: 1.9rem; }
.hero p { max-width: 720px; opacity: .92; margin: .5rem 0 0; }
.hero .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.hero .btn-primary { background: #fff; color: var(--primary); }

.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.section-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    color: var(--text);
    text-decoration: none !important;
    transition: border-color .15s, transform .15s;
}
.section-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.section-card h2 { margin: .8rem 0 .4rem; font-size: 1.02rem; }
.section-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.section-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }

/* ============ Личный кабинет ============ */
.cabinet-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1rem; }
.cabinet-grid .card { margin-bottom: 0; }
.cabinet-grid + .card { margin-top: 1rem; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0 0 1rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.stat { display: flex; flex-direction: column; padding: .9rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.stat:hover { border-color: var(--primary); }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: .82rem; color: var(--muted); }

.cabinet-single { max-width: 640px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.card-title-row h2 { margin: 0; }

/* ============ Настройки расписания ============ */
.settings-card { max-width: 720px; }
.pairs-table { margin-bottom: .5rem; }
.pairs-table td, .pairs-table th { padding: .5rem .6rem; }
.pairs-table .input { max-width: 140px; }

/* ============ Расписание (просмотр) ============ */
.week-picker { display: flex; align-items: center; justify-content: center; gap: .75rem; margin: 0 0 1rem; }
.week-label { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; flex-wrap: wrap; justify-content: center; }

.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.day-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.day-header { display: flex; align-items: baseline; gap: .5rem; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.day-name { font-weight: 600; text-transform: capitalize; }
.day-date { color: var(--muted); font-size: .9rem; }
.day-empty { padding: 1rem; color: var(--muted); font-size: .9rem; }

.lesson { display: flex; gap: .9rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); border-left: 4px solid var(--lt-color, var(--primary)); }
.lesson:last-child { border-bottom: none; }
.lesson-time { display: flex; flex-direction: column; min-width: 92px; font-size: .82rem; color: var(--muted); }
.lesson-pair { font-weight: 600; color: var(--text); }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; }
.lesson-type { margin-right: .35rem; background: color-mix(in srgb, var(--lt-color) 12%, white); color: var(--lt-color); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.lesson-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.lesson-note { font-size: .82rem; color: var(--warning); margin-top: .2rem; }

.session-day { margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.session-date { font-weight: 600; padding: .55rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.session-date::first-letter { text-transform: uppercase; }

.lt-lecture { --lt-color: var(--lt-lecture); }
.lt-practice { --lt-color: var(--lt-practice); }
.lt-lab { --lt-color: var(--lt-lab); }
.lt-seminar { --lt-color: var(--lt-seminar); }
.lt-consultation { --lt-color: var(--lt-consultation); }
.lt-credit { --lt-color: var(--lt-credit); }
.lt-exam { --lt-color: var(--lt-exam); }
.lt-coursework { --lt-color: var(--lt-coursework); }
.lt-internship { --lt-color: var(--lt-internship); }

/* ============ Редактор расписания ============ */
.sched-grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 900px; }
.sched-grid th, .sched-grid td { border: 1px solid var(--border); vertical-align: top; }
.sched-grid thead th { background: var(--surface-2); padding: .55rem; text-align: center; }
.sched-grid thead th .day-name { text-transform: capitalize; }
.sched-grid thead th .day-date { font-size: .8rem; color: var(--muted); font-weight: 400; }
.sched-grid th.today, .sched-grid td.today { background: #f3f7ff; }
.sched-grid .pair-col { width: 74px; background: var(--surface-2); text-align: center; padding: .5rem .25rem; }
.pair-num { font-weight: 700; font-size: 1.1rem; }
.pair-time { font-size: .72rem; color: var(--muted); font-weight: 400; line-height: 1.3; }
.sched-grid td { padding: 4px; height: 86px; }

.slot {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%;
    text-align: left;
    font: inherit;
    border: 1px solid color-mix(in srgb, var(--lt-color) 30%, white);
    border-left: 4px solid var(--lt-color);
    background: color-mix(in srgb, var(--lt-color) 7%, white);
    border-radius: 6px;
    padding: .3rem .45rem;
    margin-bottom: 4px;
    cursor: pointer;
}
.slot:hover { background: color-mix(in srgb, var(--lt-color) 14%, white); }
.slot-type { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--lt-color); }
.slot-subject { font-weight: 600; font-size: .84rem; line-height: 1.25; }
.slot-meta { font-size: .74rem; color: var(--muted); line-height: 1.3; }

.slot-add {
    width: 100%; height: 100%; min-height: 76px;
    border: 1px dashed transparent;
    background: transparent;
    border-radius: 6px;
    color: transparent;
    cursor: pointer;
    display: grid; place-items: center;
}
td:hover > .slot-add { border-color: #c5cfdd; color: var(--muted); }
.slot-add:hover { background: var(--primary-soft); color: var(--primary) !important; border-color: var(--primary) !important; }
.slot-add:focus-visible { color: var(--primary); border-color: var(--primary); }

.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .82rem; color: var(--muted); margin: -.25rem 0 1rem; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--lt-color); }

.repeat-box { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; padding: .9rem 1rem 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }

/* ============ Компактные таблицы ============ */
.table-compact { font-size: .86rem; }
.table-compact th, .table-compact td { padding: .45rem .65rem; }
.table-compact th { font-size: .72rem; }
.table-compact .cell-sub { font-size: .76rem; }
.table-compact .icon-btn { width: 28px; height: 28px; }
.table-compact .status { font-size: .74rem; padding: .1rem .45rem; }
.table .num, .table-compact .num { text-align: center; white-space: nowrap; }
.users-table td:first-child { min-width: 180px; }
.users-table .row-actions { gap: 0; }
@media (max-width: 1200px) { .users-table .col-login { display: none; } }

.confirm-body p { margin: 0 0 .6rem; }
.confirm-body p:last-child { margin-bottom: 0; }
.subhead { font-size: .95rem; margin: 1rem 0 .6rem; }
.result-count { margin: -.25rem 0 .75rem; font-size: .87rem; }
.btn-row-top { margin: 0 0 .75rem; }

/* ============ Цифровая библиотека ============ */
.library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 1rem; }
.book {
    display: flex; gap: 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem;
}
.book-cover {
    flex-shrink: 0; width: 56px; height: 76px; border-radius: 6px;
    display: grid; place-items: center;
    background: linear-gradient(160deg, var(--primary-soft), #d6e1fb); color: var(--primary);
}
.book-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.book-head { display: flex; align-items: center; gap: .5rem; }
.book-year { font-size: .82rem; }
.book-title { font-size: 1rem; margin: .35rem 0 .15rem; line-height: 1.3; }
.book-authors { font-size: .88rem; }
.book-publisher { font-size: .82rem; }
.book-desc {
    font-size: .85rem; color: var(--muted); margin: .4rem 0 0;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.chips-sm { margin-top: .5rem; }
.chips-sm .chip { font-size: .75rem; padding: .1rem .55rem; }
.book-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: auto; padding-top: .75rem; }
.file-current { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .88rem; padding: .4rem .6rem; margin-bottom: .4rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
input[type=file].input { padding: .35rem; }

/* ============ ЭОР и проф. базы данных ============ */
.segmented-wrap { flex-wrap: wrap; }
.resource-collection h2 { margin-bottom: .2rem; }
.collection-desc { margin: 0; font-size: .9rem; }
.resource-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; }
.resource { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .85rem; background: var(--surface-2); }
.resource-main { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.resource-title { font-weight: 600; }
.tag-kind { flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.resource-desc { font-size: .85rem; margin-top: .25rem; }
.resource-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .78rem; margin-top: .35rem; }
.resource-access { display: inline-flex; align-items: center; gap: .25rem; color: var(--warning); }
.grid-resource-head { display: grid; grid-template-columns: 1fr 120px; gap: 0 1rem; }
.resource-edit { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: .8rem .8rem 0; margin-bottom: .75rem; background: var(--surface-2); }
.resource-edit-actions { position: absolute; top: .3rem; right: .4rem; display: flex; gap: .1rem; }
.resource-edit .grid-2 { padding-right: 96px; }

/* ============ Электронный журнал ============ */
.period { display: inline-flex; align-items: center; gap: .4rem; }
.period .input { width: auto; }
.journal { border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.journal th, .journal td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.journal thead th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.journal .journal-name {
    position: sticky; left: 0; z-index: 2; background: var(--surface);
    text-align: left; padding: .45rem .8rem; white-space: nowrap; min-width: 170px;
}
.journal thead .journal-name { background: var(--surface-2); z-index: 3; font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.journal-col { padding: 0; min-width: 48px; }
.journal-head {
    width: 100%; border: none; background: transparent; font: inherit; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; padding: .35rem .25rem; line-height: 1.2;
}
.journal-head:hover { background: var(--primary-soft); }
.journal-head.editable .journal-date { color: var(--primary); }
.journal-date { font-weight: 600; font-size: .8rem; }
.journal-type { font-size: .68rem; color: var(--lt-color); }
.journal-cell { text-align: center; padding: .3rem .2rem; height: 34px; white-space: nowrap; }
.journal-cell.absent { background: var(--danger-soft); }
.journal-cell.excused { background: var(--warning-soft); }
.journal-cell .att { color: var(--danger); font-weight: 600; margin-right: 2px; }
.journal-cell.excused .att { color: var(--warning); }
.journal-sum { text-align: center; padding: .3rem .5rem; background: var(--surface-2); min-width: 40px; }
.journal tbody tr:hover td { background-color: #f3f7ff; }
.journal tbody tr:hover td.absent { background: #fbdcdc; }

.grades { display: flex; flex-wrap: wrap; gap: .25rem; }
.grade { display: inline-block; min-width: 1.5rem; text-align: center; font-weight: 700; font-size: .82rem; padding: 0 .3rem; border-radius: 5px; }
.grade-good { background: var(--success-soft); color: var(--success); }
.grade-ok { background: #e6f4ea; color: #2f7d4a; }
.grade-mid { background: var(--warning-soft); color: var(--warning); }
.grade-bad { background: var(--danger-soft); color: var(--danger); }

.segmented-sm button { padding: .2rem .55rem; font-size: .8rem; }
.segmented button:disabled { cursor: default; }
.segmented button.att-present { background: var(--success); color: #fff; }
.segmented button.att-absent { background: var(--danger); color: #fff; }
.segmented button.att-excused { background: var(--warning); color: #fff; }
.input-grade { width: 92px; }
.marks-table td { vertical-align: middle; }
.legend span strong { color: var(--text); }

/* ============ Ошибки Blazor ============ */
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 8px; }
.blazor-error-boundary::after { content: "Произошла ошибка."; }

/* ============ Адаптивность ============ */
@media (max-width: 960px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 60;
        transform: translateX(-100%);
        transition: transform .2s;
    }
    .nav-toggle:checked ~ .sidebar { transform: none; }
    .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; }
    .burger { display: inline-grid; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .cabinet-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .grid-2, .grid-3, .repeat-box { grid-template-columns: 1fr; }
    .hide-sm, .user-chip-text { display: none; }
    .input-auto { min-width: 0; width: 100%; }
    .days { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr; }
    .library-list { grid-template-columns: 1fr; }
    .book { flex-direction: column; }
    .resource-list { grid-template-columns: 1fr; }
    .period { flex-wrap: wrap; }
    .hero { padding: 1.5rem; }
    .hero h1 { font-size: 1.5rem; }
    .auth-card { padding: 1.25rem; }
}
