:root {
    --bg: #edf3ef;
    --fg: #17232b;
    --muted: #65736c;
    --line: #d7ded5;
    --line-strong: #bdc9bf;
    --accent: #2f6f63;
    --accent-hover: #25584f;
    --seal: #b84a38;
    --paper: #fffdf8;
    --paper-soft: #f7f1e6;
    --card: #fffdf8;
    --ok: #e4f2e6;
    --ok-fg: #246b3f;
    --err: #f8e7e2;
    --err-fg: #9e3428;
    --warn: #fbefd5;
    --warn-fg: #7a561c;
    --shadow: 0 18px 45px rgba(23, 35, 43, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--fg);
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(47, 111, 99, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 111, 99, 0.055) 1px, transparent 1px);
    background-size: 42px 42px;
    background-attachment: fixed;
}

.nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
    padding: 12px 24px;
    background: rgba(255, 253, 248, 0.92);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 28px rgba(23, 35, 43, 0.06);
    backdrop-filter: blur(10px);
}
.nav .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    text-decoration: none;
    color: var(--fg);
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    flex: 0 0 auto;
}
.nav a { color: var(--accent); text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav .spacer { flex: 1; }
.user-chip {
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    background: var(--paper-soft);
}
.nav-logout { margin: 0; }
.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
}
.link-button:hover { background: none; text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 24px; }
.container.wide { max-width: 1180px; }

h1 { margin: 0 0 8px; }
h2 { margin: 28px 0 10px; font-size: 1.1rem; }
.lead { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
code { background: var(--paper-soft); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; margin: 18px 0; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 18px;
    min-width: 220px;
    flex: 1;
    box-shadow: 0 10px 24px rgba(23, 35, 43, 0.06);
}
.card-num { font-size: 2rem; font-weight: 700; }
.card-num.date { font-size: 1.7rem; }
.card-label { color: var(--muted); margin-bottom: 6px; }
.card-sub { color: var(--muted); font-size: 0.9rem; }
.metric-cards { margin-top: 28px; }
.metric-card {
    color: var(--fg);
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.metric-card:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    box-shadow: 0 14px 28px rgba(23, 35, 43, 0.08);
    text-decoration: none;
}

.checklist { padding-left: 20px; }
.checklist li { margin: 4px 0; }

.toolbar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}
form.search, form.import {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 20px rgba(23, 35, 43, 0.05);
}
form.import button[type="submit"] { padding: 5px 12px; font-size: 0.85rem; }
.import-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 20px rgba(23, 35, 43, 0.05);
}
.file-label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-flex; }
.rating-progress {
    align-items: center;
    gap: 8px;
    min-height: 34px;
    color: var(--muted);
    white-space: nowrap;
}
.rating-progress progress {
    width: 150px;
    height: 8px;
    accent-color: var(--accent);
}
form.import button[disabled] {
    opacity: 0.65;
    cursor: progress;
}
/* Прогресс/результат фоновой задачи всегда на своей строке в form.import (flex-wrap), а не
   зажат между кнопкой и краем формы — без этого блок то появляется, то пропадает каждую секунду
   опроса, дёргая раскладку формы. */
form.import #import-result,
form.import #portal-reconcile-result {
    flex-basis: 100%;
}
form.import #import-result:empty,
form.import #portal-reconcile-result:empty {
    display: none;
}
form.import #import-result .notice,
form.import #portal-reconcile-result .notice {
    margin-bottom: 0;
    /* Компактнее, чем обычные уведомления в потоке страницы: две таких карточки подряд
     ("Обновить из сети" + "Сверить с порталом") иначе занимают почти весь экран по высоте. */
    padding: 5px 10px;
    font-size: 0.85rem;
}

input[type="search"], input[type="number"], input[type="file"] {
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fffefa;
    color: var(--fg);
}
input[type="search"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
.form input:not([type="checkbox"]):focus,
.form select:focus,
.addgame select:focus,
.participant-filter input:focus,
.participant-filter select:focus {
    outline: 3px solid rgba(47, 111, 99, 0.16);
    border-color: var(--accent);
}
input.num { width: 96px; }
/* Плейсхолдеры "рейтинг от"/"рейтинг до" не помещались в стандартную ширину .num. */
input.rating-input { width: 128px; }
button {
    /* компактно: высота и ширина по содержимому */
    padding: 5px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.25;
    cursor: pointer;
    font-weight: 650;
}
button:hover { background: var(--accent-hover); }
button.secondary {
    background: var(--paper-soft);
    color: var(--fg);
    border: 1px solid var(--line);
}
button.secondary:hover { background: #eee6d8; }
.btn.secondary {
    background: var(--paper-soft);
    color: var(--fg);
    border: 1px solid var(--line);
}
.btn.secondary:hover {
    background: #eee6d8;
}

table.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(23, 35, 43, 0.04);
}
table.grid th, table.grid td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}
table.grid th { background: #eef3ee; font-weight: 700; color: #24342d; }
table.grid th a.sort-link {
    color: inherit;
    text-decoration: none;
}
table.grid th a.sort-link:hover {
    color: var(--accent);
    text-decoration: underline;
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: rgba(47, 111, 99, 0.045); }
table.grid td.r, table.grid th.r { text-align: right; }
td.center { text-align: center; padding: 18px; }
.result-count { margin: 4px 0 10px; }
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
    color: var(--muted);
}

.notice {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--ok);
    color: var(--ok-fg);
    margin-bottom: 12px;
    border: 1px solid rgba(36, 107, 63, 0.16);
}
.notice.error { background: var(--err); color: var(--err-fg); border-color: rgba(158, 52, 40, 0.18); }
button.danger {
    background: var(--err-fg);
}
button.danger:hover {
    background: #7e281f;
}
.danger-zone {
    border-color: rgba(158, 52, 40, 0.22);
}

/* --- Турниры --- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 10px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { margin: 0; }

a.btn, .btn {
    display: inline-block;
    padding: 5px 12px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 650;
}
a.btn:hover { background: var(--accent-hover); }
.btn-link { color: var(--accent); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

.form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.form input:not([type="checkbox"]), .form select {
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; background: #fffefa; color: var(--fg);
}
.form input[type="checkbox"] { width: auto; margin: 0; }
.form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.form .row label { flex: 1; min-width: 120px; }
.form .row label.check-row {
    flex-direction: row;
    align-items: center;
    min-width: 140px;
    color: var(--fg);
}
.form .actions { display: flex; gap: 14px; align-items: center; margin-top: 6px; }

.meta-row { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); margin-bottom: 18px; }
.meta-row span { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.picker-panel h2 { margin: 0 0 10px; font-size: 1.05rem; }
input.full { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: #fffefa; }
.participant-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.participant-filter input,
.participant-filter select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffefa;
    color: var(--fg);
}
.participant-filter input[type="search"] { flex: 1 1 145px; }
.participant-filter input[type="number"] { flex: 0 0 92px; }
.participant-filter select { flex: 1 1 100px; }

.link-danger { background: none; color: var(--err-fg); border: 0; cursor: pointer; font-size: 1rem; padding: 2px 6px; }
.link-danger:hover { background: var(--err); border-radius: 6px; }

.scoreboard { margin: 20px 0 28px; }
/* Турнирная таблица — на всю ширину; панель пар тура ниже, а не сбоку (не сжимает таблицу). */
.score-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}
.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    box-shadow: 0 10px 24px rgba(23, 35, 43, 0.05);
}
.table-scroll table.grid { border: 0; border-radius: 0; }
/* Модификатор: карточка обжимает таблицу по её содержимому (не на всю ширину). */
.table-scroll.fit { width: fit-content; max-width: 100%; }
.standings-grid {
    font-size: 0.88rem;
    /* Без min-width: таблица отображается по содержимому (столбцы можно скрывать кнопкой «Колонки»). */
}
/* Ширина колонок — строго по содержимому (перебивает table.grid { width: 100% }). */
table.standings-grid { width: auto; }
/* Номера туров и результаты — по центру (класс .r у этих ячеек иначе выравнивает вправо). */
table.standings-grid th.round-col,
table.standings-grid td.round-col { text-align: center; }
/* ЗАГЛУШКА (отключено по просьбе): «заморозка» колонок Место+Фамилия при горизонтальной прокрутке.
   Чтобы вернуть — раскомментировать блок ниже, задать table-scroll{overflow-x:auto}, вернуть
   .standings-grid{min-width:1040px} и на table.standings-grid обязательно:
   border-collapse:separate; border-spacing:0; overflow:visible (иначе sticky в Chrome не работает —
   table.grid навязывает collapse и overflow:hidden). Подробности в базе знаний goarbiter-web-version.
.standings-grid th.col-place, .standings-grid td.col-place,
.standings-grid th.col-name, .standings-grid td.col-name { position: sticky; z-index: 2; box-sizing: border-box; }
.standings-grid .col-place { left: 0; width: 56px; min-width: 56px; background: var(--card); }
.standings-grid .col-name { left: 56px; min-width: 160px; background: var(--card); box-shadow: 1px 0 0 var(--line); }
.standings-grid thead th.col-place, .standings-grid thead th.col-name { z-index: 3; background: #eef3ee; }
*/
/* table.standings-grid — специфичность перебивает table.grid td { padding: 8px 12px }. */
table.standings-grid th,
table.standings-grid td {
    padding: 5px 7px;
    white-space: nowrap;
}
.standings-grid .round-col {
    text-align: center;
}
/* «Заморозка» левых колонок (Место + Фамилия) при горизонтальной прокрутке. */
.standings-grid th.col-place,
.standings-grid td.col-place,
.standings-grid th.col-name,
.standings-grid td.col-name {
    position: sticky;
    z-index: 2;
    box-sizing: border-box;
}
.standings-grid .col-place { left: 0; width: 56px; min-width: 56px; background: var(--card); }
.standings-grid .col-name { left: 56px; min-width: 160px; background: var(--card); box-shadow: 1px 0 0 var(--line); }
.standings-grid thead th.col-place,
.standings-grid thead th.col-name { z-index: 3; background: #eef3ee; }
/* Цвета ячейки результата — из общей пастельной палитры (решение заказчика 2026-07-04:
   таблица не должна «кричать» на фоне остального приложения). Различимость результата —
   за счёт цвета текста и жирности, а не насыщенной заливки. */
.result-cell.win { background: var(--ok); color: var(--ok-fg); font-weight: 700; }
.result-cell.loss { background: var(--err); color: var(--err-fg); font-weight: 700; }
.result-cell.draw { background: var(--warn); color: var(--warn-fg); font-weight: 700; }
.result-cell.pending { background: var(--bg); color: var(--muted); }
.result-cell.bye { background: var(--ok); color: var(--ok-fg); font-weight: 700; }
.result-cell.multi { background: var(--err); color: var(--err-fg); font-weight: 700; }
.round-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 24px rgba(23, 35, 43, 0.05);
    /* Ширину панели по таблице пар выставляет JS (syncRoundsWidth) — CSS fit-content
       схлопывается из-за детей (см. заметку у .round-tabs). */
    max-width: 100%;
}
.round-panel h3 { margin: 0; font-size: 1rem; }
.round-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
/* ВАЖНО: без overflow-x:auto — дети с overflow-auto схлопывают fit-content у .round-panel. */
.round-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.round-tabs a {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--fg);
    text-decoration: none;
    background: #fffefa;
}
.round-tabs a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.round-pairs th,
.round-pairs td {
    font-size: 0.86rem;
}
.round-editor {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    box-shadow: 0 8px 20px rgba(23, 35, 43, 0.04);
}
.round-editor > summary {
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 700;
}
.round-editor .round {
    padding: 0 12px 12px;
}
@media (max-width: 980px) {
    .score-layout { grid-template-columns: 1fr; }
}

.print-page { background: #fff; }
.print-sheet { max-width: 980px; }
.print-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    margin: 0 0 18px;
}
.print-toolbar .btn-link:first-child { margin-right: auto; }
.print-head { margin-bottom: 18px; }
.print-head h1 { margin-bottom: 4px; }
.print-head p { margin: 0; color: var(--muted); }
.print-grid th,
.print-grid td {
    font-size: 1rem;
}

/* --- Туры/партии --- */
.head-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.round { margin-bottom: 28px; }
.round h2 { margin: 0 0 8px; }
.addgame {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 8px; padding: 10px; background: var(--card);
    border: 1px solid var(--line); border-radius: 8px;
}
.addgame select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fffefa; }
.addgame input.num { width: 80px; }
.res { margin-right: 8px; }
.res-set { display: inline-flex; gap: 4px; }
.res-set button {
    padding: 2px 8px; font-size: 0.85rem; background: var(--paper-soft); color: var(--fg);
    border: 1px solid var(--line);
}
.res-set button:hover { background: var(--accent); color: #fff; }
td form { display: inline; margin: 0; }
.protocol {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
}
.protocol summary {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 600;
}
.protocol-actions {
    padding: 0 12px 8px;
}
table.compact th, table.compact td {
    padding: 6px 10px;
    font-size: 0.9rem;
}
.protocol-detail {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 7px;
    border-radius: 8px;
    background: var(--paper-soft);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}
.rating-grid .delta-pos { color: var(--ok-fg); font-weight: 700; }
.rating-grid .delta-neg { color: var(--err-fg); font-weight: 700; }

/* --- Администрирование --- */
.admin-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin: 18px 0 26px;
    box-shadow: 0 10px 24px rgba(23, 35, 43, 0.05);
}
.admin-panel h2 { margin-top: 0; }
.admin-create, .inline-actions {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
}
.admin-create label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}
.admin-create input, .admin-create select, .inline-actions input, .inline-actions select {
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffefa;
    color: var(--fg);
}
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.badge.ok { background: var(--ok); color: var(--ok-fg); }
.warn-badge { background: var(--warn); color: var(--warn-fg); }
.muted-badge { background: var(--paper-soft); color: var(--muted); }
.small { font-size: 0.85rem; }

/* --- Вход --- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 16px;
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(184, 74, 56, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(184, 74, 56, 0.045) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(237, 243, 239, 0.86));
    background-size: 48px 48px, 48px 48px, auto;
}
.login-shell {
    width: min(520px, calc(100vw - 32px));
}
.login-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 38px 40px;
    box-shadow: var(--shadow);
}
.login-panel h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 7vw, 2.8rem);
    line-height: 1.05;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 32px;
}
.login-mark {
    width: 74px;
    height: 74px;
    flex: 0 0 auto;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(23, 35, 43, 0.12);
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--seal);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}
.login-version {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

@media (max-width: 520px) {
    .login-panel {
        padding: 30px 24px;
    }
    .login-brand {
        align-items: flex-start;
    }
    .login-mark {
        width: 62px;
        height: 62px;
    }
}

@media print {
    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }
    .nav,
    .no-print {
        display: none !important;
    }
    .container,
    .container.wide,
    .print-sheet {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    table.grid {
        border: 1px solid #000;
        border-radius: 0;
        background: #fff;
    }
    table.grid th,
    table.grid td {
        border: 1px solid #000;
        padding: 5px 7px;
    }
    table.grid th {
        background: #fff;
        color: #000;
    }
    a {
        color: #000;
        text-decoration: none;
    }
}

/* Award categories filter + medals */
/* Кнопки категорий — как кнопка «Жеребьёвка» (форма/размер); активная — зелёная. */
.category-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.category-filter a {
    display: inline-block; padding: 4px 11px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 0.9rem; font-weight: 650; line-height: 1.25; color: var(--fg); background: var(--paper-soft); text-decoration: none;
}
.category-filter a:hover { background: #eee6d8; }
.category-filter a.active { background: var(--accent, #2f6f4f); color: #fff; border-color: transparent; }
.medals-cell { white-space: nowrap; }
.medal { display: inline-block; min-width: 18px; text-align: center; padding: 1px 5px; margin: 0 1px; border-radius: 4px; font-size: 0.72rem; font-weight: 600; color: #fff; }
.medal.gold { background: #d4af37; }
.medal.silver { background: #9aa3ab; }
.medal.bronze { background: #cd7f32; }
.mm-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.status-badge.draft { background: #e7e9e4; color: #5a6156; }
.status-badge.running { background: #dcefe4; color: #1f6b47; }
.status-badge.planned { background: #e4ecf7; color: #2c4a78; }
.status-badge.done { background: #efe3d6; color: #7a4a1a; }

/* Вкладки «Турнирная таблица / Участники» */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 0; }
.tab-btn {
    appearance: none; border: 1px solid transparent; border-bottom: 0; background: transparent;
    padding: 9px 16px; font-size: 0.95rem; font-weight: 600; color: var(--muted); cursor: pointer;
    border-radius: 8px 8px 0 0;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--fg); background: var(--card); border-color: var(--line); margin-bottom: -1px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Скрытые столбцы турнирной таблицы (кнопка «Колонки») */
.col-hidden { display: none !important; }
.col-menu { position: relative; }
.col-menu > summary { list-style: none; cursor: pointer; color: var(--accent); }
.col-menu > summary::-webkit-details-marker { display: none; }
.col-menu > summary::before { content: "▾ "; }
.col-menu-body {
    position: absolute; right: 0; top: 100%; z-index: 20; margin-top: 6px; min-width: 180px;
    background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
    box-shadow: 0 12px 28px rgba(23, 35, 43, 0.12); display: grid; gap: 4px;
}
.col-menu-body p { margin: 0 0 4px; font-size: 0.8rem; }
.col-menu-body label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; white-space: nowrap; }

/* Пары тура: таблица без своей рамки (карточка — сама панель), подсветка ячейки победителя */
.round-panel .round-pairs { border: 0; box-shadow: none; }
.winner-cell { background: var(--ok); color: var(--ok-fg); font-weight: 700; }
/* Правка результата по клику на ячейке тура (турнирная таблица): клик переключает по кругу */
.result-cell.editable { cursor: pointer; }
.result-cell.editable.busy { opacity: 0.5; }

/* Окно жеребьёвки (диалог, как окно в десктопе) */
#draw-dialog {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 24px 60px rgba(23, 35, 43, 0.25);
    max-width: min(94vw, 960px);
    max-height: 90vh;
}
#draw-dialog::backdrop { background: rgba(23, 35, 43, 0.35); }
.round-panel.in-dialog { border: 0; box-shadow: none; max-width: none; margin: 0; }
/* Формы внутри ячеек/шапок — без блочных отступов */
.inline-form { display: inline; margin: 0; }
.inline-form select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fffefa; font-size: 0.85rem; }
/* Ручное добавление пары/бая под таблицей пар */
.add-pair-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.add-pair-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
/* Таблицы вкладок «Участники»/«Туры»: без переносов и ширина колонок по содержимому. */
.nowrap-grid th, .nowrap-grid td { white-space: nowrap; }
table.nowrap-grid { width: auto; }
.tab-panel > .picker-panel { margin-bottom: 18px; }

/* Тулбар прямо над турнирной таблицей: фильтр категорий слева, «Колонки» справа. */
.standings-wrap { width: fit-content; max-width: 100%; }
.table-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0; }
.table-toolbar .print-menu { margin-left: auto; } /* «Печать» и «Колонки» — справа */
.table-toolbar .category-filter { margin: 0; }
