:root {
    --bg: #0e1319;
    --panel: #161d26;
    --panel-2: #1d2733;
    --line: #2b3846;
    --text: #e6edf3;
    --muted: #8b9bad;
    --red: #e5534b;
    --blue: #4b8ff0;
    --accent: #4b8ff0;
    --accent-soft: rgba(75, 143, 240, .16);
    --green: #46b17b;
    --yellow: #d9a441;
    --inset: #0c1116;
    --print: #fff;
}

/* Светлая тема: переключается атрибутом data-theme на <html>. */
[data-theme="light"] {
    --bg: #cbd0d6;
    --panel: #dddfe2;
    --panel-2: #d1d4da;
    --line: #b2bac4;
    --text: #151d26;
    --muted: #4a5664;
    --red: #a32b25;
    --blue: #235a9f;
    --accent: #235a9f;
    --accent-soft: rgba(35, 90, 159, .16);
    --green: #15633c;
    --yellow: #74500f;
    --inset: #c7cbd2;
}

[data-theme="light"] .alert { background: #fdecea; border-color: var(--red); color: #7a1c17; }
[data-theme="light"] .alert.ok { background: #e3f1e8; border-color: var(--green); color: #145c36; }
[data-theme="light"] .alert.warn { background: #fff4cc; border-color: var(--yellow); color: #6b4c00; }
[data-theme="light"] .alert code { background: rgba(0, 0, 0, .08); }
[data-theme="light"] kbd { background: rgba(0, 0, 0, .08); }
[data-theme="light"] button.primary { color: #fff; }

/* Тема «Самбо» — светлая сине-красная палитра RegSambo.ru. */
[data-theme="sambo"] {
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-2: #eef5ff;
    --line: #dbe4ee;
    --text: #1a1a2e;
    --muted: #6c757d;
    --red: #d32f2f;
    --blue: #1565c0;
    --accent: #1565c0;
    --accent-soft: rgba(21, 101, 192, .12);
    --green: #2e7d32;
    --yellow: #b26a00;
    --inset: #f7fafd;
}
[data-theme="sambo"] .top { border-top-color: #d32f2f; border-bottom-color: transparent; box-shadow: none; }
[data-theme="sambo"] .top::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #d32f2f 0 50%, #1565c0 50% 100%);
    pointer-events: none;
}
[data-theme="sambo"] .top h1 { color: #d32f2f; }
[data-theme="sambo"] button.primary { background: #d32f2f; border-color: #d32f2f; color: #fff; }
[data-theme="sambo"] button.primary:hover:not(:disabled) { background: #b71c1c; border-color: #b71c1c; }
[data-theme="sambo"] .tabs button.active { background: #ffebee; border-color: #d32f2f; color: #d32f2f; }
[data-theme="sambo"] .list li.active { border-color: #d32f2f; background: #ffebee; }
[data-theme="sambo"] .card, [data-theme="sambo"] .sidebar { box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }

/* Тема «Дзюдо» — светлая синяя палитра RegJudo.ru. */
[data-theme="judo"] {
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-2: #eef7ff;
    --line: #dbe7f5;
    --text: #1a1a2e;
    --muted: #6c757d;
    --red: #dc3545;
    --blue: #0d6efd;
    --accent: #0d6efd;
    --accent-soft: rgba(13, 110, 253, .12);
    --green: #198754;
    --yellow: #b8860b;
    --inset: #f7fbff;
}
[data-theme="judo"] .top { border-top-color: #0d6efd; box-shadow: inset 0 -2px 0 #00bcd4; }
[data-theme="judo"] button.primary { background: #0d6efd; border-color: #0d6efd; color: #fff; }
[data-theme="judo"] button.primary:hover:not(:disabled) { background: #0b5ed7; border-color: #0b5ed7; }
[data-theme="judo"] .tabs button.active { background: #e3f2fd; border-color: #0d6efd; color: #0d6efd; }
[data-theme="judo"] .card, [data-theme="judo"] .sidebar { box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }

[data-theme="sambo"] .alert,
[data-theme="judo"] .alert { background: #fdecea; border-color: var(--red); color: #7a1c17; }
[data-theme="sambo"] .alert.ok,
[data-theme="judo"] .alert.ok { background: #e8f5e9; border-color: var(--green); color: #14532d; }
[data-theme="sambo"] .alert.warn,
[data-theme="judo"] .alert.warn { background: #fff8e1; border-color: var(--yellow); color: #6b4c00; }
[data-theme="sambo"] .alert code,
[data-theme="judo"] .alert code { background: rgba(0, 0, 0, .06); }
[data-theme="sambo"] kbd,
[data-theme="judo"] kbd { background: rgba(0, 0, 0, .08); }

/* Переключатель темы в шапке. */
.theme-toggle { white-space: nowrap; }

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Segoe UI", Roboto, system-ui, sans-serif;
}

input, select, textarea, button {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 9px;
}

textarea { width: 100%; resize: vertical; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--green); border-color: var(--green); color: #07130b; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--red); border-color: var(--red); }
button.danger:hover:not(:disabled) { background: rgba(229, 83, 75, .12); border-color: var(--red); }
button:hover:not(:disabled) { border-color: var(--muted); }

/* Системная тема: нейтральные цвета ОС и «системные» (нативные) кнопки. */
[data-theme="system"] {
    --bg: #f0f0f0;
    --panel: #ffffff;
    --panel-2: #ffffff;
    --line: #c9c9c9;
    --text: #1a1a1a;
    --muted: #666666;
    --red: #c62828;
    --blue: #0a63c9;
    --accent: #0a63c9;
    --accent-soft: rgba(10, 99, 201, .14);
    --green: #1f7a45;
    --yellow: #9a6b00;
    --inset: #ededed;
}
[data-theme="system"] input,
[data-theme="system"] select,
[data-theme="system"] textarea {
    background: #ffffff;
    border: 1px solid #b6b6b6;
    border-radius: 4px;
    color: #1a1a1a;
}
[data-theme="system"] button {
    background: linear-gradient(#ffffff, #f0f0f0);
    border: 1px solid #b6b6b6;
    border-radius: 5px;
    color: #1a1a1a;
    font-weight: 500;
}
[data-theme="system"] button:hover:not(:disabled) {
    background: linear-gradient(#ffffff, #e8e8e8);
    border-color: #9c9c9c;
}
[data-theme="system"] button:active:not(:disabled) { background: #e4e4e4; }
[data-theme="system"] button.ghost {
    background: linear-gradient(#ffffff, #f0f0f0);
    border-color: #b6b6b6;
}
[data-theme="system"] button.primary {
    background: linear-gradient(#2a6fc9, #205fae);
    border-color: #1d57a1;
    color: #ffffff;
    font-weight: 600;
}
[data-theme="system"] button.primary:hover:not(:disabled) {
    background: linear-gradient(#2f76cf, #2362b0);
    border-color: #1d57a1;
}
[data-theme="system"] button.danger { color: #c62828; border-color: #c62828; background: #ffffff; }
[data-theme="system"] button.danger:hover:not(:disabled) { background: rgba(198, 40, 40, .1); }
[data-theme="system"] button.del,
[data-theme="system"] button.modal-close,
[data-theme="system"] button#theme-toggle,
[data-theme="system"] button#sidebar-toggle {
    background: transparent;
    border-color: transparent;
}
[data-theme="system"] button.del:hover,
[data-theme="system"] button.modal-close:hover { background: rgba(0, 0, 0, .08); }
[data-theme="system"] kbd { background: rgba(0, 0, 0, .08); }

/* Яркость темы: ползунок в шапке (у каждой темы своё значение). */
.top, .layout, .modal-overlay, .presence-panel, #alert {
    filter: brightness(var(--brightness, 1));
}
.theme-box { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.brightness { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.brightness-icon { font-size: 12px; }
.brightness input[type="range"] { width: 120px; padding: 0; }

kbd {
    font: 11px Consolas, monospace;
    background: rgba(0, 0, 0, .25);
    border-radius: 3px;
    padding: 1px 4px;
    font-weight: 400;
}

/* ------------------------------------------------------------------ шапка */

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-left, .top-right { display: flex; align-items: center; gap: 10px; }
.top-emblem { height: 34px; width: auto; flex: 0 0 auto; display: block; }
.top-emblem-link {
    display: inline-flex; align-items: center; flex: 0 0 auto;
    line-height: 0; border-radius: 50%;
    transition: opacity .15s ease, transform .15s ease;
}
.top-emblem-link:hover { opacity: .85; transform: scale(1.04); }
.top-emblem-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.top h1 { margin: 0; font-size: 18px; letter-spacing: .01em; color: var(--accent); }
.top-title { font-weight: 600; white-space: pre-line; }
.top-right { flex-wrap: wrap; }

.badge {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel-2);
    white-space: nowrap;
}

.alert {
    margin: 12px 20px 0;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--red);
    background: #47212a;
    color: #ffd9d6;
    font-size: 13px;
}

.alert.ok { background: #16341f; border-color: var(--green); color: #cfeedd; }
.alert.warn { background: #3c3318; border-color: var(--yellow); color: #f4e6c4; }
.alert code { background: rgba(0, 0, 0, .3); padding: 1px 4px; border-radius: 3px; }

/* Всплывающие уведомления справа сверху. */
.toast-stack {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    width: min(380px, calc(100vw - 28px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 34px 10px 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--text);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .3);
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    transform: translateX(18px);
    transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--yellow); }
.toast.error { border-left-color: var(--red); }
.toast-title { font-weight: 700; margin-bottom: 2px; padding-right: 4px; }
.toast-text { white-space: pre-line; overflow-wrap: anywhere; }
.toast-action { margin-top: 8px; padding: 4px 8px; font-size: 12px; font-weight: 600; }
.toast-close {
    position: absolute;
    top: 4px;
    right: 6px;
    padding: 1px 6px;
    line-height: 1;
    font-size: 16px;
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}
.toast-close:hover { color: var(--text); border-color: var(--line); }
[data-theme="light"] .toast,
[data-theme="sambo"] .toast,
[data-theme="judo"] .toast { box-shadow: 0 12px 28px rgba(0, 0, 0, .14); }
@media print { .toast-stack { display: none !important; } }

/* Мини-панель остатка встреч по коврам. */
.mats-panel {
    position: fixed;
    right: 16px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    z-index: 900;
    width: 196px;
    max-width: calc(100vw - 32px);
    padding: 8px 10px 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
    font-size: 12px;
    cursor: move;
    user-select: none;
}
.mats-panel[hidden] { display: none; }
.mats-panel-title {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mats-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.mats-name {
    flex: 0 0 46px;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mats-track {
    flex: 1 1 auto;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--inset);
}
.mats-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--blue);
    transition: width .25s ease;
}
.mats-fill.high { background: var(--green); }
.mats-fill.mid { background: var(--yellow); }
.mats-fill.low,
.mats-fill.blink { background: var(--red); }
.mats-row.blink {
    margin: 1px -4px;
    padding: 3px 4px;
    border-radius: 6px;
    animation: mats-blink 1s steps(2, end) infinite;
}
.mats-row.blink .mats-track { background: rgba(229, 83, 75, .35); }
.mats-row.blink .mats-count { color: var(--red); font-weight: 700; }
@keyframes mats-blink {
    50% { background: rgba(229, 83, 75, .45); }
}
.mats-count {
    flex: 0 0 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.mats-row-summary {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
}
.mats-row-summary + .mats-row-summary {
    margin-top: 2px;
    padding-top: 0;
    border-top: 0;
}
.mats-row-summary .mats-name {
    color: var(--text);
    font-weight: 700;
}
.mats-row-summary .mats-count { flex: 0 0 auto; }
.mats-summary-gap { flex: 1 1 auto; }
[data-theme="light"] .mats-panel,
[data-theme="sambo"] .mats-panel,
[data-theme="judo"] .mats-panel { box-shadow: 0 10px 24px rgba(0, 0, 0, .12); }
@media (max-width: 640px) { .mats-panel { display: none; } }
@media print { .mats-panel { display: none !important; } }

/* ------------------------------------------------------------------ сетка */

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    padding: 16px 20px 48px;
    align-items: start;
    transition: grid-template-columns .22s ease, gap .22s ease;
}

.sidebar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    position: sticky;
    top: 74px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: transform .22s ease, opacity .22s ease;
}

/* Кнопка «задвинуть/выдвинуть» боковую панель (в шапке). */
.sidebar-toggle { font-size: 16px; line-height: 1; padding: 6px 10px; }

/* Свёрнутая панель: колонка в 0, содержимое уезжает вбок, основная часть во всю ширину. */
body.sidebar-collapsed .layout { grid-template-columns: 0 minmax(0, 1fr); gap: 0; }
body.sidebar-collapsed .sidebar {
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
    border-width: 0;
    opacity: 0;
    transform: translateX(-14px);
    pointer-events: none;
}

.sidebar-foot { margin: 12px 0 0; font-size: 11px; color: var(--muted); }
.cat-search { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------- встраивание (только просмотр) */

.embed-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}
.embed-tools-label { font-size: 12px; color: var(--muted); }

.embed-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--panel-2);
}
.embed-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.embed-row-title { font-weight: 600; }
.embed-row-tag {
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 1px 8px;
}
.embed-row-featured {
    border-color: var(--accent);
    background: var(--accent-soft, var(--panel-2));
}
.embed-row-featured .embed-row-title { color: var(--accent); }
.embed-code-text {
    width: 100%;
    box-sizing: border-box;
    font: 12px Consolas, monospace;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    resize: vertical;
}
.embed-row-btns { display: flex; gap: 8px; margin-top: 8px; }
.embed-flow-opts {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 14px;
    margin-bottom: 8px;
}
.embed-flow-opts .field > span { white-space: nowrap; }
.embed-modal-body { padding: 0 16px 16px; }

body.embed .layout.embed-layout { grid-template-columns: minmax(0, 1fr); padding: 16px 20px 48px; }
body.embed .sidebar, body.embed .tabs { display: none !important; }
/* Публичный просмотр (nav=1): показываем панель вкладок как в пульте. */
body.embed.embed-nav .tabs { display: flex !important; }
body.embed .embed-internal { display: none !important; }
/* В режиме просмотра прячем все средства редактирования зрительских вкладок. */
body.embed .tab-panel form,
body.embed .tab-panel select,
body.embed .tab-panel button:not(.embed-allow) { display: none !important; }
/* Исключение: выбор возраста/веса на вкладке «Сетка» доступен и при просмотре. */
body.embed .tab-panel .bracket-picker select { display: inline-block !important; }
/* Пустые служебные панели (например, тулбар PDF) в просмотре не нужны. */
body.embed .tab-panel .card.noprint:not(.bracket-picker):not(.pdf-toolbar) { display: none !important; }
body.embed .flow-controls { display: none !important; }

body.embed-capture { background: #fff !important; }
body.embed-capture .top,
body.embed-capture .layout,
body.embed-capture .tabs,
body.embed-capture .alert,
body.embed-capture .noprint { display: none !important; }
body.embed-capture #bracketPrintArea { display: block !important; position: static !important; }
body.embed-capture #bracketPrintArea .card {
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
}
body.embed-capture #bracketPrintArea .matrix-card { background: #fff !important; overflow: visible !important; }
body.embed-capture #bracketPrintArea .matrix-card .hint,
body.embed-capture #bracketPrintArea .matrix-card .protocol-sub { color: #333 !important; }
body.embed-capture #bracketPrintArea .print-cat { page-break-after: auto; break-after: auto; }
body.embed-capture .op-bar {
    writing-mode: horizontal-tb !important;
    transform: none !important;
}
body.embed-capture .op-bar .op-bar-text {
    position: absolute;
    left: 50%;
    top: 50%;
    display: inline-block;
    white-space: nowrap;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
}
body.embed-bare .embed-top,
body.embed-bare .alert { display: none !important; }
body.embed-bare .layout.embed-layout { min-height: 100vh; padding: 0; }
body.embed-bare .main { padding: 0; }

.connection-bar {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

.connection-bar[hidden] { display: none !important; }

.connection-bar.offline { border-color: var(--red); }
.connection-bar.pending { border-color: var(--yellow); }
.connection-bar.syncing { border-color: var(--blue); }
.connection-bar.ok { border-color: var(--green); }

.connection-bar-text { line-height: 1.3; max-width: 720px; white-space: pre-line; }

.connection-bar-sync {
    flex: none;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.connection-bar-sync:hover:not(:disabled) { border-color: var(--accent); }

.connection-bar-sync:disabled { opacity: .5; cursor: default; }

/* Плашка статуса видна постоянно — оставляем место внизу, чтобы не перекрывать контент. */
body.has-connection-bar .layout { padding-bottom: 108px; }

@media (max-width: 640px) {
    .connection-bar {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        flex-direction: column;
        align-items: stretch;
    }
    .connection-bar-sync { width: 100%; }
    .connection-bar-text { max-width: none; }
    body.has-connection-bar .layout { padding-bottom: 160px; }
}

@media print {
    .connection-bar { display: none !important; }
}

.main { min-width: 0; }

.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tabs button {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    padding: 7px 12px;
}

.tabs button.active { background: var(--panel-2); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tabs button.tab-sub { font-size: 12px; padding: 4px 10px; margin-left: 12px; color: var(--muted); border-left: 2px solid var(--line); }
.tabs button.tab-sub::before { content: '↳ '; opacity: .7; }
.tabs button.tab-sub:hover { color: var(--accent); }

.tabs-dropdown { position: relative; display: flex; }
.tabs-dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; }
.tabs-caret { font-size: 11px; opacity: .7; transition: transform .15s; }
.tabs-dropdown.open .tabs-caret { transform: rotate(180deg); }
.tabs-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 220px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}
.tabs-dropdown-menu[hidden] { display: none; }
.tabs-dropdown-menu button.tab-sub {
    width: 100%;
    margin-left: 0;
    padding: 8px 10px;
    border-left: 0;
    border-radius: 6px;
    text-align: left;
    font-size: 13px;
}
.tabs-dropdown-menu button.tab-sub:hover { background: var(--panel-2); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

.hint { margin: -2px 0 12px; color: var(--muted); font-size: 12px; }
.hint.empty { padding: 18px 0; text-align: center; margin: 0; }
.hint.inline { margin: 0; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.pen-preview { font-size: 13px; color: var(--text); padding: 6px 0; }
.pen-preview.muted { color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }

/* --------------------------------------------------------------- список */

.list { list-style: none; margin: 12px 0 0; padding: 0; }

.list li {
    display: flex;
    align-items: stretch;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 4px;
}

.list li.active { border-color: var(--green); background: var(--panel-2); }
.list li.muted { color: var(--muted); font-size: 12px; padding: 6px 2px; }
.cat-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 4px 2px 2px;
    border-top: 1px solid var(--line);
    cursor: pointer;
    user-select: none;
}
.cat-group:hover { color: var(--text); }
.cat-toggle { width: 10px; }
.cat-title { flex: 1; }
.cat-count { font-size: 10px; color: var(--muted); }

button.pick {
    flex: 1;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 8px 10px;
    border-radius: 6px;
}

button.pick .meta { display: block; font-size: 11px; color: var(--muted); }

button.del { border: 0; background: transparent; color: var(--muted); font-size: 18px; padding: 0 8px; }
button.del:hover { color: var(--red); }

/* ----------------------------------------------------------------- табло */

.mats { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.mats:empty { display: none; }

.mat { margin-bottom: 0; }
.mat.decision { border-color: var(--yellow); }

.mat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.mat-label { font-weight: 600; }
.mat-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tablo-btn { font-size: 11px; padding: 2px 8px; white-space: nowrap; }
.bracket-picker { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.bracket-picker select { min-width: 180px; }
.kovyor-item { margin: 4px 0; }
.kovyor-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kovyor-name { min-width: 90px; font-weight: 600; }
.kovyor-count { width: 70px; }
.kovyor-access {
    margin: 4px 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}
.kovyor-access h3 { margin: 0 0 6px; font-size: 14px; }
.kovyor-access .acc-form { margin-bottom: 8px; }
.pult-users { margin-top: 8px; }
.pult-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
}
.pult-login { min-width: 110px; font-weight: 600; }
.pult-scope { font-size: 12px; color: var(--muted); }
.acc-scopes { display: flex; flex-wrap: wrap; gap: 16px; width: 100%; }
.acc-scope { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.pult-pass {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--inset);
    color: var(--text);
    font-family: Consolas, monospace;
}
.pult-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.kovyor-played {
    list-style: none;
    margin: 4px 0 4px 100px;
    padding: 0;
}
.kovyor-played li { margin: 2px 0; }
.kovyor-played-item { font-size: 12px; padding: 2px 8px; }

.athletes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

.athlete {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 4px solid var(--line);
    background: var(--inset);
}

.athlete.red { border-left-color: var(--red); }
.athlete.blue { border-left-color: var(--blue); }
.athlete.in-red { box-shadow: inset 0 0 0 1px var(--red); }
.athlete.in-blue { box-shadow: inset 0 0 0 1px var(--blue); }
.athlete .form { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.athlete .name { font-weight: 600; }
.athlete .score-badge { font-size: 12px; color: var(--yellow); }

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.controls input, .controls select, .field select, .field input { width: 100%; }
.field.inline select, .field.inline input { width: auto; }

.tech { margin-bottom: 10px; }
.tech summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.tech-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.tech-col { display: flex; flex-direction: column; gap: 6px; }
.tech-title { font-size: 12px; }

.actions { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.withdraw-card { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- таблицы */

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; }
tr.out td { opacity: .55; }
tr.qualified td { background: rgba(70, 177, 123, .1); }

.pen { color: var(--yellow); font-weight: 700; }

/* --------------------------------------------- таблица кругов (подгруппы) */

.sidebar-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}
.sidebar details { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.sidebar details > summary { cursor: pointer; font-size: 12px; color: var(--muted); }

.matrix-card {
    overflow-x: auto;
    background: #e6e9ec;
    color: #000;
    font-family: "Times New Roman", "PT Serif", Georgia, serif;
}
.matrix-card .protocol-title { color: #000; font-weight: 700; font-size: 17px; }
.matrix-card .protocol-sub { font-size: 16px; }
.matrix-card .protocol-sub,
.matrix-card .hint { color: #333; }
.matrix-card .protocol-signs { color: #000; }
.protocol-title, .protocol-event { text-align: center; white-space: pre-line; }
.protocol-sub { text-align: center; margin: -6px 0 8px; color: var(--muted); font-size: 12px; white-space: pre-line; }
.protocol-signs {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 24px;
    font-size: 13px;
    white-space: nowrap;
}

/* Протокол соревнований (список участников с местами) */
.protocol-event { text-align: center; font-size: 14px; font-weight: 700; margin: 0 0 2px; }
.protocol-roster { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.protocol-roster th,
.protocol-roster td {
    border: 1px solid #333;
    padding: 3px 6px;
    text-align: left;
    vertical-align: top;
}
.protocol-roster th { background: #cfe2f3; text-align: center; font-weight: 700; }
.protocol-roster td.num { text-align: center; width: 40px; }

/* Официальный «ИТОГОВЫЙ ПРОТОКОЛ» (вкладка «Протокол») — как бланк РФС. */
.official-protocol { font-family: "Times New Roman", Times, serif; color: #000; background: #fff; }
.official-protocol .op-head { position: relative; display: flex; align-items: center; justify-content: center; gap: 28px; min-height: 62px; margin-bottom: 6px; }
.official-protocol .op-emblem { display: block; height: 62px; width: auto; }
body.pdf-mode .official-protocol .op-emblem { display: block; }
@media print {
    .official-protocol .op-emblem { display: block; }
}
.official-protocol .op-head .op-emblem:first-child { position: absolute; left: 0; top: 50%; transform: translateY(-50%); }
.official-protocol .op-head .op-emblem:last-child { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.card.printable { position: relative; }
.pdf-emblem-left {
    display: none;
    position: absolute;
    top: 6px;
    left: 8px;
    width: 56px;
    height: 56px;
    object-fit: contain;
    pointer-events: none;
    z-index: 3;
}
body.pdf-mode .pdf-emblem-left { display: block; }
@media print {
    .pdf-emblem-left { display: block; }
}
.official-protocol .op-fed { font-weight: 700; font-size: 20px; letter-spacing: 1px; text-transform: uppercase; text-align: center; color: #d40000; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; padding: 0 72px; }
.official-protocol .op-headtable { width: 100%; border-collapse: collapse; }
.official-protocol .op-headtable td { border: 1.5px solid #000; padding: 3px 8px; vertical-align: middle; }
.official-protocol .op-titlecell { width: 34%; text-align: center; }
.official-protocol .op-title { font-size: 20px; font-weight: 800; letter-spacing: .5px; line-height: 1.05; }
.official-protocol .op-gender { font-size: 15px; font-weight: 700; text-decoration: none; letter-spacing: .2px; margin-top: 3px; }
.official-protocol .op-eventcell { font-size: 15px; font-weight: 700; text-align: center; white-space: pre-line; }
.official-protocol .op-venuecell { font-size: 13px; font-weight: 700; white-space: pre-line; }
.official-protocol .op-weightcell { font-size: 13px; font-weight: 700; text-align: right; white-space: nowrap; }
.official-protocol .op-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; margin-top: -1.5px; }
.official-protocol .op-table th,
.official-protocol .op-table td { border: 1.5px solid #000; padding: 3px 6px; vertical-align: top; white-space: normal; word-wrap: break-word; word-break: break-word; }
.official-protocol .op-table th { text-align: center; font-weight: 700; background: #fff; color: #000; text-transform: none; letter-spacing: normal; font-size: 13px; }
.official-protocol .op-table td.op-place, .official-protocol .op-table th.op-place { text-align: center; font-weight: 700; font-size: 14px; }
.official-protocol .op-table td.op-lot, .official-protocol .op-table th.op-lot { text-align: center; }
.official-protocol .op-table td.op-okrug { text-align: center; }
.official-protocol .op-table col.op-col-place { width: 7%; }
.official-protocol .op-table col.op-col-lot { width: 7%; }
.official-protocol .op-table col.op-col-name { width: 27%; }
.official-protocol .op-table col.op-col-date { width: 15%; }
.official-protocol .op-table col.op-col-okrug { width: 8%; }
.official-protocol .op-table col.op-col-subject { width: 22%; }
.official-protocol .op-table col.op-col-coach { width: 14%; }
.official-protocol .op-table td.op-place-1 { background: #f6d6d6; }
.official-protocol .op-table td.op-place-2 { background: #d6e4f6; }
.official-protocol .op-table td.op-place-3 { background: #c6e0b4; }
.official-protocol .op-table td.op-place-other { background: #fff2cc; }
.official-protocol .op-signs { margin-top: var(--protocol-sign-gap, 20mm); }
.official-protocol .op-signs .op-sign:first-child { margin-top: 0; }
.official-protocol .op-sign { display: flex; align-items: baseline; gap: 16px; font-weight: 700; font-size: 13px; margin-top: 6px; }
.official-protocol .op-sign-label { flex: 0 0 250px; }
.official-protocol .op-sign-name { flex: 1 1 auto; text-align: center; }
.official-protocol .op-sign-region { flex: 0 0 auto; }
.protocol-roster tr.roster-band td {
    background: #cfe2f3;
    font-weight: 700;
    text-align: left;
    font-size: 13px;
}
@media print {
    .protocol-roster th,
    .protocol-roster td { border: 1px solid #000 !important; }
    .protocol-roster th,
    .protocol-roster tr.roster-band td {
        background: #cfe2f3 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #000;
    background: #fff;
    border: 1px solid #333;
    font-weight: 600;
}
.download-btn:hover:not(:disabled) { border-color: #000; background: #f4f6f8; }
.download-btn svg { display: block; }

.matrix-table { font-size: 13px; background: #fff; }
.matrix-table th, .matrix-table td {
    padding: 3px 5px;
    white-space: nowrap;
    border: 1px solid #333;
    background: #fff;
    color: #000;
}
.matrix-table th { font-weight: 700; text-align: center; vertical-align: middle; }
.matrix-table th.caption { padding: 4px 8px; }
.matrix-table th.wrap { white-space: normal; }
.matrix-table th.vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
    padding: 4px 2px;
}
.matrix-table .rounds-head { text-align: center; letter-spacing: .08em; }
.matrix-table .round-num { font-weight: 700; }
.matrix-table td.name { white-space: normal; min-width: 120px; font-weight: 400; }
.matrix-table td.name .name-main { display: block; line-height: 1.15; }
.matrix-table td.name .name-patronymic { display: block; line-height: 1.15; color: #444; }
.matrix-table td.personal { white-space: normal; min-width: 64px; }
.matrix-table td.personal .pers-birth { display: block; line-height: 1.15; }
.matrix-table td.personal .pers-rank { display: block; line-height: 1.15; color: #444; }
.matrix-table td.personal:empty { min-width: 0; }
.matrix-table td.subject { white-space: normal; }
.matrix-table td.subject { min-width: 110px; }
.roster-table td.name .name-main { display: block; line-height: 1.15; }
.roster-table td.name .name-patronymic { display: block; line-height: 1.15; color: var(--muted); }
.roster-table td.personal .pers-birth { display: block; line-height: 1.15; }
.roster-table td.personal .pers-rank { display: block; line-height: 1.15; color: var(--muted); }
.matrix-table tr.subgroup-start td { border-top: 3px solid #000; }
.matrix-table td.rcell-cell { text-align: center; vertical-align: middle; min-width: 54px; height: 38px; padding: 0; }
.matrix-table td.rcell-cell.cross {
    background-image:
        linear-gradient(to top right, transparent calc(50% - 1px), #999 calc(50% - 1px), #999 calc(50% + 1px), transparent calc(50% + 1px)),
        linear-gradient(to bottom right, transparent calc(50% - 1px), #999 calc(50% - 1px), #999 calc(50% + 1px), transparent calc(50% + 1px));
}
.matrix-table .rcell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    min-height: 36px;
    height: 100%;
}
.matrix-table .rcell .ropp {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #333;
    font-size: 17px;
    font-weight: 400;
    line-height: 1;
}
.matrix-table .rcell .rpen {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #333;
}
.matrix-table .rcell .rtime {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}
.matrix-table .rpen { color: #000; font-size: 12px; }
.matrix-table .rpen.muted { color: #666; }
.matrix-table .rtime { color: #000; font-size: 10px; }
.matrix-table .rcell.lose .ropp { color: #666; }
.matrix-table .rcell.pending .ropp { color: #666; }
.matrix-table .rcell.disq .ropp { color: #b3241f; font-weight: 700; }
.matrix-table .rcell .ropp.rcell-click {
    cursor: pointer;
    color: #0a4;
    font-weight: 700;
    text-decoration: underline dotted;
}
.matrix-table .rcell .ropp.rcell-click:hover { background: rgba(0, 170, 68, .14); }
.matrix-table td.rcell-result { box-shadow: inset 0 0 0 2px rgba(0, 170, 68, .35); }
.matrix-table td.rcell-cell.editing { box-shadow: inset 0 0 0 2px var(--green); }
.matrix-table td.rcell-cell { position: relative; }
.rcell-editor {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    min-width: 150px;
    background: #fff;
    z-index: 5;
}
.rcell-edit-field { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.rcell-edit-label { flex: 1; white-space: nowrap; color: #333; }
.rcell-edit-input {
    width: 62px;
    padding: 2px 4px;
    border: 1px solid #888;
    border-radius: 4px;
    font-size: 12px;
}
.rcell-edit-actions { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.rcell-edit-ok, .rcell-edit-cancel, .rcell-edit-clear {
    flex: 1;
    padding: 3px 6px;
    border: 1px solid #888;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}
.rcell-edit-ok { background: var(--green); color: #fff; border-color: var(--green); }
.rcell-edit-cancel { background: #eee; }
.rcell-edit-clear {
    flex-basis: 100%;
    background: #fdecea;
    color: #b3261e;
    border-color: #e6a19b;
}
.rcell-edit-clear:hover { background: #f9d6d2; }
/* Полуфиналисты в подгруппах: 1-е место — нежно-красный, 2-е — нежно-синий.
   Правила наведения идут ниже, чтобы подсветка соперника перекрывала фон. */
.matrix-table tr.rank1 td { background: #f6d6d6; }
.matrix-table tr.rank2 td { background: #d6e4f6; }
.matrix-table tr.hl-row td { background: #fff4cc; }
.matrix-table tr.rank1.hl-row td { background: #f3c9c9; }
.matrix-table tr.rank2.hl-row td { background: #c7dbf2; }
.matrix-table tr.hl-row td.name { font-weight: 700; }
.matrix-table tr.out td { color: #000; opacity: 1; }


/* ------------------------------------------------------------------ сетка */

.draw-groups { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; align-items: flex-start; }
.draw-reserves {
    margin-top: 12px;
    border: 1px dashed var(--yellow);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--panel-2);
}
.draw-reserves-title { margin: 0 0 6px; font-size: 13px; color: var(--yellow); }
.draw-reserves-list { margin: 0; padding-left: 18px; font-size: 14px; }
.draw-reserves-list li { margin: 2px 0; }
.draw-reserves-list li[draggable="true"] { cursor: grab; }
.draw-reserves-list li.dragging { opacity: .5; }
.draw-reserves-empty { list-style: none; margin-left: -18px; color: var(--muted); }
.draw-pool {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 10px;
    background: var(--panel-2);
}
.draw-pool.over { border-color: var(--green); }
.draw-pool-head { margin-bottom: 6px; }
.draw-pool-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.draw-pool-list { display: flex; flex-wrap: wrap; gap: 6px; }
.draw-pool-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 8px;
    background: var(--panel);
    cursor: grab;
}
.draw-pool-item.dragging { opacity: .4; }
.draw-pool-item .draw-name { font-size: 13px; }
.draw-pool-item .draw-team { font-size: 11px; }
.draw-pool-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.draw-pool-th {
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.draw-pool-th:hover { color: var(--text); }
.draw-pool-arrow { font-size: 10px; }
.draw-pool-cell { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.draw-pool-name { font-family: "Arial Black", "Arial Bold", Arial, sans-serif; font-weight: 400; }
.draw-pool-row.prio-strongest > td { background: rgba(229, 83, 75, .18); }
.draw-pool-row.prio-strong > td { background: rgba(217, 164, 65, .22); }
.draw-pool-row { cursor: grab; }
.draw-pool-row.dragging { opacity: .4; }
.draw-pool-empty { padding: 8px; color: var(--muted); font-style: italic; }
.draw-col {
    flex: 1 1 300px;
    min-width: 280px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: var(--panel);
}
.draw-col-title {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.draw-slots { display: flex; flex-direction: column; gap: 6px; }
.draw-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
}
.draw-slot.draggable { cursor: grab; }
.draw-slot.dragging { opacity: .5; }
.draw-slot.over { border-color: var(--green); }
.draw-slot.bye { opacity: .6; font-style: italic; border-style: dashed; }
.draw-slot.prio-warn { border-color: var(--yellow); background: rgba(217, 164, 65, .12); }
.draw-slot.team-warn { border-color: var(--red); background: rgba(229, 83, 75, .12); }
.draw-slot.region-warn { border-color: var(--blue); background: rgba(75, 143, 240, .14); }
.draw-pos { min-width: 22px; color: var(--muted); text-align: right; }
.draw-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.draw-name { flex: 1; font-family: "Arial Black", "Arial Bold", Arial, sans-serif; font-weight: 400; }
.draw-team { font-size: 11px; }
.draw-warn { margin: 0 0 8px; color: var(--red); font-size: 12px; }
.draw-predraw { margin-bottom: 10px; padding: 8px 10px; border: 1px solid var(--red); border-radius: 6px; background: rgba(229, 83, 75, .08); }
.draw-predraw-title { font-weight: 700; color: var(--red); font-size: 13px; margin-bottom: 4px; }
.draw-star.strongest { color: var(--red); }
.draw-star.strong { color: var(--yellow); }
.draw-prio { padding: 3px 5px; }
.draw-prio-label { color: var(--muted); font-size: 12px; }
.draw-num { padding: 3px 5px; }
.draw-pool-num { white-space: nowrap; }
.draw-seednum { font-size: 10px; font-weight: 700; color: var(--yellow); margin-left: 4px; }


/* ------------------------------------------- жеребьёвка в стиле mixa.ru */

.mx-draw-quads {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
    align-items: start;
}
.mx-draw-quads.mx-draw-two { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
.mx-draw-quad {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: var(--panel);
}
.mx-draw-quad-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    gap: 8px;
}
.mx-draw-quad-name {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.mx-draw-quad-count { font-size: 11px; color: var(--muted); white-space: nowrap; }
.qwarn-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.qwarn {
    font-size: 11px;
    color: var(--red);
    background: rgba(229, 83, 75, .12);
    border: 1px solid rgba(229, 83, 75, .35);
    border-radius: 6px;
    padding: 2px 6px;
}
.mx-pairs { display: flex; flex-direction: column; gap: 8px; }
.mx-pair { border: 1px dashed var(--line); border-radius: 8px; padding: 6px; }
.mx-pair-title { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.mx-slots { display: flex; flex-direction: column; gap: 6px; }
.mx-draw-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 13px;
}
.mx-draw-slot.bye { opacity: .6; font-style: italic; }
.mx-draw-slot.draggable { cursor: grab; }
.mx-draw-slot.dragging { opacity: .5; }
.mx-draw-slot.over { border-color: var(--green); }
.mx-draw-slot.team-warn { border-color: var(--red); background: rgba(229, 83, 75, .12); }
.mx-draw-slot.prio-warn { border-color: var(--yellow); background: rgba(217, 164, 65, .12); }
.mx-draw-slot.region-warn { border-color: var(--blue); background: rgba(75, 143, 240, .14); }
.mx-draw-slot .draw-body { flex: 1; }
@media (max-width: 1100px) {
    .mx-draw-quads { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

.bracket { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; }

.bracket-col { display: flex; flex-direction: column; gap: 10px; min-width: 210px; }

.bracket-round {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.bbout {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 200px;
}

.bbout-title { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.bbout-line { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: baseline; font-size: 13px; padding: 2px 0; }
.bbout-line.win { background: rgba(70, 177, 123, .12); border-radius: 4px; font-weight: 600; }
.bbout-line.lose { opacity: .55; }
.bform { font-size: 10px; color: var(--muted); }
.bname { overflow: hidden; text-overflow: ellipsis; font-family: "Arial Black", "Arial Bold", Arial, sans-serif; font-weight: 400; }
.bscore { font-variant-numeric: tabular-nums; color: var(--muted); }
.bbout-foot { margin-top: 6px; font-size: 11px; color: var(--muted); }
.bbout-foot.muted { font-style: italic; }

/* ------------------------------------------- сетка в стиле mixa.ru */

.mx-tree { position: relative; overflow-x: auto; overflow-y: hidden; }
.mx-tree .op-circle { z-index: 4; color: #1b2430; background: #fff; border-color: #8a8a8a; }
.mx-rounds { position: relative; height: 20px; }
.mx-round-title {
    position: absolute;
    top: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    text-align: center;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--line);
}
.mx-lines { position: absolute; left: 0; top: 22px; pointer-events: none; }
.mx-line { fill: none; stroke: var(--line); stroke-width: 2; }
.mx-card {
    position: absolute;
    width: 240px;
    box-sizing: border-box;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 8px 6px;
    font-size: 13px;
}
.mx-card.clickable { cursor: pointer; }
.mx-card.clickable:hover { border-color: var(--green); }
.mx-card.done { border-color: rgba(70, 177, 123, .45); }
.mx-label {
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mx-row {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 6px;
    align-items: baseline;
    padding: 2px 4px;
    border-radius: 4px;
}
.mx-row.win { background: rgba(70, 177, 123, .16); font-weight: 600; }
.mx-row.lose { opacity: .5; }
.mx-lot { font-size: 11px; color: var(--muted); text-align: right; }
.mx-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Arial Black", "Arial Bold", Arial, sans-serif; font-weight: 400; }
.mx-score { font-variant-numeric: tabular-nums; color: var(--muted); }
.mx-foot { font-size: 11px; color: var(--muted); font-style: italic; padding: 2px 4px 0; }

.mx-ct { border-collapse: collapse; font-size: 12px; }
.mx-ct th,
.mx-ct td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.mx-ct-head,
.mx-ct-row {
    background: var(--panel-2);
    font-size: 11px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mx-ct-corner { background: var(--panel-2); }
.mx-ct-cell { font-variant-numeric: tabular-nums; min-width: 44px; }
.mx-ct-link { cursor: pointer; }
.mx-ct-link:hover { background: var(--panel-2); }
.mx-ct-diag { color: var(--muted); }
.mx-ct-win { background: rgba(70, 177, 123, .18); font-weight: 600; }
.mx-ct-lose { color: var(--muted); }
.mx-ct-cell.muted { font-size: 10px; color: var(--muted); }
.mx-ct-head.mx-ct-stat { background: var(--panel-2); }
.mx-ct-cell.mx-ct-stat { min-width: 40px; font-variant-numeric: tabular-nums; }

.mx-sched-round { margin-bottom: 8px; }
.mx-sched-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: 3px;
}
.mx-sched-line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}
.mx-sched-line.clickable { cursor: pointer; }
.mx-sched-line.clickable:hover { background: var(--panel-2); }
.mx-sched-score { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- журнал */

.notes-list { margin: 0; padding-left: 20px; font-size: 13px; }
.notes-list li { margin-bottom: 6px; }

.card .ev { color: var(--yellow); font-size: 12px; font-weight: 600; margin-right: 8px; }
.card .data { color: var(--muted); font: 12px Consolas, monospace; }

/* --------------------------------------------------------- модальное окно */

.bbout.clickable { cursor: pointer; }
.bbout.clickable:hover { border-color: var(--green); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow: auto;
    z-index: 1000;
}
.modal-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    padding: 16px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close { font-size: 18px; line-height: 1; padding: 2px 8px; }

/* Бэкапы соревнования: выбор файла на хостинге. */
.event-restore-panel { max-width: 640px; }
.backup-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
    max-height: 50vh;
    overflow: auto;
}
.backup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}
.backup-info { min-width: 0; }
.backup-title { font-weight: 600; overflow-wrap: anywhere; }
.backup-row .hint { margin: 2px 0 0; }
.backup-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Выбор соревнования при входе в вид спорта. */
.event-chooser-panel { max-width: 620px; }
.event-chooser-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0 4px;
    max-height: 55vh;
    overflow: auto;
}
.event-chooser-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: inherit;
    cursor: pointer;
}
.event-chooser-item:hover { border-color: var(--green); }
.event-chooser-name { font-weight: 600; }
.event-chooser-meta { font-size: 12px; color: var(--muted); }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.event-name-text {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    padding: 10px;
    min-height: 96px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.event-name-panel .row { margin-top: 12px; justify-content: flex-end; }
.modal-mat { border: 0; padding: 0; background: transparent; }

/* Ручная правка места в подгруппе (круговая/смешанная). */
.place-edit {
    font: inherit;
    min-width: 28px;
    padding: 1px 6px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.place-edit:hover { border-color: var(--green); color: var(--green); }
.place-edit.manual { border-style: solid; border-color: var(--green); font-weight: 700; }

/* Ручное редактирование итоговых мест на вкладке «Протокол». */
.manual-places-panel { max-width: 860px; }
.manual-places-scroll { max-height: 60vh; overflow: auto; }
.manual-places-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manual-places-table th,
.manual-places-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.manual-places-table th { text-align: left; }
.manual-places-table th.num,
.manual-places-table td.num { text-align: center; width: 64px; }
.manual-place-input {
    width: 64px;
    padding: 3px 6px;
    font: inherit;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: inherit;
}
.manual-place-input.manual { border-color: var(--green); font-weight: 700; }
.manual-place-input:disabled { opacity: .55; }
.extra-bout {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0;
}
.extra-bout button { font-size: 12px; padding: 2px 8px; }
.extra-bout .extra-del:hover { color: var(--red); border-color: var(--red); }

/* --------------------------------------- область печати крупных сеток */
#bracketPrintArea {
    display: none;
    font-family: "Times New Roman", Times, serif;
    color: #000;
    background: #fff;
}
/* Печать по всему соревнованию: каждая категория — на отдельной странице. */
.print-cat { page-break-after: always; break-after: page; }
.print-cat:last-child { page-break-after: auto; break-after: auto; }
#bracketPrintArea .mat-order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: "Times New Roman", Times, serif;
}
#bracketPrintArea .mat-order-table th,
#bracketPrintArea .mat-order-table td {
    border: 1px solid #000;
    padding: 3px 6px;
    text-align: left;
}
#bracketPrintArea .mat-order-table th { font-weight: 700; }
#bracketPrintArea .mat-order-table .mat-team { font-size: 10px; line-height: 1.15; color: #333; }
#bracketPrintArea .mat-order-table th.num,
#bracketPrintArea .mat-order-table td.num { text-align: center; width: 36px; }
.pc-wrap { position: relative; padding: 4px; }
.pc-title { text-align: center; font-size: 15px; font-weight: 800; margin-bottom: 8px; }
.pc-subtitle { text-align: center; font-size: 12px; font-weight: 700; margin: 4px 0 8px; }
.pc-sep { border-top: 2px solid #e5e7eb; margin: 14px 0 8px; }
.pc-card {
    border: 1px solid #999;
    background: #fff;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}
.pc-row {
    display: flex;
    align-items: baseline;
    gap: 2px;
    padding: 1px 3px;
    font-size: 10px;
    line-height: 1.25;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
.pc-card .pc-row + .pc-row { border-top: 1px solid #555; }
.op:not(.mp) .pc-card .pc-row { height: 20px; box-sizing: border-box; padding-right: 8px; }
.op:not(.mp) .pc-name { display: flex; align-items: baseline; gap: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.op:not(.mp) .pc-surname { flex: 0 0 auto; white-space: nowrap; }
.op:not(.mp) .pc-given { flex: 0 1 auto; min-width: 1.2ch; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.op:not(.mp) .pc-team { flex: 0 100 auto; min-width: 6ch; max-width: none; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.op:not(.mp) .pc-row.bye { color: #000; opacity: 1; }
.op:not(.mp) .pc-row.bye .pc-name { font-size: 16px; font-weight: 400; }
.pc-row.win { background: #e3f1e8; font-weight: 700; }
.pc-row.lose { opacity: 1; }
.pc-row.bye { background: transparent; }
.pc-lot { min-width: 14px; text-align: right; color: #555; font-size: 8px; }
.op .pc-name { font-size: 16px; }
.op .pc-team { font-size: 14px; }
.pc-name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.2px;
}
.pc-team { font-size: 8px; color: #444; letter-spacing: 0; }
.pc-score { flex: 0 0 auto; margin-left: auto; color: #555; font-size: 8px; font-variant-numeric: tabular-nums; }
.pc-final-label {
    text-align: center;
    font-size: 9px;
    color: #444;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 3px;
}

/* --------------------------------- печатная форма олимпийского протокола */

.op { padding: 2px; }
.op-head {
    position: relative;
    text-align: center;
    min-height: 48px;
    margin-bottom: 8px;
    border: 1.5px solid #333;
    border-radius: 12px;
    padding: 7px 12px 5px;
}
.op-head-center { padding: 0 190px; }
.op-title { font-size: 24px; font-weight: 800; line-height: 1.2; white-space: pre-line; }
.op-dates { font-size: 20px; margin-top: 2px; white-space: pre-line; }
.op-venue { font-size: 20px; margin-top: 2px; white-space: pre-line; }
.op-cat {
    position: absolute;
    right: -2px;
    top: -2px;
    border: 1.5px solid #333;
    border-radius: 10px;
    padding: 5px 12px;
    text-align: center;
    background: #fff;
    min-width: 170px;
}
.op-cat b { display: block; font-size: 22px; }
.op-cat span { display: block; font-size: 13px; color: #555; }
/* Шапка сетки: название на всю ширину, рамка возраста/веса ниже справа. */
.op-head.op-head-bracket {
    display: block;
    min-height: 0;
    padding: 6px 12px 5px;
    margin-bottom: 8px;
}
.op-head.op-head-bracket .op-head-center { padding: 0 68px; }
.op-head.op-head-bracket .op-title { overflow-wrap: break-word; }
.op-head.op-head-bracket .op-cat {
    top: calc(100% - 7px);
    right: 24px;
    left: auto;
    bottom: auto;
    z-index: 2;
    margin: 0;
}
.op-body { position: relative; display: flex; align-items: flex-start; gap: 12px; }
.op-left { min-width: 0; position: relative; }
.op-right { flex: 0 0 160px; width: 160px; }
.op-tree { overflow: hidden; }
.op-bar {
    position: absolute;
    width: 16px;
    box-sizing: border-box;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    background: #eef1f0;
    border: 1px solid #888;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.op-num {
    position: absolute;
    width: 24px;
    height: 20px;
    line-height: 18px;
    box-sizing: border-box;
    border: 1px solid #000;
    background: #fff;
    text-align: center;
    font-size: 16px;
    color: #000;
    font-weight: 700;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.op-num-first { background: #f9d5e5; color: #000; border-color: #e7a8c3; }
.op-num-second { background: #cfe8f7; color: #000; border-color: #9ec9e2; }
.op-circle {
    position: absolute;
    z-index: 3;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: 0.5px solid #555;
    border-radius: 50%;
    background: #fff;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 700;
}
.op-consol-title { font-size: 12px; font-weight: 800; margin: 8px 0 4px; }
.pc-wrap.mp .op-consol-title { font-size: 19px; }
.pc-wrap.mp .pc-row { font-size: 15px; }
.pc-wrap.mp .pc-lot { font-size: 15px; }
.pc-wrap.mp .op .pc-name { font-size: 24px; }
.pc-wrap.mp .op .pc-team { font-size: 22px; }
.pc-wrap.mp .pc-score { font-size: 15px; }
.pc-wrap.mp .pc-foot { font-size: 15px; }
.pc-wrap.mp .pc-final-label { font-size: 16px; }
.pc-wrap.mp .op-circle { width: 22px; height: 22px; font-size: 14px; margin-top: -3px; }
.op-consol { position: relative; margin-top: 32px; }
.op-bar-consol { background: #f3f0ea; }
.op-results-abs { position: absolute; width: 160px; z-index: 2; }
.op-results {
    border: 1.5px solid #333;
    border-radius: 10px;
    padding: 6px 8px;
    background: #fff;
}
.op-results-title { font-weight: 800; text-align: center; font-size: 12px; margin-bottom: 4px; }
.op-res-row { display: flex; gap: 4px; font-size: 10px; line-height: 1.35; }
.op .op-res-row { font-size: 11px; }
.op-res-place { font-weight: 700; min-width: 14px; }
.op-res-name { flex: 1 1 auto; }
.op-version { font-size: 9px; margin-top: 6px; }

/* Смешанная система: таблицы групп и пары */
.mp-table-title { font-size: 17px; font-weight: 800; margin: 8px 0 4px; }
.mp-table { width: 100%; border-collapse: collapse; font-size: 17px; margin-bottom: 10px; }
.mp-table th, .mp-table td {
    border: 1px solid #333;
    padding: 1px 4px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.mp-table th { background: #eee; font-weight: 700; }
.mp-table td.mp-name { text-align: left; white-space: nowrap; }
.mp-table td.mp-diag {
    background: #d9d9d9;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}
.mp-pairs { width: 100%; border-collapse: collapse; font-size: 16px; margin-bottom: 10px; }
.mp-pairs th, .mp-pairs td {
    border: 1px solid #333;
    padding: 1px 3px;
    font-variant-numeric: tabular-nums;
}
.mp-pairs th { background: #eee; font-weight: 700; text-align: center; }
.mp-pairs .mp-round-title { text-align: left; font-weight: 700; background: #f4f4f4; }
.mp-pairs .mp-pair { text-align: left; white-space: nowrap; }

/* ------------------------------------------- управление турниром (ковры) */
.mg-bar-head { display: flex; align-items: center; gap: 10px; }
.mg-bar-head h2 { margin: 0; }
.mg-bar-toggle { margin-left: auto; padding: 3px 10px; font-size: 12px; }
.mg-bar-body { margin-top: 10px; }
.mg-bar.mg-bar-collapsed { padding: 6px 10px; margin-bottom: 10px; }
.mg-bar.mg-bar-collapsed .mg-bar-head h2 { font-size: 15px; }
.mg-bar.mg-bar-collapsed .mg-bar-body { display: none; }
.acc-head { display: flex; align-items: center; gap: 10px; }
.acc-head h2 { margin: 0; flex: 0 0 auto; }
.acc-head-event { flex: 1 1 auto; min-width: 0; white-space: pre-line; color: var(--muted, #8b9bad); font-size: 13px; }
.acc-card.acc-collapsed { padding: 6px 10px; }
.acc-card.acc-collapsed > *:not(.acc-head):not(.acc-table-wrap):not(.acc-scroll-top):not(.acc-log) { display: none !important; }
.acc-card.acc-collapsed .acc-head h2 { font-size: 15px; }
.mg-count { width: 70px; }
.mg-widget-toggle { cursor: pointer; white-space: nowrap; user-select: none; }
.mg-widget-toggle input { width: auto; }
.mg-target { min-width: 140px; }
.mg-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.mg-card {
    position: relative;
    flex: 0 0 auto;
    width: 460px;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #111;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}
.mg-card.mg-sized .mg-matches {
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
}
.mg-resize { position: absolute; z-index: 6; }
.mg-resize-e { top: 42px; right: 0; bottom: 8px; width: 6px; cursor: ew-resize; }
.mg-resize-w { top: 42px; left: 0; bottom: 8px; width: 6px; cursor: ew-resize; }
.mg-resize-n { top: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
.mg-resize-s { bottom: 0; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.mg-resize-ne { top: 0; right: 0; width: 10px; height: 10px; cursor: nesw-resize; }
.mg-resize-nw { top: 0; left: 0; width: 10px; height: 10px; cursor: nwse-resize; }
.mg-resize-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.mg-resize-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.mg-resize:hover { background: rgba(2, 132, 199, .3); }
.mg-card.mg-over { border-color: #46b17b; box-shadow: 0 0 0 2px rgba(70, 177, 123, .25); }
.mg-header {
    background: #eef3fc;
    color: #111;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.mg-header .mg-name { margin-right: auto; }
.mg-header .field > span { color: #555; }
.mg-header button {
    color: #111;
    border-color: #8aa0b5;
}
.mg-header button:hover:not(:disabled) { border-color: #111; }
.mg-show-done-label {
    font-weight: 400;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.mg-hide-label {
    font-weight: 400;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.mg-matches {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 560px;
    overflow-y: auto;
    background: #e9edf1;
    border-top: 1px solid #8f98a1;
}
.mg-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #b7bec6;
    color: #fff;
    border: 0;
    border-bottom: 1px solid #cfd6dd;
    border-radius: 0;
    padding: 4px 8px;
    min-height: 30px;
    cursor: grab;
}
.mg-item:hover { filter: brightness(1.05); }
.mg-item.selected { outline: 2px solid #f0c000; outline-offset: -2px; }
.mg-item.dragging { opacity: .4; }
.mg-item.completed,
.mg-item.mg-green { background: #2f9b3f; opacity: 1; }
.mg-item button {
    color: #111;
    background: #eef3f8;
    border-color: #7c8a99;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.2;
}
.mg-item button:hover:not(:disabled) { background: #fff; border-color: #111; }
.mg-info { flex: 1; min-width: 0; }
.mg-item .mg-num {
    flex: 0 0 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 400;
    color: inherit;
    white-space: nowrap;
}
.mg-item .mg-name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
}
.mg-item .mg-status {
    flex: 0 0 auto;
    font-size: 11px;
    color: inherit;
    font-style: italic;
    opacity: .9;
    white-space: nowrap;
}
.mg-actions { flex: 0 0 auto; display: flex; gap: 4px; }
.mg-empty { color: #555; font-style: italic; padding: 14px; text-align: center; }
.mg-free-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.mg-free-head h3 { margin: 0; }
.mg-free-move { display: flex; align-items: center; gap: 6px; }
.mg-free .mg-item { color: #fff; }

/* ------------------------------------------- ход встреч (ковры + табло) */
.flow-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 16px;
    margin-bottom: 12px;
}
.flow-controls .field > span { white-space: nowrap; }
.flow-wrap { display: flex; flex-direction: column; gap: 12px; }
.flow-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 12px;
    align-items: start;
}
.flow-queue {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 0;
}
.flow-mat-title { font-weight: 800; margin-bottom: 6px; color: var(--text); }
.flow-empty { color: var(--muted); font-style: italic; }
.flow-bout {
    display: grid;
    grid-template-columns: 44px minmax(100px, 180px) minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
}
.flow-bout.done { opacity: .45; }
.flow-bno { color: var(--muted); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-num {
    background: #4a5560;
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    border-radius: 3px;
    padding: 3px 0;
}
.flow-cat { color: var(--yellow); font-weight: 700; font-size: 16px; white-space: normal; overflow-wrap: anywhere; }
.flow-player { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.flow-white { color: var(--text); font-weight: 700; font-size: 20px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-red { color: var(--red); font-weight: 700; font-size: 20px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-blue { color: var(--blue); font-weight: 700; font-size: 20px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-team { color: var(--muted); font-size: 16px; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; }
.flow-judges { color: var(--green); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-item .mg-judges {
    flex: 0 1 auto;
    max-width: 42%;
    font-size: 12px;
    color: inherit;
    margin: 0;
    opacity: .95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
button.mg-assign { padding: 3px 8px; font-size: 12px; font-weight: 700; }
.mg-final-label { white-space: nowrap; }
button.mg-final-assign { white-space: nowrap; font-weight: 600; }
.final-judge-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.final-judge-mat { font-weight: 700; margin-bottom: 4px; }
.final-judge-item { display: block; font-size: 13px; padding: 2px 0; cursor: pointer; }
.jud-modal-body { display: flex; flex-direction: column; gap: 10px; min-width: 360px; }
.jud-modal-body .field { display: flex; flex-direction: column; gap: 4px; }
.jud-modal-body select { width: 100%; }
.acc-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 14px;
    margin-bottom: 12px;
}
.acc-form .field { margin: 0; }
.acc-form .field input,
.acc-form .field select { width: 100%; }
.acc-form .field .req { color: var(--red); font-weight: 700; }
.jud-fatigue { min-width: 96px; }
.jud-bar { height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; margin-bottom: 3px; }
.jud-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #d9a441); border-radius: 5px; }
.jud-frac { font-size: 12px; color: var(--muted); }
.mg-judges-menu { position: relative; display: inline-block; }
.mg-judges-summary {
    list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 6px;
    padding: 6px 12px; user-select: none; font-weight: 600;
}
.mg-judges-summary::-webkit-details-marker { display: none; }
.mg-judges-summary::after { content: ' \25be'; font-size: 10px; }
.mg-judges-menu[open] .mg-judges-summary { border-color: #0284c7; }
.mg-judges-actions {
    position: absolute; z-index: 30; margin-top: 4px; min-width: 260px;
    display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 8px 22px rgba(0, 0, 0, .20); overflow: hidden;
}
.mg-judges-action { text-align: left; border: 0; border-radius: 0; padding: 9px 12px; background: transparent; }
.mg-judges-action:hover { background: var(--panel-2); }
.flow-board-only { grid-template-columns: minmax(0, 1fr); }
.flow-board-only .flow-board-col { max-width: 760px; margin: 0 auto; width: 100%; }
.embed-board-only .embed-top { display: none; }

/* Встраивание «только табло» — на весь экран, как табло зрителя. */
.embed-board-only { height: 100%; overflow: hidden; background: #000; }
.embed-board-only .layout.embed-layout { display: block; height: 100vh; margin: 0; padding: 0; }
.embed-board-only .main { height: 100vh; padding: 0; }
.embed-board-only .flow-wrap-board { height: 100vh; gap: 0; }
.embed-board-only .flow-board-only { height: 100vh; }
.embed-board-only .flow-board-only .flow-board-col { max-width: none; width: 100%; height: 100vh; margin: 0; }
.embed-board-only .flow-board { height: 100vh; width: 100%; align-self: stretch; border: 0; border-radius: 0; }
.embed-board-only .fb-red { order: 1; height: 35vh; padding: 0 2.5vw; }
.embed-board-only .fb-mid { order: 2; height: 30vh; padding: 0 2.5vw; grid-template-rows: 6vh auto; align-content: center; }
.embed-board-only .fb-blue { order: 3; height: 35vh; padding: 0 2.5vw; }
.embed-board-only .fb-info { min-width: 0; }
.embed-board-only .fb-name { font-size: 7vh; line-height: 1.02; max-width: 62vw; }
.embed-board-only .fb-team { font-size: 4vh; line-height: 1.05; }
.embed-board-only .fb-score { font-size: 20vh; line-height: 1; min-width: 18vw; text-align: right; }
.embed-board-only .fb-time { font-size: 22vh; line-height: 1; }
.embed-board-only .fb-cat { font-size: 5vh; }
.embed-board-only .fb-teamscore { font-size: 5vh; }
.embed-board-only .fb-bno { font-size: 4vh; }
.embed-board-only .fb-card { width: 4.5vh; height: 6.5vh; border-width: 2px; }
.embed-board-only .fb-warns { gap: 0; }
.embed-board-only .fb-hold { font-size: 5vh; }
.embed-board-only .fb-mid-center { gap: 2vw; }
.flow-board-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.flow-board-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.flow-board-tools button { font-size: 12px; padding: 4px 8px; }
.flow-board { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; align-self: start; width: 340px; height: 250px; }
.fb-red { background: #b3241f; color: #fff; padding: 8px 10px; height: 90px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fb-blue { background: #17398f; color: #fff; padding: 8px 10px; height: 90px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fb-mid {
    background: #000;
    color: #e0a010;
    padding: 6px 10px;
    height: 70px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: 24px 1fr;
    align-items: center;
    gap: 0 8px;
}
.fb-info { display: flex; align-items: center; gap: 6px; min-width: 0; }
.fb-names { display: flex; flex-direction: column; min-width: 0; }
.fb-name { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-team { display: block; font-size: 11px; opacity: .85; white-space: normal; overflow-wrap: anywhere; }
.fb-warns { display: inline-flex; gap: 2px; flex: 0 0 auto; }
.fb-card { display: inline-block; width: 8px; height: 12px; background: #ffe000; border: 1px solid #b9a800; border-radius: 2px; }
.fb-card.red { background: #e00000; border-color: #8a0000; }
.fb-score { font-size: 30px; font-weight: 800; }
.fb-time { grid-column: 3; grid-row: 2; justify-self: end; text-align: right; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fb-cat { grid-column: 1; grid-row: 2; justify-self: start; font-size: 12px; }
.fb-teamscore { font-size: 14px; font-weight: 800; color: #ffd700; white-space: nowrap; }
.fb-mid-center { grid-column: 2; grid-row: 2; justify-self: center; display: flex; align-items: center; gap: 8px; }
.fb-bno { font-size: 12px; color: #8b9bad; }
.fb-hold { grid-row: 1; font-size: 15px; line-height: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-hold.red { grid-column: 1; justify-self: start; color: #f18a8a; }
.fb-hold.blue { grid-column: 3; justify-self: end; color: #6fb0ee; }
.fb-empty { padding: 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ печать */

    @media print {
    body { background: #fff; color: #000; }
    .top, .sidebar, .tabs, .alert, .mats, .withdraw-card, .noprint { display: none !important; }
    .layout { display: block; padding: 0; }
    .card { border: 0; padding: 0; }
    .printable { display: block !important; }
    .matrix-card { overflow: visible; background: #fff; color: #000; }
    .matrix-card .protocol-title, .matrix-card .protocol-sub, .matrix-card .hint,
    .matrix-card .protocol-signs { color: #000; }
    .matrix-table { font-size: 12px; }
    .matrix-table, .matrix-table th, .matrix-table td {
        background: #fff !important;
        color: #000;
    }
    .matrix-table th, .matrix-table td { border: 1px solid #000; }
    /* Как в Excel: полуфиналисты — светло-красный/светло-синий, выбывшие — чёрные. */
    .matrix-table tr.rank1 td {
        background: #f6d6d6 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    .matrix-table tr.rank2 td {
        background: #d6e4f6 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    .matrix-table tr.out td { opacity: 1 !important; color: #000 !important; }
    .protocol-signs { margin-top: var(--protocol-sign-gap, 20mm); }
    th, td { border-bottom: 1px solid #999; white-space: normal; }
    .hint { color: #444; }

    /* Сохранение сетки в PDF: печатаем только активную вкладку, сетку —
       целиком (без прокрутки) и с масштабом по ширине листа A4). */
    body.pdf-mode .tab-panel { display: none !important; }
    body.pdf-mode .tab-panel:not([hidden]) {
        display: block !important;
        zoom: var(--pdf-scale, 1);
    }
    body.pdf-mode .top, body.pdf-mode .sidebar, body.pdf-mode .tabs,
    body.pdf-mode .alert, body.pdf-mode .noprint { display: none !important; }
    body.pdf-mode .card {
        border: 0 !important;
        padding: 0 !important;
        margin: 0 0 10px !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    body.pdf-mode .mx-tree { overflow: visible !important; }
    body.pdf-mode .bracket { overflow: visible !important; flex-wrap: nowrap !important; }
    body.pdf-mode .mx-card {
        border: 1px solid #999 !important;
        background: #fff !important;
        color: #000 !important;
    }
    body.pdf-mode .mx-card .mx-name,
    body.pdf-mode .mx-label,
    body.pdf-mode .mx-lot,
    body.pdf-mode .mx-score { color: #000 !important; }
    body.pdf-mode .mx-line { stroke: #888 !important; }
    body.pdf-mode .mx-ct th, body.pdf-mode .mx-ct td,
    body.pdf-mode .places-table th, body.pdf-mode .places-table td { border: 1px solid #000 !important; }

    /* Крупная сетка (65+): печатаем область A/Б/финал вместо интерфейса. */
    body.print-large .layout { display: none !important; }
    body.print-large #bracketPrintArea { display: block !important; }

    @page { size: A4 landscape; margin: 10mm; }
}

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; max-height: none; overflow: visible; }
    body.sidebar-collapsed .layout { grid-template-columns: 1fr; }
    body.sidebar-collapsed .sidebar { display: none; }
}

/* ------------------------------------------------ комиссия по допуску */
.acc-table-wrap { overflow: auto; max-height: 72vh; margin-top: 4px; }
.acc-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    margin-top: 10px;
}
.acc-scroll-top-inner { height: 1px; }
.acc-table {
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}
.acc-table th, .acc-table td {
    border: 1px solid var(--line);
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
}
.acc-table th {
    background: var(--panel-2);
    position: sticky;
    top: 0;
    z-index: 3;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--muted);
}
.acc-th { cursor: pointer; user-select: none; }
.acc-th:hover { color: var(--text); }
.acc-th.sorted { color: var(--text); }
.acc-sort { margin-left: 4px; color: var(--green); }
.acc-filters th { top: 24px; z-index: 2; padding: 2px 4px; }
.acc-column-filter {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: 2px 4px;
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
}
.acc-line { line-height: 1.25; }
/* В составной колонке (ФИО) первые строки обычные, последняя (отчество) — приглушённая. */
.acc-line:last-child:not(:first-child) { color: var(--muted); }
.acc-cell { cursor: pointer; min-width: 40px; }
.acc-cell:hover { background: rgba(217, 164, 65, .12); }
.acc-cell.editing { padding: 2px; white-space: normal; }
.acc-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    border: 1px solid var(--green);
    border-radius: 4px;
    padding: 3px 4px;
    font-size: 12px;
}
.acc-input + .acc-input { margin-top: 2px; }
.acc-actions { white-space: nowrap; }
.acc-dupe { color: var(--red); font-weight: 600; margin: 8px 0 0; }
.acc-conflict-box { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--red); border-radius: 8px; background: rgba(226, 59, 59, .08); }
.acc-conflict-box p { margin: 4px 0; color: var(--red); font-weight: 600; }
.field-conflict { outline: 2px solid var(--red); outline-offset: 1px; border-radius: 4px; }
.field-locked { background: rgba(0, 0, 0, .05); color: #667085; cursor: not-allowed; }
.conflict-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.conflict-table th, .conflict-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; font-size: 14px; }
.conflict-table th { background: var(--panel-2); }
.conflict-table tr.conflict-row td { background: rgba(226, 59, 59, .12); color: var(--text); font-weight: 600; }
.acc-filter, .acc-mode { padding: 3px 6px; }
/* ------------------------------------------- подвкладки допуска и лог */
.acc-subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 12px; }
.acc-log { margin-top: 4px; }
.acc-log-body {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 70vh;
    overflow: auto;
}
/* ------------------------------------------- настройки мандатной комиссии */
.mandat-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}
.mandat-settings[hidden] { display: none; }
.mandat-settings .field { margin: 0; }
.mandat-settings .mandat-hint { flex-basis: 100%; margin: 0; }
.mandat-settings select,
.mandat-settings input {
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.mandat-settings .mandat-ages { flex: 1 1 100%; }
.mandat-ages-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: 4px;
}
.mandat-age {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}
.mandat-age input {
    margin: 0;
    padding: 0;
    border: 0;
}
/* Смешанная система с N подгруппами: редактор состава и пар плей-офф */
.mm-config { display: flex; flex-direction: column; gap: 8px; }
.mm-config-title { margin: 10px 0 2px; }
.mm-table { border-collapse: collapse; width: auto; max-width: 100%; }
.mm-table th,
.mm-table td {
    border: 1px solid var(--line);
    padding: 4px 8px;
    text-align: left;
}
.mm-table thead th { background: var(--panel-2); }
.mm-table .mm-group-name,
.mm-table .mm-match-name { white-space: nowrap; }
.mm-size,
.mm-qual { width: 64px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.mm-slot { min-width: 76px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }

/* ------------------------------------------------- всплывающие подсказки */
.tip-bubble {
    position: fixed;
    z-index: 100000;
    max-width: 300px;
    padding: 6px 9px;
    border-radius: 6px;
    background: #1c222c;
    color: #fff;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .12s ease;
    white-space: normal;
}
.tip-bubble.show { opacity: 1; visibility: visible; }
html.tips-off .tip-bubble { display: none !important; }
.tips-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: .85;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.tips-toggle input { margin: 0; cursor: pointer; }
@media print { .tip-bubble { display: none !important; } }

/* ------------------------------------------------- обучалка (пошаговый тур) */
.tour-layer { position: fixed; inset: 0; z-index: 1200; pointer-events: none; }
.tour-spot {
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(0, 0, 0, .55);
    transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
    pointer-events: none;
}
.tour-card {
    position: absolute;
    width: 330px;
    max-width: calc(100vw - 20px);
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
    pointer-events: auto;
}
.tour-card h3 { margin: 2px 0 6px; font-size: 15px; }
.tour-card p { margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.tour-step { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tour-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tour-spacer { flex: 1; }
.tour-question { font-weight: 600; }
.tour-welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ------- показ жеребьёвки для зрителей (embed.php?tab=draw&show=1) ------- */
.draw-show-toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.draw-show-toolbar button.active { background: var(--green); border-color: var(--green); color: #fff; }
.draw-show-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.draw-show-mode-label { font-size: 12px; color: var(--muted); }
.draw-show-row button.active { background: var(--green); border-color: var(--green); color: #fff; }
.draw-show .mx-draw-slot { font-size: 15px; padding: 8px 10px; }
.draw-show .draw-slot { font-size: 16px; padding: 9px 12px; }
.draw-show .draw-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draw-show .draw-team { font-size: 12px; }
.draw-show-list { max-width: 960px; }
.draw-show-table { font-size: 15px; }
.draw-show-table .draw-pool-name { font-size: 16px; }
.draw-show-list-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; cursor: pointer; }
.draw-show-fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 99999; }
.draw-show-fly {
    position: fixed;
    max-width: 92vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: "Arial Black", "Arial Bold", Arial, sans-serif;
    font-size: 30px;
    line-height: 1.1;
    color: #fff;
    background: linear-gradient(135deg, #1d7fd6, #0b5ea8);
    padding: 8px 16px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    white-space: nowrap;
    will-change: transform, opacity;
    transition: transform .9s cubic-bezier(.4, .08, .2, 1), opacity .3s ease;
}
.draw-show-fly-name { font-size: 30px; }
.draw-show-fly-team { font-size: 16px; opacity: .9; font-family: "Segoe UI", Arial, sans-serif; }
.draw-show-legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.draw-show-legend-label { font-size: 12px; color: var(--muted); }
.draw-show-legend-item { font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }

/* ------------------------------------------------ команды (командный турнир) */
.team-card { display: block; }
.team-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.team-head-title { margin: 0 4px 0 0; font-size: 15px; }
.team-head input { flex: 1 1 160px; min-width: 120px; }
.team-members { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.team-members th, .team-members td { border: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: middle; }
.team-members th { font-size: 12px; color: var(--muted); font-weight: 600; }
.team-members input[type="text"], .team-members select { width: 100%; }
.team-member-actions { display: flex; gap: 6px; white-space: nowrap; }
.team-member-actions button { padding: 4px 8px; font-size: 12px; }
.team-member-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.team-member-add input[type="text"] { flex: 1 1 180px; min-width: 140px; }
.weights-input { width: 100%; margin-bottom: 8px; }
.team-members-wrap { margin: 8px 0 4px; }
.team-members-summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px 0; user-select: none; }
.team-members-summary::marker { color: var(--muted); }
.team-list-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.team-list-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.team-search { min-width: 220px; }
.team-list { width: 100%; border-collapse: collapse; margin-top: 10px; }
.team-list th, .team-list td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
.team-list th.team-list-th { cursor: pointer; user-select: none; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.team-list th.team-list-th:hover { color: inherit; }
.team-list-row.is-open { background: var(--panel-2); }
.team-detail-row > td { padding: 0; }
.team-detail-row .card { margin: 0; box-shadow: none; }
.mg-team-fills { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.mg-team-fills-head { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.mg-team-fill { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; background: var(--panel-2); }
.mg-team-fill-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.mg-team-fill-title { font-size: 13px; font-weight: 600; }
.mg-team-bout { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; border-top: 1px solid var(--line); }
.mg-team-bout:first-child { border-top: 0; }
.mg-team-bout.completed { color: var(--muted); }
.mg-tb-weight { flex: 0 0 46px; font-weight: 600; }
.mg-tb-red, .mg-tb-blue { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-tb-vs { color: var(--muted); }
.mg-tb-status { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.mg-team-fill-remove { padding: 2px 6px; font-size: 11px; }
.mg-team-bout-empty { color: var(--muted); font-style: italic; }
.ctx-menu { position: absolute; z-index: 2000; min-width: 240px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.ctx-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ctx-title { padding: 6px 10px; font-size: 12px; opacity: .7; }
.ctx-item:hover { background: var(--panel-2); }

/* Панель «кто онлайн» — только для супер-администратора, правый нижний угол. */
.presence-panel {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1500;
    min-width: 240px;
    max-width: 330px;
    max-height: 45vh;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    font-size: 12px;
    color: var(--text);
}
.presence-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
}
.presence-toggle { padding: 0 6px; line-height: 1; }
.presence-list { padding: 4px; }
.presence-row { padding: 5px 6px; border-radius: 6px; }
.presence-row + .presence-row { border-top: 1px solid var(--line); }
.presence-who { font-weight: 700; }
.presence-where { color: var(--muted); }
.presence-empty { color: var(--muted); padding: 6px 10px; }
.presence-panel.collapsed .presence-list { display: none; }
@media print { .presence-panel { display: none !important; } }
.ctx-sub { padding-left: 8px; }
.ctx-sub-item { padding-left: 22px; }
.lineup-panel { max-width: 760px; width: 92vw; }
.lineup-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.lineup-row { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.lineup-row.dragging { opacity: .6; }
.lineup-head { border-color: transparent; background: transparent; padding: 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lineup-head .lineup-member { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-handle { cursor: grab; color: var(--muted); }
.lineup-weight { flex: 0 0 110px; }
.lineup-member { flex: 1 1 0; min-width: 0; }
.lineup-del { padding: 2px 8px; }
.lineup-weight-label { flex: 0 0 90px; font-weight: 600; }
.lineup-reserves { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.lineup-reserve-team { margin-bottom: 8px; }
.lineup-reserve-team h4 { margin: 0 0 4px; font-size: 13px; }
.lineup-reserve-list { display: flex; flex-wrap: wrap; gap: 6px; }
.lineup-reserve-item { font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
.lineup-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.lineup-locked { opacity: .8; }
.lineup-locked select:disabled { background: transparent; cursor: not-allowed; }

.team-coaches { min-width: 200px; min-height: 40px; }

/* Справочники проекта (модалка) */
.refs-panel { max-width: 1000px; width: 94vw; max-height: 86vh; display: flex; flex-direction: column; }
.refs-body { overflow: auto; padding: 4px 2px; }
.refs-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.refs-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: inherit; cursor: pointer; }
.refs-item:hover { border-color: var(--accent); }
.refs-item-title { font-weight: 600; }
.refs-item-meta { font-size: 12px; color: var(--muted); }
.refs-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.refs-book-title { font-weight: 600; margin-right: auto; }
.refs-table-wrap { overflow: auto; max-height: 62vh; }
.refs-table { border-collapse: collapse; font-size: 13px; width: 100%; }
.refs-table th, .refs-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.refs-table th { background: var(--panel-2); position: sticky; top: 0; }
.refs-table td.num, .refs-table th.num { text-align: right; color: var(--muted); width: 48px; }

/* «Регламент» — таблица распределения весов по коврам. */
.regul-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.regul-table th, .regul-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: middle; }
.regul-table th { background: var(--panel-2); position: sticky; top: 0; }
.regul-table td.regul-group { background: var(--panel-2); font-weight: 700; }
.regul-table select { width: 100%; }
.regul-table td.regul-count { text-align: right; width: 64px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.regul-summary { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* PDF-протоколы: одинаковые правила на экране и при печати, чтобы
   масштаб считался по реальной высоте таблицы, а не по обрезанной. */
body.pdf-mode #notif-panel,
body.pdf-mode #notif-bell,
body.pdf-mode #notif-toasts,
body.pdf-mode #notif-history { display: none !important; }
body.pdf-mode th,
body.pdf-mode td { white-space: normal; }
body.pdf-mode .card {
    padding: 0 !important;
    margin: 0 0 10px !important;
}
body.pdf-mode .official-protocol .op-table th,
body.pdf-mode .official-protocol .op-table td,
body.pdf-mode .protocol-roster th,
body.pdf-mode .protocol-roster td {
    overflow-wrap: anywhere;
    word-break: break-word;
}
/* Шапка протокола: не даём эмблемам перекрывать название федерации
   на узких страницах, которые увеличиваются масштабом. */
.official-protocol .op-head .op-fed {
    padding: 0 64px;
    box-sizing: border-box;
    font-size: 15px;
    letter-spacing: 1px;
    line-height: 1.15;
}.official-protocol .op-table th { font-size: 12px; line-height: 1.15; }
/* Узкая графа «Место»: заголовок вертикально, чтобы не разбивался по буквам. */
body.pdf-mode .official-protocol .op-table th.op-place {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    letter-spacing: .02em;
    padding: 4px 2px;
}
/* Заголовок «Место» в протоколе личного первенства — вертикально. */
body.pdf-mode .protocol-roster th:last-child {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    padding: 4px 2px;
}
/* Эмблемы в PDF: меньше и с отступом текста, чтобы не перекрывать надписи. */
body.pdf-mode .official-protocol .op-emblem {
    height: 48px;
}
body.pdf-mode .pdf-emblem-left {
    width: 42px;
    height: 42px;
}
body.pdf-mode .protocol-emblem {
    width: 52px;
    height: 52px;
}
body.pdf-mode .card.printable > .protocol-title,
body.pdf-mode .card.printable > .protocol-event,
body.pdf-mode .card.printable > .protocol-sub {
    padding-left: 56px;
    padding-right: 8px;
}
body.pdf-mode .pc-wrap > .pc-title,
body.pdf-mode .pc-wrap > .pc-subtitle {
    padding-left: 52px;
    padding-right: 8px;
}
/* «Место» — горизонтально и в одну строку, колонка шире. */
body.pdf-mode .official-protocol .op-table th.op-place,
body.pdf-mode .protocol-roster th:last-child {
    writing-mode: horizontal-tb !important;
    text-orientation: initial !important;
    white-space: nowrap !important;
    padding: 3px 4px !important;
}
/* Логотип рядом с прямоугольником возраста/веса на печатных сетках. */
.op-head .op-side {
    position: absolute;
    right: -2px;
    top: -2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 3;
}
.op-head.op-head-bracket .op-side {
    top: calc(100% - 7px);
    right: 24px;
}
.op-head .op-side .op-cat {
    position: static;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    margin: 0;
}
.pdf-brand-logo {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
}
/* В круговой/смешанной таблице оставляем место под логотип у прямоугольника категории. */
.pc-wrap.mp .op-head {
    margin-bottom: 68px;
}
/* Эмблема в правом верхнем углу протокола 6 штрафных. */
.matrix-card .matrix-brand {
    position: absolute;
    top: calc(10px + 5mm);
    right: 12px;
    z-index: 3;
    pointer-events: none;
}
.matrix-card .matrix-brand .pdf-brand-logo {
    width: 56px;
    height: 56px;
}
.matrix-card .protocol-title {
    padding-right: 72px;
}
.team-protocol-card { position: relative; }
.team-protocol-brand {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 3;
    pointer-events: none;
}
.team-protocol-brand .pdf-brand-logo { width: 56px; height: 56px; }
.team-protocol-card .protocol-title { padding: 0 72px; }
.mat-order-brand {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 3;
    pointer-events: none;
}
.mat-order-brand .pdf-brand-logo { width: 48px; height: 48px; }
.mat-order .pc-title { padding-right: 60px; }

.embed-design { margin-top: 16px; }
.design-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; margin: 12px 0; }
.design-field { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.2; }
.design-field input[type=color] { width: 42px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; }
.design-field input[type=number] { width: 84px; }
.design-preview { width: 100%; height: min(72vh, 900px); min-height: 560px; max-height: 1000px; border: 1px solid var(--line); border-radius: 12px; background: repeating-conic-gradient(#1a1d24 0% 25%, #11141a 0% 50%) 50% / 24px 24px; display: block; }
.design-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.design-preview-wrap { margin-top: 10px; }
.design-preview-wrap[hidden] { display: none; }

.tabs button.tab-finish {
    margin-left: auto;
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}
.tabs button.tab-finish.finished {
    background: var(--accent);
    color: #111;
}
