/* Страница «Статистика техники» (/stats). Префикс .ts-.
   Та же логика, что у рейтинга (rating.css): одна разметка строки на всех
   ширинах, на ПК сетка-таблица, на мобиле строка раскладывается карточкой. */

.ts {
  --ts-panel: rgba(15, 15, 17, 0.55);
  --ts-blue: #4fa8ff;
  --ts-purple: #b968ff;
  --ts-red: #ff6a6a;
  /* #, танк, игроков, бои, победы, урон, опыт, фраги, выж., точн., кф, шеврон */
  --ts-cols: 44px minmax(13rem, 1fr) 88px 88px 96px 88px 84px 76px 76px 80px 72px 24px;
  color: var(--text);
}
@media (max-width: 1360px) {
  .ts-c-ratio { display: none; }
  .ts { --ts-cols: 44px minmax(12rem, 1fr) 84px 84px 96px 88px 80px 72px 72px 76px 24px; }
}
@media (max-width: 1180px) {
  .ts-c-battles, .ts-c-acc { display: none; }
  .ts { --ts-cols: 40px minmax(11rem, 1fr) 80px 96px 88px 80px 72px 72px 24px; }
}
@media (max-width: 1000px) {
  .ts-c-frags { display: none; }
  .ts { --ts-cols: 40px minmax(10rem, 1fr) 80px 96px 88px 80px 72px 24px; }
}

/* ---- шапка: выборка ---- */
.page-hero--tstats .page-hero-inner { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.page-hero--tstats .page-hero-head { flex: 1 1 30rem; min-width: 0; }
.ts-sample { flex: 0 0 auto; display: flex; gap: 14px; color: var(--text-dim); font-size: 13px; }
.ts-sample b { display: block; color: var(--text); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* ---- группы игроков ---- */
.ts-groups { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.ts-group {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text-dim);
  cursor: pointer; font: inherit; transition: border-color 0.15s, background 0.15s;
}
.ts-group:hover { border-color: var(--border-strong); }
.ts-group.active { background: var(--surface-2); border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.ts-group .ts-g-label { font-size: 13px; font-weight: 600; }
.ts-group .ts-g-n { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ts-group .ts-g-sub { font-size: 11px; color: var(--text-faint); }
.ts-group[data-key="lt50"] .ts-g-label { color: var(--text-dim); }
.ts-group[data-key="b50"] .ts-g-label { color: var(--green); }
.ts-group[data-key="b60"] .ts-g-label { color: var(--ts-blue); }
.ts-group[data-key="b70"] .ts-g-label { color: var(--ts-purple); }

/* ---- панель фильтров ---- */
.ts-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.ts-search {
  flex: 1 1 200px; min-width: 160px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit;
}
.ts-search:focus { outline: none; border-color: var(--accent); }
.ts-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ts-chip {
  padding: 6px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font: inherit; font-size: 13px; cursor: pointer; line-height: 1;
}
.ts-chip:hover { border-color: var(--border-strong); color: var(--text); }
.ts-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ts-chip img { width: 18px; height: 18px; vertical-align: -4px; opacity: 0.85; }
.ts-chip.active img { filter: brightness(0.2); }
.ts-sep { width: 1px; height: 22px; background: var(--line); }
.ts-select { padding: 7px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 13px; }
.ts-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; }
.ts-toggle input { accent-color: var(--accent); }
.ts-count { margin-left: auto; font-size: 13px; color: var(--text-faint); }

/* ---- таблица ---- */
.ts-table { background: var(--ts-panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ts-head, .ts-row {
  display: grid; grid-template-columns: var(--ts-cols); align-items: center; gap: 6px; padding: 0 10px;
}
.ts-head { position: sticky; top: 0; z-index: 2; background: #141416; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.ts-head > div { padding: 10px 4px; white-space: nowrap; }
.ts-head .ts-sort { cursor: pointer; user-select: none; }
.ts-head .ts-sort:hover { color: var(--text); }
.ts-head .ts-sort.active { color: var(--accent); }
.ts-head .ts-sort.active::after { content: ' ▾'; }
.ts-head .ts-sort.active.asc::after { content: ' ▴'; }
.ts-row { min-height: 52px; border-top: 1px solid var(--line-soft); cursor: pointer; transition: background 0.12s; }
.ts-row:hover { background: rgba(255, 255, 255, 0.03); }
.ts-row.open { background: rgba(255, 201, 77, 0.05); }
.ts-row > div { padding: 6px 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-c-num, .ts-c-players, .ts-c-battles, .ts-c-wr, .ts-c-dmg, .ts-c-xp, .ts-c-frags, .ts-c-surv, .ts-c-acc, .ts-c-ratio { text-align: right; }
.ts-c-num { color: var(--text-faint); font-size: 13px; }
.ts-c-tank { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ts-c-tank img { width: 56px; height: 36px; object-fit: contain; flex: 0 0 auto; }
.ts-tank-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-tank-meta { font-size: 12px; color: var(--text-faint); display: flex; gap: 6px; align-items: center; }
.ts-tank-meta img { width: 14px; height: 14px; opacity: 0.75; }
.ts-small { font-size: 11px; color: var(--amber); }
.ts-c-wr { font-weight: 700; }
.ts-wr-green { color: var(--green); } .ts-wr-blue { color: var(--ts-blue); } .ts-wr-purple { color: var(--ts-purple); } .ts-wr-red { color: var(--ts-red); }
.ts-c-chev { color: var(--text-faint); text-align: center; transition: transform 0.15s; }
.ts-row.open .ts-c-chev { transform: rotate(180deg); }

/* ---- раскрытая строка: группы на этой машине ---- */
.ts-detail { border-top: 1px solid var(--line-soft); background: rgba(0, 0, 0, 0.25); padding: 10px 12px 14px; }
.ts-detail h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); font-weight: 600; display: flex; gap: 14px; flex-wrap: wrap; }
.ts-detail .ts-marks { font-weight: 500; color: var(--amber); }
.ts-dt-row { display: grid; grid-template-columns: 7.5rem repeat(7, minmax(0, 1fr)); gap: 6px; padding: 6px 4px; border-top: 1px solid var(--line-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.ts-dt-row.head { border-top: 0; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.ts-dt-row > span { text-align: right; }
.ts-dt-row > span:first-child { text-align: left; font-weight: 600; }
.ts-dt-row.empty > span { color: var(--text-faint); }
.ts-dt-row .ts-bar { position: relative; height: 3px; background: var(--line-soft); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.ts-dt-row .ts-bar i { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); border-radius: 2px; }
.ts-detail .ts-links { margin-top: 10px; font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.ts-detail .ts-links a { color: var(--accent); }

.ts-empty { padding: 28px; text-align: center; color: var(--text-faint); }
.ts-foot { margin: 12px 2px 0; font-size: 12px; color: var(--text-faint); line-height: 1.5; }

/* ---- мобила: карточки ---- */
@media (max-width: 860px) {
  .ts-groups { gap: 4px; }
  .ts-group { padding: 8px 6px; }
  .ts-group .ts-g-label { font-size: 11px; }
  .ts-group .ts-g-n { font-size: 14px; }
  .ts-group .ts-g-sub { display: none; }
  .ts-sample { display: none; }
  .ts-count { flex-basis: 100%; margin-left: 0; }
  .ts-head { display: none; }
  .ts-row {
    grid-template-columns: 1fr auto; grid-template-areas:
      'tank wr'
      'stats stats';
    gap: 4px 8px; padding: 10px 12px;
  }
  .ts-row > div { padding: 0; }
  .ts-c-num, .ts-c-chev, .ts-c-players, .ts-c-battles, .ts-c-dmg, .ts-c-xp, .ts-c-frags, .ts-c-surv, .ts-c-acc, .ts-c-ratio { display: none; }
  .ts-c-tank { grid-area: tank; }
  .ts-c-wr { grid-area: wr; font-size: 18px; }
  .ts-m-stats { grid-area: stats; display: flex !important; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
  .ts-m-stats b { color: var(--text); font-weight: 600; }
  .ts-dt-row { grid-template-columns: 5.5rem repeat(3, minmax(0, 1fr)); }
  .ts-dt-row > span:nth-child(n+5) { display: none; }
}
@media (min-width: 861px) { .ts-m-stats { display: none; } }
