/* Apple Stocks-style palette, system-following light + dark. */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --divider: #D2D2D7;
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #86868B;
  --positive: #1A8A3E;
  --negative: #D70015;
  --accent: #0071E3;
  --hover-tint: rgba(0, 0, 0, 0.03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1C1C1E;
    --divider: #38383A;
    --text: #F5F5F7;
    --text-secondary: #8E8E93;
    --text-tertiary: #636366;
    --positive: #30D158;
    --negative: #FF453A;
    --accent: #2997FF;
    --hover-tint: rgba(255, 255, 255, 0.05);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-family: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 88px 32px 96px;
}

/* Top bar */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 56px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 50;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.top-time {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Hero */
.hero {
  padding: 0 0 56px;
}
.hero-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 12px;
}
.hero-figures {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hero-net {
  font-size: 64px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.hero-roi {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.hero-meta {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.pos { color: var(--positive); }
.neg { color: var(--negative); }

/* Section header */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 16px;
  padding-top: 40px;
}
.section-head h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.sort-hint {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Meeting list rows */
.meeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--divider);
  text-decoration: none;
  color: inherit;
  transition: background-color 120ms ease;
}
.meeting-row:hover { background-color: var(--hover-tint); }
.row-meta { display: flex; flex-direction: column; gap: 2px; }
.row-date { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
.row-venue-name { font-size: 14px; color: var(--text-secondary); }
.row-figures { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-net { font-size: 28px; font-weight: 500; letter-spacing: -0.01em; }
.row-roi { font-size: 14px; }

.row-fetch {
  margin-top: 6px;
}
.row-fetch button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
}
.row-fetch button:hover { opacity: 0.85; }
.row-fetch button:disabled { opacity: 0.6; cursor: progress; }

/* Race table on the detail page */
.races { margin-top: 0; }
.race-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.race-table td {
  padding: 16px 8px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}
.race-col .race-no {
  font-weight: 500;
  letter-spacing: -0.01em;
}
.race-col .race-bets {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.finishers-col { color: var(--text-secondary); }
.net-col {
  text-align: right;
  font-weight: 500;
}
.fetch-col {
  text-align: right;
  white-space: nowrap;
}

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { opacity: 0.85; }

/* Inline fetch button on race rows */
.fetch-inline {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
}
.fetch-inline:hover { opacity: 0.85; }
.fetch-inline:disabled { opacity: 0.6; cursor: progress; }

/* Inline status messages under fetch buttons */
.row-msg {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.row-msg.pending { color: var(--text-secondary); }
.row-msg.error { color: var(--negative); }

/* HTMX in-flight indicator */
.fetch-inline.htmx-request,
.row-fetch button.htmx-request {
  opacity: 0.6;
  cursor: progress;
  position: relative;
}
.fetch-inline.htmx-request::after,
.row-fetch button.htmx-request::after {
  content: "…";
  display: inline-block;
  margin-left: 4px;
}

/* Focus rings */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Empty state */
.empty-line {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Calendar */
.calendar {
  margin-top: 40px;
  border-top: 1px solid var(--divider);
  padding-top: 24px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}
.calendar-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  min-width: 220px;
  text-align: center;
}
.calendar-nav {
  background: none;
  border: 0;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 8px;
}
.calendar-nav:hover { background: var(--hover-tint); color: var(--text); }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.calendar-weekdays > span {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  transition: background-color 120ms ease, border-color 120ms ease;
}
.calendar-cell:hover { background-color: var(--hover-tint); }
.calendar-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.calendar-cell.out-of-month {
  color: var(--text-tertiary);
  cursor: default;
  pointer-events: none;
}
.calendar-cell.today {
  border-color: var(--accent);
}
.calendar-cell.selected {
  border-color: var(--accent);
  border-width: 2px;
  padding: 7px;
}
.calendar-cell.win  { background-color: rgba(52, 199, 89, 0.10); }
.calendar-cell.loss { background-color: rgba(255, 59, 48, 0.10); }
@media (prefers-color-scheme: dark) {
  .calendar-cell.win  { background-color: rgba(52, 199, 89, 0.18); }
  .calendar-cell.loss { background-color: rgba(255, 59, 48, 0.18); }
}

.cell-date {
  font-size: 13px;
  font-weight: 500;
}
.cell-net {
  font-size: 14px;
  font-weight: 500;
  align-self: stretch;
  text-align: right;
}
.calendar-cell.win  .cell-net { color: var(--positive); }
.calendar-cell.loss .cell-net { color: var(--negative); }

/* Day panel */
#day-panel:empty { display: none; }
.day-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 40px 0 16px;
}
.day-panel-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.day-fetch button {
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.day-fetch button:hover { opacity: 0.9; }
.day-fetch button:disabled { opacity: 0.6; cursor: progress; }
.day-empty {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 24px 0;
}

/* Day-panel two-level accordion */

.meeting-block {
  border-top: 1px solid var(--divider);
  padding: 16px 0;
}
.meeting-block[open] { padding-bottom: 12px; }
.meeting-block:last-child { border-bottom: 1px solid var(--divider); }

.meeting-block > summary,
.race-block > summary {
  list-style: none;
  cursor: pointer;
  display: block;
}
.meeting-block > summary::-webkit-details-marker,
.race-block > summary::-webkit-details-marker { display: none; }

.meeting-block > summary::before {
  content: "▸";
  display: inline-block;
  width: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  margin-right: 4px;
}
.meeting-block[open] > summary::before { content: "▾"; }

.meeting-block-summary { user-select: none; }
.meeting-block-line1 {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.meeting-block-label {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.meeting-block-net {
  margin-left: auto;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.meeting-block-roi {
  font-size: 14px;
}
.meeting-block-line2 {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
  margin-left: 20px;
}

.race-blocks {
  margin: 12px 0 0 20px;
}

.race-block {
  padding: 8px 0;
  border-top: 1px solid var(--divider);
}
.race-block:first-child { border-top: 0; }

.race-block > summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  color: var(--text-tertiary);
  font-size: 11px;
  margin-right: 4px;
}
.race-block[open] > summary::before { content: "▾"; }

.race-block-summary {
  display: grid;
  grid-template-columns: 14px 40px 50px auto auto auto auto;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
}
.race-no { font-weight: 500; }

.race-badge { font-weight: 500; }
.race-badge.won { color: var(--positive); }
.race-badge.loss { color: var(--negative); }
.race-badge.unfetched { color: var(--text-tertiary); }

.race-cell { color: var(--text-secondary); text-align: right; }
.race-net { font-weight: 500; }
.race-net.pos { color: var(--positive); }
.race-net.neg { color: var(--negative); }

.betline-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0 0 0 18px;
}
.betline-row {
  display: grid;
  grid-template-columns: 16px 100px auto 1fr auto;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  align-items: baseline;
}
.betline-check {
  color: var(--positive);
  font-weight: 600;
  width: 16px;
}
.betline-combo { font-weight: 500; }
.betline-stake { color: var(--text-secondary); }
.betline-acc { color: var(--text-tertiary); font-size: 12px; }
.betline-payout { color: var(--positive); font-weight: 500; text-align: right; }
.betline-row.won { background-color: rgba(52, 199, 89, 0.06); border-radius: 8px; padding: 4px 8px; }
@media (prefers-color-scheme: dark) {
  .betline-row.won { background-color: rgba(52, 199, 89, 0.12); }
}

/* Day-detail page hero */
.day-hero {
  margin: 24px 0 32px;
}
.day-hero-title {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}
.day-hero-net {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.day-hero-roi {
  font-size: 18px;
  font-weight: 500;
  margin-top: 4px;
}
.day-hero-meta {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 12px;
}

/* Hide-day button at the bottom-right of the day hero. Subtle — this is
   a power-user action, not a primary CTA. */
.day-hide-form {
  margin-top: 16px;
  text-align: right;
}
.day-hide-form button {
  font-size: 12px;
  padding: 6px 12px;
  opacity: 0.7;
}
.day-hide-form button:hover {
  opacity: 1;
}

/* Banner shown when the operator has hidden the day from the dashboard.
   Soft amber so it reads as informational, not error. */
.day-hidden-banner {
  background: rgba(180, 130, 30, 0.10);
  border: 1px solid rgba(180, 130, 30, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
