:root {
  --bg: #070b12;
  --bg-2: #0d1420;
  --panel: rgba(18, 26, 40, 0.72);
  --panel-solid: #121a28;
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #c9aa71;
  --gold-dim: #8a7348;
  --accent: #5b9fd4;
  --accent-glow: rgba(91, 159, 212, 0.25);
  --blue: #4da3ff;
  --blue-bg: rgba(77, 163, 255, 0.1);
  --red: #ff6b7a;
  --red-bg: rgba(255, 107, 122, 0.1);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 0% -10%, rgba(91, 159, 212, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(201, 170, 113, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(77, 163, 255, 0.06) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

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

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0 0.35rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(201, 170, 113, 0.25), rgba(91, 159, 212, 0.15));
  border: 1px solid rgba(201, 170, 113, 0.35);
  color: var(--gold);
  flex-shrink: 0;
}

.brand-mark svg { width: 22px; height: 22px; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 0.78rem; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(201, 170, 113, 0.12), rgba(91, 159, 212, 0.08));
  border-color: rgba(201, 170, 113, 0.25);
}

.nav-btn.active svg { opacity: 1; color: var(--gold); }

/* ── Main ── */
.main {
  padding: 2rem 2.25rem 3rem;
  max-width: 1400px;
}

.top h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 40%, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.muted { color: var(--muted); margin: 0.35rem 0 0; font-size: 0.95rem; }
.content { margin-top: 1.75rem; }

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Stat cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.stat {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  transition: border-color 0.2s, transform 0.2s;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  opacity: 0.6;
}

.stat:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.stat .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--gold);
}

.stat-icon svg { width: 18px; height: 18px; }

.stat .value {
  font-size: 2.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat:nth-child(1) .stat-icon { color: var(--accent); background: var(--accent-glow); }
.stat:nth-child(2) .stat-icon { color: var(--gold); background: rgba(201, 170, 113, 0.12); }
.stat:nth-child(3) .stat-icon { color: var(--ok); background: var(--ok-bg); }
.stat:nth-child(4) .stat-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.12); }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-wrap svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding-left: 2.5rem;
}

.toolbar input,
.field input,
.field select {
  width: 100%;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.toolbar input:focus,
.field input:focus,
.field select:focus {
  border-color: rgba(201, 170, 113, 0.45);
  box-shadow: 0 0 0 3px rgba(201, 170, 113, 0.1);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  border-radius: var(--radius-sm);
  padding: 0.58rem 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.05); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0a0e14;
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--danger-bg);
}

.btn.danger:hover { border-color: rgba(248, 113, 113, 0.5); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

/* ── Tables ── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(8px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr { transition: background 0.12s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(201, 170, 113, 0.06) !important; }
tr.clickable.active td { background: rgba(91, 159, 212, 0.1) !important; }

.mono { font-family: var(--mono); font-size: 0.82rem; }

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  font-style: italic;
}

/* ── Pills & badges ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }
.pill.locked { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }

.badge-win {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-loss {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--danger-bg);
  color: var(--danger);
}

.team-blue { color: var(--blue); font-weight: 600; }
.team-red { color: var(--red); font-weight: 600; }
.player-side-b { color: var(--blue); }
.player-side-r { color: var(--red); }

/* ── Match hero ── */
.match-hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  align-items: center;
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.match-team {
  text-align: center;
}

.match-team.blue { text-align: left; }
.match-team.red { text-align: right; }

.match-team .team-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.match-team .team-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.match-vs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  padding: 0.5rem 1rem;
  border: 1px solid rgba(201, 170, 113, 0.3);
  border-radius: 999px;
  background: rgba(201, 170, 113, 0.08);
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ── Detail grid ── */
.detail { display: grid; gap: 1.25rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label { font-size: 0.75rem; color: var(--muted); font-weight: 500; }

.field-readonly {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
}

/* ── Stats layout ── */
.stats-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
}

.panel h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel h3.player-name {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--text), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.kv div {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
}

.kv .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.kv .v { font-weight: 600; margin-top: 0.2rem; font-variant-numeric: tabular-nums; font-size: 1.05rem; }

.wr-bar {
  margin-top: 0.75rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.wr-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.4s ease;
}

.section-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Pager ── */
.pager {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Error ── */
.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.35;
  margin-bottom: 0.75rem;
}

/* ── Modal ── */
#modal {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

#modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-form { padding: 1.35rem 1.5rem 1.5rem; }

.modal-form h2 {
  margin: 0 0 1.1rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .stats-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1rem;
    gap: 1rem;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .nav-btn {
    flex: 1 1 calc(50% - 0.2rem);
    justify-content: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }

  .nav-btn svg { display: none; }
  .main { padding: 1.25rem 1rem 2rem; }
  .cards { grid-template-columns: 1fr 1fr; }
  .match-hero { grid-template-columns: 1fr; text-align: center !important; }
  .match-team.blue, .match-team.red { text-align: center; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
}
