/* ── Variables & Theme ─────────────────────────────── */
:root {
  --bg: #f5f5f5; --surface: #ffffff; --surface-alt: #fafafa; --border: #e0e0e0;
  --text: #212121; --text-secondary: #666; --text-muted: #999;
  --primary: #1a73e8; --primary-hover: #1557b0; --primary-light: #e8f0fe;
  --danger: #dc3545; --danger-hover: #b02a37;
  --success: #28a745; --success-light: #d4edda;
  --warning: #ffc107; --warning-light: #fff3cd;
  --info: #17a2b8;
  --radius: 8px; --radius-sm: 4px; --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1); --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: .2s ease;
}
[data-theme="dark"] {
  --bg: #121212; --surface: #1e1e1e; --surface-alt: #2a2a2a; --border: #333;
  --text: #e0e0e0; --text-secondary: #aaa; --text-muted: #777;
  --primary-light: #1a3a5c; --success-light: #1a3a2a; --warning-light: #3a3520;
  --shadow: 0 1px 3px rgba(0,0,0,.3); --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Navbar ──────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 52px; box-shadow: var(--shadow);
}
.nav-brand { font-weight: 700; font-size: 16px; color: var(--primary); white-space: nowrap; }
.nav-brand span { font-weight: 400; color: var(--text-muted); font-size: 13px; margin-left: 4px; }
.nav-links { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-links a {
  padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 13px; font-weight: 500; white-space: nowrap; transition: var(--transition);
}
.nav-links a:hover, .nav-links a.active { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-right select { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 12px; }
.nav-avatar { width: 28px; height: 28px; border-radius: 50%; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-warning { background: var(--warning); color: #333; border-color: var(--warning); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 6px; min-width: 32px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-inline { display: flex; gap: 8px; align-items: end; }
.form-inline .form-group { margin-bottom: 0; flex: 1; }

/* ── Tables ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; background: var(--surface-alt); }
tr:hover td { background: var(--primary-light); }
td.center, th.center { text-align: center; }

/* ── Tags / Badges ───────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}
.badge-draft { background: var(--border); color: var(--text-secondary); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-live { background: #ffe0e0; color: #d32f2f; animation: pulse 1.5s infinite; }
.badge-scheduled { background: var(--warning-light); color: #856404; }
.badge-finished { background: var(--surface-alt); color: var(--text-secondary); }
.badge-pending { background: var(--warning-light); color: #856404; }
.badge-approved { background: var(--success-light); color: var(--success); }
.badge-declined { background: #fce4e4; color: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .7; } }

/* Color dot */
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

/* ── Layout ──────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; } .gap-16 { gap: 16px; }

/* ── Tabs ────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 10px 18px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Tournament Card ─────────────────────────────── */
.tournament-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; cursor: pointer; transition: var(--transition);
  display: flex; flex-direction: column; gap: 8px;
}
.tournament-card:hover { box-shadow: var(--shadow-lg); border-color: var(--primary); transform: translateY(-1px); }
.tournament-card .tc-name { font-size: 16px; font-weight: 600; }
.tournament-card .tc-meta { font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 8px; }
.tournament-card .tc-meta span { display: inline-flex; align-items: center; gap: 4px; }
.tournament-card .tc-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }

/* ── Match Card ──────────────────────────────────── */
.match-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  transition: var(--transition); font-size: 13px;
}
.match-card:hover { box-shadow: var(--shadow); }
.match-card .mc-teams { flex: 1; display: flex; align-items: center; gap: 8px; justify-content: center; }
.match-card .mc-team { font-weight: 600; min-width: 100px; }
.match-card .mc-team.home { text-align: right; }
.match-card .mc-team.away { text-align: left; }
.match-card .mc-score {
  background: var(--surface-alt); border-radius: var(--radius-sm);
  padding: 4px 12px; font-weight: 700; font-size: 16px; min-width: 60px; text-align: center;
}
.match-card .mc-score.live { background: #d32f2f; color: #fff; }
.match-card .mc-info { font-size: 11px; color: var(--text-muted); text-align: right; min-width: 80px; }
.match-card .mc-phase { font-size: 11px; color: var(--text-muted); min-width: 60px; }
.match-card .mc-actions { display: flex; gap: 4px; }

/* ── Standings Table ─────────────────────────────── */
.standings-table th { font-size: 10px; padding: 6px 8px; }
.standings-table td { padding: 6px 8px; font-size: 13px; }
.standings-table .team-cell { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.standings-table tr.advance { background: var(--success-light); }

/* ── Bracket ─────────────────────────────────────── */
.bracket { display: flex; gap: 32px; overflow-x: auto; padding: 16px 0; align-items: flex-start; }
.bracket-round { display: flex; flex-direction: column; gap: 16px; min-width: 200px; }
.bracket-round-title { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); text-align: center; margin-bottom: 8px; }
.bracket-match {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; font-size: 13px;
}
.bracket-match .bm-team {
  display: flex; justify-content: space-between; padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.bracket-match .bm-team:last-child { border-bottom: none; }
.bracket-match .bm-team.winner { background: var(--success-light); font-weight: 600; }
.bracket-match .bm-team .bm-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bracket-match .bm-team .bm-score { font-weight: 700; min-width: 20px; text-align: right; }

/* ── Wizard ──────────────────────────────────────── */
.wizard-steps {
  display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--border);
}
.wizard-step {
  flex: 1; padding: 12px 8px; text-align: center; font-size: 12px; font-weight: 500;
  color: var(--text-muted); position: relative; cursor: default;
}
.wizard-step.active { color: var(--primary); }
.wizard-step.active::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 2px; background: var(--primary);
}
.wizard-step.done { color: var(--success); }
.wizard-step .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--border); color: var(--text-muted);
  font-size: 12px; font-weight: 600; margin-bottom: 4px;
}
.wizard-step.active .step-num { background: var(--primary); color: #fff; }
.wizard-step.done .step-num { background: var(--success); color: #fff; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 24px; }

/* ── Login / Splash ──────────────────────────────── */
.login-page {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  overflow: hidden; background: #0a193c;
}
#login-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.login-google-btn {
  position: absolute; top: 20px; right: 20px; z-index: 10;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.95); color: #333; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: var(--transition); text-decoration: none;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.login-google-btn:hover { box-shadow: 0 4px 20px rgba(0,0,0,.5); transform: translateY(-1px); text-decoration: none; }
.login-overlay {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; z-index: 5; pointer-events: none;
}
.login-title {
  font-size: 48px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 20px rgba(26,115,232,.5); margin-bottom: 12px;
}
.login-sub {
  font-size: 18px; color: rgba(255,255,255,.7); margin-bottom: 16px; font-weight: 500;
}
.login-desc {
  font-size: 14px; color: rgba(255,255,255,.4); max-width: 480px; line-height: 1.6;
}
@media (max-width: 768px) {
  .login-title { font-size: 28px; }
  .login-sub { font-size: 14px; }
  .login-desc { font-size: 12px; }
}

/* ── Stats Cards ─────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ── Messages ────────────────────────────────────── */
.message-item {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.message-item:last-child { border-bottom: none; }
.message-type {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0;
}
.message-type.system { background: var(--text-muted); }
.message-type.info { background: var(--info); }
.message-type.update { background: var(--warning); }
.message-type.result { background: var(--success); }
.message-type.warning { background: var(--danger); }
.message-type.request { background: var(--primary); }
.message-content { flex: 1; }
.message-meta { font-size: 11px; color: var(--text-muted); }

/* ── Map ─────────────────────────────────────────── */
.map-container { height: 300px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; }
.map-container .leaflet-container { height: 100%; width: 100%; }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 600; }

/* ── Toast ───────────────────────────────────────── */
.toast-container {
  position: fixed; top: 60px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideIn .3s ease;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: 0 8px; gap: 6px; }
  .nav-brand span { display: none; }
  .nav-links a { padding: 6px 8px; font-size: 12px; }
  .container { padding: 8px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .match-card { flex-wrap: wrap; }
  .match-card .mc-info { text-align: left; min-width: auto; }
  .wizard-step { font-size: 10px; padding: 8px 4px; }
  .bracket { gap: 16px; }
  .bracket-round { min-width: 160px; }
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--border);
  font-size: 12px;
}
