/*
 * Применение дизайн-токенов из theme.css.
 * Стиль: Linear/Notion/Vercel — чистый белый, тонкие границы, soft shadows,
 * выраженный акцент primary, типографика главный носитель.
 */

@import url('./theme.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    letter-spacing: -0.01em;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
}
h1 { font-size: var(--text-3xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

/* ===== КАРКАС ===== */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar content";
    min-height: 100vh;
}

/* ===== HEADER ===== */
.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 var(--space-8);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    min-width: 0;
}

.app-header__left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.app-header__title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.app-header__burger {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}
.app-header__burger:hover { background: var(--bg-muted); color: var(--text-primary); }
.app-header__burger svg { width: 22px; height: 22px; }

/* ===== SIDEBAR ===== */
.app-sidebar {
    grid-area: sidebar;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    padding: var(--space-5) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
    min-width: 0;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-6);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
}

.app-sidebar__brand-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: var(--text-on-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--color-primary) 40%, transparent);
    flex-shrink: 0;
}

.app-sidebar__logo {
    max-width: 100%;
    max-height: 40px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-sidebar__section {
    padding: var(--space-3) var(--space-3) var(--space-2);
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
}

.app-sidebar__link svg {
    flex-shrink: 0;
    opacity: 0.85;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.app-sidebar__link:hover svg {
    opacity: 1;
}

.app-sidebar__link.is-active svg {
    opacity: 1;
}

.app-sidebar__link:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.app-sidebar__link.is-active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-weight: var(--weight-semibold);
}

.app-sidebar__link.is-active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--color-primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.app-sidebar__close {
    display: none;
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.app-sidebar__close:hover { background: var(--bg-muted); }

/* ===== OVERLAY (мобильное меню) ===== */
.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: var(--z-overlay);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

/* ===== CONTENT ===== */
.app-content {
    grid-area: content;
    padding: var(--space-8);
    min-width: 0;
    overflow-x: hidden;
}

.app-content__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    animation: fadeUp 0.4s var(--transition-normal);
}

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

/* ===== КАРТОЧКА ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
    min-width: 0;
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card__title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}

.card__subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-6);
}

/* ===== КНОПКИ ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn--primary {
    background: var(--color-primary);
    color: var(--text-on-brand);
    box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}
.btn--primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--color-primary) 35%, transparent);
}
.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.btn--ghost:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* ===== ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКОВ ===== */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
}
.lang-switcher__item {
    padding: 6px var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: all var(--transition-fast);
}
.lang-switcher__item:hover { color: var(--text-primary); }
.lang-switcher__item.is-active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

/* ===== ИНФО-ТАБЛИЦА (с защитой от переполнения) ===== */
.info-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.info-table th, .info-table td {
    padding: var(--space-3) var(--space-2);
    text-align: left;
    border-bottom: 1px solid var(--border-default);
    font-size: var(--text-sm);
    vertical-align: top;
}
.info-table tr:last-child th,
.info-table tr:last-child td { border-bottom: none; }
.info-table th {
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    width: 40%;
    max-width: 220px;
}
.info-table td {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
}
.info-table .ok   { color: var(--color-success); font-weight: var(--weight-semibold); }
.info-table .fail { color: var(--color-danger);  font-weight: var(--weight-semibold); }

.color-chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 6px;
    border: 1px solid var(--border-default);
}

/* ===== АДАПТИВ ===== */
@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "content";
    }

    .app-header { padding: 0 var(--space-5); }
    .app-header__burger { display: inline-flex; }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 84vw);
        z-index: var(--z-modal);
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        box-shadow: var(--shadow-lg);
        padding-top: var(--space-5);
    }
    .app-sidebar__close { display: inline-flex; }

    body.is-menu-open .app-sidebar {
        transform: translateX(0);
    }
    body.is-menu-open .app-overlay {
        display: block;
        opacity: 1;
    }
    body.is-menu-open { overflow: hidden; }
}

@media (max-width: 640px) {
    .app-content { padding: var(--space-5); }
    .app-header { padding: 0 var(--space-4); }
    .card { padding: var(--space-5); border-radius: var(--radius-lg); }
    .info-table th { width: 45%; }
}

/* ===== BENTO GRID (концепт раздел 10) ===== */
.app-content__inner > .bento {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-5);
}

@media (max-width: 1024px) {
    .app-content__inner > .bento {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .app-content__inner > .bento {
        grid-template-columns: 1fr;
    }
}



/* ===== СТРАНИЦЫ ОШИБОК ===== */
.minimal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-6);
}

.minimal-shell {
    width: 100%;
    max-width: 560px;
}

.error-page {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.error-page__code {
    font-size: 120px;
    font-weight: var(--weight-bold);
    line-height: 1;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: var(--space-6);
}

.error-page__title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-3);
}

.error-page__description {
    font-size: var(--text-base);
    color: var(--text-muted);
    margin-bottom: var(--space-8);
    line-height: var(--leading-loose);
}

.error-page__debug {
    margin-bottom: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-align: left;
    word-break: break-word;
    white-space: pre-wrap;
}

@media (max-width: 640px) {
    .error-page__code { font-size: 80px; }
    .error-page__title { font-size: var(--text-2xl); }
}

/* ===== ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ===== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.theme-toggle svg { transition: transform var(--transition-normal); }
.theme-toggle:hover svg { transform: rotate(15deg); }

/* Показываем нужную иконку в зависимости от темы */
[data-theme="light"] .theme-toggle__sun  { display: none; }
[data-theme="light"] .theme-toggle__moon { display: block; }
[data-theme="dark"]  .theme-toggle__sun  { display: block; }
[data-theme="dark"]  .theme-toggle__moon { display: none; }



/* ===== ФОРМЫ (общие) ===== */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-field__label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
}

.form-field__input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-field__input:hover {
    border-color: var(--border-strong);
}

.form-field__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

.form-field__input::placeholder {
    color: var(--text-muted);
}

.form-error {
    background: color-mix(in srgb, var(--color-danger) 10%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-danger) 30%, transparent);
    color: var(--color-danger);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

/* ===== СТРАНИЦА ЛОГИНА ===== */
.auth-card {
    padding: var(--space-8);
}

.auth-card__head {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-card__logo {
    max-height: 48px;
    margin: 0 auto var(--space-5);
    object-fit: contain;
}

.auth-card__brand {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-5);
}

.auth-card__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}

.auth-card__subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-form__submit {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin-top: var(--space-2);
}

.auth-form__links {
    text-align: center;
    margin-top: var(--space-2);
}

.auth-link {
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: color var(--transition-fast);
}

.auth-link:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}


/* ===== ЮЗЕР В ШАПКЕ ===== */
.app-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    margin-right: var(--space-2);
    min-width: 0;
}

.app-user__name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.app-user__role {
    font-size: 11px;
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-logout {
    display: inline-flex;
}

.app-logout__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.app-logout__btn:hover {
    background: var(--bg-muted);
    color: var(--color-danger);
}

@media (max-width: 640px) {
    .app-user { display: none; }
}



/* ===== СТРАНИЦА «ЗАБЫЛИ ПАРОЛЬ» ===== */
.forgot-blocks {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.forgot-block {
    padding: var(--space-4);
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

.forgot-block__title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.forgot-block__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}



/* ===== FLASH-СООБЩЕНИЯ ===== */
.flash {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}

.flash--success {
    background: color-mix(in srgb, var(--color-success) 12%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
    color: var(--color-success);
}

.flash--error {
    background: color-mix(in srgb, var(--color-danger) 10%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-danger) 30%, transparent);
    color: var(--color-danger);
}

.flash--warning {
    background: color-mix(in srgb, var(--color-warning, #f59e0b) 10%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-warning, #f59e0b) 30%, transparent);
    color: color-mix(in srgb, var(--color-warning, #f59e0b) 80%, var(--text-primary));
}

.flash--info {
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

/* ===== PAGE TOOLBAR ===== */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.page-toolbar__left,
.page-toolbar__right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    min-width: 0;
}

@media (max-width: 480px) {
    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .page-toolbar__left,
    .page-toolbar__right {
        width: 100%;
    }
    .page-toolbar__right .btn {
        flex: 1;
    }
}

.page-toolbar__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.page-toolbar__link:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.page-toolbar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--bg-muted);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

/* ===== ТАБЛИЦА ДАННЫХ ===== */
.data-card {
    padding: 0;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    padding: var(--space-3) var(--space-5);
    text-align: left;
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.data-table tbody td {
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-default);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-muted);
}

.data-table__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-primary);
    transition: color var(--transition-fast);
}

.data-table__link:hover {
    color: var(--color-primary);
}

.data-table__name {
    font-weight: var(--weight-semibold);
}

.data-table__sub {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.data-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: var(--weight-medium);
}

@media (max-width: 768px) {
    .data-table thead { display: none; }

    .data-table tbody tr {
        display: block;
        padding: var(--space-4);
        border-bottom: 1px solid var(--border-default);
    }

    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: var(--space-2) 0;
        border: none;
    }

    .data-table tbody td.data-table__num {
        justify-content: space-between;
    }
}

/* ===== ПИЛЮЛИ (статусы) ===== */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.02em;
}

.pill--success {
    background: color-mix(in srgb, var(--color-success) 14%, var(--bg-surface));
    color: var(--color-success);
}

.pill--muted {
    background: var(--bg-muted);
    color: var(--text-muted);
}

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-12) var(--space-6);
    gap: var(--space-4);
}

.empty-state__icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: var(--bg-muted);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state__text {
    font-size: var(--text-base);
    color: var(--text-secondary);
    max-width: 360px;
}

/* ===== ХЕЛПЕРЫ ===== */
.text-muted { color: var(--text-muted); }


/* ===== ФОРМА (компоновка) ===== */
.form-card {
    max-width: 720px;
    padding: var(--space-8);
}

.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-field__req {
    color: var(--color-danger);
    margin-left: 2px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-default);
    margin-top: var(--space-2);
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column-reverse;
    }
    .form-actions .btn { width: 100%; }
}

/* ===== ЧЕКБОКС ===== */
.checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    user-select: none;
}

.checkbox:hover { background: var(--bg-muted); }

.checkbox input { position: absolute; opacity: 0; pointer-events: none; }

.checkbox__box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-strong);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    margin-top: 1px;
}

.checkbox input:focus-visible ~ .checkbox__box {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.checkbox input:checked ~ .checkbox__box {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox input:checked ~ .checkbox__box::after {
    content: '';
    width: 6px;
    height: 10px;
    border-right: 2px solid var(--text-on-brand);
    border-bottom: 2px solid var(--text-on-brand);
    transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checkbox__label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}

.checkbox__hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-normal);
}

/* ===== ФОРМА (компактный grid-вариант) ===== */
.form-card--compact {
    max-width: 760px;
    padding: 24px 28px;
}

@media (max-width: 640px) {
    .form-card--compact {
        padding: 20px;
    }
}

.form--compact {
    gap: var(--space-4);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4) var(--space-5);
}

.form-grid__span-2 {
    grid-column: 1 / -1;
}

@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* В компактном варианте hint без большого отступа */
.form--compact .form-field {
    gap: 6px;
}

.form--compact .form-field__hint {
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-muted);
}

.form--compact .form-field__input {
    padding: 10px 14px;
}

/* Чекбокс в компактном виде — без хавера на padding (он уже сжат) */
.checkbox--compact {
    padding: var(--space-2) 0;
}

.checkbox--compact:hover {
    background: transparent;
}


/* ===== ОПАСНАЯ ЗОНА (удаление) ===== */
.danger-zone {
    padding: var(--space-5);
    border-color: color-mix(in srgb, var(--color-danger) 30%, var(--border-default));
    background: color-mix(in srgb, var(--color-danger) 4%, var(--bg-surface));
}

.danger-zone__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-danger);
    margin-bottom: var(--space-2);
}

.danger-zone__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    line-height: var(--leading-normal);
}




/* ===== ШАПКА КАРТОЧКИ ШКОЛЫ ===== */
.school-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-2);
}

.school-header__name {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.school-header__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.school-header__back:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.school-header__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== ВКЛАДКИ ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-default);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
}

.tabs__item:hover {
    color: var(--text-primary);
}

.tabs__item.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tabs__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

.tabs__item.is-active .tabs__count {
    background: color-mix(in srgb, var(--color-primary) 14%, transparent);
    color: var(--color-primary);
}






/* ===== ВКЛАДКИ: адаптив для узких экранов ===== */
.tabs {
    position: relative;
    -webkit-overflow-scrolling: touch;
    /* Запас справа, чтобы последний таб не прилипал к краю при прокрутке */
    padding-right: var(--space-4);
}

@media (max-width: 640px) {
    .tabs__item {
        padding: var(--space-3);
        font-size: var(--text-xs);
    }

    .tabs__count {
        min-width: 18px;
        height: 18px;
        font-size: 10px;
    }
}


/* ===== СЕТКА КАРТОЧКИ ШКОЛЫ ===== */
.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.settings-grid__main,
.settings-grid__side {
    min-width: 0;
}

.settings-grid .form-card--compact {
    max-width: none;
}

@media (max-width: 1100px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}




/* ===== ПРЕВЬЮ ИМЕНИ КЛАССА ===== */
.class-preview {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-muted);
    border-radius: 10px;
    border: 1px dashed var(--border-strong);
}

.class-preview__label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.class-preview__value {
    font-size: 24px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum';
}

/* ===== READ-ONLY поле в форме ===== */
.form-field__readonly {
    padding: 10px 14px;
    font-size: var(--text-base);
    background: var(--bg-muted);
    border: 1px dashed var(--border-default);
    border-radius: 10px;
    color: var(--text-muted);
}

/* select-стили согласовать с input'ами */
select.form-field__input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}


/* ===== ПРЕДМЕТ В СПИСКЕ ===== */
.subject-row {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}

.subject-row__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.subject-row__dot--empty {
    background: var(--bg-muted);
    box-shadow: 0 0 0 1px var(--border-default);
}

/* ===== COLOR PICKER ===== */
.color-picker {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: 10px;
}

.color-picker__none {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.color-picker__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.color-swatch {
    position: relative;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.color-swatch input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.color-swatch__dot {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.10);
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.color-swatch:hover .color-swatch__dot {
    transform: scale(1.08);
}

.color-swatch input:checked ~ .color-swatch__dot {
    box-shadow: 0 0 0 3px var(--bg-surface), 0 0 0 5px var(--swatch);
}

.color-picker__custom {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.color-picker__custom-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.color-picker__hex {
    width: 140px;
    font-family: var(--font-mono);
    text-transform: uppercase;
}



/* ===== ФИЛЬТР ПО РОЛЯМ ===== */
.role-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.role-filter__chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    background: var(--bg-muted);
    border: 1px solid transparent;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.role-filter__chip:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: var(--border-default);
}

.role-filter__chip.is-active {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-color: transparent;
}

.role-filter__count {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    opacity: 0.7;
}

.role-filter__chip.is-active .role-filter__count {
    opacity: 1;
}

/* ===== ПИЛЮЛИ РОЛЕЙ ===== */
.role-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.role-pill--director,
.role-pill--admin       { background: color-mix(in srgb, var(--color-primary) 14%, var(--bg-surface)); color: var(--color-primary); }
.role-pill--head_teacher{ background: color-mix(in srgb, #0EA5E9 14%, var(--bg-surface)); color: #0EA5E9; }
.role-pill--teacher     { background: color-mix(in srgb, #06B6D4 14%, var(--bg-surface)); color: #06B6D4; }
.role-pill--student     { background: color-mix(in srgb, var(--color-success) 14%, var(--bg-surface)); color: var(--color-success); }
.role-pill--parent      { background: color-mix(in srgb, #F59E0B 14%, var(--bg-surface)); color: #F59E0B; }

/* ===== Логин в таблице (моноширинный) ===== */
.data-table__code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
}


/* ===== РЕЖИМ ПАРОЛЯ ===== */
.password-modes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    margin-bottom: var(--space-2);
}

.password-modes__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ===== СТРАНИЦА ПОКАЗА ПАРОЛЯ ===== */
.password-show {
    max-width: 640px;
    margin: 0 auto;
}

.password-show__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-3);
}

.password-show__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    line-height: var(--leading-normal);
}

.password-show__name {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.password-show__rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.password-show__row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.password-show__label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.password-show__row-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.password-show__value {
    flex: 1;
    min-width: 200px;
    font-family: var(--font-mono);
    font-size: var(--text-base);
    padding: 12px 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    color: var(--text-primary);
    user-select: all;
    word-break: break-all;
}

.password-show__value--secret {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--bg-surface));
    border-color: color-mix(in srgb, var(--color-primary) 30%, var(--border-default));
    font-weight: var(--weight-semibold);
    letter-spacing: 0.02em;
}


/* ===== БЛОК «РОДИТЕЛИ» ===== */
.parents-block__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

.parents-block__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin: 0;
}

.parents-block__empty {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0;
}

.parents-block__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.parents-block__list li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg-muted);
    border-radius: 10px;
}

.parents-block__link {
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    text-decoration: none;
}

.parents-block__link:hover {
    color: var(--color-primary);
}

.parents-block__phone {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ===== МОДАЛКА «ДОБАВИТЬ РОДИТЕЛЯ» ===== */
.parent-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.parent-modal.is-open {
    display: flex;
}

.parent-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.parent-modal__panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    padding: var(--space-5) var(--space-6) var(--space-6);
}

.parent-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.parent-modal__title {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    margin: 0;
}

.parent-modal__close {
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 8px;
}

.parent-modal__close:hover {
    color: var(--text-primary);
}


/* ===== ИМПОРТ ПОЛЬЗОВАТЕЛЕЙ ===== */
.import-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.import-step__head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.import-step__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    flex-shrink: 0;
}

.import-step__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin: 0;
}

.import-step__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-4);
    line-height: var(--leading-normal);
}

.import-columns {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-default);
}

.import-columns__head {
    margin-bottom: var(--space-3);
}

.import-columns__head h4 {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}



/* ===== САБ-НАВИГАЦИЯ (внутри вкладки «Оценивание») ===== */
.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: var(--space-2) 0 var(--space-4);
    padding: 4px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    width: fit-content;
    max-width: 100%;
}

.subnav__item {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.subnav__item:hover {
    color: var(--text-primary);
}

.subnav__item.is-active {
    background: var(--bg-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-xs);
}

@media (max-width: 480px) {
    .subnav {
        width: 100%;
    }
    .subnav__item {
        flex: 1;
        text-align: center;
    }
}



/* ============================================================
   Bell schedule (этап 2.2.1)
   ============================================================ */

.bell-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--space-4, 16px);
}

.bell-row {
    display: grid;
    grid-template-columns: 56px 1fr 90px 90px auto;
    align-items: center;
    gap: var(--space-3, 12px);
    padding: var(--space-3, 12px) var(--space-4, 16px);
    background: var(--surface, #fff);
    border: 1px solid var(--border-default, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.bell-row:hover {
    border-color: var(--color-primary, #4F46E5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.bell-row.is-inactive {
    opacity: 0.55;
}

.bell-row__num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-soft, #eef2ff);
    color: var(--color-primary, #4F46E5);
    font-weight: var(--weight-semibold, 600);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.bell-row__times {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.bell-row__time {
    font-weight: var(--weight-semibold, 600);
    color: var(--text-primary, #111827);
}

.bell-row__dash {
    color: var(--text-muted, #9ca3af);
    font-size: 14px;
}

.bell-row__duration {
    color: var(--text-muted, #6b7280);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.bell-row__status {
    min-width: 40px;
}

.bell-row__actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.bell-row__form {
    margin: 0;
}

.bell-break {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-3, 12px);
    margin: 4px 0;
    padding: 0 var(--space-4, 16px);
}

.bell-break__line {
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        var(--border-default, #e5e7eb),
        transparent
    );
}

.bell-break__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    text-transform: lowercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Кнопки-действия в строке слота — фиксированный квадратный размер
   с гарантированно видимой иконкой на любых экранах. */
.bell-row__actions .btn {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}

.bell-row__actions .btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.bell-row__actions .btn--danger {
    color: var(--text-muted);
}

.bell-row__actions .btn--danger:hover {
    color: var(--color-danger);
    border-color: color-mix(in srgb, var(--color-danger) 30%, var(--border-default));
    background: color-mix(in srgb, var(--color-danger) 8%, var(--bg-surface));
}

@media (max-width: 640px) {
    .bell-row {
        grid-template-columns: 44px 1fr auto;
        grid-template-areas:
            "num times actions"
            ".   duration .";
        gap: var(--space-2, 8px);
    }
    .bell-row__num     { grid-area: num; }
    .bell-row__times   { grid-area: times; }
    .bell-row__actions { grid-area: actions; }
    .bell-row__duration { grid-area: duration; font-size: 12px; }
    .bell-row__status  { display: none; }
}


/* Жёлтая плашка предупреждения — соседствует с .form-error для красных ошибок */
.form-error--warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}



/* ============================================================
   Schedule view (read-only, для учителя/ученика/родителя)
   ============================================================ */

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

.schedule-toolbar__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.schedule-toolbar__h1 {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin: 0;
}

.schedule-toolbar__sub {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.schedule-toolbar__sub-sep {
    margin: 0 4px;
    opacity: 0.5;
}

.schedule-toolbar__nav {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.schedule-toolbar__nav .btn.is-current {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-color: transparent;
}

/* === Сетка-неделя === */

.sched-grid-card {
    padding: var(--space-4);
}

.sched-grid-wrap {
    overflow-x: auto;
}

.sched-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 760px;
}

.sched-grid th {
    padding: 10px 8px;
    font-weight: var(--weight-semibold);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-align: center;
    background: transparent;
}

.sched-cell-day {
    line-height: 1.3;
}

.sched-cell-day__name {
    font-size: 12px;
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sched-cell-day__date {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    text-transform: none;
    letter-spacing: 0;
}

.sched-cell-day.is-today {
    color: var(--color-primary);
}
.sched-cell-day.is-today .sched-cell-day__date {
    color: var(--color-primary);
}

.sched-cell-time {
    width: 90px;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}

.sched-slot-num {
    font-size: 18px;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
}

.sched-slot-time {
    font-size: 11px;
    font-family: var(--font-mono);
    margin-top: 2px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.sched-slot-time__sep {
    opacity: 0.5;
    margin: 0 1px;
}

.sched-cell {
    padding: 0;
    height: 80px;
    border-radius: var(--radius-md);
    position: relative;
    vertical-align: stretch;
}

.sched-cell--filled {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.sched-cell--filled:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.sched-cell__inner {
    padding: 8px 10px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.sched-cell__subject {
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    line-height: 1.2;
}

.sched-cell__meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.sched-cell__room {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.sched-cell__topic {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-top: auto;
    padding-top: 2px;
    border-top: 1px dashed var(--border-default);
}

.sched-cell__badge {
    align-self: flex-start;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-danger);
    font-weight: var(--weight-semibold);
}

.sched-cell--cancelled {
    background: color-mix(in srgb, var(--color-danger) 5%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-danger) 25%, var(--border-default));
}
.sched-cell--cancelled .sched-cell__subject,
.sched-cell--cancelled .sched-cell__meta,
.sched-cell--cancelled .sched-cell__room,
.sched-cell--cancelled .sched-cell__topic {
    text-decoration: line-through;
    opacity: 0.65;
}

.sched-cell--empty {
    background: transparent;
    border: 1px dashed var(--border-default);
    opacity: 0.6;
}

.sched-cell--holiday {
    background: color-mix(in srgb, var(--color-accent, #22C55E) 8%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--color-accent, #22C55E) 25%, var(--border-default));
}

.sched-cell__holiday-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: color-mix(in srgb, var(--color-accent, #22C55E) 80%, var(--text-primary));
}

.sched-cell.is-today {
    box-shadow: 0 0 0 2px var(--color-primary-soft);
}

/* === Мобильный аккордеон === */

.sched-mobile-wrap {
    display: none;
}

@media (max-width: 1024px) {
    .sched-grid-card { display: none; }
    .sched-mobile-wrap { display: flex; flex-direction: column; gap: var(--space-3); }
}

.sched-day-acc {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

.sched-day-acc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-weight: var(--weight-semibold);
}

.sched-day-acc__summary::-webkit-details-marker { display: none; }
.sched-day-acc[open] > .sched-day-acc__summary svg { transform: rotate(180deg); }
.sched-day-acc__summary svg { transition: transform 200ms ease; }

.sched-day-acc__list {
    padding: 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sched-mobile-row {
    display: grid;
    grid-template-columns: 28px 50px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
}

.sched-mobile-row.is-cancelled { opacity: 0.7; }
.sched-mobile-row.is-cancelled .sched-mobile-row__subject,
.sched-mobile-row.is-cancelled .sched-mobile-row__meta {
    text-decoration: line-through;
}

.sched-mobile-row__num {
    font-weight: var(--weight-bold);
    color: var(--text-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sched-mobile-row__time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sched-mobile-row__subject {
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
}

.sched-mobile-row__meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.sched-mobile-row__topic {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-default);
}

.sched-mobile-row__badge {
    margin-top: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-danger);
    font-weight: var(--weight-semibold);
}

.sched-mobile-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.sched-mobile-holiday {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    color: color-mix(in srgb, var(--color-accent, #22C55E) 80%, var(--text-primary));
    background: color-mix(in srgb, var(--color-accent, #22C55E) 8%, var(--bg-surface));
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
}



/* ============================================================
   Timetable header + grid (этап 2.2.2 + 2.2.5)
   Используется на /timetable, /lessons и в формах замен
   ============================================================ */

/* === Шапка === */
.tt-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap;
}
.tt-class-switcher {
    display: flex; align-items: center; gap: var(--space-2);
}
.tt-arrow {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius-sm, 8px);
    color: var(--text-muted); border: 1px solid var(--border-default, #e5e7eb);
    background: var(--bg-surface, #fff); transition: all 150ms ease;
    text-decoration: none;
}
.tt-arrow:hover { color: var(--color-primary); border-color: var(--color-primary); }
.tt-arrow--disabled { opacity: 0.35; pointer-events: none; }
.tt-class-select {
    padding: 6px 12px; font-size: 16px; font-weight: var(--weight-semibold);
    border: 1px solid var(--border-default, #e5e7eb); border-radius: var(--radius-sm, 8px);
    background: var(--bg-surface, #fff); color: var(--text-primary); min-width: 100px;
}
.tt-header__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }



/* ============================================================
   Compact form — мелкий шрифт инпутов и textarea
   Соответствует размеру лейблов и hint в form--compact
   ============================================================ */

.form--compact .form-field__input {
    font-size: var(--text-sm);
}

.form--compact textarea.form-field__input {
    resize: vertical;
    min-height: 72px;
    font-family: inherit;
    line-height: 1.4;
}

/* Компактный заголовок внутри form-card */
.form-card--compact h2,
.form-card--compact h3 {
    font-size: 16px;
    font-weight: var(--weight-semibold);
    letter-spacing: -0.01em;
    margin: 0 0 var(--space-3);
}



/* ============================================================
   Journal grid (этап 2.3.3)

   Двумерная сетка «ученики × уроки» с двумя sticky-направлениями:
   - левая колонка ФИО — sticky слева при горизонтальной прокрутке;
   - шапка дат/слотов — sticky сверху при вертикальной прокрутке.

   Стилевая логика:
   - моноширинный шрифт оценок («5 4» через пробел) — для бумажного канона;
   - бейдж work_type вокруг каждой оценки — тонкая обводка цветом из
     grade_works.color, не заливка (иначе сетка пёстрая);
   - tabular-nums для дат — чтобы шапка не «прыгала» по ширине;
   - hover на ячейке только под учителем (data-edit) — иначе наблюдатель
     зря думает, что строки кликабельны.
   ============================================================ */

/* ---- Шапка модуля: класс/предмет + селектор периода ---- */
.journal-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.journal-head__title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    margin: 0;
}

.journal-head__title-sep {
    color: var(--text-muted);
    font-weight: var(--weight-medium);
}

.journal-head__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}
.journal-head__back:hover { background: var(--bg-muted); color: var(--text-primary); }

.journal-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.journal-meta__period-label {
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
}

.journal-meta__orphans {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-warning) 12%, var(--bg-surface));
    color: color-mix(in srgb, var(--color-warning) 80%, var(--text-primary));
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-decoration: none;
    transition: background var(--transition-fast);
}
.journal-meta__orphans:hover {
    background: color-mix(in srgb, var(--color-warning) 22%, var(--bg-surface));
}
.journal-meta__orphans svg { flex-shrink: 0; }

.journal-help {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-normal);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-muted);
    border-radius: var(--radius-md);
}

/* ---- Скролл-контейнер сетки ---- */
.journal-grid-wrap {
    position: relative;
    overflow: auto;
    max-height: calc(100vh - 240px); /* Шапка + toolbar + селектор + воздух */
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
}

/* ---- Сама таблица ---- */
.journal-grid {
    border-collapse: separate; /* критично для sticky */
    border-spacing: 0;
    font-size: var(--text-sm);
    width: max-content; /* шапка не сжимается, ячейки фиксированной ширины */
    min-width: 100%;
}

/* ---- Шапка (даты + номера слотов) ---- */
.journal-grid thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border-default);
    padding: 0;
    font-weight: var(--weight-medium);
    text-align: center;
    white-space: nowrap;
}

.journal-grid thead th.journal-grid__corner {
    /* Угловая ячейка — sticky одновременно слева и сверху */
    position: sticky;
    left: 0;
    top: 0;
    z-index: 3;
    background: var(--bg-muted);
    border-right: 1px solid var(--border-default);
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    min-width: 220px;
    width: 220px;
}

.journal-grid__head-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    width: 56px;
    min-width: 56px;
    line-height: 1.2;
}

.journal-grid__head-date {
    font-size: 12px;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.journal-grid__head-slot {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.journal-grid__head-sub {
    width: 14px;
    height: 14px;
    color: var(--color-warning);
    margin-top: 2px;
}
.journal-grid__head-sub svg { display: block; }

/* ---- Левая колонка (ФИО учеников) ---- */
.journal-grid tbody th.journal-grid__name {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
    padding: var(--space-2) var(--space-4);
    text-align: left;
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    min-width: 220px;
    width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journal-grid tbody tr:hover th.journal-grid__name {
    background: var(--bg-muted); /* подсветка строки и в sticky-колонке */
}

.journal-grid__name-inactive {
    color: var(--text-muted);
    font-style: italic;
}

/* ---- Ячейки данных ---- */
.journal-grid tbody td.journal-grid__cell {
    border-bottom: 1px solid var(--border-default);
    border-right: 1px solid var(--border-default);
    padding: 0;
    text-align: center;
    vertical-align: middle;
    width: 56px;
    min-width: 56px;
    height: 40px;
    background: var(--bg-surface);
    transition: background var(--transition-fast);
}

.journal-grid tbody tr:hover td.journal-grid__cell {
    background: var(--bg-muted);
}

/* Ячейка с разрешением на клик (только под учителем) */
.journal-grid tbody td.journal-grid__cell--editable {
    cursor: cell;
}
.journal-grid tbody td.journal-grid__cell--editable:hover {
    background: color-mix(in srgb, var(--color-primary) 6%, var(--bg-surface));
}

/* Ячейка отсутствия — серый фон, бледный текст */
.journal-grid tbody td.journal-grid__cell--absent {
    background: color-mix(in srgb, var(--text-muted) 10%, var(--bg-surface));
}
.journal-grid tbody tr:hover td.journal-grid__cell--absent {
    background: color-mix(in srgb, var(--text-muted) 18%, var(--bg-surface));
}

/* ---- Содержимое ячейки ---- */
.journal-grid__cell-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 6px;
    height: 100%;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* Бейдж одной оценки: цветная обводка + лёгкая заливка фоном того же цвета.
   Двойная сигнализация (цвет рамки + цвет фона) гарантирует, что разные
   виды работ видно в журнале с одного взгляда.
   --grade-color приходит из CSS-переменной, которую шаблон ставит
   inline-стилем на каждом бейдже из grade_works.color. */
.journal-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    padding: 3px 7px;
    border-radius: 6px;
    border: 2px solid var(--grade-color, var(--border-default));
    background: color-mix(in srgb, var(--grade-color, var(--border-default)) 10%, var(--bg-surface));
    color: var(--text-primary);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}
.journal-grade:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--grade-color, var(--border-default)) 30%, transparent);
}

/* Маркер отсутствия в ячейке — буква «н» */
.journal-attendance {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: var(--weight-bold);
    text-transform: lowercase;
}

/* ---- Состояние «уроков нет» / «учеников нет» — внутри карточки ---- */
.journal-empty {
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* ---- Адаптив: на мобильных скролл уже горизонтальный по факту ---- */
@media (max-width: 768px) {
    .journal-grid-wrap {
        max-height: calc(100vh - 200px);
    }
    .journal-grid thead th.journal-grid__corner,
    .journal-grid tbody th.journal-grid__name {
        min-width: 160px;
        width: 160px;
    }
    .journal-head__title { font-size: var(--text-xl); }
}

/* ---- Тёмная тема: переменные уже подменены в theme.css, нужны точечные правки ---- */
[data-theme="dark"] .journal-grid thead th {
    background: var(--bg-elevated);
}
[data-theme="dark"] .journal-grid thead th.journal-grid__corner {
    background: var(--bg-elevated);
}
[data-theme="dark"] .journal-grade {
    background: var(--bg-surface);
}




/* ============================================================
   Journal grid — состояния inline-редактирования (порция 3)
   ============================================================ */

/* Бейдж в режиме редактирования: внутри input на месте оценки */
.journal-grade--editing {
    padding: 0;
    border-color: var(--color-primary);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.journal-grade__input {
    width: 36px;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    text-align: center;
    outline: none;
}

/* Бейдж сохраняется — пульсирующая граница */
.journal-grade--saving {
    border-color: var(--color-primary);
    animation: journal-grade-pulse 1.2s ease-in-out infinite;
}

@keyframes journal-grade-pulse {
    0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 30%, transparent); }
    50%     { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 30%, transparent); }
}

/* Ошибка сохранения — красная подсветка */
.journal-grade--error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-danger) 25%, transparent);
}

/* Reason-textarea под ячейкой */
.journal-reason {
    position: absolute;
    z-index: 5;
    margin-top: 4px;
    width: 220px;
    padding: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.journal-reason__textarea {
    width: 100%;
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--font-sans);
    line-height: 1.3;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

.journal-reason__textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.journal-reason--required .journal-reason__textarea {
    border-color: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 6%, var(--bg-surface));
}

/* Reason-textarea должен «вырваться» из ячейки сетки — родительская
   ячейка с overflow hidden обрежет, поэтому фиксируем position:relative */
.journal-grid tbody td.journal-grid__cell {
    position: relative;
}

/* Flash-уведомление снизу */
.journal-flash {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 1500;
    padding: 12px 20px;
    background: var(--text-primary);
    color: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    max-width: 90vw;
    text-align: center;
}

.journal-flash--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}



/* ============================================================
   Journal grid — состояния создания оценки в пустой ячейке (порция 4)
   ============================================================ */

/* Ячейка в режиме ввода новой оценки */
.journal-grid__cell.journal-cell--creating {
    background: color-mix(in srgb, var(--color-primary) 6%, var(--bg-surface));
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Состояние сохранения нового значения — пульс по контуру ячейки */
.journal-grid__cell.journal-cell--saving {
    animation: journal-cell-pulse 1.2s ease-in-out infinite;
}

@keyframes journal-cell-pulse {
    0%,100% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-primary) 50%, transparent); }
    50%     { box-shadow: inset 0 0 0 2px var(--color-primary); }
}

/* Ошибка создания — красная подсветка ячейки */
.journal-grid__cell.journal-cell--error {
    box-shadow: inset 0 0 0 2px var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 6%, var(--bg-surface));
}

/* Input создания — больше места внутри ячейки чем у inline-edit input'а */
.journal-grade__input--create {
    width: 44px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
}

.journal-grade__input--create:focus {
    border-color: var(--color-primary);
    outline: none;
}





/* ============================================================
   Журнальная сетка — лента типов работ под ячейкой (порция 5)
   ============================================================ */

/* Панель под ячейкой при создании оценки */
.journal-types-panel {
    z-index: 50;
    min-width: 360px;
    max-width: 540px;
    margin-top: 4px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: box-shadow var(--transition-fast);
}

.journal-types-panel--flash {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent),
                var(--shadow-lg);
}

/* Лента кнопок-типов */
.journal-types-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.journal-types-bar--advanced {
    border-top: 1px dashed var(--border-default);
    padding-top: 6px;
    margin-top: 2px;
}

/* Один chip — буква + название */
.journal-types-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border: 1.5px solid var(--chip-color, var(--border-default));
    background: color-mix(in srgb, var(--chip-color, var(--border-default)) 8%, var(--bg-surface));
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-sans);
    line-height: 1.2;
}

.journal-types-chip:hover {
    transform: scale(1.05);
}

.journal-types-chip.is-active {
    background: var(--chip-color, var(--color-primary));
    color: white;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chip-color, var(--color-primary)) 35%, transparent);
}

.journal-types-chip.is-active .journal-types-chip__letter {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.journal-types-chip__letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--chip-color, var(--border-default));
    color: white;
    font-weight: var(--weight-bold);
    font-size: 11px;
    flex-shrink: 0;
}

.journal-types-chip__label {
    font-weight: var(--weight-medium);
    white-space: nowrap;
}

/* Кнопка "+ Ещё" */
.journal-types-bar__more {
    margin-left: auto;
    padding: 4px 10px;
    border: 1px dashed var(--border-default);
    background: var(--bg-surface);
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    font-family: var(--font-sans);
}

.journal-types-bar__more:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

/* Ряд "Тема" — для не-агрегирующих типов */
.journal-types-panel__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--border-default);
}

.journal-types-panel__title-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.journal-types-panel__title-input {
    flex: 1;
    padding: 4px 8px;
    font-size: var(--text-sm);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.journal-types-panel__title-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.journal-types-panel__title-input--required {
    border-color: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 6%, var(--bg-surface));
}


/* ============================================================
   Журнальная сетка — двухзонные ячейки и именованные бейджи работ
   (этап 2.3.3, переход к EduPage-совместимой модели)
   ============================================================ */

/* Внутренний контейнер ячейки — теперь две зоны вместо одной строки.
   Зона 1 (агрегирующие оценки) — горизонтальная компактная.
   Зона 2 (именованные бейджи СОР/Контрольная/СОЧ) — вертикальная,
   каждый бейдж на новой строке. */
.journal-grid__cell-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
    padding: 4px 6px;
    height: 100%;
}

/* Зона 1 — компактные бейджи через пробел */
.journal-grid__cell-agg {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* Зона 2 — именованные бейджи СОР/Контрольная/СОЧ */
.journal-grid__cell-works {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: stretch;
}

/* Если в ячейке есть именованные работы — увеличиваем высоту строки */
.journal-grid__cell--has-work {
    min-height: auto !important;
}

.journal-grid tbody td.journal-grid__cell--has-work {
    height: auto;
    min-width: 130px;
    width: 130px;
}

/* Шапка в колонках, где у учеников могут быть именованные работы,
   тоже шире. Управляется через JS на этапе 5 — пока шапка узкая,
   но содержимое ячейки расширяется. Для эстетики именованные бейджи
   сами уменьшаются. */

/* === Именованный бейдж не-агрегирующей работы === */
.journal-grade--work {
    /* Сбрасываем компактные правила .journal-grade */
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 4px 8px;
    border: 1.5px solid var(--grade-color, var(--border-default));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--grade-color, var(--border-default)) 8%, var(--bg-surface));
    font-family: var(--font-sans);
    font-size: 11px;
    line-height: 1.2;
    gap: 6px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.journal-grade--work:hover {
    transform: none; /* отключаем scale из базового .journal-grade */
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--grade-color, var(--border-default)) 30%, transparent);
}

/* Левая часть — название (СОР · Раздел 1...) */
.journal-grade__label {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Правая часть — оценка/максимум, моноширинная */
.journal-grade__value {
    font-family: var(--font-mono);
    font-weight: var(--weight-bold);
    font-size: 12px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    white-space: nowrap;
}

.journal-grade__max {
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    font-size: 11px;
}

/* Тёмная тема — фон бейджа чуть темнее */
[data-theme="dark"] .journal-grade--work {
    background: color-mix(in srgb, var(--grade-color, var(--border-default)) 18%, var(--bg-elevated));
}



/* ============================================================
   Журнальная сетка — пустые слоты запланированных работ + лента типов
   (этап 2.3.3, EduPage-совместимая модель)
   ============================================================ */

/* Зона 3: контейнер пустых слотов (плейсхолдеров запланированных работ) */
.journal-grid__cell-empty-slots {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: stretch;
}

/* Кнопка пустого слота — компактный пунктирный плейсхолдер */
.journal-empty-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 7px;
    border: 1.5px dashed var(--grade-color, var(--border-default));
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
    transition: background var(--transition-fast),
                border-style var(--transition-fast),
                color var(--transition-fast);
    width: 100%;
    min-width: 0;
}

.journal-empty-slot:hover {
    background: color-mix(in srgb, var(--grade-color, var(--border-default)) 8%, var(--bg-surface));
    border-style: solid;
    color: var(--text-primary);
}

.journal-empty-slot__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--weight-medium);
}

.journal-empty-slot__plus {
    color: var(--grade-color, var(--text-muted));
    font-weight: var(--weight-bold);
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

/* Активный слот — с input внутри */
.journal-empty-slot--active {
    border-style: solid;
    background: color-mix(in srgb, var(--grade-color, var(--color-primary)) 6%, var(--bg-surface));
    padding: 2px 4px;
}

.journal-empty-slot__input {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: var(--weight-bold);
    font-size: 13px;
    text-align: center;
    outline: none;
    padding: 2px 4px;
}

.journal-empty-slot--saving {
    animation: journal-cell-pulse 1.2s ease-in-out infinite;
}

.journal-empty-slot--error {
    border-style: solid;
    border-color: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 6%, var(--bg-surface));
}

/* === Лента 4 типов под ячейкой при создании агрегирующей оценки === */
.journal-types-panel {
    min-width: 360px;
    margin-top: 4px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: box-shadow var(--transition-fast);
}

.journal-types-panel--flash {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent),
                var(--shadow-lg);
}

.journal-types-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.journal-types-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border: 1.5px solid var(--chip-color, var(--border-default));
    background: color-mix(in srgb, var(--chip-color, var(--border-default)) 8%, var(--bg-surface));
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-sans);
    line-height: 1.2;
}

.journal-types-chip:hover {
    transform: scale(1.05);
}

.journal-types-chip.is-active {
    background: var(--chip-color, var(--color-primary));
    color: white;
}

.journal-types-chip.is-active .journal-types-chip__letter {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.journal-types-chip__letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--chip-color, var(--border-default));
    color: white;
    font-weight: var(--weight-bold);
    font-size: 11px;
    flex-shrink: 0;
}

.journal-types-chip__label {
    font-weight: var(--weight-medium);
    white-space: nowrap;
}


/* ============================================================
   Журнал — легенда цветов видов работ
   ============================================================ */
.journal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
}

.journal-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.journal-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.journal-legend__label {
    font-weight: var(--weight-medium);
}



/* ============================================================
   2.3.5 — Popover истории оценки (журнал-сетка)
   ============================================================ */

/* Триггер «часы» внутри бейджа оценки */
.grade-history-trigger {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: currentColor;
    cursor: pointer;
    opacity: 0;
    transition: opacity 150ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    z-index: 2;
}

.grade-history-trigger svg {
    width: 11px;
    height: 11px;
    stroke-width: 2;
    pointer-events: none;
}

/* Появление триггера при наведении на бейдж или ячейку */
.journal-grade:hover .grade-history-trigger,
.journal-grid__cell:hover .grade-history-trigger {
    opacity: 0.55;
}

.grade-history-trigger:hover,
.grade-history-trigger:focus-visible {
    opacity: 1 !important;
    outline: none;
}

.grade-history-trigger:focus-visible {
    box-shadow: 0 0 0 2px var(--color-primary, #3B82F6);
    border-radius: 2px;
}

/* Для именованных бейджей — слегка сдвигаем триггер,
   чтобы не наезжал на /max */
.journal-grade--work .grade-history-trigger {
    top: 2px;
    right: 4px;
}

/* В режиме редактирования (input на месте бейджа) — скрываем триггер */
.journal-grade--editing .grade-history-trigger,
.journal-grade--saving  .grade-history-trigger {
    display: none;
}

/* Скрываем на мобильных — там популярные ячейки слишком тесные.
   История на мобиле будет доступна через дневник (2.3.6). */
@media (max-width: 768px) {
    .grade-history-trigger { display: none; }
}

/* ------------------------------------------------------------
   Backdrop под popover
   ------------------------------------------------------------ */
.history-popover__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.04);
    z-index: 1000;
    opacity: 0;
    transition: opacity 150ms ease;
}
.history-popover__backdrop.is-visible { opacity: 1; }

/* ------------------------------------------------------------
   Карточка popover'а
   ------------------------------------------------------------ */
.history-popover {
    position: fixed;
    z-index: 1001;
    width: 340px;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    background: var(--surface, #fff);
    color: var(--text, #1a1d24);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);

    opacity: 0;
    transform: scale(0.98);
    transition: opacity 150ms ease, transform 150ms ease;
    font-size: 13px;
    line-height: 1.45;
}
.history-popover.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Заголовок */
.history-popover__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.history-popover__title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text, #1a1d24);
    margin: 0;
}
.history-popover__close {
    background: transparent;
    border: 0;
    padding: 4px;
    margin: -4px;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.history-popover__close:hover { color: var(--text, #1a1d24); background: var(--surface-hover, #f3f4f6); }
.history-popover__close svg { width: 16px; height: 16px; }

/* Контекст работы (под заголовком) */
.history-popover__context {
    padding: 10px 14px 12px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    background: var(--surface-muted, #fafafa);
}
.history-popover__context-title {
    font-weight: 500;
    font-size: 13px;
    color: var(--text, #1a1d24);
    margin-bottom: 4px;
    word-break: break-word;
}
.history-popover__context-meta {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}
.history-popover__context-deleted {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    background: var(--color-danger-bg, #fef2f2);
    color: var(--color-danger, #dc2626);
    border-radius: 4px;
}

/* Список ревизий — прокручиваемая зона */
.history-popover__body {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: 10px 14px 12px;
}

.history-popover__empty,
.history-popover__loading,
.history-popover__error {
    text-align: center;
    color: var(--text-muted, #6b7280);
    padding: 20px 10px;
    font-size: 13px;
}
.history-popover__error-retry {
    margin-top: 8px;
    background: transparent;
    border: 1px solid var(--border, #e5e7eb);
    color: var(--text, #1a1d24);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.history-popover__error-retry:hover { background: var(--surface-hover, #f3f4f6); }

/* Timeline */
.history-popover__list {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}
.history-popover__item {
    position: relative;
    padding: 6px 0 14px 18px;
    border-left: 1px solid var(--border, #e5e7eb);
    margin-left: 4px;
}
.history-popover__item:last-child {
    border-left-color: transparent;
    padding-bottom: 4px;
}
.history-popover__item::before {
    /* Маркер-точка слева */
    content: '';
    position: absolute;
    left: -5px;
    top: 9px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--marker-color, #94a3b8);
    box-shadow: 0 0 0 2px var(--surface, #fff);
}
.history-popover__item--created   { --marker-color: var(--color-success, #10b981); }
.history-popover__item--updated   { --marker-color: var(--color-warning, #f59e0b); }
.history-popover__item--deleted   { --marker-color: var(--color-danger,  #ef4444); }
.history-popover__item--restored  { --marker-color: var(--color-info,    #3b82f6); }

.history-popover__item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}
.history-popover__action {
    font-weight: 600;
    font-size: 12px;
    color: var(--text, #1a1d24);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.history-popover__time {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
}

.history-popover__author {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    margin-bottom: 4px;
    word-break: break-word;
}

.history-popover__value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 13px;
    color: var(--text, #1a1d24);
    background: var(--surface-muted, #f6f7f9);
    border-radius: 4px;
    padding: 2px 6px;
    display: inline-block;
    margin: 2px 0;
}
.history-popover__value--cleared {
    color: var(--text-muted, #6b7280);
    font-style: italic;
}

.history-popover__field {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    word-break: break-word;
}
.history-popover__field b {
    font-weight: 600;
    color: var(--text, #1a1d24);
    margin-right: 4px;
}

.history-popover__ip {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted, #6b7280);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    opacity: 0.7;
}

/* ------------------------------------------------------------
   Mobile: bottom-sheet (≤768px)
   ------------------------------------------------------------ */
@media (max-width: 768px) {
    .history-popover {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 75vh;
        border-radius: 14px 14px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        transform: translateY(20px);
    }
    .history-popover.is-visible {
        transform: translateY(0);
    }
    .history-popover::before {
        /* Drag-handle */
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border, #e5e7eb);
        border-radius: 2px;
        margin: 8px auto 4px;
    }
    .history-popover__header {
        padding-top: 4px;
    }
}

/* ------------------------------------------------------------
   Тёмная тема
   ------------------------------------------------------------ */
[data-theme="dark"] .history-popover {
    background: var(--surface, #1a1d24);
    border-color: var(--border, #2a2f3b);
}
[data-theme="dark"] .history-popover__context,
[data-theme="dark"] .history-popover__value {
    background: var(--surface-muted, #232733);
}
[data-theme="dark"] .history-popover__backdrop {
    background: rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .history-popover__item::before {
    box-shadow: 0 0 0 2px var(--surface, #1a1d24);
}



/* ============================================================
   2.3.6 — Дневник ученика/родителя (порция 5)

   Сетка строк по предметам в стиле EduPage:
     [● Предмет]  [бейджи оценок]  [средний + плашка + прогноз]

   Все бейджи в строке одного предмета покрашены в цвет ПРЕДМЕТА
   через CSS-переменную --grade-color, которую view ставит inline
   на корневом .diary-row из subject.color. .journal-grade и
   .journal-grade--work из журнала переиспользуются 1-в-1.
   ============================================================ */

.diary-subjects {
    display: flex;
    flex-direction: column;
}

/* === Одна строка предмета === */
.diary-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr) 140px;
    gap: var(--space-5);
    align-items: center;
    padding: 14px var(--space-5);
    border-bottom: 1px solid var(--border-default);
    transition: background var(--transition-fast);
}

.diary-row:last-child {
    border-bottom: none;
}

.diary-row:hover {
    background: var(--bg-muted);
}

/* Зона 1 — название предмета */
.diary-row__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.diary-row__subject {
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Зона 2 — бейджи оценок */
.diary-row__grades {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.diary-row__empty {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* Зона 3 — средний + прогноз */
.diary-row__avg {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.diary-avg__value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    background: var(--bg-muted);
    border: 1.5px solid transparent;
    line-height: 1;
}

.diary-avg__value--empty {
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    background: transparent;
    border: 1px dashed var(--border-default);
}

.diary-avg__forecast {
    font-size: 11px;
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* === Цветовая плашка среднего по passing_value шкалы === */

/* poor — ниже passing (красная) */
.diary-row--avg-poor .diary-avg__value {
    background: color-mix(in srgb, var(--color-danger) 12%, var(--bg-surface));
    color: color-mix(in srgb, var(--color-danger) 85%, var(--text-primary));
    border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
}

/* low — passing..passing+1 (оранжевая) */
.diary-row--avg-low .diary-avg__value {
    background: color-mix(in srgb, var(--color-warning, #f59e0b) 14%, var(--bg-surface));
    color: color-mix(in srgb, var(--color-warning, #f59e0b) 85%, var(--text-primary));
    border-color: color-mix(in srgb, var(--color-warning, #f59e0b) 30%, transparent);
}

/* mid — passing+1..max-1 (жёлто-зелёная) */
.diary-row--avg-mid .diary-avg__value {
    background: color-mix(in srgb, #84cc16 14%, var(--bg-surface));
    color: color-mix(in srgb, #65a30d 85%, var(--text-primary));
    border-color: color-mix(in srgb, #84cc16 30%, transparent);
}

/* high — равно max (зелёная) */
.diary-row--avg-high .diary-avg__value {
    background: color-mix(in srgb, var(--color-success) 14%, var(--bg-surface));
    color: color-mix(in srgb, var(--color-success) 85%, var(--text-primary));
    border-color: color-mix(in srgb, var(--color-success) 35%, transparent);
}

/* === Адаптив === */

@media (max-width: 768px) {
    .diary-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "head avg"
            "grades grades";
        row-gap: 8px;
    }
    .diary-row__head    { grid-area: head; }
    .diary-row__avg     { grid-area: avg; }
    .diary-row__grades  { grid-area: grades; }
}

/* Тёмная тема */
[data-theme="dark"] .diary-avg__value {
    background: var(--bg-elevated);
}