/* ============ Warchest UI ============ */
:root {
  --bg: #080b11;
  --bg-2: #0b1018;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #e9eef7;
  --muted: #8b98ac;
  --gold: #f2b53c;
  --gold-2: #ffd479;
  --win: #4ade80;
  --loss: #fb7185;
  --win-soft: rgba(74, 222, 128, 0.13);
  --loss-soft: rgba(251, 113, 133, 0.13);
  --radius: 16px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(242, 181, 60, 0.13), transparent 60%),
    radial-gradient(760px 420px at 92% -4%, rgba(88, 128, 255, 0.12), transparent 62%),
    radial-gradient(900px 600px at 50% 115%, rgba(120, 60, 180, 0.1), transparent 65%);
}

a { color: var(--gold-2); text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 24px;
  background: rgba(8, 11, 17, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  color: #1b1305;
  background: linear-gradient(150deg, var(--gold-2), #d2900f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 10px 22px -12px rgba(242, 181, 60, 0.9);
  flex: none;
}

.brand-text h1 { font-size: 17px; letter-spacing: 0.01em; }
.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.select {
  appearance: none;
  background: rgba(255, 255, 255, 0.05) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%238b98ac' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 30px 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  cursor: pointer;
  max-width: 220px;
}
.select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.15); }
.select-sm {
  padding: 5px 26px 5px 9px;
  font-size: 12px;
  border-radius: 8px;
  background-position: right 8px center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }

.btn-primary {
  color: #1b1305;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: transparent;
  box-shadow: 0 10px 24px -12px rgba(242, 181, 60, 0.9);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffe09a, #f7be4d); }

.btn-ghost { background: transparent; }
.btn-danger { color: #ffb3bd; border-color: rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.08); }
.btn-danger:hover { background: rgba(251, 113, 133, 0.16); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 7px 9px; border-radius: 8px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon svg { display: block; }
.plus { display: inline-flex; align-items: center; }

/* ---------- layout ---------- */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1420px;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.view { display: none; animation: fadeUp 0.25s ease; }
.view.is-active { display: block; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.view-head h2 { font-size: 22px; letter-spacing: -0.02em; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid-kpi { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
.grid-2-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.016));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 14.5px; letter-spacing: 0.01em; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.kpi {
  position: relative;
  overflow: hidden;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
}
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.kpi-value {
  margin-top: 6px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* ---------- player chips ---------- */
.pchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.pchip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--gold));
  flex: none;
  box-shadow: 0 0 8px -1px var(--c, var(--gold));
}
.pchip.is-win { background: var(--win-soft); border-color: rgba(74, 222, 128, 0.22); }
.pchip.is-loss { background: var(--loss-soft); border-color: rgba(251, 113, 133, 0.2); }
.pchip.is-muted { opacity: 0.55; }
.pchip.is-clickable { cursor: pointer; }
.pchip.is-clickable:hover { background: rgba(255, 255, 255, 0.1); }

.team-line { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.vs { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; padding: 0 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  position: sticky;
  top: 0;
  background: #0d121b;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.028); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .pos { color: var(--win); font-weight: 600; }
.table .neg { color: var(--loss); font-weight: 600; }

.rank {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rank.r1 { background: linear-gradient(160deg, #ffd479, #d2900f); color: #1b1305; }
.rank.r2 { background: linear-gradient(160deg, #dfe7f5, #94a3b8); color: #141a24; }
.rank.r3 { background: linear-gradient(160deg, #e8b48a, #b06f3d); color: #1c1208; }

.player-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #10141c;
  flex: none;
  box-shadow: inset 0 -8px 14px -8px rgba(0, 0, 0, 0.5);
}
.player-name { font-weight: 600; }
.player-tag { font-size: 11px; color: var(--muted); }

.wr { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; min-width: 62px; }
.wr > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #c98b16, var(--gold-2)); }
.wr.is-loss > span { background: linear-gradient(90deg, #a3455a, var(--loss)); }

.form { display: inline-flex; gap: 3px; }
.form i { width: 7px; height: 7px; border-radius: 2px; background: var(--win); opacity: 0.9; }
.form i.l { background: var(--loss); }

/* ---------- matches ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search {
  flex: 1;
  min-width: 220px;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  font-size: 13.5px;
}
.search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.14); }
.search::placeholder { color: #5f6b7e; }

.match-list { display: grid; gap: 8px; }

.match-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.022);
  transition: background 0.14s, border-color 0.14s;
}
.match-row:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); }
.match-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.match-date b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.match-teams { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.team-group { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.match-note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.match-actions { display: flex; gap: 6px; opacity: 0.45; transition: opacity 0.15s; }
.match-row:hover .match-actions, .match-row:focus-within .match-actions { opacity: 1; }
.match-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
}
.match-badge.warn { background: rgba(251, 113, 133, 0.14); color: #fda4af; }

.pager { display: flex; justify-content: center; margin-top: 14px; }
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 13.5px;
}

/* ---------- players ---------- */
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.player-card {
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.player-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.player-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--c);
  opacity: 0.85;
}
.player-card.is-archived { opacity: 0.5; }
.pc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pc-head.is-clickable, .pc-body.is-clickable { cursor: pointer; }
.pc-head.is-clickable:hover .pc-name { color: var(--gold-2); }
.pc-body.is-clickable:hover .ring { transform: scale(1.03); }
.ring { transition: transform 0.15s; }
.pc-head .avatar { width: 38px; height: 38px; font-size: 14px; }
.pc-name { font-size: 15px; font-weight: 700; }
.pc-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pc-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pc-stats { display: flex; gap: 14px; }
.pc-stat { font-size: 11.5px; color: var(--muted); }
.pc-stat b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #0c1119; }
.ring span { position: relative; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.pc-elo { font-size: 12px; color: var(--muted); white-space: nowrap; flex: none; }
.pc-elo b { color: var(--text); font-size: 13px; }
.pc-actions { display: flex; gap: 4px; }

.add-player {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.012);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  font-size: 13.5px;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 181, 60, 0.14); }
.input[type="date"] { color-scheme: dark; }
.input[type="color"] { padding: 3px; height: 38px; cursor: pointer; }

/* ---------- analysis ---------- */
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-row.is-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.chips-row.is-scroll::-webkit-scrollbar { height: 5px; }
.chips-row.is-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 99px; }
.chips-row.is-scroll .pchip { flex: none; }
.focus-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chart-box { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: rgba(255, 255, 255, 0.065); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 10.5px; }
.chart-empty { fill: var(--muted); font-size: 13px; }
.chart-crosshair { stroke: rgba(255, 255, 255, 0.35); stroke-dasharray: 3 3; }
.chart-tooltip {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(9, 13, 20, 0.97);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 34px -18px #000;
  font-size: 12px;
  min-width: 132px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s;
}
.chart-tooltip.show { opacity: 1; transform: none; }
.tip-title { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.tip-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; padding: 1px 0; }
.tip-row i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.tip-row b { font-variant-numeric: tabular-nums; }

.bar-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 12.5px;
}
.bar-label { display: flex; align-items: center; gap: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-label i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.bar-track { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-sub { color: var(--muted); font-weight: 500; margin-left: 3px; font-size: 11px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.season-table td:first-child { font-weight: 600; }

/* ---------- сезоны ---------- */
.matrix th, .matrix td { padding: 7px 9px; }
.matrix .matrix-name {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 168px;
  background: #0d121b;
}
.matrix tbody tr:hover .matrix-name { background: #0f1520; }
.mcell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.mcell.is-empty { background: transparent !important; color: var(--muted); }
.mcell.is-out { opacity: 0.38; }
.matrix-row { cursor: pointer; }
.matrix-row.is-focus td { box-shadow: inset 0 0 0 1px rgba(242, 181, 60, 0.35); }
.matrix-total { font-weight: 700; }
.rating-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.06);
}
.rating-badge.pos { color: var(--win); background: rgba(74, 222, 128, 0.12); }
.rating-badge.neg { color: var(--loss); background: rgba(251, 113, 133, 0.12); }
.author-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }

/* расходящиеся полосы «рейтинг по сезонам» */
.divbar-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 44px; gap: 10px; align-items: center; padding: 3px 0; font-size: 12px; }
.divbar-label { color: var(--muted); font-variant-numeric: tabular-nums; }
.divbar-track { position: relative; height: 16px; border-radius: 5px; background: rgba(255, 255, 255, 0.04); }
.divbar-track::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.18); }
.divbar-fill { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; background: linear-gradient(90deg, #2f9e5f, var(--win)); }
.divbar-fill.neg { background: linear-gradient(90deg, var(--loss), #a3455a); }
.divbar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.divbar-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; padding-left: 56px; }
.season-summary { margin-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 12px; display: grid; gap: 7px; }
.season-summary div { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.season-summary span { color: var(--muted); }
.season-summary b { font-variant-numeric: tabular-nums; }

/* ---------- лидер периода ---------- */
.leader-hero { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.leader-hero .avatar { width: 44px; height: 44px; font-size: 16px; }
.leader-name { font-size: 17px; font-weight: 700; }
.leader-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.leader-value span {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.leader-rows { display: grid; gap: 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 12px; }
.leader-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.leader-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- календарь активности ---------- */
.heat-cell { cursor: pointer; transition: stroke 0.1s; }
.heat-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
.heat-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.heat-legend span { margin: 0 4px; }
.heat-0 { background: rgba(255, 255, 255, 0.05); }
.heat-1 { background: rgba(242, 181, 60, 0.28); }
.heat-2 { background: rgba(242, 181, 60, 0.5); }
.heat-3 { background: rgba(242, 181, 60, 0.75); }
.heat-4 { background: #f2b53c; }
.tip-note { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ---------- карточка игрока в модалке ---------- */
.player-summary { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ps-ring { width: 72px; height: 72px; }
.ps-ring span { font-size: 15px; }
.ps-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; flex: 1; min-width: 220px; }
.ps-stats div { display: grid; gap: 2px; }
.ps-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.ps-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.modal-subtitle {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.mini-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12.5px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row .player-tag { margin-left: auto; }
.mini-row b { min-width: 44px; text-align: right; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 5, 9, 0.8);
  backdrop-filter: blur(8px);
  animation: fade 0.15s ease;
}
.modal {
  width: min(780px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #121a28, #0b1018 60%);
  box-shadow: 0 40px 100px -40px #000;
  animation: pop 0.18s ease;
}
.modal.is-small { width: min(460px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}
.modal-head h3 { font-size: 17px; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 0 20px 8px; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 14px;
}
.modal-foot .left { margin-right: auto; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  gap: 3px;
}
.segmented button {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.segmented button.is-active { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.segmented button.is-active.win { background: rgba(74, 222, 128, 0.18); color: #b6f3ca; }
.segmented button.is-active.loss { background: rgba(251, 113, 133, 0.18); color: #ffc2cb; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.team-box {
  min-height: 108px;
  padding: 11px;
  border-radius: 13px;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.018);
  transition: border-color 0.15s, background 0.15s;
}
.team-box.is-win { border-color: rgba(74, 222, 128, 0.32); background: rgba(74, 222, 128, 0.05); }
.team-box.is-loss { border-color: rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.045); }
.team-box.is-target { box-shadow: 0 0 0 2px rgba(242, 181, 60, 0.3) inset; }
.team-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}
.team-title .count { color: var(--text); }
.team-empty { font-size: 12px; color: #5f6b7e; padding: 6px 2px; }

.pool { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pool .pchip { padding: 5px 11px; font-size: 12.5px; }
.pool .pchip.is-picked { opacity: 0.35; text-decoration: line-through; }

.form-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 16px; }
.form-hint.is-error { color: #fda4af; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; }
.toast {
  padding: 11px 15px;
  border-radius: 11px;
  background: rgba(15, 21, 31, 0.97);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 44px -22px #000;
  font-size: 13px;
  animation: slideIn 0.2s ease;
  max-width: 340px;
}
.toast.ok { border-color: rgba(74, 222, 128, 0.35); }
.toast.err { border-color: rgba(251, 113, 133, 0.4); }

/* ---------- footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 18px 24px 30px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.footer-right { display: flex; gap: 14px; }
.link:hover { text-decoration: underline; }

/* ---------- animations ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(8px); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } }

/* ---------- встраивание в APK (WebView) ---------- */
body.is-embedded .brand { display: none; }
body.is-embedded .topbar { padding-top: 8px; }
body.is-embedded #view-dashboard .view-head .btn-primary,
body.is-embedded #view-matches .view-head .btn-primary,
body.is-embedded #view-players .view-head .btn-primary { display: none; }
body.is-embedded .footer { padding-bottom: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-2-even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
  .table-leader th:nth-child(2), .table-leader td:nth-child(2),
  .table-leader th:nth-child(3), .table-leader td:nth-child(3),
  .table-leader th:nth-child(6), .table-leader td:nth-child(6),
  .table-leader th:nth-child(7), .table-leader td:nth-child(7) { display: none; }
  .table-leader th, .table-leader td { padding: 9px 6px; }
  .table-leader td:nth-child(5) { min-width: 64px !important; }
  .table-leader .wr { min-width: 40px; }
  .table-leader .player-cell { gap: 7px; }
  .table-leader .avatar { width: 24px; height: 24px; font-size: 11px; }
}

@media (max-width: 820px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .select { max-width: none; flex: 1; }
  .layout { padding: 16px 14px 30px; }
  .teams { grid-template-columns: 1fr; }
  .match-row { grid-template-columns: minmax(0, 1fr) auto; align-items: start; row-gap: 7px; }
  .match-date { grid-column: 1; grid-row: 1; display: flex; align-items: baseline; gap: 8px; }
  .match-date b { display: inline; }
  .match-row > div:nth-child(2) { grid-column: 1; grid-row: 2; }
  .match-actions { grid-column: 2; grid-row: 1; align-self: center; opacity: 0.9; padding-left: 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 96px minmax(0, 1fr) 60px; }
  .brand-text p { display: none; }
  .footer { padding: 16px 14px 24px; }
}
