:root {
  --ice: #EEF4F8;
  --ice-2: #DDE8F0;
  --card: #FBFCFD;
  --navy: #0F2340;
  --text-2: #3A4A63;
  --muted: #5B6B82;
  --red: #C8102E;
  --blue: #1F5FA8;
  --line: #C9D8E6;
  --dot-empty: #9FB5CB;
  --ok: #1E6B3A;
  --radius: 14px;
  --head: "Oswald", "Arial Narrow", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ice);
  color: var(--navy);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--blue); }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; text-transform: uppercase; letter-spacing: .5px; }
h2 { font-size: 22px; text-transform: uppercase; letter-spacing: .5px; }
h3 { font-size: 18px; }
p { margin: 0; }

/* ---------- шапка ---------- */
.top {
  background: var(--navy);
  color: var(--ice);
  border-bottom: 5px solid var(--red);
  position: sticky; top: 0; z-index: 10;
}
.top-in { max-width: 680px; margin: 0 auto; padding: 0 12px; display: flex; align-items: center; min-height: 56px; gap: 4px; }
.logo { font-family: var(--head); font-weight: 700; font-size: 20px; letter-spacing: 1.5px; color: var(--ice); text-decoration: none; margin-right: auto; padding: 10px 4px; }
.nav a, .nav button {
  color: #BFD3E6; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
  min-height: 44px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 10px;
}
.nav a:hover, .nav button:hover { color: var(--ice); background: rgba(255,255,255,.08); }
.nav form { display: inline; }

main { max-width: 680px; margin: 0 auto; padding: 16px 12px 48px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- общие блоки ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.section-title { font-family: var(--head); font-size: 15px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--blue); padding-bottom: 6px; border-bottom: 2px solid var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.flash { border-radius: 12px; padding: 12px 14px; background: #E3F1E8; color: var(--ok); border: 1px solid #B8DCC5; }
.flash.error { background: #FBE9EC; color: #9B0D24; border-color: #F0C2CB; }
.notice { border-left: 4px solid var(--blue); background: var(--card); padding: 12px 14px; border-radius: 0 12px 12px 0; }
.notice.red { border-left-color: var(--red); }

.empty { text-align: center; padding: 32px 16px; color: var(--text-2); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- кнопки и формы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 2px solid var(--navy);
  background: var(--navy); color: var(--ice); font: 600 16px/1 system-ui, sans-serif; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1B3560; border-color: #1B3560; }
.btn.red { background: var(--red); border-color: var(--red); }
.btn.red:hover { background: #A50D26; border-color: #A50D26; }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: var(--ice-2); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
form.inline { display: inline; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
input, select, textarea {
  font: 16px system-ui, sans-serif; color: var(--navy); background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(31,95,168,.35); outline-offset: 1px; border-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }
.field-error { color: #9B0D24; font-weight: 400; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; min-height: 44px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.check input { width: 20px; min-height: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; font-size: 15px; margin-bottom: 6px; padding: 0; }

/* ---------- карточка тренировки ---------- */
.card { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--blue); }
.card.cancelled { opacity: .6; }
.when { font-family: var(--head); font-size: 22px; font-weight: 600; }
.cost { font-weight: 600; }
.meta { color: var(--text-2); }

.dots { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 2px solid var(--dot-empty); }
.dot.on { background: var(--red); border-color: var(--red); }
.dots-big .dot { width: 18px; height: 18px; }
.slot-row { display: flex; align-items: center; gap: 8px; }
.slot-row .ico { width: 22px; text-align: center; }
.counter { font-weight: 600; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--ice-2); color: var(--navy); }
.badge.red { background: #FBE9EC; color: #9B0D24; }
.badge.blue { background: #E1ECF8; color: var(--blue); }
.badge.green { background: #E3F1E8; color: var(--ok); }

.person { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .ico { font-size: 18px; width: 24px; text-align: center; }
.person-main { flex: 1; min-width: 0; }
.person-name { font-weight: 600; }

table.list { width: 100%; border-collapse: collapse; }
table.list td, table.list th { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

@media (max-width: 420px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .logo { font-size: 18px; }
}

/* ---------- этап 2: комментарии и фильтры ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.comment { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--ice); }
.comment.own { background: #E1ECF8; }
.comment-text { white-space: pre-line; overflow-wrap: anywhere; }
.comment-del { align-self: flex-end; }
.link-btn { background: none; border: 0; padding: 8px 4px; min-height: 36px; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: #9B0D24; }

.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.filters select { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.filters select.on { border-color: var(--navy); border-width: 2px; font-weight: 600; }
.filters-bar { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.htmx-request.list-wrap, .htmx-request .list-wrap { opacity: .55; transition: opacity .15s; }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr 1fr; } }

/* ---------- этапы 3–9 ---------- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
table.stats th, table.stats td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.stats th:first-child, table.stats td:first-child { text-align: left; white-space: normal; }
table.stats th a { color: var(--navy); text-decoration: none; }
table.stats th a.on { color: var(--red); }
.rel { font-weight: 700; }
.rel.low { color: #9B0D24; }
.rel.mid { color: #8A5A00; }
.rel.high { color: var(--ok); }
.att-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.att-row:last-child { border-bottom: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex-direction: row; min-height: 40px; padding: 0 12px; align-items: center; font-weight: 600; font-size: 14px; cursor: pointer; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0; padding: 0; }
.seg label:has(input:checked).yes { background: #E3F1E8; color: var(--ok); }
.seg label:has(input:checked).no { background: #FBE9EC; color: #9B0D24; }
.seg label:has(input:focus-visible) { outline: 3px solid rgba(31,95,168,.35); }

@media (max-width: 680px) { .logo-tail { display: none; } }
@media (max-width: 480px) {
  .nav .logout { display: none; }   /* на телефоне «Выйти» — внизу профиля */
  .nav a, .nav button { padding: 0 8px; }
}

@media (max-width: 480px) {
  table.stats { font-size: 14px; }
  table.stats th, table.stats td { padding: 8px 4px; }
  table.stats td:first-child { min-width: 120px; }
}

.lockers { font-weight: 700; font-size: 17px; color: var(--navy); background: var(--card); border: 1.5px solid var(--blue);
           border-radius: 10px; padding: 8px 12px; align-self: flex-start; }

/* подписи амплуа */
.balance { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--text-2); margin: 0; }
.balance span { white-space: nowrap; }
.balance b { color: var(--navy); }
.slot-row { display: grid; grid-template-columns: 118px 1fr auto; align-items: center; gap: 8px; }
.slot-name { font-size: 14px; color: var(--text-2); white-space: nowrap; }

/* ---------- «Ищут игру» ---------- */
main.wide { max-width: 1180px; }
@media (max-width: 480px) { .nav .nav-wide { display: none; } }
.looking-cta { width: 100%; }
.me-summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 44px; }
.me-summary::-webkit-details-marker { display: none; }
.slot-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.day-row { border-top: 1px solid var(--line); padding-top: 10px; }
.day-row legend { font-family: var(--head); font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.check.chip { min-height: 40px; padding: 0 10px; font-size: 15px; }
.check.chip:has(input:checked) { background: #E1ECF8; border-color: var(--blue); }
.week-tabs .btn { flex: 1; }

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.board .tab-radio, .board .col-tabs { display: none; }
.board .col { min-width: 0; }
.looker { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.looker:last-child { border-bottom: 0; }
.looker.me { background: #E1ECF8; margin: 0 -10px; padding: 12px 10px; border-radius: 10px; }
.queue-no { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; border-radius: 50%;
            background: var(--navy); color: var(--ice); font-weight: 700; font-size: 13px; }
.looker-days { margin: 0; padding-left: 18px; font-size: 14px; color: var(--text-2); }
.invite summary { list-style: none; }
.invite summary::-webkit-details-marker { display: none; }

@media (max-width: 899px) {
  .board { grid-template-columns: 1fr; gap: 0; }
  .board .col-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
  .col-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 4px;
             border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 13px; font-weight: 600;
             text-align: center; cursor: pointer; line-height: 1.2; }
  .col-tab b { font-size: 16px; }
  .board .col { display: none; }
  .board:has(#col-forward:checked) .col-forward,
  .board:has(#col-defense:checked) .col-defense,
  .board:has(#col-goalie:checked) .col-goalie { display: flex; }
  .board:has(#col-forward:checked) label[for=col-forward],
  .board:has(#col-defense:checked) label[for=col-defense],
  .board:has(#col-goalie:checked) label[for=col-goalie] { background: var(--navy); color: var(--ice); border-color: var(--navy); }
}

@media (min-width: 900px) {
  .days-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  #me form .btn.wide, #me form + form .btn.wide { max-width: 420px; }
}

@media (max-width: 480px) {
  .check.chip { padding: 0 8px; gap: 6px; font-size: 14px; }
  .day-row .checks { gap: 6px; }
}

/* время в «Ищут игру»: чипы-переключатели без квадратика — 4 штуки в строку на телефоне */
.day-row .checks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.day-row .check.chip { justify-content: center; padding: 0 4px; font-weight: 600; font-size: 14px; }
.day-row .check.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; }
.day-row .check.chip:has(input:checked) { background: var(--navy); color: var(--ice); border-color: var(--navy); }
@media (min-width: 420px) { .day-row .check.chip:has(input:checked)::before { content: "✓"; margin-right: 2px; } }
.day-row .check.chip:has(input:focus-visible) { outline: 3px solid rgba(31,95,168,.35); }

.invite-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 4px; }
.invite-form select { min-height: 40px; padding: 6px 8px; font-size: 14px; }

/* цвета амплуа: занятые места и легенда */
:root { --c-goalie: #7A3E9D; --c-defense: #1F5FA8; --c-forward: #C8102E; --c-universal: #0F8A6F; --c-none: #5B6B82; }
.dot.on.goalie    { background: var(--c-goalie);    border-color: var(--c-goalie); }
.dot.on.defense   { background: var(--c-defense);   border-color: var(--c-defense); }
.dot.on.forward   { background: var(--c-forward);   border-color: var(--c-forward); }
.dot.on.universal { background: var(--c-universal); border-color: var(--c-universal); }
.dot.on.none      { background: var(--c-none);      border-color: var(--c-none); }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.sw.goalie { background: var(--c-goalie); } .sw.defense { background: var(--c-defense); }
.sw.forward { background: var(--c-forward); } .sw.universal { background: var(--c-universal); }

/* свободные места в режиме «по амплуа» — обводка цветом амплуа */
.dots.slot-goalie .dot:not(.on)  { border-color: color-mix(in srgb, var(--c-goalie) 45%, white); }
.dots.slot-defense .dot:not(.on) { border-color: color-mix(in srgb, var(--c-defense) 45%, white); }
.dots.slot-forward .dot:not(.on) { border-color: color-mix(in srgb, var(--c-forward) 45%, white); }

/* личная статистика */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--ice); }
.tile-num { font-family: var(--head); font-size: 30px; font-weight: 700; line-height: 1; color: var(--navy); }
.tile-label { font-size: 13px; color: var(--text-2); line-height: 1.25; }
table.stats tr.muted td { color: var(--muted); }
@media (max-width: 480px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* аватарки */
.ava { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: var(--ice-2); }
.ava.sm { width: 28px; height: 28px; font-size: 11px; }
.ava.xl { width: 88px; height: 88px; font-size: 30px; }
.ava-empty { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
             color: #fff; background: var(--c-none); letter-spacing: .5px; }
.ava-empty.goalie { background: var(--c-goalie); } .ava-empty.defense { background: var(--c-defense); }
.ava-empty.forward { background: var(--c-forward); } .ava-empty.universal { background: var(--c-universal); }
.file-btn { position: relative; overflow: hidden; align-self: flex-start; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

/* свободный набор: строки по амплуа + свободные места */
.sw.none { background: var(--c-none); }
.sw.free { background: transparent; border: 2px solid var(--dot-empty); width: 9px; height: 9px; }
.slot-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
