:root {
  --bg: #0c1118;
  --surface: #151d28;
  --surface2: #1c2736;
  --border: #2a3a4f;
  --text: #e8eef5;
  --muted: #8fa3bc;
  --accent: #3d8bfd;
  --accent-dim: #2563b8;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --high: #22c55e;
  --medium: #eab308;
  --low: #94a3b8;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  background: linear-gradient(135deg, #121a26 0%, #0f1724 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.health-badge {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.health-ok {
  border-color: #166534;
  color: var(--success);
}

.health-bad {
  border-color: #7f1d1d;
  color: var(--danger);
}

.health-loading {
  color: var(--muted);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.controls form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  align-items: end;
}

.field label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
}

.field-wide {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .field-wide {
    grid-column: span 1;
  }
}

.btn-primary {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.btn-secondary {
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cache-status {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--success);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.error-box {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: #fecaca;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

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

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 1rem;
}

.picks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.pick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 4px solid var(--accent);
}

.pick-card.confidence-high {
  border-left-color: var(--high);
}

.pick-card.confidence-medium {
  border-left-color: var(--medium);
}

.pick-card.confidence-low {
  border-left-color: var(--low);
}

.pick-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.pick-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.pick-winner {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 0.5rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.pick-reasons {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  padding-left: 1.1rem;
}

.pick-reasons li {
  margin-bottom: 0.25rem;
}

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

.search {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  min-width: 220px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.predictions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.predictions-table th {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.predictions-table tr:hover {
  background: rgba(61, 139, 253, 0.06);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

.disclaimer {
  margin-top: 2rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 640px;
  width: calc(100% - 2rem);
  padding: 0;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  padding: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.9rem;
}

.modal-body pre {
  white-space: pre-wrap;
  font-family: inherit;
  background: var(--surface2);
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

.prob-bars {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.prob-row {
  display: grid;
  grid-template-columns: 60px 1fr 48px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
}

.prob-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
