:root {
  --accent: #c8102e;
  --accent-soft: #c8102e18;
  --navy: #0f1b2d;
  --navy-2: #172a44;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #16202e;
  --muted: #6b778a;
  --line: #e2e7ee;
  --ok: #1f9d55;
  --warn: #d98a00;
  --bad: #d64545;
  --info: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

/* ---------- каркас ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--navy); color: #cfd8e6;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; width: 100%; background: none; border: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.brand:hover { background: var(--navy-2); }
.brand-text { flex: 1; min-width: 0; }
.brand-caret { color: #8fa0b8; font-size: 12px; }
.team-menu { margin: 0 10px 8px; padding: 4px; border-radius: 10px; background: var(--navy-2); display: flex; flex-direction: column; gap: 2px; }
.team-menu[hidden] { display: none; }
.team-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; border-radius: 8px; background: none; color: #cfd8e6; font: inherit; text-align: left; cursor: pointer; }
.team-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.team-item.on { color: #fff; }
.team-item b { display: block; font-size: 14px; font-weight: 600; }
.team-item small { display: block; font-size: 12px; color: #8fa0b8; }
.team-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.team-check { margin-left: auto; color: #fff; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: .02em;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: #8fa0b8; }
.nav { padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f819b; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: #cfd8e6; text-decoration: none; font-size: 14px;
}
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 12px 18px 16px; font-size: 12px; color: #8fa0b8; border-top: 1px solid var(--navy-2); }
.save-state { display: flex; align-items: center; gap: 6px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save-state.saving .save-dot { background: var(--warn); }
.save-state.error .save-dot { background: var(--bad); }

.main { flex: 1; overflow-y: auto; }
.page { max-width: 1280px; margin: 0 auto; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-right: auto; }
.page-sub { color: var(--muted); margin: -10px 0 18px; }

/* ---------- элементы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: #c3ccd8; background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: #fdf0f0; border-color: #f0c4c4; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f5; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 6px 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin-right: auto; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (max-width: 1100px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .sidebar { width: 64px; } .brand-name, .brand-sub, .brand-caret, .team-item span:not(.team-dot), .nav a span, .nav-group, .sidebar-foot { display: none; } .page { padding: 18px 14px 40px; } }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 7px 10px; outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.45; }
.search { width: 240px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 14px; cursor: pointer; border: none; background: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef1f5; color: #445167; white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: #e3f5ea; color: var(--ok); }
.chip.warn { background: #fdf2dc; color: #a86b00; }
.chip.bad { background: #fde8e8; color: var(--bad); }
.chip.info { background: #e6eefe; color: var(--info); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty {
  text-align: center; color: var(--muted); padding: 40px 20px;
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: #fafbfc;
}
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.pre { white-space: pre-wrap; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f8fafc; }
.tbl tr.us td { background: var(--accent-soft); font-weight: 650; }
.num { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: 7px; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #dde3eb; }
.dots i.on { background: var(--accent); }

/* ---------- модальные окна ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 27, 45, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal.xwide { max-width: 1240px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin-right: auto; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.tagpick button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 13px; }
.tagpick button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.rating { display: flex; gap: 4px; }
.rating button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; }
.rating button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 100; font-weight: 550;
}

/* ---------- главная ---------- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.next-event { display: flex; gap: 14px; align-items: center; }
.date-badge { width: 58px; flex-shrink: 0; text-align: center; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.date-badge .m { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 3px 0; }
.date-badge .d { font-size: 22px; font-weight: 750; padding: 4px 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }

/* ---------- календарь ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-h { padding: 8px; font-size: 12px; font-weight: 650; color: var(--muted); text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafbfc; }
.cal-d { min-height: 104px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; background: #fff; display: flex; flex-direction: column; gap: 3px; }
.cal-d:hover { background: #fafbfd; }
.cal-d.other { background: #f8f9fb; color: #aab3c0; }
.cal-d.today .dn { background: var(--accent); color: #fff; }
.dn { align-self: flex-start; font-weight: 650; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.ev { font-size: 12px; padding: 2px 6px; border-radius: 5px; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; font-weight: 550; cursor: pointer; }
.ev.match { background: #fde8e8; color: #a51d1d; }
.ev.training { background: #e6eefe; color: #1d4ed8; }
.ev.event { background: #eceef2; color: #3b4658; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .l-match::before { background: #f3b4b4; }
.legend .l-training::before { background: #b3c8f7; }
.legend .l-event::before { background: #cfd4dc; }

/* ---------- звенья ---------- */
.lineup { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.bench { position: sticky; top: 10px; max-height: calc(100vh - 140px); overflow-y: auto; }
.pchip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 8px; cursor: grab; user-select: none; font-size: 13px;
}
.pchip:hover { border-color: #c3ccd8; }
.pchip.used { opacity: .45; }
.pchip .num { min-width: 26px; height: 22px; font-size: 12px; }
.pchip .pos { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
.bench .pchip + .pchip { margin-top: 6px; }
.unit { display: flex; align-items: stretch; gap: 8px; margin-bottom: 10px; }
.unit-name { width: 92px; flex-shrink: 0; display: flex; align-items: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.slots { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; flex: 1; }
.slot {
  min-height: 54px; border: 1.5px dashed #cfd6e0; border-radius: 10px;
  padding: 5px 7px; background: #fafbfc; display: flex; flex-direction: column; justify-content: center;
}
.slot .slot-pos { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .05em; }
.slot.filled { border-style: solid; border-color: var(--line); background: #fff; }
.slot.over { border-color: var(--accent); background: var(--accent-soft); }
.slot.mismatch { border-color: #f0c675; }
.slot .pchip { border: none; padding: 2px 0; background: transparent; }
.unit-sep { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- тактическая доска ---------- */
.board-wrap { display: grid; grid-template-columns: 1fr; gap: 10px; }
.board-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; }
.tool.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tool svg { width: 18px; height: 18px; }
.tool-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.board-svg { width: 100%; height: auto; display: block; background: #fff; border-radius: 12px; border: 1px solid var(--line); touch-action: none; user-select: none; }
.board-svg.cross { cursor: crosshair; }
.board-mini { width: 100%; height: auto; display: block; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.scheme-card { cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.scheme-card:hover { box-shadow: 0 2px 4px rgba(15,27,45,.08), 0 10px 26px rgba(15,27,45,.09); }

/* ---------- тренировки ---------- */
.plan-row { display: grid; grid-template-columns: 26px 1fr 80px 1fr 64px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.plan-row .idx { font-weight: 700; color: var(--muted); text-align: center; }
.att-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.att-row .who { flex: 1; display: flex; align-items: center; gap: 8px; }
.att-btns { display: flex; gap: 4px; }
.att-btns button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-weight: 600; }
.att-btns button.on.present { background: var(--ok); border-color: var(--ok); color: #fff; }
.att-btns button.on.late { background: var(--warn); border-color: var(--warn); color: #fff; }
.att-btns button.on.excused { background: var(--info); border-color: var(--info); color: #fff; }
.att-btns button.on.absent { background: var(--bad); border-color: var(--bad); color: #fff; }
.att-btns button.on.injured { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.bar { height: 7px; background: #eef1f5; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.month-title { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

/* ---------- турниры: сетка ---------- */
.bracket { display: flex; gap: 34px; overflow-x: auto; padding: 6px 2px 14px; }
.round { display: flex; flex-direction: column; min-width: 220px; }
.round-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 14px; }
.round-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.pair { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; position: relative; }
.pair-team { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.pair-team + .pair-team { border-top: 1px solid var(--line); }
.pair-team.win { font-weight: 700; background: #f0faf4; }
.pair-team .tn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair-team input { width: 44px; text-align: center; padding: 3px; }
.pair-team select { flex: 1; min-width: 0; padding: 3px 6px; }

/* ---------- заметки / штаб ---------- */
.note { display: flex; flex-direction: column; gap: 8px; cursor: pointer; border-top: 4px solid transparent; }
.note.pinned { border-top-color: var(--accent); }
.note .pre { max-height: 160px; overflow: hidden; color: #354155; }
.person { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 18px 0 8px; }

/* ---------- печать ---------- */
@media print {
  .sidebar, .no-print, .modal-foot, .modal-head .btn { display: none !important; }
  body { background: #fff; }
  .layout { display: block; height: auto; }
  .main { overflow: visible; }
  .modal-back { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; }
  body.printing-modal .main { display: none; }
  .card { box-shadow: none; border: 1px solid var(--line); }
}
@media print {
  body.printing-modal .modal-back:not(.print-target) { display: none !important; }
}

/* карточка упражнения/схемы: поля слева, площадка справа */
.doc-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.doc-board { position: sticky; top: 0; }
.form-one .form { grid-template-columns: 1fr; }
@media (max-width: 1000px) { .doc-grid { grid-template-columns: 1fr; } .doc-board { position: static; } }

/* звенья: построения */
.formation { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.unit-card .card-head { margin-bottom: 10px; }
.sm-select { padding: 4px 8px; font-size: 13px; }
.formation .pchip .pos { display: none; }
.formation .pchip span:nth-child(2) { white-space: nowrap; font-weight: 600; }
.units-col { grid-template-columns: 1fr; }
.formation .pchip { align-items: center; }
.formation .slot { min-width: 0; }

/* календарь: тренировка с направленностью и задачей */
.ev.ev-block { white-space: normal; display: flex; flex-direction: column; gap: 2px; padding: 4px 6px; }
.ev-block .ev-title { font-weight: 650; }
.ev-block .ev-focus { font-size: 11px; font-weight: 600; opacity: .9; }
.ev-block .ev-goal { font-size: 11px; font-weight: 400; color: #34405a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* уровень игрока — звёзды */
.stars { display: inline-flex; gap: 1px; font-size: 15px; line-height: 1; letter-spacing: 0; }
.stars i { font-style: normal; color: #d9dee6; }
.stars i.on { color: #f5a524; }
.starpick { display: flex; align-items: center; gap: 2px; }
.starpick button { border: none; background: none; cursor: pointer; font-size: 28px; line-height: 1; padding: 0 2px; color: #d9dee6; transition: transform .1s; }
.starpick button.lit { color: #f5a524; }
.starpick button:hover { transform: scale(1.15); }
.starpick .star-cap { margin-left: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* вариации упражнения */
.var-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.var-tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.var-tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.var-tab.add { border-style: dashed; color: var(--accent); }
.var-form { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 10px; padding: 10px; background: #f6f8fb; border-radius: 10px; }
.var-form .btn { justify-self: start; }

/* звенья: уровень игроков */
.pname { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pstars .stars { font-size: 11px; }
.unit-level { background: #fff6e0; color: #a86b00; }

/* выбор цвета */
.colorpick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.colorpick .sw { width: 28px; height: 28px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; display: grid; place-items: center; font-size: 12px; color: var(--muted); box-shadow: 0 0 0 1px var(--line); position: relative; overflow: hidden; }
.colorpick .sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--text); }
.colorpick .sw.none { background: #fff; }
.colorpick .custom { background: conic-gradient(#d64545, #e0b100, #1f9d55, #0ea5e9, #7c3aed, #d64545); color: #fff; font-weight: 700; text-shadow: 0 0 3px #000; }
.colorpick .custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.lc-row { margin-top: 6px; }
.chip.lc { border: none; cursor: pointer; }
.chip.lc:hover { filter: brightness(.95); }
.lc-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* редактор текста с оформлением */
.rte { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 4px 6px; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: 8px 8px 0 0; }
.rte-bar button { border: 1px solid transparent; background: none; border-radius: 6px; min-width: 26px; height: 26px; padding: 0 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.rte-bar button:hover { background: #eef1f5; border-color: var(--line); }
.rte-bar .rte-color span { font-weight: 800; font-size: 14px; }
.rte-bar .rte-mark { min-width: 20px; width: 20px; height: 20px; border: 1px solid #0001; }
.rte-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rte-area { padding: 8px 10px; outline: none; line-height: 1.45; overflow-y: auto; max-height: 360px; }
.rte-area:empty::before { content: attr(data-ph); color: #9aa5b5; }
.rte-area ul, .pre ul { margin: 2px 0; padding-left: 20px; }
.pre div, .pre p { margin: 0; }
.ev-goal div, .ev-goal p { display: inline; }
.ev-goal div + div::before { content: " "; }

/* матчи */
.match-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px 20px; margin-bottom: 16px; }
.mh-team { font-size: 22px; font-weight: 750; }
.mh-team.right { text-align: right; }
.mh-score { text-align: center; font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.mh-score i { font-style: normal; margin: 0 8px; color: var(--muted); }
.mh-score em { font-style: normal; font-size: 14px; color: var(--muted); margin-left: 6px; vertical-align: top; }
.mh-score div { margin-top: 8px; font-size: 13px; }
.mh-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 10px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.st-in { width: 60px; text-align: center; padding: 4px 6px; }
.stat-tbl td, .stat-tbl th { text-align: center; }
.stat-tbl td:nth-child(2), .stat-tbl th:nth-child(2) { text-align: left; }
.stat-tbl tr.tot td { background: #f6f8fb; font-weight: 700; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable.on { color: var(--accent); }

/* туры турнира */
.round-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.round-head h3 { font-size: 16px; }

/* Итоговые места и награды турнира */
.tour-medal { width: 38px; height: 48px; vertical-align: middle; flex-shrink: 0; }
.tour-cup { width: 110px; height: 122px; filter: drop-shadow(0 5px 8px #ad761825); }
.tour-place-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tour-place-row span { overflow-wrap: anywhere; }
.tour-card-result { display: flex; align-items: center; gap: 8px; }
.tour-card-result .tour-medal { width: 24px; height: 30px; }
.tour-results { background: linear-gradient(145deg, #fff, #fffaf0); }
.tour-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 720px; margin: 24px auto 0; align-items: end; }
.tour-podium-place { text-align: center; min-width: 0; }
.tour-podium-place.place-2 { grid-column: 1; }
.tour-podium-place.place-1 { grid-column: 2; }
.tour-podium-place.place-3 { grid-column: 3; }
.tour-podium-award { height: 126px; display: flex; align-items: end; justify-content: center; margin-bottom: 10px; }
.tour-podium-award .tour-medal { width: 58px; height: 73px; }
.tour-podium-name { font-weight: 700; overflow-wrap: anywhere; padding: 0 4px 12px; }
.tour-podium-step { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100px; border-radius: 12px 12px 0 0; background: linear-gradient(135deg, #e7edf5, #bdc9d9); color: var(--navy); }
.place-1 .tour-podium-step { height: 145px; background: linear-gradient(135deg, #fff0a1, #e3b64d); }
.place-3 .tour-podium-step { height: 75px; background: linear-gradient(135deg, #f6d8bd, #c98e60); }
.tour-podium-step b { font-size: 36px; line-height: 1.2; }
.tour-podium-step span { font-size: 13px; }
.tour-results-table td:nth-child(1) { width: 80px; }
.tour-results-table td:nth-child(2) { width: 90px; }
@media (max-width: 600px) {
  .tour-podium { gap: 6px; }
  .tour-podium-name { font-size: 12px; }
  .tour-cup { width: 85px; height: 100px; }
  .tour-podium-award { height: 104px; }
  .tour-podium-step b { font-size: 28px; }
}

/* шахматка турнира */
.chess-wrap { padding: 8px; }
table.chess { border-collapse: collapse; width: 100%; }
.chess th, .chess td { border: 1px solid var(--line); text-align: center; padding: 4px; font-size: 13px; }
.chess th { background: #fafbfc; color: var(--muted); font-weight: 650; }
.chess .ch-name { text-align: left; white-space: nowrap; font-weight: 650; padding: 6px 10px; }
.chess .ch-corner { width: 34px; color: var(--muted); }
.chess .ch-colhead { min-width: 64px; }
.chess tr.us td { background: var(--accent-soft); }
.chess .ch-self { background: repeating-linear-gradient(45deg, #eef1f5, #eef1f5 6px, #f7f8fa 6px, #f7f8fa 12px); }
.chess .ch-cell { position: relative; min-width: 64px; height: 38px; }
.ch-g { display: block; margin: 2px auto; padding: 2px 6px; border-radius: 6px; font-weight: 700; cursor: pointer; width: fit-content; }
.ch-g small { font-size: 10px; margin-left: 2px; opacity: .8; }
.ch-win { background: #e3f5ea; color: var(--ok); }
.ch-loss { background: #fde8e8; color: var(--bad); }
.ch-draw { background: #eef1f5; color: #445167; }
.ch-future { background: #fff; color: var(--muted); font-weight: 600; border: 1px dashed #cfd6e0; }
.ch-add { position: absolute; right: 2px; bottom: 2px; border: none; background: none; color: #b7c0cc; cursor: pointer; font-size: 13px; line-height: 1; padding: 1px 3px; border-radius: 4px; opacity: 0; }
.chess .ch-cell:hover .ch-add { opacity: 1; }
.ch-add:hover { background: var(--accent-soft); color: var(--accent); }
.ch-legend { display: inline-block; padding: 1px 6px; border-radius: 5px; font-weight: 600; }

/* таблица соперников */
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.opp-tbl td.center, .opp-tbl th { text-align: center; }
.opp-tbl th:first-child, .opp-tbl th:nth-child(2), .opp-tbl th:nth-child(4), .opp-tbl th:nth-child(5) { text-align: left; }

/* ---------- библиотека: книги и примеры тренировок ---------- */
a.lib-book { display: block; text-decoration: none; color: inherit; border-top: 4px solid var(--navy-2); }
a.lib-book:nth-child(even) { border-top-color: var(--accent); }
a.lib-book:hover { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.lib-num { font-size: 30px; font-weight: 700; color: var(--line); line-height: 1; margin-bottom: 8px; }
.lib-book h3 { font-size: 16px; margin-bottom: 4px; }
.lib-clamp { margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lib-read { max-width: 900px; }
.lib-lead { font-size: 15px; line-height: 1.55; margin: 14px 0; }
.lib-idea { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 16px; line-height: 1.5; }
.lib-list { margin: 8px 0; padding-left: 20px; line-height: 1.5; }
.lib-list li { margin: 4px 0; }
.lib-ch summary { cursor: pointer; line-height: 1.45; }
.lib-ch summary div { margin-top: 3px; }
.lib-ch[open] summary { margin-bottom: 6px; }
.grid ~ .lib-ch, .lib-ch + .lib-ch { margin-top: 10px; }
.lib-quote { border-left: 3px solid var(--accent); margin: 10px 0; padding-left: 14px; font-style: italic; }
.lib-apply { background: #eef4ff; border-left: 3px solid var(--info); padding: 8px 14px; border-radius: 0 8px 8px 0; margin-top: 8px; }
.lib-links { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-plan + .lib-plan { margin-top: 16px; }
.lib-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 12px 0 6px; }
.lib-bar span { background: var(--navy-2); border-right: 2px solid var(--card); }
.lib-bar span.alt { background: var(--accent); }
.lib-block { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); line-height: 1.45; }
.lib-min { font-size: 18px; font-weight: 700; color: var(--accent); }

/* ---------- ведение матча (match-live.js) ---------- */
.per-wrap { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.per-tbl { border-collapse: collapse; font-size: 14px; }
.per-tbl th, .per-tbl td { padding: 4px 8px; text-align: center; border-bottom: 1px solid var(--line); }
.per-tbl thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.per-tbl tbody th { text-align: left; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.per-tbl .per-tot { font-weight: 800; font-size: 16px; }
.per-in { width: 52px; padding: 4px 6px; text-align: center; }
.live-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; padding: 12px 14px; }
.live-per { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.live-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.live-goal { font-weight: 700; }
.live-goal.us { background: var(--accent); border-color: var(--accent); color: #fff; }
.live-goal.them { background: var(--navy); border-color: var(--navy); color: #fff; }
.live-goal:hover { filter: brightness(1.1); }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; color: inherit; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tl { padding: 4px 0; margin-bottom: 14px; }
.tl-row { display: grid; grid-template-columns: 60px 30px 1fr auto auto; align-items: center; gap: 10px; padding: 9px 14px; border-left: 4px solid transparent; cursor: pointer; }
.tl-row + .tl-row { border-top: 1px solid var(--line); }
.tl-row:hover { background: var(--accent-soft); }
.tl-row.goal.us { border-left-color: var(--accent); }
.tl-row.goal.them { border-left-color: var(--navy); }
.tl-row.pen { opacity: .85; }
.tl-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.tl-ico { font-size: 18px; text-align: center; }
.tl-main b { display: block; }
.tl-main small { color: var(--muted); font-size: 12px; }
.tl-score { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.tl-score.small { font-size: 12px; font-weight: 600; color: var(--muted); }
.ev-form .field { margin-bottom: 14px; }
.ev-form .field[hidden] { display: none; }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.pl-btn { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-size: 13px; text-align: left; cursor: pointer; color: inherit; }
.pl-btn:hover:not(:disabled) { border-color: var(--accent); }
.pl-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pl-btn:disabled { opacity: .35; cursor: default; }
.pl-btn[data-tag="1"]::after, .pl-btn[data-tag="2"]::after { content: attr(data-tag); position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; display: grid; place-items: center; }
.pl-num { min-width: 24px; height: 22px; border-radius: 6px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.pl-btn.on .pl-num { background: rgba(0,0,0,.25); }
.per-foot { gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.per-foot select { width: auto; padding: 4px 8px; }
.tot-in { font-weight: 800; }
.pair-date { border-top: 1px dashed var(--line); padding: 4px 8px; background: #fafbfd; }
.pair-date input { width: 100%; padding: 2px 6px; font-size: 12px; border-color: transparent; background: transparent; color: var(--muted); }
.pair-date input:hover, .pair-date input:focus { border-color: var(--line); background: #fff; color: inherit; }
.mk { font-size: 13px; }
.mk-chip { font-weight: 600; }
.mk-btn { border: none; background: none; padding: 0 2px; margin: 0; font: inherit; font-size: 13px; line-height: 1; cursor: pointer; border-radius: 4px; }
.mk-btn:hover { background: rgba(0,0,0,.08); outline: 1px solid rgba(0,0,0,.15); }
button.mk-chip { border: none; cursor: pointer; font: inherit; font-size: 12px; }
button.mk-chip:hover { filter: brightness(.95); outline: 1px solid var(--line); }
.kind-menu { position: fixed; z-index: 2000; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,27,45,.18); padding: 4px; display: flex; flex-direction: column; min-width: 200px; }
.kind-menu button { border: none; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer; color: inherit; }
.kind-menu button:hover { background: var(--accent-soft); }
.kind-menu button.on { font-weight: 700; background: var(--accent-soft); }
.tnote { cursor: pointer; margin-bottom: 10px; }
.tnote:hover { box-shadow: 0 0 0 1px var(--accent) inset; }
.tnote-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.board-zone-opts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px var(--navy); }
.board-zone-opts input[type="range"] { width: 120px; }

/* ---------- сайт: вход, пользователь, добавление команды ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg, #f3f5f8); }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-logo { display: flex; }
.login-err { color: var(--bad, #d64545); font-size: 14px; min-height: 0; }
.login-err:empty { display: none; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.user-row .btn { color: #cfd8e6; }
.team-add { border-top: 1px solid rgba(255,255,255,.1); border-radius: 0 0 8px 8px; margin-top: 4px; }
.team-add .team-dot { display: flex; align-items: center; justify-content: center; width: 12px; height: 12px; font-size: 14px; line-height: 1; }
