* { box-sizing: border-box; }

/* ==========================================================================
   BOROZDOV — токены. Два лика: ОБСИДИАН (по умолчанию) и ТИТАН.
   Лик задаётся data-theme на <html> инлайн-скриптом до отрисовки (index.html).
   Канон: ~/.claude/skills/borozdov-style/references/tokens.md.
   ========================================================================== */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Berkeley Mono", ui-monospace, SFMono-Regular, monospace;

  --r-xs: 2px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --header-h: 66px;
  --title-size: 17px;
  --result-size: 16px;
  --result-mobile-size: 26px;
  --result-weight: 700;
  --maxw: 1320px;
  --cols: 38px minmax(150px,2fr) 1fr 116px 92px 1.75fr 84px;
}

:root,
:root[data-theme="obsidian"] {
  color-scheme: dark;
  --canvas: #0d0d0d;
  --inset: #121212;
  --surface: #1a1a1a;
  --hover: #212121;
  --zebra: #161616;
  --hairline: #2e2e2e;
  --strong: #6b6b6b;
  --slate: #8a8a8a;
  --tertiary: #6b6b6b;
  --soft: #d1d1d1;
  --ink: #fafafa;
  --focus-ring: rgba(250, 250, 250, .22);
  --scrim: rgba(0, 0, 0, .7);
}

:root[data-theme="titan"] {
  color-scheme: light;
  --canvas: #fafafa;
  --inset: #ececec;
  --surface: #ffffff;
  --hover: #f2f2f2;
  --zebra: #f6f6f6;
  --hairline: #e4e4e4;
  --strong: #8a8a8a;
  --slate: #6b6b6b;
  --tertiary: #8a8a8a;
  --soft: #3d3d3d;
  --ink: #0d0d0d;
  --focus-ring: rgba(13, 13, 13, .22);
  --scrim: rgba(13, 13, 13, .45);
}

@keyframes rp-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes rp-sweep { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes rp-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Мгновенная смена лика — глушим transition на время смены (app.js делает reflow) */
.theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: none !important;
}

html, body {
  background: var(--canvas);
  color: var(--ink);
  /* Подстраховка: даже если где-то содержимое всё же окажется шире вьюпорта,
     страница не должна давать горизонтальный скролл/сдвиг. */
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
}
body.sheet-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--canvas); }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb { background: var(--strong); }
::-webkit-scrollbar-thumb:hover { background: var(--ink); }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--canvas);
  color: var(--ink);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--canvas);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand h1 {
  margin: 0; font-size: var(--title-size); font-weight: 600; font-family: var(--font-sans);
  text-transform: uppercase; letter-spacing: -.02em; line-height: 1.1;
}
.brand-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--slate); letter-spacing: .005em; }

.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--slate);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, border-color .15s ease, color .15s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-sun, .icon-moon { transition: transform .3s ease, opacity .2s ease; }
.icon-moon { display: none; }
[data-theme="titan"] .icon-sun { display: none; }
[data-theme="titan"] .icon-moon { display: block; }

/* ---------- Layout ---------- */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 300px minmax(0,1fr);
  gap: 20px;
  align-items: start;
}

/* ---------- Filters ---------- */
.filters {
  position: sticky;
  top: 84px;
  width: 100%;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.filters-sheet-top { display: flex; flex-direction: column; }
.sheet-handle { display: none; }
.filters-heading {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; padding: 0; margin: 0;
  font-family: inherit; text-align: left; cursor: default;
}
.filters-heading strong { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--slate); }
.filters-close-mobile { display: none; margin-left: auto; }

.filter-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px;
  background: var(--ink); color: var(--canvas);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.filters-body { display: flex; flex-direction: column; gap: 15px; }

.filters-footer {
  display: flex; gap: 10px;
  padding-top: 14px;
  margin-top: 2px;
  border-top: 1px solid var(--hairline);
}
.filters-footer #reset-filters { flex: 1; }
.btn.filters-apply-btn { display: none; flex: 2; }

/* Mobile filter trigger (results toolbar) */
.btn.filter-trigger-mobile { display: none; }
.filter-trigger-mobile .filter-count-badge { margin-left: 2px; }

/* Общая подложка для bottom sheet / модалок (шторка фильтров, панель поиска себя) */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Person search (найти себя по дистанциям) ---------- */
.person-search-panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.97);
  width: min(480px, calc(100vw - 32px));
  max-height: 86vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 18px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.person-search-panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.person-search-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.person-search-header strong { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); }
.person-search-hint { margin: 0; font-size: 12px; color: var(--slate); line-height: 1.5; }

.person-search-disciplines { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; padding: 2px; }
.psd-group-label { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--slate); margin-bottom: 4px; }
.psd-options { display: flex; flex-wrap: wrap; gap: 6px; }
.psd-option {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  font-size: 12px; color: var(--slate); cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.psd-option input { accent-color: var(--ink); width: 13px; height: 13px; }
.psd-option.checked { border-color: var(--strong); color: var(--ink); font-weight: 600; }

.person-search-estimate { font-family: var(--font-mono); font-size: 11.5px; color: var(--slate); min-height: 1em; }

/* Панель фильтров визуально отключена (не спрятана), пока идёт поиск себя */
.filters.is-disabled { opacity: .45; pointer-events: none; }

.row-group-label {
  padding: 8px 18px;
  font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em;
  color: var(--slate); background: var(--inset);
  border-bottom: 1px solid var(--hairline);
}
.result-group-label {
  padding: 2px 2px 8px;
  font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em;
  color: var(--slate);
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 11px; font-weight: 500; color: var(--slate); text-transform: uppercase; letter-spacing: .08em; }

.link-btn {
  align-self: flex-start;
  background: none; border: none; padding: 0; margin-top: 1px;
  font-family: inherit; font-size: 11.5px; color: var(--slate);
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
  transition: color .15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .link-btn:hover { color: var(--ink); }
}

.input {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  font-size: 13.5px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--inset);
  color: var(--ink);
  font-family: inherit;
}
.input::placeholder { color: var(--tertiary); }
.input:focus {
  outline: none;
  border-color: var(--strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.range-inputs { display: flex; align-items: center; gap: 7px; position: relative; }
.range-sep { color: var(--slate); flex-shrink: 0; }

/* ---------- Custom select (discipline) ---------- */
.custom-select { position: relative; }
.custom-select-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-align: left; cursor: pointer;
}
.custom-select-trigger svg { flex-shrink: 0; color: var(--slate); transition: transform .2s ease; }
.custom-select-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.custom-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.custom-select-group + .custom-select-group { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.custom-select-group-label {
  padding: 6px 10px 4px;
  font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  color: var(--slate);
}
.custom-select-option {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--ink);
  cursor: pointer; font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.custom-select-option.active { background: var(--ink); color: var(--canvas); font-weight: 600; }

/* ---------- Custom date picker ---------- */
.date-picker { min-width: 0; flex: 1; }
.date-picker-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  text-align: left; cursor: pointer;
}
.date-picker-trigger svg { flex-shrink: 0; color: var(--slate); }
.date-picker-trigger-label {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.date-picker-trigger-label.is-placeholder { color: var(--tertiary); }
.date-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(272px, calc(100vw - 48px));
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  z-index: 30;
  padding: 12px;
}
#date-end-panel { left: auto; right: 0; }
.date-picker-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.date-picker-nav .icon-btn { width: 30px; height: 30px; }
.date-picker-month { font-size: 11px; font-weight: 500; color: var(--slate); text-transform: uppercase; letter-spacing: .08em; }
.date-picker-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.date-picker-weekdays span { display: block; text-align: center; font-size: 10.5px; color: var(--slate); font-weight: 500; }
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-picker-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.date-picker-day.is-outside { color: var(--tertiary); opacity: .6; }
.date-picker-day.is-today { box-shadow: inset 0 0 0 1px var(--strong); font-weight: 700; }
.date-picker-day.is-selected { background: var(--ink); color: var(--canvas); font-weight: 700; }
.date-picker-footer { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--hairline); }
.date-picker-footer .btn { flex: 1; padding: 7px 10px; font-size: 11px; }

.segmented {
  display: flex;
  background: var(--inset);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  flex: 1;
  padding: 7px 6px;
  font-size: 12.5px;
  border: none;
  background: transparent;
  color: var(--slate);
  font-weight: 500;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg-btn.active { background: var(--ink); color: var(--canvas); font-weight: 600; }

.checkbox-field {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.35;
}
.checkbox-field input { margin-top: 2px; accent-color: var(--ink); width: 16px; height: 16px; flex-shrink: 0; }

/* Territory multiselect */
.territory-control { position: relative; display: flex; flex-direction: column; gap: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink);
  color: var(--canvas);
  border-radius: var(--r-sm);
  padding: 4px 5px 4px 10px;
  font-size: 12px;
  font-weight: 600;
  max-width: 100%;
}
.chip-remove {
  border: none; background: transparent; color: inherit;
  width: 16px; height: 16px; border-radius: var(--r-xs);
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: .7;
}
.chip-remove:hover { opacity: 1; }

.territory-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  max-height: 220px;
  overflow-y: auto;
  z-index: 30;
  padding: 5px;
}
.territory-option {
  display: flex; flex-direction: column; gap: 1px;
  width: 100%; text-align: left;
  padding: 7px 10px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
}
.opt-big { font-size: 13px; color: var(--ink); }
.opt-small { font-size: 11px; color: var(--slate); }
.territory-empty { padding: 10px; font-size: 13px; color: var(--slate); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  font-size: 11.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: transform .12s ease, border-color .15s ease, color .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn[hidden] { display: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--ink);
  color: var(--canvas);
  border-color: transparent;
  font-weight: 600;
}

.btn.active { background: var(--ink); color: var(--canvas); border-color: transparent; }
.btn.active .fav-star-icon { fill: currentColor; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--strong); }
  .btn-primary:hover { filter: brightness(.85); }
  .icon-btn:hover { border-color: var(--strong); color: var(--ink); }
  .seg-btn:not(.active):hover { color: var(--ink); }
  .sort-btn:not(.active):hover { border-color: var(--strong); color: var(--ink); }
  .pg-btn:not(.active):not(.ellipsis):hover, .pg-arrow:not(:disabled):hover { border-color: var(--strong); }
  .territory-option:hover { background: var(--hover); }
  .custom-select-option:not(.active):hover { background: var(--hover); }
  .date-picker-day:not(.is-selected):hover { background: var(--hover); }
}

/* ---------- Results toolbar ---------- */
.results-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px;
  margin-bottom: 14px;
}
.result-count { font-family: var(--font-mono); font-size: 12.5px; color: var(--slate); margin-right: auto; font-variant-numeric: tabular-nums; }

.sort-toggle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sort-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--slate); margin-right: 2px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 11px;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--slate);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}
.sort-btn:active { transform: scale(.96); }
.sort-btn.active { background: var(--ink); color: var(--canvas); border-color: transparent; font-weight: 600; }
.sort-btn-icon { flex-shrink: 0; transition: transform .2s ease; }
.sort-btn.is-desc .sort-btn-icon { transform: rotate(180deg); }

/* ---------- Loading / status ---------- */
.loading-bar {
  height: 2px; overflow: hidden;
  background: var(--hairline);
  margin-bottom: 12px;
  position: relative;
}
.loading-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%;
  width: 40%; background: var(--ink);
  animation: rp-sweep 1.1s ease-in-out infinite;
}
.loading-bar[hidden] { display: none; }

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.skeleton-row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--hairline);
}
.skeleton-row:last-child { border-bottom: none; }
.skeleton-block {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--inset), var(--hairline), var(--inset));
  background-size: 200% 100%;
  animation: rp-shimmer 1.3s infinite;
}
.skeleton-num { width: 20px; height: 12px; flex-shrink: 0; }
.skeleton-main { flex: 2; display: flex; flex-direction: column; gap: 6px; }
.skeleton-main .skeleton-block:first-child { width: 52%; height: 13px; }
.skeleton-main .skeleton-block:last-child { width: 34%; height: 9px; }
.skeleton-mid { flex: 1; height: 16px; }
.skeleton-pill { width: 42px; height: 16px; flex-shrink: 0; }

.error-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--strong);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 13.5px;
}
.error-banner span { flex: 1; min-width: 160px; }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--slate);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.empty-icon-wrap {
  width: 60px; height: 60px;
  border-radius: var(--r-lg);
  background: var(--inset);
  color: var(--slate);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.empty-title { font-size: 14.5px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty-sub { font-size: 13px; margin-bottom: 18px; }

/* ---------- Results grid (desktop) ---------- */
.results-grid {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 14px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--hairline);
  align-items: center;
}
.row:last-child { border-bottom: none; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.row:not(.row-head) { animation: rp-rise .28s ease both; }
.row-head {
  font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em;
  color: var(--slate); background: var(--inset);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.cell-index { color: var(--slate); font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }

.cell-athlete { min-width: 0; }
.athlete-name { font-weight: 700; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.athlete-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: 11.5px; color: var(--slate); align-items: center; }

.rank-badge {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: var(--r-xs);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.rank-elite { background: var(--ink); color: var(--canvas); }
.rank-ms    { border: 1px solid var(--strong); color: var(--soft); }
.rank-mono  { padding: 0; border-radius: 0; color: var(--slate); font-weight: 600; }

.cell-discipline { font-size: 12.5px; color: var(--slate); line-height: 1.3; min-width: 0; }
.pool-tag {
  display: inline-block; margin-left: 6px;
  font-size: 10px; font-weight: 500; color: var(--slate);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xs); padding: 0 5px; white-space: nowrap;
}

.result-value { color: var(--ink); font-family: var(--font-mono); font-size: var(--result-size); font-weight: var(--result-weight); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.aqua-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 600;
  color: var(--soft);
}

.cell-event { font-size: 12.5px; line-height: 1.35; min-width: 0; }
.cell-event .event-tournament { color: var(--ink); font-weight: 600; text-wrap: pretty; }
.event-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--slate); font-size: 11.5px; margin-top: 2px; }

.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.fav-star, .row-export {
  height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  color: var(--slate); cursor: pointer; flex-shrink: 0;
  transition: color .15s ease, border-color .15s ease, transform .12s ease;
}
.fav-star { width: 28px; }
.row-export {
  padding: 0 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px; font-weight: 600; letter-spacing: .5px;
}
.fav-star:active, .row-export:active { transform: scale(.92); }
.fav-star.is-fav { color: var(--ink); border-color: var(--strong); }
.fav-star.is-fav svg { fill: currentColor; }
.row-export:disabled { opacity: .4; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .fav-star:hover, .row-export:not(:disabled):hover { border-color: var(--strong); color: var(--ink); }
}

/* ---------- Results cards (mobile) ---------- */
.results-cards { display: flex; flex-direction: column; gap: 9px; }
.result-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 13px 14px;
  animation: rp-rise .28s ease both;
}
.result-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-card-head-right { display: flex; align-items: center; gap: 8px; }
.result-card-pos { color: var(--slate); font-family: var(--font-mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-card-aqua { display: inline-flex; align-items: center; gap: 5px; }
.result-card-aqua-label { font-size: 10px; color: var(--slate); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; }
.result-card-name { margin-top: 7px; font-weight: 700; font-size: 15.5px; color: var(--ink); }
.result-card-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: 4px; font-size: 11.5px; color: var(--slate); align-items: center; }
.result-card-main { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; }
/* flex-элементы по умолчанию не сжимаются уже своего контента (min-width:auto) — длинное
   название дисциплины без этого раздвигало карточку шире экрана и давало горизонтальный
   скролл всей странице. Время — flex-shrink:0 (никогда не обрезается), дисциплина — сжимается
   и обрезается многоточием первой. */
.result-card-result { color: var(--ink); font-family: var(--font-mono); font-size: var(--result-mobile-size); font-weight: var(--result-weight); font-variant-numeric: tabular-nums; letter-spacing: -.015em; line-height: 1; flex-shrink: 0; }
.result-card-disc { font-size: 12px; color: var(--slate); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-card-footer { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--hairline); font-size: 12px; color: var(--slate); line-height: 1.35; }
.result-card-tournament { color: var(--ink); font-weight: 600; }
.result-card-footer-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- Pager ---------- */
.pager { display: flex; flex-direction: column; align-items: center; gap: 9px; margin-top: 20px; }
.pager[hidden] { display: none; }
.pager-buttons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pg-btn {
  min-width: 34px; height: 34px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 600;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--hairline);
  background: transparent; color: var(--ink);
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.pg-btn:active { transform: scale(.94); }
.pg-btn.active { background: var(--ink); color: var(--canvas); border-color: transparent; }
.pg-btn.ellipsis { min-width: 22px; border: none; background: transparent; color: var(--slate); cursor: default; }
.pg-btn:disabled:not(.active) { opacity: .45; cursor: default; }
.pg-arrow {
  min-width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: transparent; color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.pg-arrow:active:not(:disabled) { transform: scale(.94); }
.pg-arrow:disabled { color: var(--slate); opacity: .45; cursor: default; }
.pager-caption { font-family: var(--font-mono); font-size: 12px; color: var(--slate); font-variant-numeric: tabular-nums; }
.pager.is-loading .pager-caption { color: var(--ink); animation: rp-pulse 1s ease-in-out infinite; }

@keyframes rp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- Responsive ---------- */
.disp-desktop { display: block; }
.disp-mobile { display: none; }

/* Десктоп — app-shell: страница не скроллится, скроллится только таблица.
   Шапка, фильтры, тулбар и пейджер всегда на месте. */
@media (min-width: 1000px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: flex; flex-direction: column; }
  .topbar { flex-shrink: 0; }

  .layout {
    flex: 1;
    min-height: 0; /* без этого grid-потомок flex-колонки не ужимается и таблица не получает свой скролл */
    width: 100%;
    align-items: stretch;
  }
  .filters {
    position: static; /* sticky не нужен — страница больше не скроллится */
    align-self: start;
  }
  .results { display: flex; flex-direction: column; min-height: 0; }
  .results-toolbar, #status-banner, .pager { flex-shrink: 0; }
  .results-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  .row-head { position: sticky; top: 0; z-index: 5; }
  .pager { margin-top: 14px; }
}

@media (max-width: 999px) {
  .layout { grid-template-columns: 1fr; }
  .disp-desktop { display: none; }
  .disp-mobile { display: block; }

  .btn.filter-trigger-mobile { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; }

  .results-toolbar {
    position: sticky;
    top: var(--header-h, 66px);
    z-index: 20;
    background: var(--canvas);
    margin: 0 -20px 14px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--hairline);
  }

  /* Bottom sheet — обычная карточка; глубина только у подложки (scrim+blur) */
  .filters {
    position: fixed;
    inset: auto 0 0 0;
    width: auto;
    max-height: 88vh;
    overflow-y: auto;
    margin: 0;
    z-index: 60;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: none;
    padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform .32s cubic-bezier(.32,.72,0,1);
  }
  .filters.open { transform: translateY(0); }
  .filters[aria-hidden="true"] { pointer-events: none; }

  .filters-sheet-top { position: sticky; top: 0; z-index: 2; background: var(--surface); flex-shrink: 0; }
  .sheet-handle { display: block; width: 36px; height: 4px; border-radius: var(--r-xs); background: var(--hairline); margin: 0 auto 10px; flex-shrink: 0; }
  .filters-close-mobile { display: flex; }
  .filters-body { padding-bottom: 4px; }

  .filters-footer { position: sticky; bottom: 0; z-index: 2; background: var(--surface); }
  .btn.filters-apply-btn { display: inline-flex; }

  .seg-btn { padding: 10px 6px; }
  .pg-btn, .pg-arrow { min-width: 40px; height: 40px; font-size: 14px; }
}

@media (max-width: 480px) {
  .topbar-inner { padding: 12px 16px; }
  .brand-sub { display: none; }
  .layout { padding: 16px 12px 30px; }
  .results-toolbar { gap: 8px 10px; margin: 0 -12px 12px; padding: 10px 12px; }
  .sort-toggle { width: 100%; }
  .filter-trigger-mobile { width: 100%; justify-content: center; }
}
