:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-soft: #dcfce7;
  --accent-amber: #f59e0b;
  --accent-blue: #2563eb;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 3rem;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.9rem;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dot {
  margin: 0 0.35rem;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 0.48rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: #bbf7d0;
}

.main-content {
  margin-top: 1.5rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.muted {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.select-input,
.text-input {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.92rem;
  color: var(--text);
  min-width: 220px;
}

.podium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.podium-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.podium-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.podium-name {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.podium-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sort-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.clickable-player {
  color: var(--accent-blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.clickable-player:hover {
  text-decoration: underline;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-muted);
}

.rank-1 {
  background: #fef3c7;
  color: #b45309;
}
.rank-2 {
  background: #e2e8f0;
  color: #334155;
}
.rank-3 {
  background: #ffedd5;
  color: #9a3412;
}

/* Matches Layout */
.matches-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
}

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

.date-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.date-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.date-item:hover {
  border-color: #cbd5e1;
}

.date-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.date-item-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.date-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Players Grid */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.player-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.player-card-name {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 0.5rem;
}

.player-card-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Champions Gallery */
.champions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}

.champion-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: #fafafa;
}

.champion-season {
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 0.5rem;
  color: var(--primary-hover);
}

.champion-line {
  font-size: 0.86rem;
  margin: 0.2rem 0;
}

/* Admin Panel */
.login-card {
  max-width: 440px;
  margin: 2rem auto;
  padding: 1.75rem;
}

.login-card h2 {
  font-size: 1.18rem;
  margin-bottom: 0.4rem;
}

.login-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.login-form .text-input {
  flex: 1;
  min-width: 0;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.kv-list {
  padding: 1rem 1.25rem;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-key {
  color: var(--text-muted);
  font-weight: 500;
}

.kv-val {
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.error-msg {
  color: var(--danger);
  font-size: 0.86rem;
  margin-top: 0.75rem;
}

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
