/* Админка. Тот же знак и те же цвета, что у формы: тёмно-синий, красное солнце и белые поля. */

body.admin { background: var(--mist); font-size: 16px; }

.admin .input { min-height: 46px; font-size: 16px; }
.admin .btn { min-height: 46px; font-size: 16px; }
.admin .btn.small { min-height: 40px; font-size: 15px; }
.admin .chip label { min-height: 42px; }
.muted { color: var(--ink-3); }

.loading { display: grid; place-items: center; min-height: 240px; }

/* ---------- вход ---------- */

.login {
  position: relative; overflow: hidden; min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px; background: var(--ink);
}
.login::after {
  content: ""; position: absolute; width: min(72vw, 640px); aspect-ratio: 1; border-radius: 50%;
  background: var(--red); right: -14vw; bottom: -24vw;
}
.login-card {
  position: relative; z-index: 1; width: min(420px, 100%); display: grid; gap: 18px;
  padding: 30px 28px; border-radius: 24px; background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand b { display: block; font-size: 19px; line-height: 1.2; }
.login-brand span { color: var(--ink-3); font-size: 14px; }
.login h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.password { position: relative; }
.password .input { padding-right: 54px; }
.password .icon-btn { position: absolute; top: 1px; right: 2px; }
.password .icon-btn[aria-pressed="true"] { color: var(--blue); }

/* ---------- оболочка ---------- */

.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: 22px 14px 18px; background: var(--ink); color: #fff; overflow: hidden;
}
.side::after {
  content: ""; position: absolute; width: 104px; height: 104px; border-radius: 50%;
  background: var(--red); right: -46px; top: -52px;
}
.side > * { position: relative; z-index: 1; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; color: #fff; text-decoration: none; }
.side-brand b { display: block; font-size: 18px; line-height: 1.2; }
.side-brand small { color: rgba(255, 255, 255, .6); font-size: 14px; }
.side-nav { display: grid; gap: 4px; }
.side-nav a, .side-link {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px;
  background: none; color: rgba(255, 255, 255, .78); font-size: 16px; font-weight: 600; text-decoration: none; text-align: left;
}
.side-nav a:hover, .side-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.side-nav a[aria-current="page"] { background: rgba(255, 255, 255, .15); color: #fff; }
.side-foot { margin-top: auto; display: grid; gap: 2px; }

.topbar, .tabbar { display: none; }
.main { min-width: 0; }
.route { min-width: 0; }

.page { max-width: 1120px; margin: 0 auto; padding: 30px 32px 64px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 22px; }
.page-head > div { flex: 1 1 300px; min-width: 0; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.lead { margin-top: 6px; color: var(--ink-2); max-width: 62ch; }
.section-title { font-size: 20px; font-weight: 800; margin: 34px 0 12px; }

/* ---------- пустые экраны ---------- */

.empty {
  display: grid; justify-items: center; gap: 10px; padding: 48px 22px; text-align: center;
  border: 1.5px dashed var(--line-2); border-radius: 18px; background: #fff;
}
.empty h2 { font-size: 22px; }
.empty p { color: var(--ink-2); max-width: 46ch; }
.empty .btn { margin-top: 6px; }
.empty .badge { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--blue-50); color: var(--blue); }

/* ---------- турниры ---------- */

.game-list { display: grid; gap: 10px; }
.game-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto 22px; align-items: center; gap: 4px 18px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff;
  color: inherit; text-decoration: none; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.game-row:hover { border-color: var(--blue); box-shadow: 0 6px 20px rgba(36, 87, 214, .08); }
.game-row .chev { color: var(--ink-3); }
.date-block { display: grid; place-content: center; width: 64px; height: 64px; border-radius: 14px; background: var(--blue-50); color: var(--blue); text-align: center; line-height: 1; }
.date-block b { display: block; font-size: 27px; font-weight: 800; }
.date-block span { display: block; margin-top: 3px; font-size: 14px; font-weight: 700; }
.game-main h3 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.game-meta { display: flex; flex-wrap: wrap; gap: 0 16px; margin-top: 2px; color: var(--ink-3); font-size: 15px; }
.game-side { display: grid; justify-items: end; gap: 6px; text-align: right; }
.game-count { color: var(--ink-2); font-size: 14px; }
.game-count b { color: var(--ink); font-size: 16px; }
.game-row.is-past { background: transparent; }
.game-row.is-past .date-block { background: var(--line); color: var(--ink-3); }

/* ---------- страница турнира ---------- */

.crumb { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; margin-left: -6px; padding: 0 10px 0 2px; border-radius: 10px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.crumb:hover { background: rgba(16, 26, 61, .06); }
.crumb svg { width: 22px; height: 22px; }

.game-head { display: grid; gap: 10px; margin-top: 6px; }
.game-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.game-title h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.game-sub { display: flex; flex-wrap: wrap; gap: 2px 20px; color: var(--ink-2); }
.game-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 6px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; flex: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line-2); transition: background-color .2s var(--ease); }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(16, 26, 61, .3); transition: transform .2s var(--ease);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(36, 87, 214, .45); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

.game-head .notice { margin-top: 2px; }

.tabs { display: flex; gap: 2px; margin: 20px 0 22px; border-bottom: 1.5px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; color: var(--ink-3); font-weight: 700; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1.5px; height: 3px; border-radius: 3px 3px 0 0; background: var(--blue); }
.tab-count { padding: 1px 9px; border-radius: 999px; background: var(--blue-50); color: var(--blue); font-size: 14px; }

.sm { display: none; }

.tab-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 18px; }
.tab-head .lead { margin: 0; }

/* ---------- участники ---------- */

.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .search { position: relative; min-width: 0; }
.toolbar .search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.toolbar .search .input { padding-left: 44px; }
.toolbar .filters { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.toolbar-actions { display: flex; gap: 10px; }

.list-count { margin: 0 2px 8px; color: var(--ink-3); font-size: 14px; }

.people { margin: 0; padding: 0; list-style: none; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.prow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name weight" "group cat" "club actions";
  align-items: center; gap: 4px 12px; padding: 12px 14px; border-top: 1px solid var(--line);
}
.prow.head { display: none; }
.prow:not(.head):hover { background: #fafbfe; }
.prow[data-id] { cursor: pointer; }
.prow[data-id]:hover { background: var(--blue-50); }
.p-name { grid-area: name; min-width: 0; }
.p-weight { grid-area: weight; justify-self: end; }
.p-group { grid-area: group; color: var(--ink-2); font-size: 15px; }
.p-cat { grid-area: cat; justify-self: end; color: var(--ink-3); font-size: 14px; }
.p-club { grid-area: club; min-width: 0; font-size: 15px; }
.p-actions { grid-area: actions; justify-self: end; display: flex; gap: 2px; }
.p-name span, .p-club small { display: block; color: var(--ink-3); font-size: 14px; }
.p-club small { overflow-wrap: anywhere; }
.name-btn { padding: 0; border: 0; background: none; color: var(--ink); font-size: 17px; font-weight: 800; text-align: left; letter-spacing: -.01em; }
.name-btn:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.icon-btn.is-danger:hover { background: var(--red-50); color: var(--red-d); }

.placard {
  display: inline-grid; place-items: center; min-width: 64px; padding: 6px 12px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 16px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums;
}

/* ---------- панель справа ---------- */

dialog.drawer {
  width: min(540px, 100vw); max-width: none; height: 100vh; height: 100dvh; max-height: none;
  margin: 0 0 0 auto; padding: 0; border-radius: 24px 0 0 24px; overflow: hidden;
}
dialog.drawer[open] { display: flex; animation: drawer-in .24s var(--ease); }
dialog.drawer::backdrop { background: rgba(16, 26, 61, .5); }
@keyframes drawer-in { from { opacity: 0; transform: translateX(36px); } }

.drawer-form { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 10px 12px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 22px; font-weight: 800; }
.drawer-body { flex: 1; display: grid; align-content: start; gap: 18px; padding: 22px 24px 28px; overflow-y: auto; overscroll-behavior: contain; }
.drawer-lead { color: var(--ink-2); }
.drawer-foot {
  display: flex; align-items: center; gap: 8px; padding: 14px 24px; padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: #fff;
}
.drawer-foot .spacer { flex: 1; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.picks:empty { display: none; }
.pick {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1.5px dashed var(--line-2);
  border-radius: 999px; background: #fff; color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.pick:hover { border-color: var(--blue); color: var(--blue); }
.pick.is-on { border-style: solid; border-color: var(--blue); background: var(--blue-50); color: var(--blue); }
.admin .seg label { font-size: 16px; }

/* ---------- быстрый ввод списком ---------- */

.quick-text { min-height: 170px; line-height: 1.55; font-size: 16px; }
.quick-preview:empty { display: none; }
.q-summary { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; font-weight: 600; }
.q-summary.has-errors { color: var(--red-d); }
.qlist { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.qrow {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px;
}
.qrow > div { min-width: 0; overflow-wrap: anywhere; }
.qrow small { display: block; margin-top: 2px; color: var(--ink-2); font-size: 14px; }
.q-icon { display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; }
.q-year { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.q-weight { font-weight: 700; color: var(--ink); }
.q-raw { font-weight: 600; }
.qrow.is-ok .q-icon { background: var(--green-50); color: var(--green); }
.qrow.is-dup { background: var(--mist); }
.qrow.is-dup .q-icon { background: var(--amber-50); color: var(--amber); }
.qrow.is-error { border-color: #f3b9be; background: var(--red-50); }
.qrow.is-error .q-icon { background: #fff; color: var(--red-d); }
.qrow.is-error small { color: var(--red-d); }
.qrow.is-header { grid-template-columns: 22px minmax(0, 1fr); border-style: dashed; background: transparent; color: var(--ink-2); }
.qrow.is-header .q-icon { background: var(--blue-50); color: var(--blue); }

/* ---------- весовые категории ---------- */

.gpanels { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); }
.gpanel { display: grid; align-content: start; gap: 14px; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.gpanel header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.gpanel h3 { font-size: 18px; font-weight: 800; }
.plaques { display: flex; flex-wrap: wrap; gap: 10px; }
.plaque {
  position: relative; min-width: 66px; min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums;
  transition: background-color .15s var(--ease), transform .1s var(--ease);
}
.plaque:hover { background: #1c2b61; }
.plaque:active { transform: scale(.97); }
.plaque small {
  position: absolute; top: -8px; right: -8px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px;
  border: 2px solid #fff; border-radius: 999px; background: var(--red); font-size: 12px; font-weight: 800;
}
.adder { display: flex; gap: 8px; }
.adder .input { flex: 1; min-width: 0; }
.gempty > summary { display: flex; align-items: center; min-height: 48px; color: var(--ink-2); font-weight: 700; cursor: pointer; }
.gempty > .gpanels { margin-top: 8px; }

/* ---------- настройки ---------- */

.settings { display: grid; gap: 16px; max-width: 720px; }
.panel { display: grid; gap: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.panel h2 { font-size: 20px; }
.panel-foot { display: flex; justify-content: flex-end; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; min-width: 0; }
.danger-zone { border-color: #f1c2c7; }
.danger-zone .btn { justify-self: start; }

/* ---------- клубы ---------- */

.clubs { display: grid; gap: 10px; }
details.club { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
details.club > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 22px; align-items: center; gap: 4px 18px;
  min-height: 66px; padding: 12px 18px; list-style: none; cursor: pointer;
}
details.club > summary::-webkit-details-marker { display: none; }
details.club > summary:hover { background: #fafbfe; }
.club-name b { font-size: 18px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.club-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { padding: 2px 9px; border-radius: 7px; background: var(--mist); color: var(--ink-2); font-size: 13px; font-weight: 700; }
.club-counts { display: flex; gap: 18px; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.club-counts b { color: var(--ink); font-size: 16px; }
details.club .chev { color: var(--ink-3); transition: transform .2s var(--ease); }
details.club[open] .chev { transform: rotate(90deg); }
.club-body { display: grid; gap: 14px; padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.trainers { margin: 0; padding: 0; list-style: none; display: grid; }
.trainers li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 2px; border-bottom: 1px solid var(--mist); font-weight: 600; }
.trainers li:last-child { border-bottom: 0; }
.row-actions { display: inline-flex; }
.club-tools { display: flex; justify-content: flex-start; }

/* ---------- планшет и телефон ---------- */

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }

  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    padding: 6px 6px 6px 16px; padding-top: calc(6px + env(safe-area-inset-top)); background: var(--ink); color: #fff;
  }
  .topbar-brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; text-decoration: none; }
  .topbar .icon-btn { color: rgba(255, 255, 255, .85); }
  .topbar .icon-btn:hover { background: rgba(255, 255, 255, .12); }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr);
    padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: #fff;
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 60px; border: 0; background: none;
    color: var(--ink-3); font-size: 12px; font-weight: 700; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .tabbar [aria-current="page"] { color: var(--blue); }
  .main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  .page { padding: 20px 16px 36px; }
  .page-head h1, .game-title h1 { font-size: 28px; }
  .page-head .btn { width: 100%; }
}

@media (max-width: 700px) {
  .lg { display: none; }
  .sm { display: inline; }
  .tabs a { padding: 0 12px; }

  .game-row { grid-template-columns: 56px minmax(0, 1fr) 20px; gap: 6px 14px; padding: 12px 14px; }
  .date-block { width: 56px; height: 56px; }
  .date-block b { font-size: 24px; }
  .game-side { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; }
  .game-row .chev { grid-column: 3; grid-row: 1 / span 2; }

  .game-actions { gap: 4px 12px; }
  .action-buttons { width: 100%; }
  .action-buttons .btn { flex: 1 1 0; }

  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .toolbar > .toolbar-actions { order: -1; }
  .toolbar-actions .btn { flex: 1 1 0; }
  .toolbar .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .filters select:last-child { grid-column: 1 / -1; }

  .pair { grid-template-columns: 1fr; gap: 18px; }
  .gpanels { grid-template-columns: minmax(0, 1fr); }
  .tab-head .btn { width: 100%; }

  details.club > summary { grid-template-columns: minmax(0, 1fr) 22px; }
  .club-counts { grid-column: 1; grid-row: 2; }
  details.club .chev { grid-column: 2; grid-row: 1 / span 2; }

  dialog.drawer {
    width: 100vw; height: auto; max-height: 94vh; max-height: 94dvh; margin: auto 0 0; border-radius: 24px 24px 0 0;
  }
  dialog.drawer[open] { animation-name: sheet-in; }
  .drawer-form { max-height: inherit; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 18px; padding-right: 18px; }
  .drawer-head { padding-right: 8px; }
  .copy-row { flex-direction: column; }
  .login-card { padding: 26px 20px; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(40px); } }

/* Таблица, когда места хватает */
@media (min-width: 1180px) {
  .prow {
    grid-template-columns: minmax(170px, 1.3fr) minmax(130px, 1.1fr) 90px 110px minmax(150px, 1.5fr) 96px;
    grid-template-areas: none; gap: 16px; padding: 12px 18px;
  }
  .prow > * { grid-area: auto; justify-self: auto; }
  .p-actions { justify-content: flex-end; }
  .p-cat { color: var(--ink-2); font-size: 15px; }
  .prow.head { display: grid; border-top: 0; background: var(--mist); color: var(--ink-3); font-size: 14px; font-weight: 700; padding-block: 10px; }
}
