/* Qymbat v3: плотный школьный журнал, боковая навигация, синяя ручка. */
:root {
    --color-ink: #101828;
    --color-sidebar: #16233B;
    --color-page: #F4F6F8;
    --color-surface: #FFFFFF;
    --color-rule: #E3E7EC;
    --color-accent: #2747D4;
    --color-success: #0E7C4A;
    --color-warning: #B45309;
    --color-error: #C2313B;
    --color-overlay: rgba(16, 24, 40, .48);
    --color-muted: rgba(16, 24, 40, .65);
    --color-faint: rgba(16, 24, 40, .45);
    --color-accent-soft: rgba(39, 71, 212, .07);
    --color-success-soft: rgba(14, 124, 74, .07);
    --color-warning-soft: rgba(180, 83, 9, .08);
    --color-error-soft: rgba(194, 49, 59, .07);
    --color-focus: rgba(39, 71, 212, .28);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    --radius-small: 4px;
    --radius-large: 8px;
    --border: 1px;
    --subject-line: 3px;
    --focus-size: 3px;
    --shadow-small: 0 1px 2px rgba(16, 24, 40, .08);
    --shadow-modal: 0 2px 2px rgba(16, 24, 40, .16);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --font-page: 20px;
    --font-section: 15px;
    --font-body: 13px;
    --font-small: 11px;
    --line: 1.45;
    --line-tight: 1.25;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --sidebar-width: 200px;
    --sidebar-collapsed: 64px;
    --mobile-bar-height: 48px;
    --control-height: 34px;
    --table-row: 40px;
    --grid-row: 76px;
    --grid-lesson: 42px;
    --grid-day: 128px;
    --grid-min: 760px;
    --right-panel: 286px;
    --modal-max: 640px;
    --toast-width: 360px;
    --transition: 120ms ease;
}

* { box-sizing: border-box; }
html { min-width: 0; color-scheme: light; }
body {
    min-width: 0;
    margin: 0;
    background: var(--color-page);
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-size: var(--font-body);
    font-variant-numeric: tabular-nums;
    line-height: var(--line);
}
body.has-modal { overflow: hidden; }
button, input, select, textarea { font: inherit; font-variant-numeric: tabular-nums; }
button, a, input, select, textarea, [tabindex] { -webkit-tap-highlight-color: transparent; }
a { color: var(--color-accent); text-underline-offset: var(--space-1); }
a:hover { color: var(--color-ink); }
:focus { outline: none; }
:focus-visible { outline: var(--focus-size) solid var(--color-focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: var(--space-1); font-size: var(--font-page); line-height: var(--line-tight); }
h2, .card__title { margin-bottom: var(--space-2); font-size: var(--font-section); line-height: var(--line-tight); }
h3 { margin-bottom: var(--space-2); font-size: var(--font-body); }
p { margin-bottom: var(--space-3); }
hr { margin: var(--space-4) 0; border: 0; border-top: var(--border) solid var(--color-rule); }
code, .tech-id {
    color: var(--color-faint);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--font-small);
}

/* Боковая панель */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: var(--space-3);
    background: var(--color-sidebar);
    color: var(--color-surface);
    transition: width var(--transition), transform var(--transition);
}
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 42px;
    padding-bottom: var(--space-3);
    border-bottom: var(--border) solid rgba(255,255,255,.12);
}
.site-title {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: var(--space-2);
    color: var(--color-surface);
    font-weight: var(--weight-semibold);
    text-decoration: none;
}
.site-title:hover { color: var(--color-surface); }
.site-title__mark {
    display: grid;
    flex: 0 0 34px;
    place-items: center;
    width: 34px;
    height: 34px;
    border: var(--border) solid rgba(255,255,255,.42);
    border-radius: var(--radius-small);
    font-size: var(--font-small);
    letter-spacing: .08em;
}
.site-title__text { line-height: var(--line-tight); }
.sidebar__collapse {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    margin-left: auto;
    border: 0;
    border-radius: var(--radius-small);
    background: rgba(255,255,255,.08);
    color: var(--color-surface);
    cursor: pointer;
}
.sidebar-nav { display: grid; gap: var(--space-1); margin-top: var(--space-4); }
.sidebar-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 38px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-small);
    color: rgba(255,255,255,.76);
    font-weight: var(--weight-medium);
    text-decoration: none;
    cursor: pointer;
}
.sidebar-nav__link:hover { background: rgba(255,255,255,.08); color: var(--color-surface); }
.sidebar-nav__link[aria-current="page"] {
    background: var(--color-accent);
    color: var(--color-surface);
}
.sidebar-nav__icon {
    display: grid;
    flex: 0 0 20px;
    place-items: center;
    width: 20px;
    font-size: var(--font-section);
}
.sidebar-settings > summary { list-style: none; }
.sidebar-settings > summary::-webkit-details-marker { display: none; }
.sidebar-subnav {
    display: grid;
    margin: var(--space-1) 0 var(--space-2) 32px;
    padding-left: var(--space-3);
    border-left: var(--border) solid rgba(255,255,255,.18);
}
.sidebar-subnav a {
    padding: 6px var(--space-2);
    border-radius: var(--radius-small);
    color: rgba(255,255,255,.68);
    font-size: var(--font-small);
    text-decoration: none;
}
.sidebar-subnav a:hover,
.sidebar-subnav a[aria-current="page"] { color: var(--color-surface); background: rgba(255,255,255,.08); }
.schedule-health {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-top: auto;
    padding: var(--space-3);
    border-top: var(--border) solid rgba(255,255,255,.14);
    color: var(--color-surface);
    text-decoration: none;
}
.schedule-health:hover { color: var(--color-surface); }
.schedule-health__dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--color-success);
}
.schedule-health__copy { display: grid; min-width: 0; }
.schedule-health__label { color: rgba(255,255,255,.54); font-size: var(--font-small); letter-spacing: .08em; text-transform: uppercase; }
.schedule-health__title { font-size: var(--font-body); }
.schedule-health__status { font-size: var(--font-small); }
.mobile-menu {
    display: none;
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 80;
    width: 34px;
    height: 34px;
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-sidebar);
}
.sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: var(--color-overlay); }
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
}
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
.sidebar-collapsed .app-shell { margin-left: var(--sidebar-collapsed); }
.sidebar-collapsed .site-title__text,
.sidebar-collapsed .sidebar-nav__label,
.sidebar-collapsed .sidebar-subnav,
.sidebar-collapsed .schedule-health__copy { display: none; }
.sidebar-collapsed .sidebar__brand { justify-content: center; }
.sidebar-collapsed .sidebar__collapse {
    position: absolute;
    top: var(--space-2);
    right: calc(var(--space-2) * -1);
}
.sidebar-collapsed .sidebar-nav__link { justify-content: center; padding: 0; }
.sidebar-collapsed .schedule-health { justify-content: center; padding: var(--space-3) 0; }

/* Страница */
.page {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: var(--space-6);
}
.page--wide { max-width: none; }
.site-footer {
    padding: var(--space-3) var(--space-6);
    border-top: var(--border) solid var(--color-rule);
    color: var(--color-faint);
    font-size: var(--font-small);
    text-align: center;
}
.page-header {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
}
.page-header__copy { min-width: 0; }
.page-header__eyebrow { display: none; }
.page-header__subtitle { margin: 0; color: var(--color-muted); font-size: var(--font-body); }
.toolbar, .editor-actions, .filters, .form-row {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.toolbar { justify-content: flex-end; }
.card {
    margin-bottom: var(--space-6);
    padding: var(--space-4);
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-large);
    background: var(--color-surface);
}
.grid-2, .dashboard-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--space-4); }
.dashboard-grid { grid-template-columns: minmax(0,2fr) minmax(240px,1fr); }
.dashboard-stack { display: grid; gap: var(--space-4); }
.hint, .text-muted, .field__help { color: var(--color-muted); font-size: var(--font-small); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Действия */
.btn {
    display: inline-flex;
    min-height: var(--control-height);
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-3);
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-ink);
    font-weight: var(--weight-medium);
    line-height: var(--line-tight);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.btn:hover { border-color: var(--color-muted); background: var(--color-page); color: var(--color-ink); }
.btn--primary { border-color: var(--color-accent); background: var(--color-accent); color: var(--color-surface); }
.btn--primary:hover { background: var(--color-sidebar); color: var(--color-surface); }
.btn--secondary { border-color: var(--color-accent); color: var(--color-accent); }
.btn--ghost, .btn--text { border-color: transparent; background: transparent; }
.btn--text { min-height: 28px; padding: 0 var(--space-2); }
.btn--danger { border-color: transparent; background: transparent; color: var(--color-muted); }
.btn--danger:hover { border-color: var(--color-error); background: var(--color-error); color: var(--color-surface); }
.btn--small { min-height: 28px; padding: 0 var(--space-2); font-size: var(--font-small); }
.btn--icon { width: 30px; min-height: 30px; padding: 0; font-size: var(--font-section); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary:disabled { border-color: var(--color-rule); background: var(--color-rule); color: var(--color-faint); }
.badge {
    display: inline-flex;
    min-height: 20px;
    align-items: center;
    padding: 0 6px;
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: var(--font-small);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}
.badge--accent { border-color: var(--color-accent); color: var(--color-accent); }
.badge--success { border-color: var(--color-success); color: var(--color-success); }
.badge--warning { border-color: var(--color-warning); color: var(--color-warning); }
.badge--error { border-color: var(--color-error); color: var(--color-error); }

/* Поля */
.field { display: grid; gap: var(--space-1); min-width: 170px; }
.field--narrow { min-width: 148px; max-width: 180px; }
.field--wide { flex: 1 1 100%; max-width: none; }
.field--compact { display: flex; min-width: 150px; align-items: center; gap: var(--space-2); }
.field label, fieldset legend { color: var(--color-muted); font-size: var(--font-small); font-weight: var(--weight-semibold); }
input, select, textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: 6px var(--space-2);
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-ink);
}
input[type="date"] { min-width: 150px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--color-accent); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; accent-color: var(--color-accent); }
input[type="number"], input[inputmode="decimal"] { text-align: right; }
fieldset { margin: 0; padding: var(--space-3); border: var(--border) solid var(--color-rule); border-radius: var(--radius-small); }
.filters { margin-bottom: var(--space-3); padding-bottom: var(--space-3); border-bottom: var(--border) solid var(--color-rule); }
.inline-form { display: inline-flex; gap: var(--space-1); align-items: center; }
.checkbox-list { display: grid; gap: var(--space-2); }
.checkbox-list label { display: flex; gap: var(--space-2); align-items: center; }

/* Таблицы */
.table-tools { display: flex; justify-content: flex-end; margin-bottom: var(--space-2); }
.table-search { max-width: 260px; }
.table-wrap {
    position: relative;
    max-width: 100%;
    overflow: auto;
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
}
.table-wrap.is-scrollable:not(.is-scroll-end) { box-shadow: inset -14px 0 12px -14px rgba(16,24,40,.48); }
.table-wrap > table:not(.schedule-grid) { min-width: 680px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td {
    height: var(--table-row);
    padding: 6px var(--space-3);
    border-right: var(--border) solid var(--color-rule);
    border-bottom: var(--border) solid var(--color-rule);
    text-align: left;
    vertical-align: middle;
}
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child > td, tbody tr:last-child > th, tfoot tr:last-child > * { border-bottom: 0; }
thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--color-page);
    color: var(--color-muted);
    font-size: var(--font-small);
    font-weight: var(--weight-bold);
    letter-spacing: .04em;
    text-transform: uppercase;
}
thead th.num { text-align: right; }
tbody tr:hover > td, tbody tr:hover > th { background: var(--color-accent-soft); }
th[data-sort] { cursor: pointer; }
th[data-sort-dir="asc"]::after { content: " ↑"; color: var(--color-accent); }
th[data-sort-dir="desc"]::after { content: " ↓"; color: var(--color-accent); }
.row-link { cursor: pointer; }
.row-actions { display: flex; justify-content: flex-end; gap: var(--space-1); white-space: nowrap; }

/* Компактная строка итогов */
.summary-strip, .tiles {
    display: grid;
    grid-template-columns: repeat(5,minmax(0,1fr));
    min-height: 64px;
    margin-bottom: var(--space-6);
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
    background: var(--color-surface);
}
.summary-strip a, .tile {
    display: grid;
    align-content: center;
    gap: 2px;
    padding: var(--space-2) var(--space-4);
    border-right: var(--border) solid var(--color-rule);
    color: var(--color-ink);
    text-decoration: none;
}
.summary-strip a:last-child, .tile:last-child { border-right: 0; }
.summary-strip a:hover, a.tile:hover { background: var(--color-accent-soft); }
.summary-strip strong, .tile__value { font-size: var(--font-page); font-weight: var(--weight-bold); line-height: 1; text-align: right; }
.summary-strip span, .tile__label { color: var(--color-muted); font-size: var(--font-small); }
.summary-strip__success strong, .tile--success .tile__value { color: var(--color-success); }
.summary-strip__warning strong, .tile--warning .tile__value { color: var(--color-warning); }
.summary-strip__danger strong, .tile--error .tile__value { color: var(--color-error); }
.tiles { grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); }

/* Журнал и сетка */
.journal { overflow: hidden; border: var(--border) solid var(--color-rule); border-radius: var(--radius-large); background: var(--color-surface); }
.journal__toolbar, .editor-grid-toolbar {
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-bottom: var(--border) solid var(--color-rule);
}
.journal__toolbar h2 { margin: 0 auto 0 0; }
.journal__grid-wrap { border: 0; border-radius: 0; }
.schedule-grid { min-width: var(--grid-min); table-layout: fixed; }
.schedule-grid th, .schedule-grid td { border-right: var(--border) solid var(--color-rule); border-bottom: var(--border) solid var(--color-rule); }
.schedule-grid thead th {
    height: 36px;
    padding: var(--space-2);
    background: var(--color-surface);
    color: var(--color-ink);
    font-size: var(--font-small);
    letter-spacing: .12em;
    text-align: center;
    text-transform: uppercase;
}
.schedule-grid .lesson-no {
    position: sticky;
    left: 0;
    z-index: 5;
    width: var(--grid-lesson);
    padding: var(--space-1);
    background: var(--color-sidebar);
    color: var(--color-surface);
    font-size: var(--font-small);
    font-weight: var(--weight-bold);
    text-align: center;
}
.schedule-grid thead .lesson-no { z-index: 7; }
.schedule-grid .slot-cell {
    position: relative;
    width: var(--grid-day);
    height: var(--grid-row);
    padding: var(--space-1);
    background: var(--color-surface);
    vertical-align: top;
}
.schedule-grid tbody tr:hover > .slot-cell { background: var(--color-surface); }
.slot-card {
    display: grid;
    align-content: center;
    min-height: calc(var(--grid-row) - var(--space-2));
    padding: var(--space-2) var(--space-4);
    border: var(--border) solid var(--color-rule);
    border-left: var(--subject-line) solid var(--subject-color,var(--color-accent));
    border-radius: var(--radius-small);
    background: var(--color-surface) !important;
    color: var(--color-ink);
    cursor: grab;
}
.slot-card + .slot-card { margin-top: var(--space-1); }
.slot-card:active, .slot-card.is-dragging { cursor: grabbing; }
.slot-card.is-dragging { opacity: .42; }
.schedule-grid--readonly .slot-card { cursor: default; }
.slot-card__subject { font-size: var(--font-section); font-weight: var(--weight-semibold); line-height: var(--line-tight); white-space: normal; }
.slot-card__meta { color: var(--color-muted); font-size: var(--font-small); line-height: var(--line-tight); white-space: normal; overflow-wrap: anywhere; }
.slot-cell.is-dragover { outline: var(--focus-size) dashed var(--color-accent); outline-offset: -3px; }
.slot-cell.is-invalid-target { outline: var(--focus-size) dashed var(--color-error); outline-offset: -3px; }
.slot-cell.has-error { box-shadow: inset 0 0 0 2px var(--color-error); }
.slot-cell.has-warning { box-shadow: inset 0 0 0 2px var(--color-warning); }
.slot-cell.has-error::after { content:""; position:absolute; top:3px; right:3px; width:7px; height:7px; border-radius:50%; background:var(--color-error); }
.slot-cell.is-highlighted { outline: var(--focus-size) solid var(--color-accent); outline-offset: -3px; }
.slot-cell.is-pulsing { animation: cell-pulse 120ms ease 2 alternate; }
@keyframes cell-pulse { to { box-shadow: inset 0 0 0 3px var(--color-accent); } }

/* Редактор без левой панели */
.editor-actions { align-items: center; justify-content: space-between; gap: var(--space-6); }
.editor-actions__links, .editor-actions__controls { display: flex; align-items: center; gap: var(--space-1); }
.change-count { color: inherit; font-size: var(--font-small); }
.editor-shell { display: grid; grid-template-columns: minmax(0,1fr) var(--right-panel); align-items: start; gap: var(--space-3); }
.editor-main { min-width: 0; padding: 0; overflow: hidden; }
.editor-main .table-wrap { border: 0; border-radius: 0; }
.editor-grid-toolbar { flex-wrap: wrap; }
.editor-grid-toolbar .field { display: flex; align-items: center; min-width: 160px; }
.editor-grid-toolbar .field select { min-width: 120px; }
.editor-grid-toolbar__hint { margin: 0 0 0 auto; color: var(--color-muted); font-size: var(--font-small); }
.editor-sidebar {
    position: sticky;
    top: var(--space-3);
    display: grid;
    min-width: 0;
    max-height: calc(100vh - var(--space-6));
    gap: var(--space-3);
    overflow: auto;
    overscroll-behavior: contain;
}
.editor-sidebar .card { margin: 0; }
.segmented {
    display: grid;
    flex: 0 0 220px;
    grid-template-columns: repeat(2,minmax(0,1fr));
    padding: 2px;
    border: var(--border) solid var(--color-rule);
    border-radius: var(--radius-small);
}
.segmented__option { min-width: 0; cursor: pointer; }
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option span {
    display: grid;
    min-height: 28px;
    place-items: center;
    padding: 0 var(--space-2);
    border-radius: 3px;
    color: var(--color-muted);
    font-size: var(--font-small);
    white-space: nowrap;
}
.segmented__option input:checked + span { background: var(--color-sidebar); color: var(--color-surface); }
.segmented__option input:focus-visible + span { outline: var(--focus-size) solid var(--color-focus); }
.conflict-groups { display: grid; gap: var(--space-3); }
.conflict-heading { display: flex; justify-content: space-between; margin-bottom: var(--space-1); font-weight: var(--weight-semibold); }
.conflict-list, .side-list, .compact-list { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.conflict-list { max-height: 34vh; overflow: auto; overscroll-behavior: contain; }
.conflict { padding: var(--space-2); border-left: var(--subject-line) solid var(--color-error); background: var(--color-error-soft); font-size: var(--font-small); cursor: pointer; }
.conflict--warning { border-left-color: var(--color-warning); background: var(--color-warning-soft); }
.conflict__code { display:block; color:var(--color-faint); font-family:ui-monospace,Menlo,monospace; font-size:var(--font-small); }
.conflict-ok { padding:var(--space-3); border-left:var(--subject-line) solid var(--color-success); background:var(--color-success-soft); color:var(--color-success); font-weight:var(--weight-semibold); }
.side-list li, .compact-list li { display:flex; justify-content:space-between; gap:var(--space-2); padding:var(--space-1) 0; border-bottom:var(--border) solid var(--color-rule); font-size:var(--font-small); }
.side-list li:last-child, .compact-list li:last-child { border-bottom:0; }
.table-wrap > table.class-hours-table { min-width:0; }
.class-hours-table th, .class-hours-table td { height:32px; padding:var(--space-1); font-size:var(--font-small); }
.class-hours__difference { font-weight:var(--weight-bold); }
.class-hours__difference--shortage { background:var(--color-warning-soft); color:var(--color-warning); }
.class-hours__difference--overage { background:var(--color-error-soft); color:var(--color-error); }
.class-hours__difference--balanced { color:var(--color-success); }
.class-hours-total { margin:var(--space-2) 0 0; font-weight:var(--weight-semibold); text-align:right; }

/* Учебный план */
.section-tabs {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-3);
    border-bottom: var(--border) solid var(--color-rule);
}
.section-tabs a { position:relative; padding:var(--space-2) 0; color:var(--color-muted); font-weight:var(--weight-semibold); text-decoration:none; }
.section-tabs a[aria-current="page"] { color:var(--color-accent); }
.section-tabs a[aria-current="page"]::after { content:""; position:absolute; right:0; bottom:-1px; left:0; height:2px; background:var(--color-accent); }
.curriculum-matrix table { min-width: 1080px; }
.curriculum-matrix tbody th, .curriculum-matrix tfoot th:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--color-surface);
}
.curriculum-cell { min-width:88px; padding:3px; background:var(--color-surface); }
.curriculum-cell__button {
    width:100%;
    min-height:52px;
    padding:var(--space-1);
    border:var(--border) solid transparent;
    border-radius:var(--radius-small);
    background:var(--color-surface);
    color:var(--color-ink);
    cursor:pointer;
    text-align:center;
}
.curriculum-cell__button strong { display:block; font-size:var(--font-section); font-weight:var(--weight-bold); text-align:center; }
.curriculum-cell__button small { display:block; margin-top:2px; color:var(--color-muted); font-size:var(--font-small); white-space:normal; }
.curriculum-cell__button:hover { border-color:var(--color-accent); }
.curriculum-cell__add { width:100%; color:var(--color-faint); font-size:var(--font-section); opacity:.55; }
.curriculum-matrix tbody tr:hover .curriculum-cell__add { color:var(--color-accent); opacity:1; }
tr.is-saving { opacity:.55; }
.tabs { display:flex; gap:var(--space-4); margin-bottom:var(--space-3); border-bottom:var(--border) solid var(--color-rule); }
.tabs__button { position:relative; padding:var(--space-2) 0; border:0; background:transparent; color:var(--color-muted); font-weight:var(--weight-semibold); cursor:pointer; }
.tabs__button[aria-selected="true"] { color:var(--color-accent); }
.tabs__button[aria-selected="true"]::after { content:""; position:absolute; right:0; bottom:-1px; left:0; height:2px; background:var(--color-accent); }
.tab-panel { margin-bottom:var(--space-6); }
.teacher-schedule { min-width:var(--grid-min); }
.teacher-gap { background:var(--color-warning-soft) !important; }
.progress-bar, .load-progress { width:100%; height:7px; overflow:hidden; border:0; border-radius:3px; background:var(--color-rule); }
.progress-bar__fill { height:100%; background:var(--color-accent); }
.progress-bar--success .progress-bar__fill { background:var(--color-success); }
.progress-bar--warning .progress-bar__fill { background:var(--color-warning); }
.progress-bar--error .progress-bar__fill { background:var(--color-error); }
.load-progress::-webkit-progress-bar { background:var(--color-rule); }
.load-progress::-webkit-progress-value { background:var(--color-accent); }
.load-progress.is-over::-webkit-progress-value { background:var(--color-error); }
.load-progress::-moz-progress-bar { background:var(--color-accent); }

/* Справочники */
.teacher-subjects { display:flex; flex-wrap:wrap; gap:var(--space-1); }
.class-name { display:block; font-size:var(--font-section); font-weight:var(--weight-semibold); }
.group-section { margin-bottom:var(--space-6); }
.group-cards, .schedule-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:var(--space-3); }
.group-card, .schedule-card { padding:var(--space-4); border:var(--border) solid var(--color-rule); border-radius:var(--radius-large); background:var(--color-surface); }
.schedule-card--active { border-left:var(--subject-line) solid var(--color-accent); }
.schedule-card__head, .schedule-card__meta, .schedule-card__metrics { display:flex; align-items:center; justify-content:space-between; gap:var(--space-2); }
.schedule-card__title { margin:0; font-size:var(--font-section); }
.schedule-card__meta { margin:var(--space-2) 0; color:var(--color-muted); font-size:var(--font-small); }
.schedule-card__metrics { justify-content:flex-start; flex-wrap:wrap; margin-bottom:var(--space-3); }
.subject-dot { display:block; width:12px; height:12px; border-radius:50%; background:var(--subject-color,var(--color-accent)); }
.inline-value { width:100%; min-height:28px; padding:0; border:0; background:transparent; color:var(--color-ink); text-align:left; cursor:text; }
.inline-value:hover { color:var(--color-accent); text-decoration:underline; text-decoration-style:dotted; }
.inline-value__input { min-height:30px; padding:3px var(--space-1); }
.type-picker { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:var(--space-3); }
.type-picker__card { padding:var(--space-3); border:var(--border) solid var(--color-rule); border-radius:var(--radius-small); cursor:pointer; }
.type-picker__card:has(input:checked) { border-color:var(--color-accent); background:var(--color-accent-soft); }
.type-picker + [data-group-form], .type-picker ~ [data-group-form] { margin-top:var(--space-4); }

/* Отсутствия — вертикальный журнал */
.calendar-lane { display:grid; gap:var(--space-4); }
.calendar-day { display:grid; grid-template-columns:128px minmax(0,1fr); gap:var(--space-3); }
.calendar-day__head {
    position:sticky;
    top:var(--space-3);
    align-self:start;
    display:grid;
    gap:var(--space-1);
    padding:var(--space-2);
    border-left:var(--subject-line) solid var(--color-accent);
    background:var(--color-page);
}
.calendar-day__items { display:grid; grid-template-columns:minmax(0,1fr); gap:var(--space-2); }
.absence-card { display:grid; gap:var(--space-2); padding:var(--space-3); border:var(--border) solid var(--color-rule); border-radius:var(--radius-small); background:var(--color-surface); }
.absence-card p { margin:0; }
.absence-card__actions { display:flex; align-items:center; justify-content:space-between; gap:var(--space-2); }
.absence-feed { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:var(--space-3); }
.absence-feed__item { padding-left:var(--space-3); border-left:var(--subject-line) solid var(--color-accent); }

/* ИИ */
.ai-quick-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:var(--space-3); margin-bottom:var(--space-6); }
.ai-task, .ai-generator { padding:var(--space-4); border:var(--border) solid var(--color-rule); border-radius:var(--radius-large); background:var(--color-surface); }
.ai-task--compact { display:grid; grid-template-columns:auto 1fr; align-items:start; gap:var(--space-3); }
.ai-task--compact > form, .ai-task--compact > .btn { grid-column:2; justify-self:start; }
.ai-task__symbol { display:grid; width:28px; height:28px; place-items:center; color:var(--color-accent); font-size:var(--font-section); font-weight:var(--weight-bold); }
.ai-task h2, .ai-generator h2 { margin-bottom:var(--space-1); }
.ai-task p, .ai-generator p { margin:0; color:var(--color-muted); font-size:var(--font-small); }
.ai-task__result { grid-column:1/-1; margin-top:var(--space-2); padding:var(--space-3); border-left:var(--subject-line) solid var(--color-accent); background:var(--color-accent-soft); }
.ai-answer { white-space:pre-wrap; }
.ai-generator { margin-bottom:var(--space-6); }
.ai-generator__intro { display:flex; gap:var(--space-3); margin-bottom:var(--space-3); }
.ai-generator__form { display:grid; grid-template-columns:minmax(180px,1fr) 160px auto; align-items:end; gap:var(--space-3); }
.class-pills { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:var(--space-1); }
.class-pills input { position:absolute; opacity:0; pointer-events:none; }
.class-pills span { display:inline-flex; min-height:28px; align-items:center; padding:0 var(--space-3); border:var(--border) solid var(--color-rule); border-radius:var(--radius-large); cursor:pointer; }
.class-pills input:checked + span { border-color:var(--color-accent); background:var(--color-accent); color:var(--color-surface); }
.class-pills input:focus-visible + span { outline:var(--focus-size) solid var(--color-focus); }
.ai-task.is-loading, .ai-generator.is-loading { border-color:var(--color-accent); }

/* Состояния */
.notice { margin-bottom:var(--space-3); padding:var(--space-3); border-left:var(--subject-line) solid var(--color-accent); background:var(--color-accent-soft); }
.notice--ok, .notice--success { border-left-color:var(--color-success); background:var(--color-success-soft); }
.notice--warning { border-left-color:var(--color-warning); background:var(--color-warning-soft); }
.notice--error { border-left-color:var(--color-error); background:var(--color-error-soft); }
.empty-state { display:grid; min-height:112px; place-items:center; gap:var(--space-2); padding:var(--space-6); color:var(--color-muted); text-align:center; }
.empty-state__icon { display:grid; width:32px; height:32px; place-items:center; border:var(--border) solid var(--color-rule); border-radius:var(--radius-small); color:var(--color-accent); font-size:var(--font-section); }
.empty-state__title { color:var(--color-ink); font-weight:var(--weight-semibold); }
.modal { position:fixed; inset:0; z-index:100; display:grid; place-items:center; padding:var(--space-4); background:var(--color-overlay); }
.modal__box { width:min(100%,var(--modal-max)); max-height:calc(100vh - var(--space-8)); overflow:auto; padding:var(--space-4); border:var(--border) solid var(--color-rule); border-radius:var(--radius-large); background:var(--color-surface); box-shadow:var(--shadow-modal); }
.modal__header { display:flex; align-items:flex-start; justify-content:space-between; gap:var(--space-4); margin-bottom:var(--space-3); padding-bottom:var(--space-2); border-bottom:var(--border) solid var(--color-rule); }
.modal__header h2 { margin:0; }
.toast-region { position:fixed; right:var(--space-4); bottom:var(--space-4); z-index:120; display:grid; gap:var(--space-2); width:min(calc(100% - var(--space-8)),var(--toast-width)); }
.toast { padding:var(--space-3); border:var(--border) solid var(--color-rule); border-left:var(--subject-line) solid var(--color-accent); border-radius:var(--radius-small); background:var(--color-surface); box-shadow:var(--shadow-small); }
.toast--success { border-left-color:var(--color-success); }
.toast--warning { border-left-color:var(--color-warning); }
.toast--error { border-left-color:var(--color-error); }
.print-only { display:none; }

@media (max-width: 1120px) {
    .editor-shell { grid-template-columns:minmax(0,1fr); }
    .editor-sidebar {
        position:static;
        grid-template-columns:repeat(2,minmax(0,1fr));
        max-height:none;
        overflow:visible;
    }
    .calendar-day__items { grid-template-columns:minmax(0,1fr); }
    .ai-quick-grid { grid-template-columns:minmax(0,1fr); }
}

@media (max-width: 760px) {
    .mobile-menu { display:grid; place-items:center; }
    .sidebar { width:var(--sidebar-width); transform:translateX(-100%); }
    .sidebar.is-open { transform:translateX(0); }
    .sidebar__collapse { display:none; }
    .app-shell, .sidebar-collapsed .app-shell { margin-left:0; padding-top:var(--mobile-bar-height); }
    .sidebar-collapsed .sidebar { width:var(--sidebar-width); }
    .sidebar-collapsed .site-title__text,
    .sidebar-collapsed .sidebar-nav__label,
    .sidebar-collapsed .sidebar-subnav,
    .sidebar-collapsed .schedule-health__copy { display:initial; }
    .sidebar-collapsed .sidebar-nav__link { justify-content:flex-start; padding:0 var(--space-3); }
    .page { padding:var(--space-4) var(--space-3); }
    .page-header { align-items:flex-start; flex-direction:column; gap:var(--space-2); }
    .toolbar, .editor-actions { justify-content:flex-start; }
    .grid-2, .dashboard-grid { grid-template-columns:minmax(0,1fr); }
    .summary-strip, .tiles { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .summary-strip a, .tile { border-bottom:var(--border) solid var(--color-rule); }
    .editor-actions { width:100%; }
    .editor-actions__links, .editor-actions__controls { flex-wrap:wrap; }
    .editor-grid-toolbar__hint { flex-basis:100%; margin-left:0; }
    .calendar-day { grid-template-columns:minmax(0,1fr); }
    .calendar-day__head { position:sticky; top:var(--mobile-bar-height); z-index:4; grid-template-columns:1fr auto; }
    .type-picker { grid-template-columns:minmax(0,1fr); }
    .ai-generator__form { grid-template-columns:minmax(0,1fr); }
    .class-pills { grid-column:auto; }
}

@media (max-width: 520px) {
    .page-header { margin-bottom:var(--space-3); }
    .toolbar, .editor-actions, .filters, .form-row { align-items:stretch; }
    .toolbar .btn { flex:1 1 auto; }
    .field, .field--narrow { width:100%; max-width:none; }
    .summary-strip, .tiles { grid-template-columns:minmax(0,1fr); }
    .summary-strip a, .tile { grid-template-columns:52px 1fr; align-items:baseline; border-right:0; }
    .summary-strip strong, .tile__value { font-size:var(--font-section); }
    .journal__toolbar { flex-wrap:wrap; align-items:center; }
    .journal__toolbar h2 { flex:1 1 auto; }
    .journal__toolbar .field { width:auto; min-width:150px; }
    .journal__toolbar [data-home-empty-days] { flex:1 1 100%; }
    .card { padding:var(--space-3); }
    .group-cards, .schedule-cards { grid-template-columns:minmax(0,1fr); }
    .table-wrap > table:not(.schedule-grid) th:first-child,
    .table-wrap > table:not(.schedule-grid) td:first-child {
        position:sticky;
        left:0;
        z-index:2;
        background:var(--color-surface);
    }
    .table-wrap > table:not(.schedule-grid) thead th:first-child { z-index:4; background:var(--color-page); }
    .schedule-grid { min-width:var(--grid-min); }
    .slot-card { cursor:default; padding:var(--space-2); }
    .editor-sidebar { grid-template-columns:minmax(0,1fr); }
    .conflict-list { max-height:360px; }
    .segmented { flex-basis:100%; }
    .editor-grid-toolbar .field { width:100%; }
    .modal { padding:var(--space-2); }
    .modal__box { padding:var(--space-3); }
}

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

@page { size:A4 landscape; margin:8mm; }
@media print {
    .sidebar, .mobile-menu, .site-footer, .page-header, .editor-actions,
    .editor-grid-toolbar, .editor-sidebar, .summary-strip, .toast-region, .modal,
    .journal__toolbar .btn { display:none !important; }
    .app-shell { margin:0; min-height:0; }
    .page, .page--wide { width:100%; padding:0; }
    .print-only { display:block; }
    .journal, .editor-main, .table-wrap { border:0; overflow:visible; }
    .editor-shell { display:block; }
    .schedule-grid { width:100%; min-width:0; table-layout:fixed; font-size:8pt; }
    .schedule-grid thead th { position:static; height:auto; background:var(--color-page)!important; color:var(--color-ink)!important; }
    .schedule-grid .lesson-no { position:static; width:8mm; background:var(--color-rule)!important; color:var(--color-ink)!important; }
    .schedule-grid .slot-cell { height:11mm; padding:.8mm; background:var(--color-surface)!important; }
    .schedule-grid .slot-cell { outline:0!important; box-shadow:none!important; }
    .slot-card { min-height:0!important; padding:.8mm 1mm; border-color:var(--color-rule)!important; border-left-color:var(--color-ink)!important; background:var(--color-surface)!important; color:var(--color-ink)!important; break-inside:avoid; }
    .slot-card + .slot-card { margin-top:.5mm; }
    .slot-card__subject, .slot-card__meta { font-size:6.5pt; line-height:1.05; }
}

/* =====================================================================
   ОБЩИЕ ЭКРАНЫ ИМПОРТА (_shared/ai_import)

   Экран подтверждения ИИ-импорта лежит в общей папке и наследует
   base.html этой программы, но подписи классов у него свои. Ниже — только
   недостающие классы, собранные из тех же переменных, что и весь остальной
   интерфейс. Ни одно существующее правило здесь не переопределяется.
   ===================================================================== */

.eyebrow {
    color: var(--color-muted);
    font-size: var(--font-small);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.muted { color: var(--color-muted); }
.small { font-size: var(--font-small); }
.req { color: var(--color-error); }

.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-4) 0;
    flex-wrap: wrap;
}

.card__header h2 {
    margin: 0;
    font-size: var(--font-section);
}

.card__body { padding: var(--space-4); }

.ai-verdict {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.ai-verdict__kind {
    font-size: var(--font-section);
    font-weight: var(--weight-semibold);
}

.ai-rows {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-small);
}

.ai-rows th,
.ai-rows td {
    min-width: 130px;
    padding: var(--space-2) var(--space-3);
    border-bottom: var(--border);
    text-align: left;
    vertical-align: top;
}

.ai-rows th {
    background: var(--color-page);
    color: var(--color-muted);
}

.ai-rows input:not([type="checkbox"]),
.ai-rows select {
    min-width: 150px;
    max-width: 100%;
}

/* Строка с накладкой и строка «уже есть» — видно, не читая подписи. */
.row-red { background: var(--color-error-soft); }
.row-done { background: var(--color-page); }

.badge--ok { background: var(--color-success-soft); color: var(--color-success); }
.badge--warn { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger { background: var(--color-error-soft); color: var(--color-error); }

.count-chip {
    display: inline-flex;
    padding: 0 var(--space-2);
    border-radius: var(--radius-small);
    background: var(--color-page);
    color: var(--color-muted);
    font-size: var(--font-small);
    vertical-align: middle;
}

.notice-list {
    margin: var(--space-3) 0;
    padding-left: var(--space-6);
}

.notice-list--err { color: var(--color-error); }

.empty-state__title {
    font-size: var(--font-section);
    font-weight: var(--weight-semibold);
}

.empty-state__text {
    margin-top: var(--space-2);
    color: var(--color-muted);
}

/* Кнопка «Добавить отмеченные» не должна уезжать вверх на длинной таблице. */
.sticky-actions {
    position: sticky;
    bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-4);
    padding: var(--space-3);
    border: var(--border);
    border-radius: var(--radius-large);
    background: var(--color-surface);
    box-shadow: var(--shadow-modal);
}

.btn.primary {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: #fff;
}

.btn.text {
    border-color: transparent;
    background: transparent;
    color: var(--color-muted);
}
