:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-raised: #1a2236;
  --border: #1f2d44;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --danger: #ff4757;
  --danger-dim: rgba(255, 71, 87, 0.12);
  --halftime-accent: #f5a623;
  --llm-accent: #a78bfa;
  --llm-dim: rgba(167, 139, 250, 0.12);
  --font-body: 'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

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

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-accent {
  color: var(--accent);
}

.source-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

main.container {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.source-section {
  margin-bottom: 40px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.odds-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.odds-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent-dim);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}

.match-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.source-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.source-badge.kalshi {
  background: var(--accent-dim);
  color: var(--accent);
}

.source-badge.polymarket {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
}

.fetched-at {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fetched-at span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.outcomes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outcome-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-raised);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.outcome-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.probability {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.loading-state,
.error-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

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

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

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.match-meta {
  margin-bottom: 16px;
}

.meta-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stage-badge,
.group-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.stage-badge {
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.group-badge {
  background: var(--accent-dim);
  color: var(--accent);
}

.match-datetime {
  display: flex;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.match-date {
  font-weight: 500;
  color: var(--text);
}

.team-names {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.team-a,
.team-b {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.vs {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.match-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.link-chip {
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.link-chip.kalshi {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(0, 212, 170, 0.25);
}

.link-chip.kalshi:hover {
  background: rgba(0, 212, 170, 0.25);
}

.link-chip.polymarket {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.25);
}

.link-chip.polymarket:hover {
  background: rgba(99, 102, 241, 0.25);
}

.card-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 16px;
}

.odds-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.odds-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.odds-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.event-title {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.timing-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.no-odds {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 10px 0;
}

/* Timing-section (chronological) layout */
.timing-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface-raised);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.timing-section.halftime {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.06);
}

.timing-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.timing-section-header:hover .chevron {
  color: var(--text);
}

.timing-section-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timing-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 0;
}

.timing-source-pill {
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.timing-section[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.timing-section .timing-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.timing-section.halftime .timing-label {
  background: rgba(245, 158, 11, 0.15);
  color: #f5a623;
  border-color: rgba(245, 158, 11, 0.35);
}

.timing-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timing-content[hidden] {
  display: none;
}

.timing-section.halftime .chevron {
  color: var(--halftime-accent);
}

.source-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* LLM analysis block                                                  */
/* ------------------------------------------------------------------ */
.source-badge.llm {
  background: var(--llm-dim);
  color: var(--llm-accent);
}

.timing-source-pill.llm-pill {
  background: var(--llm-dim);
  color: var(--llm-accent);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.llm-block {
  border-left: 2px solid var(--llm-accent);
  padding-left: 12px;
}

.llm-version-cap {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.llm-predictions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.llm-prediction {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.llm-prediction-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.llm-prediction-header::-webkit-details-marker {
  display: none;
}

.llm-prediction[open] .llm-chevron {
  transform: rotate(90deg);
}

.version-item[open] .llm-chevron {
  transform: rotate(90deg);
}

.llm-chevron {
  margin-left: auto;
}

.llm-model-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--llm-dim);
  color: var(--llm-accent);
  white-space: nowrap;
}

.llm-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.llm-raw {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding: 10px 12px;
  margin: 0;
  border-top: 1px solid var(--border);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.llm-prediction-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--danger-dim);
  border-color: rgba(255, 71, 87, 0.3);
}

.llm-prediction-error .llm-model-tag {
  background: var(--danger-dim);
  color: var(--danger);
}

.llm-error-line {
  font-size: 0.75rem;
  color: var(--danger);
}

.llm-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: capitalize;
}

/* ------------------------------------------------------------------ */
/* Admin / forms                                                       */
/* ------------------------------------------------------------------ */
.admin-page,
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
}

.login-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 64px 24px;
  width: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.login-card .sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field textarea,
.field select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 200px;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

select[multiple] {
  min-height: 120px;
  padding: 8px;
}

select[multiple] option {
  padding: 4px 8px;
  border-radius: 4px;
}

.btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
  background: rgba(0, 212, 170, 0.25);
}

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

.btn-secondary {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

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

.btn-danger {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 71, 87, 0.25);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-row .field {
  flex: 1;
  min-width: 140px;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-topbar .logo {
  font-size: 1.15rem;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.admin-section .section-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 20px;
}

.var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.var-chip {
  font-size: 0.72rem;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--llm-accent);
  cursor: pointer;
  white-space: nowrap;
}

.var-chip:hover {
  border-color: var(--llm-accent);
}

.preview-pre {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.version-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}

.version-item > summary.version-item-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.version-item > summary.version-item-summary::-webkit-details-marker {
  display: none;
}

.version-item-body {
  padding: 0 14px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.version-detail-line {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.version-item-body .llm-raw {
  margin: 0;
}

.version-item.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.version-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.version-num {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.active-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
}

.version-models {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.version-models .llm-model-tag {
  font-size: 0.65rem;
  background: var(--surface);
  color: var(--text-muted);
}

.trigger-result {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-entry {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.error-banner {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.note-banner {
  background: var(--llm-dim);
  border: 1px solid var(--llm-accent);
  border-radius: 8px;
  color: var(--llm-accent);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.login-error {
  color: var(--danger);
  font-size: 0.82rem;
  min-height: 1.2em;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .site-header .container {
    flex-direction: column;
    align-items: stretch;
  }

  .source-tabs {
    justify-content: center;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .team-a,
  .team-b {
    font-size: 1.1rem;
  }

  .version-models {
    margin-left: 0;
  }
}
