:root {
  color-scheme: light;
  --blue: #1a73e8;
  --blue-soft: #f3f7fd;
  --red: #d03030;
  --green: #188038;
  --text: #202124;
  --muted: #666;
  --line: #ccc;
  --light-line: #ddd;
  --header: #f3f3f3;
}

* {
  box-sizing: border-box;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 13px;
}

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: #fff; }
button, input { font: inherit; }
button { cursor: pointer; }

.account-bar { display: flex; align-items: center; gap: 12px; color: #5f6368; }
.account-bar span { font-size: 12px; }
.agent-drawer-toggle {
  position: fixed;
  right: 0;
  top: 42%;
  z-index: 902;
  width: 42px;
  min-height: 112px;
  padding: 10px 6px;
  color: #fff;
  border: 1px solid #1557b0;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #1a73e8;
  box-shadow: -2px 2px 10px rgba(60, 64, 67, .18);
}
.agent-drawer-toggle span {
  display: inline-block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.agent-drawer-toggle:hover { background: #1765cc; }
.agent-drawer-toggle[aria-expanded="true"] { opacity: 0; pointer-events: none; }

.agent-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: transparent;
  pointer-events: none;
}
.agent-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 901;
  display: flex;
  width: min(760px, 56vw);
  height: 100dvh;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #dadce0;
  box-shadow: -8px 0 24px rgba(60, 64, 67, .16);
  transform: translateX(101%);
  transition: transform 180ms ease-out;
}
.agent-drawer.open { transform: translateX(0); }
.agent-drawer-header {
  min-height: 58px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #dadce0;
  background: #fff;
}
.agent-drawer-header strong,
.agent-drawer-header span { display: block; }
.agent-drawer-header strong { font-size: 15px; }
.agent-drawer-header span { margin-top: 2px; color: #5f6368; font-size: 12px; }
.agent-drawer-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.agent-drawer-actions a,
.agent-drawer-actions button {
  color: #1a73e8;
  font: inherit;
  font-size: 12px;
  border: 0;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}
.agent-drawer-actions a:hover,
.agent-drawer-actions button:hover { text-decoration: underline; }
.agent-drawer iframe { width: 100%; min-height: 0; flex: 1; border: 0; background: #fff; }
.text-button { padding: 5px 8px; color: #1a73e8; border: 0; background: transparent; }
.text-button:hover { text-decoration: underline; }

.auth-page { min-height: 100vh; background: #fff; }
.auth-shell { display: grid; place-items: center; min-height: 100vh; width: 100%; margin: 0; padding: 20px; }
.auth-card { width: min(400px, 100%); padding: 36px 40px; border: 1px solid #dadce0; border-radius: 8px; }
.auth-card h1 { text-align: center; font-size: 24px; font-weight: 500; }
.auth-subtitle { margin: 10px 0 24px; color: #5f6368; text-align: center; line-height: 1.6; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 20px; border-bottom: 1px solid #dadce0; }
.auth-tabs button { padding: 10px; color: #5f6368; border: 0; border-bottom: 2px solid transparent; background: #fff; }
.auth-tabs button.active { color: #1a73e8; border-bottom-color: #1a73e8; }
.auth-form { display: grid; gap: 16px; }
.auth-form[hidden] { display: none; }
.auth-form label { display: grid; gap: 6px; color: #3c4043; }
.auth-form input { min-height: 44px; padding: 9px 11px; border: 1px solid #dadce0; border-radius: 4px; outline: none; }
.auth-form input:focus { border-color: #1a73e8; box-shadow: 0 0 0 1px #1a73e8; }
.primary-button { min-height: 42px; color: #fff; border: 1px solid #1a73e8; border-radius: 4px; background: #1a73e8; font-weight: 600; }
.primary-button:hover { background: #1765cc; }
.auth-message { min-height: 20px; margin: 14px 0 0; color: #c5221f; text-align: center; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 max(10px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--light-line);
  background: #fff;
}

h1 { margin: 0; font-size: 20px; font-weight: 600; }
.live-badge, .eyebrow { display: none; }

main { width: min(1180px, calc(100% - 20px)); margin: 12px auto 28px; }
.selector-card {
  padding: 12px;
  border: 1px solid var(--light-line);
  background: #fff;
}

.section-heading, .dashboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 { margin: 0; font-size: 16px; }
.section-heading p, .dashboard-heading p { margin: 4px 0 0; color: #777; font-size: 12px; }

.coverage-panel {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 10px 14px;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #dadce0;
  background: #fff;
}
.coverage-panel.warning { border-color: #dadce0; background: #fff; }
.coverage-summary { display: grid; gap: 2px; }
.coverage-summary strong { font-size: 13px; }
.coverage-summary span { color: #5f6368; font-size: 12px; }
.coverage-badges, .match-data-badges, .evidence-line {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.coverage-badges { justify-content: flex-end; }
.data-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 3px;
  background: #fff;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}
.data-badge.ok,
.data-badge.api,
.data-badge.partial {
  color: #3c4043;
  border-color: #dadce0;
  background: #fff;
}
.data-badge.missing { color: #777; border-color: #e0e0e0; background: #f8f9fa; }

.secondary {
  min-height: 32px;
  padding: 5px 12px;
  color: #174ea6;
  border: 1px solid #a8c7fa;
  border-radius: 3px;
  background: #fff;
}
.secondary:hover { background: #f6fafe; }
.secondary:disabled { color: #999; border-color: #ddd; cursor: wait; }

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #fff;
}
.search-box span { color: #777; }
.search-box input { width: 100%; min-height: 36px; border: 0; outline: 0; background: transparent; }
.source-filters { display: flex; align-items: center; gap: 18px; margin-top: 10px; }
.source-filters label { display: flex; align-items: center; gap: 7px; color: #555; }
.source-filters select { min-height: 32px; padding: 4px 28px 4px 8px; color: #333; border: 1px solid #ccc; border-radius: 3px; background: #fff; }
.check-filter input { width: 16px; height: 16px; accent-color: var(--blue); }
.league-filters { display: flex; gap: 6px; margin-top: 10px; padding-bottom: 3px; overflow-x: auto; }
.league-filter { flex: 0 0 auto; padding: 4px 9px; color: #444; border: 1px solid #ccc; border-radius: 3px; background: #fff; }
.league-filter:hover { background: #f8f9fa; }
.league-filter.active { color: #174ea6; border-color: #8ab4f8; background: var(--blue-soft); }
.state-line { min-height: 20px; margin-top: 8px; color: #666; }
.state-line.error, .market-error { color: var(--red); }

.match-list {
  max-height: 290px;
  overflow: auto;
  border: 1px solid var(--light-line);
}
.match-group + .match-group { border-top: 1px solid #bbb; }
.match-group-title { position: sticky; top: 0; z-index: 2; margin: 0; padding: 6px 9px; color: #333; border-bottom: 1px solid var(--light-line); background: #f3f3f3; font-size: 13px; }
.match-group-title span { margin-left: 5px; color: #777; font-weight: normal; }
.match-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.match-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 62px;
  padding: 8px 10px;
  border-right: 1px solid var(--light-line);
  border-bottom: 1px solid var(--light-line);
  background: #fff;
}
.match-option:hover { background: #f8f9fa; }
.match-option.selected {
  background: #f8f9fa;
  box-shadow: inset 3px 0 0 var(--blue);
}
.match-option input { width: 17px; height: 17px; accent-color: var(--blue); }
.match-option-main { min-width: 0; cursor: pointer; }
.match-option strong, .match-option small { display: block; }
.match-option strong { margin: 2px 0; font-size: 13px; }
.match-option small, .match-tags { color: #666; font-size: 12px; }
.match-tags { display: flex; gap: 6px; align-items: center; }
.match-data-badges { margin-top: 5px; }
.league-tag { color: #174ea6; }

.dashboard-heading { margin: 18px 0 8px; }
.market-navigation { display: flex; gap: 0; margin-bottom: 8px; overflow-x: auto; border: 1px solid var(--light-line); background: #fff; }
.market-navigation button { flex: 0 0 auto; min-height: 38px; padding: 7px 16px; color: #333; border: 0; border-right: 1px solid var(--light-line); background: #fff; }
.market-navigation button:hover { background: #f8f9fa; }
.market-navigation button.active { color: #174ea6; border-bottom: 2px solid #1a73e8; font-weight: 600; background: #f6fafe; }
.selected-matches { display: grid; gap: 18px; }
.empty-state { padding: 28px 12px; text-align: center; color: #777; border: 1px solid var(--light-line); }

.match-panel { overflow: hidden; border: 1px solid var(--light-line); background: #fff; }
.match-header {
  padding: 16px;
  text-align: center;
  background: #f8f9fa;
  border-bottom: 1px solid #dadce0;
}
.team-versus { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; max-width: 650px; margin: 0 auto; }
.team-versus > div { display: grid; justify-items: center; gap: 4px; }
.team-versus img { width: 46px; height: 46px; object-fit: contain; }
.team-versus strong { font-size: 20px; }
.team-versus > b { color: #333; font-size: 20px; }
.team-versus small { min-height: 16px; color: #666; font-weight: normal; }
.match-meta { margin: 6px 0 0; color: #555; }
.match-facts, .coach-line, .red-card-line, .match-explain { margin: 5px 0 0; color: #555; }
.coach-line { font-size: 12px; }
.red-card-line, .match-explain { color: var(--red); }
.evidence-line {
  justify-content: center;
  margin-top: 8px;
}
.evidence-line span {
  padding: 2px 6px;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 3px;
  background: #fff;
  font-size: 11px;
}
.match-data-badges.detail { justify-content: center; margin-top: 7px; }
.countdown { margin-top: 8px; color: var(--red); font-size: 15px; font-weight: bold; }
.panel-body { padding: 12px; }

.market-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 3px 0 7px; }
.market-title h3 { margin: 0; color: #333; font-size: 16px; }
.market-title span { color: #777; font-size: 12px; }
.mobile-only { display: none; }
.euro-grid { display: grid; grid-template-columns: 1fr; gap: 0; margin-bottom: 12px; }
.table-scroll { width: 100%; margin-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); background: #fff; }
.table-scroll table { min-width: 700px; }
.euro-grid .table-scroll table { min-width: 800px; }
.euro-table small { display: block; margin-top: 2px; color: #777; font-size: 10px; }
.euro-table tbody tr:first-child { background: #f8f9fa; font-weight: 600; }
.kelly-high { color: var(--red); font-weight: 600; }
.score-odds-table { min-width: 350px !important; }
.score-odds-table td:nth-child(2), .score-odds-table td:nth-child(3) { font-weight: 600; }
.statistics-block { margin-top: 14px; }
.statistics-block h4 { margin: 0 0 6px; color: #333; font-size: 14px; }
.statistics-table, .history-table { min-width: 760px; }
.history-table td:nth-child(4) { color: var(--red); font-weight: 600; }
.history-index-table { min-width: 980px !important; }
.history-index-table small { display: block; margin-top: 2px; color: #777; font-size: 10px; }
.history-index-list { display: grid; gap: 2px; text-align: left; }
th, td { padding: 6px 8px; text-align: center; border: 1px solid var(--line); white-space: nowrap; }
th { background: var(--header); font-weight: 600; }
.company { text-align: center; font-weight: normal; }
.odds-up { color: #c5221f; }
.odds-down { color: var(--green); }
.loading-card, .error-card { padding: 26px 12px; text-align: center; color: #777; }
.error-card { color: var(--red); }

@media (max-width: 720px) {
  .agent-drawer-toggle {
    top: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 1000;
    width: 56px;
    height: 56px;
    min-height: 56px;
    padding: 0;
    border: 1px solid #1557b0;
    border-radius: 50%;
    box-shadow: 0 3px 14px rgba(60, 64, 67, .28);
  }
  .agent-drawer-toggle span {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: 12px;
    line-height: 1;
  }
  .agent-drawer { width: 100vw; }
  .agent-drawer-header { padding-inline: 10px; }
  .agent-drawer-actions a { display: none; }
  .topbar { min-height: 48px; padding: 0 10px; }
  h1 { font-size: 18px; }
  .account-bar { gap: 7px; }
  #accountEmail { display: none; }
  .auth-shell { padding: 0; }
  .auth-card { width: 100%; padding: 28px 24px; border: 0; border-radius: 0; }
  main { width: calc(100% - 12px); margin-top: 6px; }
  .selector-card { padding: 8px; }
  .section-heading p { display: none; }
  .coverage-panel { grid-template-columns: 1fr; }
  .coverage-badges { justify-content: flex-start; }
  .source-filters { justify-content: space-between; gap: 10px; }
  .match-list { max-height: 330px; }
  .match-group-grid { grid-template-columns: 1fr; }
  .match-option { grid-template-columns: auto minmax(0, 1fr); border-right: 0; min-height: 58px; }
  .dashboard-heading { display: block; margin-top: 14px; }
  .match-header { padding: 14px 8px; }
  .team-versus { gap: 7px; }
  .team-versus img { width: 38px; height: 38px; }
  .team-versus strong { font-size: 16px; }
  .team-versus > b { font-size: 17px; }
  .team-versus small { font-size: 11px; }
  .coach-line { display: none; }
  .panel-body { padding: 6px; }
  .market-navigation button { padding-inline: 12px; }
  .euro-grid .table-scroll table { min-width: 800px; }
  .market-title { margin-top: 6px; }
  .mobile-only { display: inline; }
  th, td { padding: 6px 5px; }
}

@media (max-width: 360px) {
  .secondary { padding-inline: 8px; }
  .market-title span { display: none; }
}
