:root {
  color-scheme: dark;
  --bg-page: #0d0f14;
  --bg-card: #161a22;
  --bg-card-hover: #1c212c;
  --bg-input: #0d0f14;
  --border: #2a3140;
  --text: #e8eaed;
  --text-muted: #8b929e;
  --text-dim: #5c6370;
  --accent: #4a9eff;
  --accent-dim: #2d6cb5;
  --accent-hot: #ff6b6b;
  --header-from: #1a3d6b;
  --header-to: #0f2847;
  --shadow: rgba(0, 0, 0, 0.35);
  --error-bg: #3d1f24;
  --error-text: #ff8a8a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header */
.app-header {
  background: linear-gradient(180deg, var(--header-from) 0%, var(--header-to) 100%);
  color: #fff;
  padding-bottom: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-header.compact {
  padding-bottom: 0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 48px;
}

.header-top h1 {
  font-size: 18px;
  font-weight: 600;
}

.header-back {
  font-size: 28px;
  line-height: 1;
  width: 32px;
  opacity: 0.95;
}

.header-filter {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.date-scroll {
  display: flex;
  overflow-x: auto;
  padding: 8px 12px 4px;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.date-scroll::-webkit-scrollbar {
  display: none;
}

.date-item {
  flex-shrink: 0;
  font-size: 14px;
  opacity: 0.65;
  padding: 4px 2px;
  white-space: nowrap;
}

.date-item.active {
  font-size: 20px;
  font-weight: 700;
  opacity: 1;
}

.date-full {
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
  padding: 4px 0 8px;
}

/* Match list */
.match-list {
  background: var(--bg-card);
}

.match-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}

.match-row:active {
  background: var(--bg-card-hover);
}

.match-left {
  text-align: left;
}

.league-name {
  color: var(--accent-hot);
  font-size: 13px;
  margin-bottom: 4px;
}

.match-time {
  color: var(--accent-hot);
  font-size: 14px;
  font-weight: 500;
}

.match-center {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}

.match-teams {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.match-teams .team-name {
  flex: 1 1 40%;
  min-width: 0;
}

.match-teams .vs,
.match-score-inline {
  flex: 0 0 auto;
  font-weight: 700;
}

.match-score-inline {
  color: var(--accent);
  font-size: 16px;
  padding: 0 4px;
}

.live-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #e53935;
  border-radius: 3px;
}

.match-score {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.match-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.live-icon {
  font-size: 16px;
  opacity: 0.7;
}

.handicap {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #0d0f14 0%, #0f2847 50%, #0d0f14 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  width: min(360px, 90vw);
  box-shadow: 0 12px 40px var(--shadow);
}

.login-card h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text);
}

.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-card label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  margin-bottom: 16px;
  background: var(--bg-input);
  color: var(--text);
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

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

.error-msg {
  background: var(--error-bg);
  color: var(--error-text);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-page);
}

.empty-state .btn-primary {
  margin-top: 16px;
  max-width: 200px;
}

/* Detail page */
.detail-page {
  padding: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}

.detail-card h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text);
}

.detail-teams {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}

.detail-teams .vs {
  color: var(--text-muted);
  font-weight: 500;
  margin: 0 8px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.chart-wrap {
  position: relative;
  height: 220px;
  margin-bottom: 16px;
}

.odds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.odds-table th,
.odds-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.odds-table th {
  background: var(--bg-page);
  color: var(--text-muted);
  font-weight: 600;
}

.odds-table tbody tr:hover {
  background: var(--bg-card-hover);
}

#matchNote {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text);
}

#matchNote:focus {
  outline: none;
  border-color: var(--accent);
}

#matchNote::placeholder {
  color: var(--text-dim);
}

.note-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

/* Match detail — odds index (schedule-style) */
.detail-match-card {
  text-align: center;
}

.detail-league {
  color: var(--accent-hot);
  font-size: 13px;
  margin-bottom: 8px;
}

.detail-team {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.detail-score {
  flex: 0 0 auto;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  padding: 0 8px;
}

.detail-teams {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

.odds-index-card {
  padding: 0;
  overflow: hidden;
}

.odds-index-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.odds-index-header h2 {
  margin: 0;
  font-size: 15px;
}

.odds-sync-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.odds-table-head,
.odds-company-toggle,
.odds-history-head,
.odds-history-row {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr 0.7fr 0.7fr 20px;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.odds-table-head {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}

.odds-company-head span:first-child {
  text-align: left;
}

.odds-line-group {
  border-bottom: 1px solid var(--border);
}

.odds-line-group:last-child {
  border-bottom: none;
}

.odds-line-toggle,
.odds-company-toggle {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.odds-line-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-card);
}

.odds-line-toggle:active,
.odds-company-toggle:active {
  background: var(--bg-card-hover);
}

.odds-line-title {
  font-size: 15px;
  font-weight: 700;
  color: #ff9800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.main-line-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #ff9800;
  border-radius: 3px;
  vertical-align: middle;
}

.odds-line-meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.odds-chevron {
  color: var(--text-dim);
  font-size: 18px;
  transition: transform 0.15s ease;
}

.odds-chevron.sm {
  font-size: 14px;
}

.odds-line-toggle[aria-expanded="true"] .odds-chevron,
.odds-company-toggle[aria-expanded="true"] .odds-chevron {
  transform: rotate(90deg);
}

.odds-line-body {
  background: var(--bg-page);
  border-top: 1px solid var(--border);
}

.odds-company-block {
  border-bottom: 1px solid var(--border);
}

.odds-company-block:last-child {
  border-bottom: none;
}

.odds-company-toggle {
  padding: 10px 12px;
}

.odds-company-toggle .company-name {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.odds-company-history {
  padding-bottom: 8px;
  background: #11151c;
}

.odds-company-history .odds-history-head {
  padding: 6px 12px;
  font-size: 11px;
}

.odds-company-history .odds-history-row {
  padding: 6px 12px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.odds-time {
  color: var(--text-muted);
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.odds-line-val {
  font-weight: 700;
  color: #ff9800;
}

.odds-val {
  font-weight: 600;
  color: var(--accent);
}

/* legacy detail odds (kept for compatibility) */
.odds-current {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
}

.odds-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.odds-col-home {
  text-align: center;
}

.odds-col-away {
  text-align: center;
}

.odds-col-line {
  padding: 0 8px;
  min-width: 72px;
}

.odds-team {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  max-width: 100%;
  word-break: break-word;
}

.odds-water {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.odds-icon {
  font-size: 18px;
  opacity: 0.85;
  filter: sepia(1) saturate(4) hue-rotate(-10deg);
}

.odds-handicap {
  font-size: 22px;
  font-weight: 800;
  color: #ff9800;
  line-height: 1.2;
  margin-top: 2px;
}

.odds-history-head,
.odds-history-row {
  display: grid;
  grid-template-columns: 52px 1fr 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}

.odds-history-head {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}

.odds-history-row {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

.odds-time {
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
}

.odds-line-val {
  font-weight: 700;
  color: #ff9800;
}

.odds-val {
  font-weight: 600;
  color: var(--accent);
}

@media (min-width: 768px) {
  .match-row {
    grid-template-columns: 100px 1fr 80px;
    padding: 16px 24px;
  }

  .match-center {
    font-size: 16px;
  }
}
