/* ==========================================================================
   СК-Система — базовые стили. Mobile-first: сначала 360px, потом десктоп.
   Требования: тач-цели ≥44px, кегль ≥16px, без горизонтального скролла.
   ========================================================================== */

:root {
    --sk-primary: #0d6efd;
    --sk-primary-dark: #0a58ca;
    --sk-radius: 12px;
    --sk-radius-sm: 8px;
    --sk-gap: 12px;

    --sk-present: #198754;
    --sk-late: #fd7e14;
    --sk-excused: #e0a800;
    --sk-unexcused: #dc3545;
    --sk-sick: #0d6efd;
    --sk-cancelled: #6c757d;
    --sk-trial: #6f42c1;

    --sk-bg: #f4f6f9;
    --sk-surface: #ffffff;
    --sk-text: #1f2937;
    --sk-muted: #6b7280;
    --sk-border: #e2e6ee;

    --sk-bottom-nav: 62px;
    --sk-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; }

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

body {
    background: var(--sk-bg);
    color: var(--sk-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Никакого горизонтального скролла */
img, svg, video, table { max-width: 100%; }

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

/* Крупные элементы управления: палец, а не мышка */
.btn, .form-control, .form-select, .nav-link, .list-group-item-action {
    min-height: 44px;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-weight: 500; }
.btn-lg { min-height: 52px; font-size: 1.0625rem; }
.btn-sm { min-height: 34px; font-size: .875rem; }
.form-control, .form-select { font-size: 16px; } /* иначе Safari зумит */
.form-control-lg, .form-select-lg { font-size: 16px; min-height: 52px; }
.form-label { font-weight: 600; font-size: .9375rem; margin-bottom: .25rem; }
.form-text { font-size: .8125rem; }

/* Видимое состояние фокуса (доступность) */
:focus-visible {
    outline: 3px solid rgba(13, 110, 253, .55);
    outline-offset: 2px;
    border-radius: 4px;
}
a:focus-visible, button:focus-visible, .btn:focus-visible { outline-offset: 3px; }

/* ---------- Каркас ---------- */
.sk-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--sk-surface);
    border-bottom: 1px solid var(--sk-border);
    padding: .5rem .875rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 56px;
}
.sk-topbar .sk-brand {
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--sk-text);
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}
.sk-topbar .sk-brand i { color: var(--sk-primary); font-size: 1.25rem; }
.sk-topbar .sk-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-topbar .sk-actions { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.sk-icon-btn {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; border-radius: 50%;
    color: var(--sk-text); font-size: 1.25rem;
}
.sk-icon-btn:hover { background: #eef2f7; }

.sk-page { padding: .875rem; padding-bottom: calc(var(--sk-bottom-nav) + 1rem); }
@media (min-width: 992px) {
    .sk-page { padding: 1.5rem; padding-bottom: 2rem; }
}

.sk-page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 .75rem;
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.sk-page-title .btn { margin-left: auto; }

/* ---------- Нижняя навигация (телефон) ---------- */
.sk-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1040;
    background: var(--sk-surface);
    border-top: 1px solid var(--sk-border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: var(--sk-safe-bottom);
    box-shadow: 0 -2px 12px rgba(16, 24, 40, .06);
}
.sk-bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    min-height: var(--sk-bottom-nav);
    color: var(--sk-muted);
    font-size: .6875rem;
    text-decoration: none;
    padding-top: 6px;
}
.sk-bottom-nav a i { font-size: 1.35rem; line-height: 1; }
.sk-bottom-nav a.active { color: var(--sk-primary); font-weight: 600; }
.sk-bottom-nav a.active i { transform: translateY(-1px); }
@media (min-width: 992px) { .sk-bottom-nav { display: none; } }

/* ---------- Карточки ---------- */
.sk-card {
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: var(--sk-radius);
    padding: .875rem;
    margin-bottom: var(--sk-gap);
}
.sk-card-title {
    font-size: 1rem; font-weight: 700; margin: 0 0 .625rem;
    display: flex; align-items: center; gap: .5rem;
}
.sk-card-title .badge { font-weight: 600; }
.sk-empty {
    text-align: center; padding: 2rem 1rem; color: var(--sk-muted);
}
.sk-empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* ---------- Метрики дашборда ---------- */
.sk-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sk-gap); }
@media (min-width: 768px) { .sk-metrics { grid-template-columns: repeat(4, 1fr); } }
.sk-metric {
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: var(--sk-radius);
    padding: .75rem;
    display: flex; flex-direction: column; gap: .125rem;
}
.sk-metric .label { font-size: .8125rem; color: var(--sk-muted); }
.sk-metric .value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.sk-metric .hint { font-size: .75rem; color: var(--sk-muted); }
.sk-metric.warn .value { color: var(--sk-unexcused); }

/* ---------- Таблицы → карточки на телефоне ---------- */
.sk-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sk-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.sk-table th, .sk-table td { padding: .5rem .625rem; border-bottom: 1px solid var(--sk-border); text-align: left; vertical-align: middle; }
.sk-table th { font-size: .8125rem; text-transform: uppercase; letter-spacing: .02em; color: var(--sk-muted); font-weight: 600; white-space: nowrap; }
.sk-table tbody tr:hover { background: #fafbfd; }

@media (max-width: 575.98px) {
    .sk-table-cards thead { display: none; }
    .sk-table-cards, .sk-table-cards tbody, .sk-table-cards tr, .sk-table-cards td { display: block; width: 100%; }
    .sk-table-cards tr {
        border: 1px solid var(--sk-border);
        border-radius: var(--sk-radius-sm);
        margin-bottom: .625rem;
        padding: .5rem .75rem;
        background: var(--sk-surface);
    }
    .sk-table-cards td { border: 0; padding: .1875rem 0; display: flex; gap: .5rem; }
    .sk-table-cards td::before {
        content: attr(data-label);
        font-size: .75rem; color: var(--sk-muted); min-width: 96px; flex: 0 0 auto;
    }
    .sk-table-cards td[data-label=""]::before { display: none; }
}

/* ---------- Статусы (цвет + буква/иконка) ---------- */
.status-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .5rem; border-radius: 999px;
    font-size: .75rem; font-weight: 700; line-height: 1.5;
    border: 1px solid transparent; white-space: nowrap;
}
.status-badge .letter {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(255,255,255,.85); font-size: .625rem; font-weight: 800;
}
.status-present { background: #d1e7dd; color: #0a3622; border-color: #a3cfbb; }
.status-late { background: #ffe5d0; color: #7a3a00; border-color: #fdcba7; }
.status-excused { background: #fff3cd; color: #664d03; border-color: #ffe69c; }
.status-unexcused { background: #f8d7da; color: #842029; border-color: #f1aeb5; }
.status-sick { background: #cfe2ff; color: #084298; border-color: #9ec5fe; }
.status-cancelled { background: #e2e3e5; color: #41464b; border-color: #c4c8cb; }
.status-trial { background: #e2d9f3; color: #432874; border-color: #c5b3e6; }
.status-none { background: #eef1f5; color: #5c636a; border-color: #dfe3e8; }

.sk-badge-debt { background: #7f1d1d; color: #fff; padding: .15rem .45rem; border-radius: var(--sk-radius-sm); font-size: .75rem; font-weight: 700; }
.sk-badge-warn { background: #fff3cd; color: #664d03; padding: .15rem .45rem; border-radius: var(--sk-radius-sm); font-size: .75rem; font-weight: 600; }
.sk-badge-danger { background: #f8d7da; color: #842029; padding: .15rem .45rem; border-radius: var(--sk-radius-sm); font-size: .75rem; font-weight: 600; }
.sk-badge-ok { background: #d1e7dd; color: #0a3622; padding: .15rem .45rem; border-radius: var(--sk-radius-sm); font-size: .75rem; font-weight: 600; }

/* ---------- Аватар / инициалы ---------- */
.sk-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: #e7f1ff; color: var(--sk-primary-dark);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9375rem; flex: 0 0 auto; overflow: hidden;
}
.sk-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sk-avatar.lg { width: 64px; height: 64px; font-size: 1.375rem; }

/* ---------- Строка списка с действием ---------- */
.sk-list { display: flex; flex-direction: column; }
.sk-list-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .625rem 0; border-bottom: 1px solid var(--sk-border);
}
.sk-list-item:last-child { border-bottom: 0; }
.sk-list-item .main { min-width: 0; flex: 1 1 auto; }
.sk-list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-list-item .sub { font-size: .8125rem; color: var(--sk-muted); }

/* ---------- Формы ---------- */
.sk-form-actions {
    position: sticky; bottom: 0;
    background: var(--sk-bg);
    padding: .75rem 0;
    display: flex; gap: .5rem;
    z-index: 5;
}
@media (max-width: 991.98px) {
    .sk-form-actions .btn { flex: 1 1 0; }
}

/* ---------- Модальные окна: снизу на телефоне ---------- */
@media (max-width: 575.98px) {
    .modal-dialog { margin: 0; min-height: 100%; align-items: flex-end; }
    .modal-content { border-radius: var(--sk-radius) var(--sk-radius) 0 0; min-height: 40vh; max-height: 92vh; }
    .modal-footer { position: sticky; bottom: 0; background: var(--sk-surface); padding-bottom: calc(.75rem + var(--sk-safe-bottom)); }
    .modal-footer .btn { flex: 1 1 0; min-height: 48px; }
}

/* ---------- Вход ---------- */
.sk-auth {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem;
    background: linear-gradient(160deg, #eef4ff 0%, #f7f8fb 60%, #ffffff 100%);
}
.sk-auth-card {
    width: 100%; max-width: 420px;
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: 16px;
    padding: 1.5rem 1.25rem;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .07);
}
.sk-auth-logo { text-align: center; margin-bottom: 1.25rem; }
.sk-auth-logo i { font-size: 2.5rem; color: var(--sk-primary); }
.sk-auth-logo h1 { font-size: 1.25rem; font-weight: 700; margin: .5rem 0 .125rem; }
.sk-auth-logo p { color: var(--sk-muted); font-size: .875rem; margin: 0; }

/* ---------- Тост ---------- */
.sk-toast-stack {
    position: fixed; left: .75rem; right: .75rem; bottom: calc(var(--sk-safe-bottom) + .75rem);
    z-index: 1080; display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
@media (min-width: 992px) { .sk-toast-stack { left: auto; width: 360px; } }
.sk-toast {
    background: #212529; color: #fff; border-radius: var(--sk-radius-sm);
    padding: .75rem .875rem; font-size: .9375rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    display: flex; align-items: flex-start; gap: .5rem;
    animation: sk-toast-in .18s ease-out;
}
.sk-toast.success { background: #0f5132; }
.sk-toast.error { background: #842029; }
.sk-toast.warning { background: #664d03; }
@keyframes sk-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Утилиты ---------- */
.text-muted-sm { font-size: .8125rem; color: var(--sk-muted); }
.sk-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-mono { font-variant-numeric: tabular-nums; }
.sk-divider { height: 1px; background: var(--sk-border); margin: .75rem 0; }
.sk-sticky-actions { position: sticky; top: 56px; z-index: 10; background: var(--sk-bg); padding: .5rem 0; }
.visually-hidden-focusable:focus { position: static !important; }

/* Скрытая подпись для скринридеров */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Печать */
@media print {
    .sk-topbar, .sk-bottom-nav, .sk-toast-stack, .no-print, .sk-form-actions { display: none !important; }
    body { background: #fff; }
    .sk-card { border: 0; padding: 0; }
    .sk-page { padding: 0; padding-bottom: 0; }
}

/* ---------- Пояса дзюдо ---------- */
/* Метка: образец пояса + название. Образец отдельным элементом, потому что
   красно-белый пояс — это полосы (gradient), а не сплошной цвет. */
.belt-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .45rem .1rem .35rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: .6875rem;
    font-weight: 600;
    line-height: 1.6;
    color: #1f2937;
    white-space: nowrap;
    vertical-align: middle;
}

.belt-swatch {
    display: inline-block;
    width: 18px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid #94a3b8;
    flex: 0 0 auto;
    /* Полосатый узор задаётся inline для красно-белого пояса */
    background-size: auto;
}

.belt-badge .belt-label {
    line-height: 1;
}

/* Компактный вид — только образец пояса, без подписи.
   Используется в плотных таблицах, где мало места. */
.belt-badge--compact {
    padding: .1rem .2rem;
    background: transparent;
    border: 0;
    gap: 0;
}

.belt-badge--compact .belt-swatch {
    width: 20px;
    height: 14px;
}

/* Печать: пояс должен остаться различимым в ч/б,
   поэтому добавляем тонкую рамку вокруг образца */
@media print {
    .belt-badge {
        background: transparent;
        border: 0;
    }

    .belt-swatch {
        border: 1px solid #000;
    }
}
/* ---------- Логотип клуба ---------- */
/* Логотип в шапке: по высоте строки, без растягивания */
.sk-brand-logo {
    height: 28px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
}

/* Если логотип широкий, на узком экране он не должен ломать шапку */
@media (max-width: 400px) {
    .sk-brand-logo {
        max-width: 84px;
        height: 24px;
    }
}

/* ---------- Документация в браузере ---------- */
.sk-doc {
    font-size: .9375rem;
    line-height: 1.65;
    overflow-wrap: break-word;
}

.sk-doc h1,
.sk-doc h2,
.sk-doc h3,
.sk-doc h4 {
    scroll-margin-top: 80px;   /* чтобы заголовок не уходил под шапку */
    line-height: 1.3;
}

.sk-doc-h1 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

.sk-doc-h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 1.75rem 0 .75rem;
    padding-bottom: .375rem;
    border-bottom: 1px solid var(--sk-border, #e2e6ee);
}

.sk-doc-h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 .5rem;
}

.sk-doc-h4 {
    font-size: .9375rem;
    font-weight: 600;
    margin: 1rem 0 .5rem;
}

.sk-doc p {
    margin: 0 0 .875rem;
}

.sk-doc ul,
.sk-doc ol {
    margin: 0 0 .875rem;
    padding-left: 1.375rem;
}

.sk-doc li {
    margin-bottom: .25rem;
}

.sk-doc hr {
    margin: 1.5rem 0;
    border-color: var(--sk-border, #e2e6ee);
    opacity: 1;
}

/* Код: переносим длинные строки, иначе на телефоне горизонтальный скролл */
.sk-doc-pre {
    background: #f6f8fa;
    border: 1px solid var(--sk-border, #e2e6ee);
    border-radius: 8px;
    padding: .75rem .875rem;
    overflow-x: auto;
    font-size: .8125rem;
    line-height: 1.5;
    margin: 0 0 .875rem;
}

.sk-doc-pre code {
    white-space: pre;
}

.sk-doc code {
    background: #f1f5f9;
    border-radius: 4px;
    padding: .1em .35em;
    font-size: .875em;
    color: #b02a37;
    overflow-wrap: anywhere;
}

.sk-doc-pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Ссылка-путь: /activate и подобные разделы системы */
.sk-doc-path {
    text-decoration: none;
}

.sk-doc-path code {
    color: #0d6efd;
    background: #e7f1ff;
    border-bottom: 1px solid #b6d4fe;
}

.sk-doc-path:hover code {
    background: #cfe2ff;
}

.sk-doc-table {
    font-size: .8125rem;
    margin-bottom: .875rem;
}

.sk-doc-table th {
    background: #f8fafc;
    font-weight: 600;
    white-space: nowrap;
}

/* Оглавление */
.sk-doc-toc {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.sk-doc-toc-link {
    color: #495057;
    border-left: 2px solid transparent;
    padding-left: .5rem;
    border-radius: 0 4px 4px 0;
}

.sk-doc-toc-link:hover {
    background: #f1f5f9;
    color: #0d6efd;
    border-left-color: #0d6efd;
}

/* На телефоне оглавление — сверху и не липкое */
@media (max-width: 991.98px) {
    .sk-doc-toc {
        position: static;
        max-height: none;
    }

    .sk-doc {
        font-size: .875rem;
    }
}
