:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --surface: #ffffff;
  --ink: #16231d;
  --muted: #65736d;
  --line: #d9e3dc;
  --green: #116149;
  --green-soft: #dcefe5;
  --blue: #285b8f;
  --amber: #8a5b10;
  --red: #a43b2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 12px calc(96px + env(safe-area-inset-bottom));
}

.hero {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

button,
input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 0 10px;
  font-weight: 600;
}

.icon-button {
  min-width: 70px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button.secondary {
  background: var(--surface);
  color: var(--green);
  border-color: var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 0 0;
}

.compact-grid {
  padding-top: 10px;
}

.summary-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.chart-panel,
.candidate-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.chart-panel {
  margin-top: 12px;
  padding: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
}

#equityChart {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.card-list {
  display: grid;
  gap: 11px;
  padding-top: 12px;
}

.candidate-card {
  padding: 14px;
}

.candidate-top {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.kickoff {
  color: var(--green);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.league {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.teams {
  min-width: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 800;
}

.teams span {
  display: block;
  overflow-wrap: anywhere;
}

.teams em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.market-tag {
  min-width: 54px;
  padding: 7px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  text-align: center;
  font-weight: 850;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.pending-text {
  color: var(--amber);
}

.history-filter {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding-top: 12px;
}

.filter-button.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.history-card {
  padding: 12px;
}

.history-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.history-title {
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.history-sub {
  color: var(--muted);
}

.result {
  min-width: 66px;
  text-align: right;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.empty {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty.mini {
  margin-top: 8px;
  padding: 14px 12px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.status-row span:first-child {
  color: var(--muted);
}

.status-row span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(16px);
}

.nav-button {
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  font-size: 14px;
}

.nav-button.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

dialog {
  width: min(calc(100vw - 24px), 560px);
  max-height: min(80vh, 700px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop {
  background: rgb(0 0 0 / 42%);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-body {
  padding: 12px;
}

@media (min-width: 640px) {
  .card-list {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
