/*
 * Оформление — штатные компоненты Tabler. Здесь только то, чего в Tabler нет, и по минимуму.
 *
 * Цвета, шрифты и мера — из StageMaker (решение Alex 08.10.2026, World Project/DESIGN_TOKENS_FROM_STAGEMAKER.md):
 * серые светлой темы — шкала Slate, статусы, Roboto / Roboto Condensed / JetBrains Mono, плотный кегль, скругления 6 и 8 px.
 * Акцент — голубой (кнопки действия), оранжевый акцент StageMaker не берём. Таблицы — свои.
 * Фоны тёмной темы — прежние, тёмно-синие из прототипов (#0f1117 / #161b27): так решил Alex, посмотрев результат.
 * Компоненты остаются штатными: меняются переменные Tabler, от которых он сам считает фон, карточки и границы.
 */
:root {
    /* Серые — Slate. */
    --tblr-gray-50: #f8fafc;
    --tblr-gray-100: #f1f5f9;
    --tblr-gray-200: #e2e8f0;
    --tblr-gray-300: #cbd5e1;
    --tblr-gray-400: #94a3b8;
    --tblr-gray-500: #64748b;
    --tblr-gray-600: #475569;
    /* Тёмные ступени — фоны прежней тёмно-синей темы из прототипов (Alex 08.10: «верни фоны как было»). */
    --tblr-gray-700: #2d3748;
    --tblr-gray-800: #161b27;
    --tblr-gray-900: #0f1117;
    --tblr-gray-950: #0b0d13;

    /* Статусы. */
    --tblr-green: #22c55e;   --tblr-green-rgb: 34, 197, 94;
    --tblr-success: #22c55e; --tblr-success-rgb: 34, 197, 94;
    --tblr-red: #ef4444;     --tblr-red-rgb: 239, 68, 68;
    --tblr-danger: #ef4444;  --tblr-danger-rgb: 239, 68, 68;
    --tblr-yellow: #f0a000;  --tblr-yellow-rgb: 240, 160, 0;
    --tblr-warning: #f0a000; --tblr-warning-rgb: 240, 160, 0;
    --tblr-info: #3a8fc0;    --tblr-info-rgb: 58, 143, 192;

    /* Шрифты: текст, заголовки и шапки таблиц, числа. */
    --tblr-font-sans-serif: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --aps-font-display: 'Roboto Condensed', 'Roboto', system-ui, sans-serif;
    --tblr-font-monospace: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    /* Мера: основной текст 13 px; скругления — кнопки и поля 6, бейджи 4, карточки 8, окна 12. */
    --tblr-body-font-size: .8125rem;
    --tblr-border-radius: 6px;
    --tblr-border-radius-sm: 4px;
    --tblr-border-radius-lg: 8px;
    --tblr-border-radius-xl: 12px;
    --tblr-card-border-radius: 8px;
}
[data-bs-theme="light"] {
    --tblr-body-bg: #f1f5f9;
    --tblr-body-color: #334155;
    --tblr-secondary: #64748b;
    --tblr-bg-surface: #ffffff;
    --tblr-bg-surface-secondary: #f8fafc;
    --tblr-border-color: #e2e8f0;
    --tblr-border-color-translucent: #e2e8f0;
}
[data-bs-theme="dark"] {
    /* Фоны и рамки тёмной темы — прежние, из прототипов; текст и остальное — по StageMaker. */
    --tblr-body-bg: #0f1117;
    --tblr-body-color: #e2e8f0;
    --tblr-secondary: #94a3b8;
    --tblr-bg-surface: #161b27;
    --tblr-bg-surface-secondary: #13182a;
    --tblr-bg-surface-tertiary: #13182a;
    --tblr-bg-forms: #1e2535;
    /* Рамки — тонкие, как в прототипе (--border); более заметная (--border2) — у полей ввода. */
    --tblr-border-color: #1e2535;
    --tblr-border-color-translucent: #1e2535;
}
/*
 * Тёмная тема по прототипу (kcf_k4_table и страницы соревнования): таблицы и вкладки лежат прямо на фоне страницы
 * (#0f1117), карточками (#161b27) остаются только шапка, плитки показателей и всплывающее; полос у строк нет.
 * В штатном Tabler таблица стоит в карточке на карточке — из-за этого страница выходила заметно светлее прототипа.
 */
[data-bs-theme="dark"] .card:has(> .table-responsive),
[data-bs-theme="dark"] .card:has(> form > .table-responsive),
[data-bs-theme="dark"] .card:has(> .card-header > .card-header-tabs),
[data-bs-theme="dark"] .card:has(> .collapse) {
    background-color: var(--tblr-body-bg);
}
[data-bs-theme="dark"] .table {
    --tblr-table-striped-bg: transparent;
    --tblr-table-hover-bg: #161b27;
}
[data-bs-theme="dark"] .table tbody tr:hover > * { background-color: #161b27; }
[data-bs-theme="dark"] .table thead th { background-color: transparent; color: #6c7a95; }
[data-bs-theme="dark"] .card-header:has(> .card-header-tabs) { background-color: #13182a; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { border-color: #2d3748; }
[data-bs-theme="dark"] .race-clock, [data-bs-theme="dark"] .weather-strip, [data-bs-theme="dark"] .crew-member { background-color: #0f1117; }

/* Шрифты лежат в приложении (Roboto и Roboto Condensed — SIL OFL 1.1, JetBrains Mono — SIL OFL 1.1): страница и печать
   выглядят одинаково без сети. */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono/jetbrains-mono-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/roboto/roboto-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/roboto/roboto-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/roboto/roboto-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Roboto Condensed';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/roboto-condensed/roboto-condensed-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Roboto Condensed';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/roboto-condensed/roboto-condensed-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Roboto Condensed';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/roboto-condensed/roboto-condensed-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Заголовки, шапки таблиц, ярлыки — Roboto Condensed, 600. */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .page-title, .card-title, .subheader, .page-pretitle,
.table thead th, .nav-tabs .nav-link, .navbar .nav-link-title, .badge, .steps .step-item {
    font-family: var(--aps-font-display);
}
h1, h2, h3, h4, .h1, .h2, .h3, .h4, .page-title, .card-title { font-weight: 600; }
.btn { font-weight: 600; }
/* Заголовки колонок — 10 px прописными; подписи полей — 12 px; бейджи — 11 px. */
.table thead th {
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .07em;
}
.form-label, .form-hint, .form-check-label { font-size: .75rem; }
.form-label { font-weight: 500; }
.form-control, .form-select { font-size: .875rem; }
.badge { font-size: .6875rem; font-weight: 600; border-radius: 4px; }
.nav-tabs .nav-link { font-size: .8125rem; font-weight: 500; }
.table .small,
.card-sm .text-secondary {
    font-size: .75rem;
}
/* Блоки отделяются рамкой и фоном; тень — только у того, что лежит поверх страницы. */
.card { box-shadow: none; }
.dropdown-menu { box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }
[data-bs-theme="light"] .dropdown-menu { box-shadow: 0 4px 24px rgba(0, 0, 0, .08); }

/* Числа — моноширинным шрифтом: время и номера стоят разряд под разрядом. */
.result-value, .result-input, .race-clock, .font-monospace, .bib-input {
    font-family: var(--tblr-font-monospace);
    font-variant-numeric: tabular-nums;
}
[data-bs-theme="dark"] .result-value { color: #4ade80; }
[data-bs-theme="light"] .result-value { color: #15803d; }

/* Раскладка по прототипам (kcf_competition_*): страница во всю ширину с полями 1.5rem; заголовок 1.5rem / 800,
   сведения под ним строкой .78rem; вкладки — подчёркиванием, .8rem, счётчик .62rem; кнопки действий .78rem. */
.container-xl { max-width: none; padding-left: 1.5rem; padding-right: 1.5rem; }
@media (max-width: 767.98px) { .container-xl { padding-left: .75rem; padding-right: .75rem; } }
.page-header .col:has(> .page-pretitle), .page-header > .container-xl:has(> .page-pretitle) { display: flex; flex-direction: column; }
.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 2px; }
.page-pretitle { order: 2; text-transform: none; letter-spacing: 0; font-size: .78rem; font-weight: 400; font-family: var(--tblr-font-sans-serif); color: var(--tblr-secondary); }
@media (max-width: 767.98px) { .page-title { font-size: 1.1rem; } }
/* Вкладки — полосой на фоне страницы, без внешней карточки (в прототипе её нет). */
.card:has(> .card-header > .card-header-tabs) { border: 0; background: transparent; box-shadow: none; }
.card:has(> .card-header > .card-header-tabs) > .card-body { padding: 1.25rem 0 0; }
.card-header:has(> .card-header-tabs) { padding: 0 .5rem; border: 1px solid var(--tblr-border-color); border-radius: 8px; background: var(--tblr-bg-surface-secondary); }
.card-header-tabs { margin: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.card-header-tabs .nav-link { padding: .7rem .9rem; font-size: .8rem; font-weight: 500; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--tblr-secondary); white-space: nowrap; }
.card-header-tabs .nav-link .icon { font-size: .95rem; width: auto; height: auto; }
.card-header-tabs .nav-link.active, .card-header-tabs .nav-link.active:hover { color: var(--tblr-body-color); background: transparent; border-bottom-color: var(--tblr-primary); }
.card-header-tabs .nav-link .badge { font-size: .62rem; font-weight: 700; padding: 0 5px; line-height: 1.6; }
.page-header .btn, .card-actions .btn { font-size: .78rem; padding: .3rem .85rem; min-height: 0; }
.footer { font-size: .68rem; }
/* Полоса стадий: девять ячеек, сверху черта — зелёная у пройденных, голубая у текущей. */
.stage-track { display: flex; gap: 1px; background: var(--tblr-border-color); border-radius: 8px; overflow: hidden; }
.stage-cell { flex: 1; min-width: 0; padding: .7rem .8rem; background: var(--tblr-bg-surface); border-top: 3px solid var(--tblr-border-color); }
.stage-cell.done { border-top-color: var(--tblr-green); }
.stage-cell.current { border-top-color: var(--tblr-primary); background: var(--tblr-bg-forms, var(--tblr-bg-surface-secondary)); }
.stage-cell .n { font-size: .6rem; font-weight: 700; letter-spacing: .08em; color: var(--tblr-secondary); }
.stage-cell .t { font-size: .75rem; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-cell.done .t { color: var(--tblr-secondary); }
.stage-cell.current .t { color: var(--tblr-primary); }
@media (max-width: 767.98px) { .stage-track { overflow-x: auto; } .stage-cell { min-width: 110px; } }
/* Полоса показателей и сведения: подпись .65rem прописными, значение 1rem / 700, пояснение .68rem. */
.stats-strip, .info-grid { display: flex; flex-wrap: wrap; gap: 1px; background: var(--tblr-border-color); border-radius: 8px; overflow: hidden; }
.stat-block { flex: 1; min-width: 130px; padding: .7rem 1rem; background: var(--tblr-bg-surface); }
.stat-label, .info-card .k { font-size: .65rem; text-transform: uppercase; letter-spacing: .07em; color: var(--tblr-secondary); margin-bottom: 3px; }
.stat-val { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub, .info-card .s { font-size: .68rem; color: var(--tblr-secondary); }
.info-card { flex: 1; min-width: 180px; padding: .9rem 1rem; background: var(--tblr-bg-surface); }
.info-card .v { font-size: .88rem; font-weight: 600; }

/* Логотипы: высота под шапку Tabler, ширина по рисунку. */
.brand-logo { height: 2.5rem; width: auto; }
.brand-logo-lg { height: 4rem; }
.footer-logo { height: 2.25rem; width: auto; }
/* Логотипы соревнования в шапке документов — размер как в KCF. Логотип системы в подвале печати — мелкий. */
.doc-logos { display: flex; justify-content: center; align-items: center; gap: 40px; }
.doc-logo { height: 60px; width: auto; max-width: 45%; object-fit: contain; }
.print-footer-logo { height: 1.5rem; width: auto; }
.logo-preview { height: 40px; width: auto; max-width: 100%; }
/* Часы и погода в шапке — размеры из прототипа. */
.header-center { margin: 0 auto; gap: .75rem; }
.race-clock, .weather-strip { background: var(--tblr-bg-surface-secondary); border: 1px solid var(--tblr-border-color); border-radius: 8px; font-variant-numeric: tabular-nums; }
.race-clock { display: flex; align-items: center; padding: 0 .75rem; font-size: 1.3rem; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
.weather-strip { display: flex; align-items: stretch; overflow: hidden; }
.weather-divider { width: 1px; background: var(--tblr-border-color); flex-shrink: 0; }
.weather-slot { padding: .2rem .6rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 72px; }
.weather-slot .w-label { font-size: .55rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--tblr-secondary); }
.weather-slot .w-main { display: flex; align-items: center; gap: 3px; font-size: .78rem; font-weight: 700; line-height: 1; }
.weather-slot .w-wind { display: flex; align-items: center; gap: 2px; font-size: .65rem; font-weight: 600; color: var(--tblr-secondary); }
.weather-slot .w-dir { font-size: .6rem; }
.text-pre-line { white-space: pre-line; }
/* Таблица заезда — размеры из прототипов (kcf_race_table, kcf_k4_final): текст .82rem, шапка .68rem, имя .85rem
   (в экипаже .75rem), метки .62rem, Bib .62rem (в экипаже .55rem). */
.race-table { font-size: .82rem; }
.race-table thead th { font-size: .68rem; padding: .6rem .75rem; }
.race-table td { padding: .7rem .75rem; }
.race-table .lane-num { font-size: .9rem; font-weight: 700; color: var(--tblr-secondary); }
.race-table .fw-medium { font-size: .85rem; font-weight: 600; }
.race-table .avatar-sm { --tblr-avatar-size: 32px; font-size: .65rem; flex-shrink: 0; }
.race-table .result-input { font-size: .82rem; font-weight: 700; padding: .3rem .25rem; text-align: center; max-width: none; width: 100%; letter-spacing: 0; }
.race-table .result-value { font-size: .9rem; font-weight: 700; }
.race-table .mark-btn { font-size: .62rem; font-weight: 700; padding: 2px 5px; min-height: 0; line-height: 1.2; border-radius: 4px; letter-spacing: .04em; }
.race-table .btn-list:has(.mark-btn) { gap: 3px; flex-wrap: nowrap; }
.bib-tag { font-size: .62rem; font-weight: 800; letter-spacing: .03em; padding: 1px 6px; }
.athlete-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.athlete-badges .badge, .boat-badges .badge { font-size: .62rem; font-weight: 700; padding: 1px 6px; line-height: 1.5; }
.athlete-badges .badge .ti { font-size: .6rem; }
.athlete-badges .badge-outline { border-color: var(--tblr-border-color); background: var(--tblr-bg-surface-tertiary, transparent); font-weight: 600; }
[data-bs-theme="dark"] .athlete-badges .badge-outline { border-color: #2d3748; background: #1e2535; color: #94a3b8 !important; }
.boat-badges { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.boat-badges:has(.badge) { margin-bottom: .4rem; }
.crew-list { display: flex; flex-direction: row; gap: 5px; flex-wrap: nowrap; }
.crew-member { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 5px 6px; border: 1px solid var(--tblr-border-color); border-radius: 6px; background: var(--tblr-bg-surface-secondary); }
.crew-member-top { display: flex; align-items: flex-start; gap: .35rem; min-width: 0; }
.crew-member-info { flex: 1; min-width: 0; }
.crew-member-name { font-size: .75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crew-member-name .bib-tag { font-size: .55rem; padding: 1px 4px; vertical-align: middle; }
.crew-member-sub { display: flex; align-items: center; gap: 4px; margin-top: 3px; flex-wrap: nowrap; }
.crew-country { font-size: .7rem; font-weight: 700; line-height: 1; }
.crew-details-toggle { font-size: .6rem; color: var(--tblr-secondary); display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px; border-radius: 3px; border: 0; background: transparent; cursor: pointer; }
.crew-details-toggle:hover { color: var(--tblr-body-color); background: var(--tblr-border-color); }
.crew-details-toggle .arrow { font-size: .55rem; transition: transform .2s; display: inline-block; }
.crew-details-toggle[aria-expanded="true"] .arrow { transform: rotate(90deg); }
.crew-details-body { display: none; padding-top: 6px; margin-top: 6px; border-top: 1px solid var(--tblr-border-color); width: 100%; }
.crew-details-body.open { display: block; }
.crew-details-body .athlete-badges { margin-top: 0; }
@media print { .crew-details-body { display: block; } .crew-list { flex-wrap: wrap; } }
.race-time-col { width: 150px; }
/* Аккредитация: узкое поле номера; в печати каждый клуб — с новой страницы. */
.bib-input { width: 4.5rem; }
.accreditation-sheet + .accreditation-sheet { break-before: page; margin-top: 2rem; }

/* Времена и места стоят столбиком: цифры одной ширины. */
.result-input { max-width: 9rem; font-variant-numeric: tabular-nums; }
.result-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Протокол печатается чёрным по белому при любой теме, заезд не рвётся между страницами. */
@media print {
    html, body, .page, .page-wrapper, .card { background: #fff !important; color: #000 !important; }
    .card { border: 0 !important; box-shadow: none !important; }
    .table, .table td, .table th { color: #000 !important; }
    .protocol-race { break-inside: avoid; }
}

/* Финишный таймер на странице дисциплины: кнопка слева и панель, выезжающая сверху. Числа — из KCF
   (Race/class-shortcode.php:163,176-177): кнопка 48 px в 120 px от верха, панель до 500 px с отступом 70 px. */
.finish-timer-toggle { position: fixed; top: 120px; left: 20px; z-index: 1040; width: 48px; height: 48px; transition: transform .2s; }
.finish-timer-toggle.open { transform: rotate(90deg); }
.finish-timer-popup { position: fixed; top: 0; left: 0; right: 0; z-index: 1035; display: flex; justify-content: center; transform: translateY(-110%); transition: transform .35s cubic-bezier(.4, 0, .2, 1); pointer-events: none; }
.finish-timer-popup.open { transform: translateY(0); }
.finish-timer-popup > .card { pointer-events: auto; margin-top: 70px; max-width: 500px; width: 90%; }
.finish-timer-popup #timer-results { max-height: 200px; overflow-y: auto; }
