:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f3f5f9;
  --line: #e3e8f0;
  --line-soft: #eef1f6;
  --text: #1d2737;
  --muted: #67748b;
  --muted-2: #98a3b5;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --group-bg: #e9edf4;
  --zebra-odd: #f5f7fb;
  --debt: #dc2626;
  --blue: #2563eb;
  --shadow: 0 18px 50px -26px rgba(29, 39, 55, 0.35);
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Manrope", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(37, 99, 235, 0.07), transparent 60%),
    radial-gradient(900px 500px at -8% 112%, rgba(13, 148, 136, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Приложение занимает ВСЮ доступную ширину окна (без ограничения max-width),
   поэтому и таблица растягивается на 100% ширины браузера/контейнера. */
.app {
  width: 100%;
  padding: 40px 28px 72px;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 16px;
  flex-wrap: nowrap;
  flex-direction: row;
  margin-bottom: 30px;
}

/* Левый блок: заголовок (eyebrow) и подзаголовок вместе. */
.header-left {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.header-left .subtitle {
  margin-top: 6px;
}

.header-left .eyebrow {
  margin-bottom: 0;
}

.header-actions {
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: flex-start;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
}

.title {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 4.2vw, 44px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.title em {
  font-style: italic;
  color: var(--accent);
}

/* Бейдж версии в заголовке — по нему видно, какой билд запущен. */
.version {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

.version::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  max-width: 640px;
  line-height: 1.5;
}

/* Номер версии в конце подзаголовка — мельче текста на ~30%. */
.version-inline {
  display: inline-block;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  vertical-align: baseline;
  white-space: nowrap;
}

/* ---- Header actions & buttons ---- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.refresh-btn,
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}

.refresh-btn:active,
.export-btn:active {
  transform: translateY(1px);
}

.export-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.export-btn:hover {
  background: #1d4fd7;
}

.export-btn svg {
  color: #ffffff;
}

.refresh-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.refresh-btn:hover {
  border-color: var(--accent);
}

.export-btn:disabled,
.refresh-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---- KPI band ---- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi-main {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.kpi-value.amount {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 21px;
}

.kpi-value.debt {
  color: var(--debt);
}

.kpi-sub {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted-2);
}

/* ---- Controls ---- */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.search {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0 0 12px;
  width: 42px;
  height: 36px;
  cursor: text;
  transition: width 0.25s ease, border-color 0.2s, box-shadow 0.2s, padding 0.25s ease;
  box-shadow: var(--shadow);
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  width: 100%;
  padding: 0 14px;
  height: 42px;
}

.search.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  width: 100%;
  padding: 0 14px;
  height: 42px;
}

.search svg {
  flex-shrink: 0;
  color: var(--muted-2);
}

.search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.search-icon:hover svg {
  color: var(--accent);
}

.search input {
  flex: 1;
  width: 0;
  opacity: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  height: 100%;
  transition: opacity 0.15s ease 0.12s;
}

.search.open input {
  width: auto;
  opacity: 1;
}

.search:focus-within input {
  width: auto;
  opacity: 1;
}

.search input::placeholder {
  color: var(--muted-2);
}

.search-wrap {
  position: relative;
  flex: 1 1 260px;
}

/* Выпадающий список подсказок поиска (команды и турниры) */
.sugg-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px -26px rgba(29, 39, 55, 0.45);
  padding: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.sugg-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
}

.sugg-item:hover {
  background: var(--panel-2);
}

.sugg-kind {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.sugg-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

/* ---- Фильтры (год / турнир) и настройка колонок ---- */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2367748b' stroke-width='2.4'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 12px center;
  background-color: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  max-width: 230px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.clear-btn {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--debt);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.clear-btn:hover {
  border-color: var(--debt);
}

.cols-wrap {
  position: relative;
}

.cols-btn {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 34px 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2367748b' stroke-width='2.4'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 12px center;
  background-color: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px; /* как у фильтров «Год»/«Турнир» */
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.cols-btn.open,
.cols-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cols-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 210px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 24px 60px -24px rgba(29, 39, 55, 0.45);
}

.cols-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.cols-opt:hover {
  background: var(--panel-2);
}

.cols-opt input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.cols-reset {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 6px;
  padding: 9px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cols-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Сводка по турнирам ---- */
.summary {
  margin-bottom: 18px;
  padding: 16px 18px;
}

.summary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.summary-hint {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-2);
}

.summary-clear {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--debt);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.summary-clear:hover {
  border-color: var(--debt);
  background: rgba(220, 38, 38, 0.1);
  color: var(--debt);
}

.summary-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.summary-item {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.15s, background 0.15s;
}

.summary-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.summary-item:hover {
  border-color: var(--accent);
}

.summary-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.summary-item.active .summary-debt {
  color: var(--debt);
}

.summary-year {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}

.summary-name {
  /* −20% к 12.5px базового: название турнира показываем полностью с переносом */
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.summary-count {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.summary-debt {
  text-align: right;
  font-weight: 800;
  font-size: 13px;
  color: var(--debt);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 0;
}

/* ---- Table card: гарантированное заполнение всей ширины ---- */
.card {
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

/* Простая и надёжная таблица: НИКАКИХ процентов и никаких <colgroup>.
   table-layout: fixed + width:100% заставляют таблицу ровно занимать всю
   ширину контейнера; колонки распределяются равномерно и не вылезают за
   пределы. Длинный текст обрезается многоточием (white-space: nowrap
   на ячейках), поэтому таблица никогда не расширяется из-за контента. */
table {
  width: 100% !important;
  max-width: 100% !important;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Заголовки колонок: компактные, с переносом слов на узких экранах,
   чтобы не наезжали друг на друга. */
.head-row th {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 8.4px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  padding: 9px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-row th.num {
  text-align: right;
}

tbody td {
  border-bottom: 1px solid var(--line-soft);
  font-size: 10px;
  vertical-align: middle;
  padding: 10px 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr.row:nth-child(even) {
  background: var(--zebra-odd);
}

tbody tr.row:nth-child(odd) {
  background: #ffffff;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.amount-cell {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.amount-cell.debt {
  color: var(--debt);
}

/* Group header (строка турнира) */
.group-row td {
  background: var(--group-bg);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.group-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.year-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.tournament-name {
  font-weight: 700;
  font-size: 13.5px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.group-total {
  margin-left: auto;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.group-total b {
  color: var(--text);
  font-weight: 700;
}

/* Links in cells */
.cell-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.cell-btn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.no-underline {
  text-decoration: none;
}

.deal-link {
  color: var(--blue);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.deal-link:hover,
.amount-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.amount-link {
  color: inherit;
  text-decoration: none;
}

.empty-debt {
  color: var(--muted-2);
}

/* Grand total */
tfoot .grand td {
  background: var(--panel-2);
  border-top: 2px solid var(--accent);
  padding: 16px 16px;
  font-weight: 800;
}

.grand-label {
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grand-amount {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* States */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  min-height: 320px;
}

.state-icon {
  font-size: 44px;
  margin-bottom: 18px;
}

.state h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 22px;
}

.state p {
  margin: 0;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.5;
}

/* Skeleton */
.skeleton {
  padding: 24px;
}

.sk-row {
  height: 54px;
  border-radius: 10px;
  background: linear-gradient(90deg, #eef1f6 25%, #e4e9f1 42%, #eef1f6 60%);
  background-size: 200% 100%;
  margin-bottom: 10px;
}

.sk-row:last-child {
  margin-bottom: 0;
}

.sk-head {
  height: 40px;
  background: #e4e9f1;
  border-radius: 10px;
  margin-bottom: 16px;
}

/* Footer note */
.note {
  margin-top: 20px;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.5;
}

.note a {
  color: var(--blue);
  text-decoration: none;
}

.note a:hover {
  text-decoration: underline;
}

/* ---- Написать бухгалтеру ---- */
.accountant {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.accountant-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.accountant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.accountant-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.accountant-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 20, 33, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(13, 20, 33, 0.6);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-kind {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.modal-close {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: var(--panel-2);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-body {
  padding: 18px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-field-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.card-field-value {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.card-field-value.money {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--debt);
}

.card-link-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}

.card-link-btn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.modal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 24px 24px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.modal-link:hover {
  background: #1d4ed8;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 24px 24px;
}

.modal-actions .modal-link {
  margin: 0;
}

.modal-link.external {
  background: var(--text);
}

.modal-link.external:hover {
  background: #2a3a52;
}

/* ---- Всплывающий индикатор загрузки ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(238, 241, 246, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .app {
    padding: 24px 14px 60px;
  }
  .header {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .header-left {
    flex: 1 1 auto;
    min-width: 0;
  }
  .title {
    font-size: 24px;
  }
  .subtitle {
    font-size: 10px;
    max-width: none;
    margin-top: 6px;
    text-align: left;
  }
  .header-actions {
    align-items: flex-start;
    margin-left: 0;
    gap: 8px;
    flex: 0 0 auto;
  }
  .refresh-btn,
  .export-btn {
    flex: 0 0 auto;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
  }
  .refresh-btn .btn-label,
  .export-btn .btn-label {
    display: none;
  }
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrap {
    flex: 0 0 auto;
    width: 100%;
  }
  .filter-select,
  .clear-btn {
    max-width: 100%;
    width: 100%;
  }
  .cols-wrap {
    align-self: flex-start;
  }
  .cols-panel {
    right: auto;
    left: 0;
  }
  .summary-list {
    grid-template-columns: 1fr;
  }
  .summary {
    padding: 14px;
  }
  .summary-head {
    font-size: 15px;
  }
  .search {
    align-self: flex-start;
  }
  .search:focus-within {
    align-self: stretch;
    width: 100%;
  }
  .search.open {
    align-self: stretch;
    width: 100%;
  }
  .kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
  }
  .kpi {
    padding: 14px 14px;
    width: 100%;
  }

  .summary,
  .card,
  .table-wrap {
    width: 100%;
  }
  table {
    min-width: 100%;
  }
  .kpi-main {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .kpi-main .kpi-sub {
    margin-top: 0;
    line-height: 1;
  }
  .kpi-value {
    font-size: 22px;
  }
  .kpi-value.amount {
    font-size: 17px;
  }

  /* Компактнее таблица на узких экранах */
  .head-row th {
    font-size: 8.4px;
    letter-spacing: 0.03em;
    padding: 8px 8px;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15;
  }
  .head-row th.num {
    text-align: right;
  }
  tbody td {
    font-size: 10px;
    padding: 9px 8px;
  }
  .group-row td {
    padding: 10px 8px;
  }
  .year-chip {
    min-width: 0;
    font-size: 13px;
    padding: 3px 8px;
  }
  .tournament-name {
    /* −30% к 13.5px базового: название турнира в шапке группы на узком экране */
    font-size: 9.5px;
  }
  .group-total {
    font-size: 12px;
  }
  .grand-amount {
    /* −39% к 18px базового: компактнее при всех включённых колонках, чтобы сумма
       не выезжала за правый край в итоговой строке */
    font-size: 11px;
  }
  tfoot .grand td {
    padding: 10px 8px;
  }
  .grand-label {
    /* −30% к 13px базового: строка «Всего задолженность» не помещается по ширине */
    font-size: 9px;
    letter-spacing: 0.02em;
  }
  .modal {
    max-width: 100%;
  }
  .modal-body {
    padding: 16px 18px 20px;
  }
}
