/* ── Dashboard Layout ── */
.dash-header {
  background: #0D1B2A;
  border-bottom: 1px solid #243B56;
  padding: 16px 0;
}
.dash-header h1 { font-size: 1.4em; margin: 4px 0; }
.dash-meta { display: flex; gap: 16px; align-items: center; font-size: 0.85em; color: #99AABB; flex-wrap: wrap; }
.back-link { color: #C9A84C; text-decoration: none; font-size: 0.85em; }
.live-indicator { display: flex; align-items: center; gap: 6px; color: #C9A84C; font-weight: 600; font-size: 0.8em; }
.live-dot { width: 8px; height: 8px; background: #C9A84C; border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Track Tabs ── */
.track-tabs { background: #142236; border-bottom: 1px solid #243B56; overflow-x: auto; white-space: nowrap; padding: 8px 0; }
.track-tabs .container { display: flex; gap: 6px; }
.track-tab {
  background: #1B2D44; border: 1px solid #2D4460; color: #B8AEA0; padding: 6px 14px;
  border-radius: 20px; cursor: pointer; font-size: 0.8em; transition: all 0.2s;
}
.track-tab:hover { border-color: #6B7D8F; color: #fff; }
.track-tab.active { background: #C9A84C; color: #000; border-color: #C9A84C; font-weight: 600; }
.track-tab .race-count { font-size: 0.75em; opacity: 0.7; margin-left: 4px; }
.track-tab .mtp-badge { font-size: 0.7em; background: rgba(255,255,255,0.15); padding: 1px 5px; border-radius: 8px; margin-left: 4px; }

/* ── Race Cards ── */
.dash-main { padding: 20px 0; }
.loading-msg { text-align: center; color: #7A8DA0; padding: 40px; }

.race-card {
  background: #142236; border: 1px solid #243B56; border-radius: 8px;
  margin-bottom: 16px; overflow: hidden;
}
.race-card.has-edge { border-color: #C9A84C; }

.race-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #1B2D44; border-bottom: 1px solid #243B56;
  flex-wrap: wrap; gap: 8px;
}
.race-title { font-weight: 600; font-size: 0.95em; }
.race-info { display: flex; gap: 10px; font-size: 0.8em; color: #99AABB; flex-wrap: wrap; }
.race-tag {
  background: #243B56; padding: 2px 8px; border-radius: 4px; font-size: 0.75em;
}
.race-tag.turf { background: #2A2818; color: #C9A84C; }
.race-tag.dirt { background: #3a2a1a; color: #c89e6a; }
.race-tag.synthetic { background: #1a2a3a; color: #6aacda; }
.mtp-tag { font-weight: 600; }
.mtp-tag.soon { color: #D4A84C; }
.mtp-tag.imminent { color: #E87461; animation: pulse 1s infinite; }
.mtp-tag.finished { color: #7A8DA0; }

.race-desc { font-size: 0.75em; color: #7A8DA0; padding: 4px 14px; border-bottom: 1px solid #1B2D44; }

/* ── Horse Table ── */
.horse-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.horse-table th {
  text-align: left; padding: 6px 10px; color: #7A8DA0; font-weight: 500;
  font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #243B56;
}
.horse-table td { padding: 6px 10px; border-bottom: 1px solid #1B2D44; }
.horse-table tr:last-child td { border-bottom: none; }
.horse-table tr:hover { background: #1B2D44; }
.horse-table tr.scratched td { opacity: 0.3; text-decoration: line-through; }
.horse-table tr.scratched.was-pick td {
  opacity: 0.5; text-decoration: line-through;
  background: rgba(232, 116, 97, 0.05);
}
.horse-table tr.scratched.was-pick td::after { content: ''; }
.horse-table tr.scratched.was-pick .horse-name::after {
  content: ' SCRATCHED';
  color: #E87461; font-size: 0.7em; font-weight: 600;
  text-decoration: none; display: inline-block; margin-left: 6px;
}
.horse-table tr.edge-row { background: rgba(201, 168, 76, 0.05); }
.horse-table tr.strong-edge { background: rgba(201, 168, 76, 0.1); }

.horse-num { font-weight: 600; width: 30px; }
.horse-name { font-weight: 500; }
.horse-connections { color: #99AABB; font-size: 0.8em; }
.odds-cell { font-family: monospace; font-weight: 600; text-align: right; }
.odds-live { color: #fff; }
.odds-ml { color: #7A8DA0; font-size: 0.85em; }
.odds-fav { color: #D4A84C; }
.prob-cell { text-align: right; font-family: monospace; }
.edge-cell { text-align: right; font-family: monospace; }
.edge-primary { font-weight: 700; font-size: 1.05em; }
.edge-secondary { font-weight: 400; opacity: 0.5; font-size: 0.85em; }
.edge-positive { color: #4ADE80; }
.edge-negative { color: #7A8DA0; }
.edge-strong { color: #4ADE80; font-size: 1.2em; font-weight: 800; }
.edge-ml-val { color: #8899AA; }
.edge-source-tag { font-size: 0.65em; color: #6B7D8F; font-weight: 400; vertical-align: super; }
.rec-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 0.75em; font-weight: 600;
}
.rec-strong { background: #C9A84C; color: #000; }
.rec-value { background: #2A2818; color: #C9A84C; }
.rec-pass { color: #6B7D8F; }
.rec-toss { color: #2D4460; }
.form-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.form-tag {
  font-size: 0.7em; padding: 1px 5px; border-radius: 3px;
  background: #243B56; color: #B8AEA0;
}
.form-tag.peaking { background: #2A2818; color: #C9A84C; }
.form-tag.improving { background: #1a2a3a; color: #6aacda; }
.form-tag.bounce_risk { background: #3a1a1a; color: #E87461; }
.form-tag.tired { background: #2a1a1a; color: #a67373; }

/* ── Edge Shift Indicators ── */
.shift-up {
  color: #4ADE80; font-size: 0.75em; margin-left: 4px; font-weight: 600;
  display: inline-block; animation: fadeIn 0.5s;
}
.shift-down {
  color: #E87461; font-size: 0.75em; margin-left: 4px; font-weight: 600;
  display: inline-block; animation: fadeIn 0.5s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Official / Completed Races ── */
.race-card.race-just-finished {
  border-color: #6B7D8F;
}
.race-card.race-official {
  opacity: 0.7;
  border-color: #2D4460;
}
.race-card.race-official:hover {
  opacity: 1;
}
.official-badge {
  background: #2D4460;
  color: #B8AEA0;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  font-weight: 600;
}
.finish-pos {
  display: inline-block;
  font-size: 0.8em;
  font-weight: 600;
  color: #99AABB;
  margin-right: 6px;
}
.finish-win {
  color: #4ADE80;
}

/* ── Results Box ── */
.results-box {
  border-top: 1px solid #2D4460;
  padding: 8px 14px 10px;
  background: #0F1F30;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8em;
}
.results-hdr td {
  color: #6B7D8F;
  font-size: 0.75em;
  font-weight: 500;
  text-transform: uppercase;
  padding: 0 0 4px;
  text-align: right;
}
.results-hdr td:nth-child(1),
.results-hdr td:nth-child(2) { text-align: left; }
.results-table .rp { width: 32px; font-weight: 600; color: #99AABB; }
.results-table .rn { color: #B8AEA0; }
.results-table .rw,
.results-table .rpl,
.results-table .rs { text-align: right; font-family: monospace; color: #8899AA; width: 65px; }
.results-table tr.results-winner .rp,
.results-table tr.results-winner .rn { color: #4ADE80; }
.results-table tr.results-winner .rw { color: #4ADE80; font-weight: 600; }
.results-also-row {
  font-size: 0.7em;
  color: #5A6D80;
  padding: 4px 0 0;
}
.results-exotics {
  border-top: 1px solid #1B2D44;
  margin-top: 6px;
  padding-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ex {
  font-size: 0.7em;
  color: #7A8DA0;
  background: #162438;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.ex b { color: #99AABB; font-weight: 600; }

/* ── Thesis & Guard Rails ── */
.thesis-text {
  font-size: 0.75em;
  color: #99AABB;
  font-style: italic;
  margin-top: 4px;
}

.drift-flag {
  font-size: 0.7em;
  color: #D4A84C;
  margin-top: 2px;
}

.horse-table tr.drift-warning {
  background: rgba(255, 152, 0, 0.05);
}
.horse-table tr.drift-warning .odds-live {
  color: #D4A84C;
}

/* ── History Navigation ── */
.history-nav {
  background: #0F1F30; border-bottom: 1px solid #243B56; padding: 8px 0;
}
.history-nav .container {
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.hist-btn {
  background: #1B2D44; border: 1px solid #2D4460; color: #B8AEA0; padding: 6px 14px;
  border-radius: 6px; cursor: pointer; font-size: 0.85em; transition: all 0.2s;
}
.hist-btn:hover { border-color: #6B7D8F; color: #fff; }
.hist-btn.active { background: #C9A84C; color: #000; border-color: #C9A84C; font-weight: 600; }
.hist-date-picker {
  background: #1B2D44; border: 1px solid #2D4460; color: #ccc; padding: 6px 10px;
  border-radius: 6px; font-size: 0.85em; font-family: inherit;
}
.hist-date-picker::-webkit-calendar-picker-indicator { filter: invert(0.7); }

/* ── History Summary Bar ── */
.history-summary { background: #142236; border-bottom: 1px solid #243B56; padding: 12px 0; }
.hist-stats {
  display: flex; gap: 24px; align-items: center; justify-content: center;
  flex-wrap: wrap; font-size: 0.9em;
}
.hist-stat { display: flex; flex-direction: column; align-items: center; }
.hist-stat-val { font-weight: 700; font-size: 1.2em; }
.hist-stat-val.positive { color: #4ADE80; }
.hist-stat-val.negative { color: #E87461; }
.hist-stat-label { color: #7A8DA0; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── History Mode Tweaks ── */
body.history-mode .live-indicator { display: none; }
body.history-mode .race-card.race-official { opacity: 1; }

/* ── Pick Result Highlight in History ── */
.pick-result {
  display: inline-block; font-size: 0.75em; font-weight: 600;
  padding: 1px 6px; border-radius: 3px; margin-left: 4px;
}
.pick-result.pick-won { background: #1a2a18; color: #4ADE80; }
.pick-result.pick-lost { background: #2a1a1a; color: #99AABB; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .horse-table { font-size: 0.75em; }
  .horse-table th, .horse-table td { padding: 4px 6px; }
  .race-header { padding: 8px 10px; }
  .form-tags { display: none; }
}
