:root {
  --canvas: #f6f4ee;
  --surface: #ffffff;
  --surface-subtle: #fbfaf6;
  --ink: #111613;
  --ink-muted: #555f58;
  --ink-faint: #848e87;
  --border: #dfd9cc;
  --border-strong: #c8c0af;
  --emerald: #0d5c3e;
  --emerald-dark: #09422c;
  --emerald-soft: #e6f2ec;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --crimson: #b91c1c;
  --crimson-soft: #fee2e2;
  --slate-soft: #eceae3;
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(17, 22, 19, 0.05);
  --shadow-md: 0 12px 32px rgba(17, 22, 19, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  background-image: radial-gradient(rgba(13, 92, 62, 0.04) 1px, transparent 0);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Masthead */
.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.masthead-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--emerald);
  color: #f6f4ee;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: var(--emerald-soft);
  color: var(--emerald);
  padding: 2px 7px;
  border-radius: 4px;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.control-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  font-weight: 600;
}

.control-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
}

.control-input:focus {
  outline: 2px solid rgba(13, 92, 62, 0.25);
  border-color: var(--emerald);
}

.search-group {
  display: flex;
  align-items: center;
}

.search-input {
  width: 190px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}

.btn-icon {
  height: 36px;
  width: 36px;
  border: 1px solid var(--emerald);
  background: var(--emerald);
  color: #fff;
  border-top-right-radius: 7px;
  border-bottom-right-radius: 7px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.btn-icon:hover { background: var(--emerald-dark); }

.btn-outline {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline:hover { border-color: var(--emerald); color: var(--emerald); }

.btn-primary {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--emerald);
  background: var(--emerald);
  color: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.btn-primary:hover { background: var(--emerald-dark); }

.dot-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.dot-status.active { background: #16a34a; }

/* Subnav */
.subnav {
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
}

.subnav-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tab-group { display: flex; gap: 6px; }

.tab-btn {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab-btn.active {
  color: var(--emerald);
  border-bottom-color: var(--emerald);
}

.tab-count, .tab-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--slate-soft);
  color: var(--ink-muted);
}

.tab-btn.active .tab-count, .tab-btn.active .tab-pill {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.subnav-right {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}

.badge-clean {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--emerald);
  font-weight: 500;
}

.doc-link {
  font-size: 12px;
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 600;
}

.doc-link:hover { color: var(--emerald); }

/* Workspace */
.workspace {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 180ms ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scanner Layout */
.scanner-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.race-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 126px;
}

.rail-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rail-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.rail-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
}

.race-list {
  overflow-y: auto;
  padding: 8px;
}

.reunion-group { margin-bottom: 10px; }

.reunion-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 8px 4px;
  display: flex;
  justify-content: space-between;
}

.race-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 3px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  color: var(--ink);
  transition: background 120ms, border-color 120ms;
}

.race-item:hover { background: var(--surface-subtle); border-color: var(--border); }

.race-item.active {
  background: var(--emerald-soft);
  border-color: var(--emerald);
}

.race-item-id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--emerald);
}

.race-item-meta {
  font-size: 11px;
  color: var(--ink-muted);
  display: block;
}

.pill-free {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  background: var(--emerald);
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
}

/* Race Card Stage */
.scanner-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.race-hero {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #faf8f2 100%);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
}

.race-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.race-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.race-specs {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kpi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  min-width: 96px;
}

.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  margin-top: 1px;
}

.kpi-val.emerald { color: var(--emerald); }
.kpi-val.amber { color: var(--amber); }
.kpi-val.crimson { color: var(--crimson); }

/* Data Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pro-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pro-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.pro-table th:hover { color: var(--emerald); }
.pro-table th.sorted { color: var(--emerald); }

.pro-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #efece4;
  vertical-align: middle;
}

.pro-table tbody tr:hover { background: #faf8f3; }

.num-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.horse-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.horse-btn:hover { color: var(--emerald); text-decoration: underline; }

.sub-line {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: block;
  margin-top: 2px;
}

.mono { font-family: var(--font-mono); }

.odds-main {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
}

.move-down { color: var(--emerald); font-size: 11px; font-family: var(--font-mono); }
.move-up { color: var(--crimson); font-size: 11px; font-family: var(--font-mono); }

.prob-cell { min-width: 110px; }
.prob-bar-track {
  height: 5px;
  background: var(--slate-soft);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
}
.prob-bar-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: 99px;
}

.delta-pos { color: var(--emerald); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.delta-neg { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; }

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

.pill-first-d4 { background: var(--amber-soft); color: var(--amber); border: 1px solid #f59e0b; }
.pill-d4 { background: var(--emerald-soft); color: var(--emerald); }
.pill-da, .pill-dp { background: #e0f2fe; color: #0369a1; }
.pill-ferre { background: var(--slate-soft); color: var(--ink-muted); }

.pill-dai-high { background: var(--crimson-soft); color: var(--crimson); }
.pill-dai-med { background: var(--amber-soft); color: var(--amber); }
.pill-dai-low { background: var(--emerald-soft); color: var(--emerald); }

.speed-rank {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--slate-soft);
  color: var(--ink);
  margin-right: 4px;
}

.speed-rank.top { background: var(--emerald); color: #fff; }

.musique-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* Radar Grid */
.radar-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.02em;
}

.section-lead {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
}

.radar-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.radar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.radar-card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.radar-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.radar-row {
  padding: 10px 16px;
  border-bottom: 1px solid #efece4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.radar-row:last-child { border-bottom: 0; }
.radar-row:hover { background: #faf8f3; }

.radar-metric {
  text-align: right;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* Paywall / Empty States */
.empty-state {
  padding: 28px 18px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
}

.empty-state.large { padding: 56px 24px; }

.paywall-box {
  padding: 44px 24px;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.paywall-box h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 8px;
}

.paywall-box p { color: var(--ink-muted); margin: 0 0 18px; }

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 22, 19, 0.42);
  z-index: 60;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100vw);
  background: var(--surface);
  z-index: 70;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--emerald);
  font-weight: 600;
}

.drawer-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 22px;
}

.btn-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
}

.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 18px 0 8px;
  font-weight: 600;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 22, 19, 0.45);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: min(440px, 100%);
  box-shadow: var(--shadow-md);
}

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

.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
}

.modal-desc {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 14px;
}

.full-width { width: 100%; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* Top Banner & Pricing & Legal */
.top-banner {
  background: var(--emerald);
  color: #fff;
  padding: 10px 20px;
  font-size: 13px;
  text-align: center;
}
.top-banner code {
  background: rgba(255, 255, 255, 0.16);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  user-select: all;
}

.pricing-hero {
  max-width: 760px;
  margin: 8px auto 26px;
  text-align: center;
}

.active-plan-banner {
  margin-top: 14px;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--emerald-soft);
  border: 1px solid var(--emerald);
  color: var(--emerald);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
  margin-bottom: 22px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
}

.price-card.featured {
  border: 2px solid var(--emerald);
  box-shadow: 0 10px 28px rgba(13, 92, 62, 0.10);
}

.price-ribbon {
  position: absolute;
  top: -11px;
  right: 18px;
  background: var(--emerald);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 99px;
}

.price-tier {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.price-amount {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  margin: 8px 0 6px;
  letter-spacing: -0.02em;
}

.price-period {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}

.price-desc {
  color: var(--ink-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.price-features {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  flex: 1;
}

.price-features li {
  padding: 6px 0 6px 20px;
  position: relative;
  font-size: 13px;
  border-bottom: 1px dashed #ebe7dc;
}

.price-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--emerald);
  font-weight: 700;
}

.b2b-banner {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.b2b-title {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 2px 0 6px;
}

.legal-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 920px;
  margin: 0 auto;
}

.legal-doc h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 22px 0 8px;
  color: var(--emerald);
}

.legal-doc p, .legal-doc li {
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.6;
}

.checkout-error {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12.5px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 24px;
}

.footer-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

[hidden] { display: none !important; }

/* Mobile Responsive */
@media (max-width: 960px) {
  .scanner-layout { grid-template-columns: 1fr; }
  .race-rail {
    position: static;
    max-height: 260px;
  }
  .radar-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .legal-doc { padding: 20px 18px; }
  .search-input { width: 145px; }
}
