@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0f1c;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(23, 33, 54, 0.9);
  --border: rgba(255,255,255,0.08);
  --border-active: rgba(0,230,118,0.4);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #00e676;
  --accent-dim: rgba(0,230,118,0.15);
  --gold: #ffd740;
  --gold-dim: rgba(255,215,64,0.15);
  --red: #ff5252;
  --red-dim: rgba(255,82,82,0.15);
  --blue: #448aff;
  --blue-dim: rgba(68,138,255,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

html { font-size: 15px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  padding-bottom: 72px;
  overflow-x: hidden;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #0d1420 0%, #0a1628 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 16px 12px;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(20px);
}
.header h1 {
  font-size: 1.2rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header .subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Bottom Tab Navigation ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,15,28,0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px 6px; gap: 3px;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.65rem; font-family: inherit; cursor: pointer;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { width: 22px; height: 22px; transition: transform var(--transition); }
.tab-btn.active { color: var(--accent); }
.tab-btn.active svg { transform: scale(1.1); }

/* ===== Tab Content ===== */
.tab-content { display: none; padding: 16px; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
  transition: border-color var(--transition), transform var(--transition);
}
.card:hover { border-color: var(--border-active); }
.card-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.card-title .icon { color: var(--accent); }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block; font-size: 0.75rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 4px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

input, select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem; font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select option { background: var(--bg-secondary); color: var(--text-primary); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00c853);
  color: #0a0f1c; width: 100%;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,230,118,0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); width: 100%;
}
.btn-sm { padding: 7px 14px; font-size: 0.78rem; min-height: 36px; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #ffab00); color: #0a0f1c; }

/* ===== Result Cards ===== */
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
}
.match-card:active { transform: scale(0.99); }
.match-card .match-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.match-card .match-meta {
  font-size: 0.7rem; color: var(--text-muted);
  display: flex; gap: 8px; align-items: center;
}
.match-card .match-teams {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.match-card .team-name { font-size: 0.85rem; font-weight: 500; flex: 1; }
.match-card .team-name.away { text-align: right; }
.match-card .score {
  font-size: 1.1rem; font-weight: 700; color: var(--accent);
  min-width: 50px; text-align: center;
  background: var(--accent-dim); border-radius: 6px; padding: 4px 8px;
}
.match-card .match-detail {
  display: none; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.match-card.expanded .match-detail { display: block; animation: fadeIn 0.2s ease; }

.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 0.78rem;
}
.stat-row .stat-label { color: var(--text-muted); flex: 1; text-align: center; }
.stat-row .stat-val { flex: 0 0 40px; font-weight: 600; }
.stat-row .stat-val:first-child { text-align: left; }
.stat-row .stat-val:last-child { text-align: right; }

/* ===== Stats Overview ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px; text-align: center;
}
.stat-card .stat-number {
  font-size: 1.5rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-desc { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Bar Chart (CSS-only) ===== */
.bar-chart { margin: 12px 0; }
.bar-item { margin-bottom: 8px; }
.bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.75rem; margin-bottom: 3px;
}
.bar-label span:first-child { color: var(--text-secondary); }
.bar-label span:last-child { color: var(--accent); font-weight: 600; }
.bar-track {
  height: 8px; background: var(--bg-primary);
  border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.bar-fill.red { background: linear-gradient(90deg, var(--red), #ff8a80); }
.bar-fill.blue { background: linear-gradient(90deg, var(--blue), #82b1ff); }

/* ===== Badge / Tags ===== */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  font-size: 0.68rem; font-weight: 600;
}
.badge-green { background: var(--accent-dim); color: var(--accent); }
.badge-gold { background: var(--gold-dim); color: var(--gold); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.78rem; white-space: nowrap;
}
.data-table th {
  background: var(--bg-secondary); color: var(--text-muted);
  font-weight: 600; text-align: left;
  padding: 10px 12px; position: sticky; top: 0;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== Loading ===== */
.loading {
  display: none; text-align: center; padding: 32px;
}
.loading.show { display: block; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.85rem; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: 0.82rem; z-index: 200;
  backdrop-filter: blur(20px);
  transition: transform 0.3s ease;
  max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--red); }

/* ===== Progress ===== */
.progress-wrap { margin: 12px 0; }
.progress-bar {
  height: 6px; background: var(--bg-primary);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-text { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Autocomplete ===== */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 200px; overflow-y: auto;
  z-index: 50; display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
  padding: 10px 12px; font-size: 0.82rem;
  cursor: pointer; transition: background var(--transition);
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--accent-dim); color: var(--accent); }

/* ===== Chips (filter tags) ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: var(--accent-dim);
  border-radius: 20px; font-size: 0.72rem; color: var(--accent);
  margin: 2px; cursor: pointer;
}
.chip .chip-x { font-weight: 700; margin-left: 2px; }

/* ===== Section titles ===== */
.section-title {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ===== Odds display ===== */
.odds-group {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 10px 0;
}
.odds-cell {
  text-align: center; padding: 10px 6px;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.odds-cell .odds-label { font-size: 0.68rem; color: var(--text-muted); }
.odds-cell .odds-val { font-size: 1rem; font-weight: 700; color: var(--gold); margin-top: 2px; }

/* ===== Result count ===== */
.result-count {
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .tab-content { padding: 20px; max-width: 768px; margin: 0 auto; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 1024px) {
  .tab-content { max-width: 960px; }
  body { padding-bottom: 0; }
  .tab-bar {
    position: sticky; top: 52px; bottom: auto;
    border-top: none; border-bottom: 1px solid var(--border);
    max-width: 960px; margin: 0 auto;
  }
  .tab-btn { flex-direction: row; gap: 6px; padding: 12px 8px; font-size: 0.8rem; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Import page specific ===== */
.import-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.import-check {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.8rem; cursor: pointer;
  transition: all var(--transition);
}
.import-check:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }
.import-check input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
}
.import-log {
  background: #050810; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  font-family: 'Courier New', monospace; font-size: 0.72rem;
  max-height: 300px; overflow-y: auto;
  color: var(--text-muted); line-height: 1.8;
}
.import-log .log-ok { color: var(--accent); }
.import-log .log-err { color: var(--red); }
.import-log .log-info { color: var(--blue); }
