:root {
  --navy-950: #111a2a;
  --navy-900: #18243a;
  --navy-850: #1e2c44;
  --navy-800: #263650;
  --ink: #1b273b;
  --muted: #68768b;
  --line: #dce3ed;
  --line-strong: #cbd5e2;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --canvas: #edf1f6;
  --blue: #3578f6;
  --blue-soft: #eaf1ff;
  --teal: #0d8c91;
  --teal-dark: #086a70;
  --teal-soft: #e3f5f4;
  --green: #25a86b;
  --green-soft: #e7f7ef;
  --amber: #e89b25;
  --amber-soft: #fff4dc;
  --red: #db5b63;
  --red-soft: #fdebed;
  --shadow-sm: 0 1px 2px rgba(20, 35, 60, .06), 0 4px 18px rgba(20, 35, 60, .04);
  --shadow-md: 0 14px 36px rgba(28, 42, 67, .11);
  --radius: 16px;
  --sidebar: 238px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  color: #dbe5f4;
  background:
    radial-gradient(circle at 20% 4%, rgba(26, 143, 151, .25), transparent 25%),
    linear-gradient(180deg, var(--navy-900), var(--navy-950));
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 13px; color: white; font-weight: 900; font-size: 19px;
  background: linear-gradient(145deg, #31b4a8, #2775ef);
  box-shadow: 0 8px 20px rgba(33, 132, 183, .28);
}
.brand-mark.small { width: 31px; height: 31px; border-radius: 10px; font-size: 15px; }
.brand > span:last-child { display: flex; align-items: baseline; font-size: 19px; letter-spacing: -.4px; }
.brand strong { color: white; }
.brand em { color: #72d2cb; font-style: normal; font-weight: 700; }
.nav-list { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  width: 100%; min-height: 45px; padding: 0 12px; display: grid;
  grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px;
  color: #aebbd0; background: transparent; border: 0; border-radius: 11px;
  text-align: left; cursor: pointer; transition: .18s ease;
}
.nav-item > span:first-child { color: #8092ac; font-size: 18px; text-align: center; }
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(45,128,246,.26), rgba(15,143,145,.11)); }
.nav-item.active > span:first-child { color: #68cfc8; }
.nav-item small { font-size: 9px; text-transform: uppercase; color: #71819a; }
.nav-item b { min-width: 20px; padding: 2px 6px; border-radius: 10px; font-size: 10px; text-align: center; color: #cfe9ff; background: rgba(62,126,235,.22); }
.sidebar-footer { margin-top: auto; padding: 15px 10px 0; display: grid; gap: 12px; color: #71819a; font-size: 11px; border-top: 1px solid rgba(255,255,255,.07); }
.api-indicator { display: grid; grid-template-columns: 9px 1fr; column-gap: 7px; align-items: center; }
.api-indicator strong { grid-column: 2; color: #8fa0b8; font-size: 10px; font-weight: 500; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(232,155,37,.12); }
.status-dot.online { background: #37c982; box-shadow: 0 0 0 3px rgba(55,201,130,.12); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 3px rgba(219,91,99,.12); }

.main-column { min-width: 0; min-height: 100vh; margin-left: var(--sidebar); max-width: calc(100vw - var(--sidebar)); }
.topbar {
  position: sticky; top: 0; z-index: 25; height: 70px; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.92); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(207,216,229,.8);
}
.topbar-context { display: grid; gap: 2px; }
.topbar-context strong { font-size: 15px; }
.eyebrow { color: var(--teal); font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; font-size: 19px; }
.icon-button:hover { color: var(--blue); border-color: #b8cdf6; }
.profile-button { display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border: 0; background: transparent; cursor: default; }
.profile-button > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy-800); font-size: 11px; font-weight: 800; }
.profile-button div { display: grid; text-align: left; }
.profile-button strong { font-size: 12px; }
.profile-button small { color: var(--muted); font-size: 10px; }
.mobile-brand { display: none; }

main { width: 100%; max-width: 1500px; min-width: 0; margin: 0 auto; padding: 28px 32px 54px; }
.page { min-width: 0; max-width: 100%; display: grid; gap: 22px; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: .4; transform: translateY(4px); } }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-heading h1 { margin: 3px 0 5px; font-size: clamp(25px, 2.4vw, 34px); line-height: 1.1; letter-spacing: -.8px; }
.page-heading p { margin: 0; color: var(--muted); }
.heading-kicker { color: var(--teal); font-weight: 800; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; }
.date-pill { padding: 10px 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; color: #46556b; background: white; border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-sm); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.summary-card { position: relative; overflow: hidden; min-height: 95px; padding: 17px; display: grid; align-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); }
.summary-card::after { content: ""; position: absolute; width: 70px; height: 70px; right: -27px; top: -26px; border-radius: 50%; background: var(--blue-soft); }
.summary-card.teal::after { background: var(--teal-soft); }
.summary-card.amber::after { background: var(--amber-soft); }
.summary-card.green::after { background: var(--green-soft); }
.summary-card span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .45px; }
.summary-card strong { font-size: 25px; letter-spacing: -.5px; }
.summary-card small { color: var(--muted); }

.panel { min-width: 0; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-header { padding: 17px 19px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 9px; }
.panel-title h2 { margin: 0; font-size: 15px; }
.panel-title span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; color: var(--teal-dark); background: var(--teal-soft); }
.panel-header small { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; color: #56657a; background: white; cursor: pointer; font-size: 12px; font-weight: 700; }
.filter-button:hover { border-color: #9fc4c5; }
.filter-button.active { color: white; border-color: var(--teal); background: var(--teal); }

.timeline-wrap { padding: 14px 18px 17px; overflow: hidden; }
.timeline { display: flex; gap: 10px; padding: 4px 1px 8px; overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity; }
.course-chip { position: relative; min-width: 150px; max-width: 150px; padding: 12px; display: grid; gap: 4px; scroll-snap-align: start; text-align: left; color: #425168; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.course-chip:hover { border-color: #9ab8c9; transform: translateY(-1px); }
.course-chip.current { color: #174d51; background: var(--teal-soft); border-color: #8ac9c6; box-shadow: inset 0 0 0 1px rgba(13,140,145,.08); }
.course-chip.finished { opacity: .58; }
.course-chip .chip-top { display: flex; align-items: center; justify-content: space-between; }
.course-chip b { color: var(--ink); font-size: 12px; }
.course-chip time { color: var(--teal-dark); font-weight: 800; }
.course-chip small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.course-chip .chip-status { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.course-chip.finished .chip-status { background: #8793a5; }
.course-chip.next .chip-status { background: var(--amber); box-shadow: 0 0 0 4px rgba(232,155,37,.13); }

.program-grid { padding: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.program-card { position: relative; min-height: 155px; padding: 16px; display: grid; gap: 13px; color: inherit; background: white; border: 1px solid var(--line); border-radius: 13px; transition: .18s ease; }
.program-card:hover { transform: translateY(-2px); border-color: #a8bccf; box-shadow: var(--shadow-md); }
.program-card.finished { opacity: .68; background: #fafbfd; }
.program-card.current { border-color: #7bc6c4; box-shadow: inset 3px 0 0 var(--teal); }
.program-card-head, .program-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.race-ref { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-weight: 900; }
.race-time { font-size: 19px; font-weight: 850; letter-spacing: -.5px; }
.race-place { display: grid; gap: 3px; }
.race-place strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.race-place span { color: var(--muted); font-size: 12px; }
.tag { padding: 4px 7px; border-radius: 7px; font-size: 9px; font-weight: 850; letter-spacing: .25px; text-transform: uppercase; background: var(--blue-soft); color: var(--blue); }
.tag.quinte { color: #7a5312; background: var(--amber-soft); }
.market-signal { color: var(--muted); font-size: 11px; }
.market-signal strong { color: var(--green); }

.course-nav {
  position: sticky; top: 82px; z-index: 18; padding: 10px;
  display: grid; grid-template-columns: minmax(130px, 1fr) minmax(180px, auto) minmax(130px, 1fr);
  gap: 10px; align-items: center; color: white;
  background: linear-gradient(100deg, var(--navy-900), var(--navy-800));
  border: 1px solid rgba(255,255,255,.08); border-radius: 14px; box-shadow: var(--shadow-md);
}
.course-nav button { min-height: 44px; padding: 6px 12px; display: flex; align-items: center; gap: 10px; color: #d8e2ef; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; cursor: pointer; }
.course-nav button:hover:not(:disabled) { color: white; background: rgba(255,255,255,.13); }
.course-nav button:disabled { opacity: .3; cursor: not-allowed; }
.course-nav button.next { justify-content: flex-end; text-align: right; }
.course-nav button div { display: grid; gap: 1px; }
.course-nav button small { color: #90a0b6; font-size: 9px; text-transform: uppercase; letter-spacing: .6px; }
.course-nav button strong { font-size: 11px; }
.course-nav-current { display: grid; justify-items: center; text-align: center; }
.course-nav-current strong { font-size: 14px; }
.course-nav-current span { color: #8dd4d0; font-size: 11px; }

.course-hero { overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); }
.course-identity { padding: 23px; background: linear-gradient(135deg, #fff, #f8fbff); }
.breadcrumb { margin-bottom: 14px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.breadcrumb a { color: var(--blue); font-weight: 700; }
.course-identity h1 { margin: 0 0 8px; font-size: clamp(24px, 3vw, 36px); line-height: 1.1; letter-spacing: -.8px; }
.course-subline { display: flex; flex-wrap: wrap; gap: 8px 15px; color: var(--muted); }
.course-subline strong { color: var(--ink); }
.course-facts { padding: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; align-content: center; background: var(--surface-soft); border-left: 1px solid var(--line); }
.fact { min-height: 63px; padding: 11px; display: grid; align-content: center; gap: 3px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.fact span { color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .45px; }
.fact strong { font-size: 14px; }

.runner-panel { min-width: 0; max-width: 100%; overflow: hidden; }
.runner-toolbar { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.runner-toolbar h2 { margin: 0; font-size: 15px; }
.runner-toolbar p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.view-toggle { display: flex; gap: 5px; padding: 3px; border-radius: 10px; background: var(--surface-soft); }
.view-toggle button { padding: 7px 9px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.view-toggle button.active { color: var(--ink); background: white; box-shadow: var(--shadow-sm); }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.runner-table { width: 100%; min-width: 980px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.runner-table th:nth-child(1) { width: 44px; }
.runner-table th:nth-child(2) { width: 50px; }
.runner-table th:nth-child(3) { width: 64px; }
.runner-table th:nth-child(4) { width: 170px; }
.runner-table th:nth-child(5) { width: 155px; }
.runner-table th:nth-child(6) { width: 125px; }
.runner-table th:nth-child(7) { width: 78px; }
.runner-table th:nth-child(8) { width: 160px; }
.runner-table th:nth-child(9) { width: 125px; }
.runner-table th:nth-child(10) { width: 120px; }
.runner-table th:nth-child(11) { width: 96px; }
.runner-table th:nth-child(12) { width: 126px; }
.runner-table th { position: sticky; top: 0; z-index: 2; padding: 10px 9px; color: #d9e3ef; background: var(--navy-800); border-right: 1px solid rgba(255,255,255,.08); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; white-space: nowrap; }
.runner-table th:first-child { padding-left: 15px; }
.runner-table td { padding: 11px 9px; border-right: 1px solid #e6ebf2; border-bottom: 1px solid #e4e9f0; vertical-align: middle; }
.runner-table tbody tr { background: white; transition: background .15s; }
.runner-table tbody tr:nth-child(even) { background: #f9fbfd; }
.runner-table tbody tr:hover { background: #f0f7f9; }
.runner-table tbody tr:last-child td { border-bottom: 0; }
.favorite-button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; color: #9aa6b7; background: transparent; cursor: pointer; font-size: 21px; line-height: 1; }
.favorite-button:hover { color: var(--amber); background: var(--amber-soft); }
.favorite-button.active { color: var(--amber); }
.runner-number { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--navy-800); font-weight: 850; }
.score { display: grid; gap: 2px; color: var(--blue); font-weight: 900; font-size: 16px; }
.score small { color: var(--muted); font-size: 9px; font-weight: 600; }
.horse-cell { min-width: 170px; display: grid; gap: 3px; }
.horse-cell strong { color: #176cb9; font-size: 13px; }
.horse-cell small, .connection-cell small { color: var(--muted); font-size: 9px; }
.connection-cell { min-width: 145px; display: grid; gap: 3px; }
.connection-cell span { overflow: hidden; max-width: 160px; white-space: nowrap; text-overflow: ellipsis; }
.elo-group { display: grid; grid-template-columns: repeat(3, minmax(34px, 1fr)); gap: 4px; }
.elo { padding: 5px 4px; display: grid; justify-items: center; border-radius: 7px; color: #245b9d; background: var(--blue-soft); font-weight: 850; font-size: 10px; }
.elo:nth-child(2) { color: #17755f; background: var(--green-soft); }
.elo:nth-child(3) { color: #905d13; background: var(--amber-soft); }
.elo small { font-size: 7px; opacity: .7; }
.odds { min-width: 72px; display: grid; gap: 2px; }
.odds strong { font-size: 16px; }
.odds small { color: var(--muted); font-size: 9px; }
.variation { font-size: 9px; font-weight: 800; }
.variation.up { color: var(--red); }
.variation.down { color: var(--green); }
.stake-cell { min-width: 145px; display: grid; gap: 6px; }
.stake-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 5px; align-items: center; font-size: 9px; }
.stake-row > span:first-child { font-weight: 850; color: var(--muted); }
.stake-track { height: 7px; overflow: hidden; border-radius: 5px; background: #e9edf3; }
.stake-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #3fbf94); }
.stake-row.sp .stake-fill { background: linear-gradient(90deg, #3279ed, #50a0ee); }
.stake-row strong { font-size: 9px; }
.music { min-width: 120px; color: #48566b; font-size: 10px; line-height: 1.4; }
.form-cell { min-width: 115px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.form-stat { padding: 5px 3px; display: grid; justify-items: center; gap: 1px; border-radius: 7px; background: var(--surface-soft); }
.form-stat strong { font-size: 10px; }
.form-stat small { color: var(--muted); font-size: 7px; }
.info-tags { min-width: 90px; display: flex; flex-wrap: wrap; gap: 4px; }
.info-tag { padding: 4px 6px; border-radius: 6px; color: #46546a; background: #edf1f6; font-size: 8px; font-weight: 800; }
.info-tag.good { color: #15724f; background: var(--green-soft); }
.selection-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.selection-action { min-height: 28px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; font-size: 8px; font-weight: 850; }
.selection-action:hover { border-color: #93adcb; }
.selection-action.active[data-selection-status="retained"] { color: #15724f; background: var(--green-soft); border-color: #a6dfc5; }
.selection-action.active[data-selection-status="watch"] { color: #8a5a11; background: var(--amber-soft); border-color: #efd398; }
.selection-action.active[data-selection-status="rejected"] { color: #a33c45; background: var(--red-soft); border-color: #efb8bd; }

.empty-state, .error-state { padding: 44px 20px; display: grid; place-items: center; text-align: center; gap: 9px; color: var(--muted); }
.empty-state strong, .error-state strong { color: var(--ink); font-size: 16px; }
.error-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 22px; }
.primary-button { padding: 10px 14px; color: white; background: var(--blue); border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; }
.loading-view { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.loading-view strong { color: var(--ink); }
.loader { width: 33px; height: 33px; margin-bottom: 5px; border: 3px solid #d8e3ef; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-region { position: fixed; z-index: 80; right: 22px; bottom: 22px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; color: white; background: var(--navy-900); border-radius: 11px; box-shadow: var(--shadow-md); animation: toastIn .2s ease; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
.favorite-drawer { position: fixed; z-index: 60; inset: 0 0 0 auto; width: min(400px, 94vw); padding: 23px; background: white; box-shadow: -20px 0 50px rgba(25,39,62,.18); transform: translateX(105%); transition: transform .23s ease; }
.favorite-drawer.open { transform: none; }
.drawer-backdrop { position: fixed; z-index: 55; inset: 0; background: rgba(17,26,42,.27); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; }
.drawer-head button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--surface-soft); cursor: pointer; }
.favorite-list { margin-top: 20px; display: grid; gap: 8px; }
.favorite-item { padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 10px; }
.favorite-item div { display: grid; gap: 2px; }
.favorite-item small { color: var(--muted); }
.dashboard-list { padding: 18px; display: grid; gap: 9px; }
.dashboard-row { padding: 13px 14px; display: grid; grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(80px, .5fr)) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: white; }
.dashboard-row:hover { border-color: #afc0d3; }
.dashboard-row-main { display: grid; gap: 3px; }
.dashboard-row-main strong { color: #176cb9; }
.dashboard-row-main small, .dashboard-cell small { color: var(--muted); }
.dashboard-cell { display: grid; gap: 2px; }
.status-badge { width: fit-content; padding: 5px 8px; border-radius: 7px; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.status-badge.retained { color: #15724f; background: var(--green-soft); }
.status-badge.watch { color: #8a5a11; background: var(--amber-soft); }
.status-badge.rejected { color: #a33c45; background: var(--red-soft); }
.row-link { padding: 7px 9px; color: var(--blue); background: var(--blue-soft); border: 0; border-radius: 8px; cursor: pointer; font-weight: 800; font-size: 10px; }
.journal-form { padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.journal-form label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 750; }
.journal-form input, .journal-form select, .journal-form textarea { width: 100%; padding: 9px 10px; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; }
.journal-form input:focus, .journal-form select:focus, .journal-form textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,120,246,.1); }
.journal-form .wide { grid-column: span 2; }
.journal-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.analysis-workspace { min-width: 0; overflow: hidden; }
.analysis-tabs { padding: 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.analysis-tabs button { min-width: 0; min-height: 44px; padding: 8px 11px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 11px; font-weight: 800; }
.analysis-tabs button:hover { color: var(--ink); background: white; }
.analysis-tabs button.active { color: var(--teal-dark); background: white; border-color: var(--line); box-shadow: var(--shadow-sm); }
.analysis-tabs button b { min-width: 23px; padding: 3px 6px; border-radius: 10px; color: var(--muted); background: #e9eef5; font-size: 9px; }
.analysis-tabs button.active b { color: var(--teal-dark); background: var(--teal-soft); }
.analysis-filters { padding: 15px 18px; display: grid; grid-template-columns: minmax(230px, 1fr) 190px auto; gap: 10px; align-items: end; border-bottom: 1px solid var(--line); }
.analysis-filters label { min-width: 0; display: grid; gap: 5px; }
.analysis-filters label > span { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.analysis-filters input, .analysis-filters select { width: 100%; min-width: 0; height: 39px; padding: 0 10px; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; }
.analysis-filters input:focus, .analysis-filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,120,246,.1); }
.analysis-filters .primary-button { height: 39px; }
.analysis-result-head { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.analysis-result-head h2 { margin: 0; font-size: 15px; }
.analysis-result-head small { color: var(--muted); }
.analysis-table { width: 100%; min-width: 900px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.analysis-table th { padding: 10px 11px; color: #d9e3ef; background: var(--navy-800); border-right: 1px solid rgba(255,255,255,.08); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; white-space: nowrap; }
.analysis-table td { padding: 11px; border-right: 1px solid #e6ebf2; border-bottom: 1px solid #e4e9f0; vertical-align: middle; }
.analysis-table tbody tr:nth-child(even) { background: #f9fbfd; }
.analysis-table tbody tr:hover { background: #f0f7f9; }
.analysis-table tbody tr:last-child td { border-bottom: 0; }
.horse-analysis-table th:nth-child(1) { width: 75px; }
.horse-analysis-table th:nth-child(2) { width: 190px; }
.horse-analysis-table th:nth-child(3) { width: 165px; }
.horse-analysis-table th:nth-child(4), .horse-analysis-table th:nth-child(5) { width: 75px; }
.horse-analysis-table th:nth-child(6) { width: 170px; }
.horse-analysis-table th:nth-child(7) { width: 145px; }
.horse-analysis-table th:nth-child(8) { width: 70px; }
.analysis-rank { display: flex; align-items: center; gap: 7px; }
.analysis-rank small { color: var(--muted); font-size: 9px; font-weight: 800; }
.analysis-elo { color: #176cb9; font-size: 15px; }
.analysis-form { display: flex; flex-wrap: wrap; gap: 4px; }
.analysis-form span { padding: 5px 7px; color: var(--muted); background: var(--surface-soft); border-radius: 7px; font-size: 9px; }
.analysis-form b { color: var(--ink); }
.rate-pair { display: flex; gap: 5px; }
.rate-pair > span { min-width: 57px; padding: 5px 7px; display: grid; gap: 1px; border-radius: 8px; background: var(--green-soft); }
.rate-pair > span:nth-child(2) { background: var(--blue-soft); }
.rate-pair b { color: #15724f; font-size: 10px; }
.rate-pair > span:nth-child(2) b { color: #225fae; }
.rate-pair small { color: var(--muted); font-size: 7px; text-transform: uppercase; }
.analysis-person { min-width: 0; display: flex; align-items: center; gap: 9px; }
.analysis-person > span { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: white; background: linear-gradient(145deg, var(--teal), var(--blue)); font-weight: 900; }
.analysis-person div { min-width: 0; display: grid; gap: 2px; }
.analysis-person strong, .analysis-person small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.analysis-person small { color: var(--muted); font-size: 9px; }
.people-analysis-table th:first-child { width: 220px; }
.people-analysis-table th { width: 100px; }
.people-analysis-table th:nth-last-child(2) { width: 145px; }
.opinion-grid { padding: 17px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.opinion-card { min-width: 0; padding: 15px; display: grid; gap: 13px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.opinion-card:hover { border-color: #a8bccf; box-shadow: var(--shadow-sm); }
.opinion-card-head { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.opinion-card-head div { min-width: 0; display: grid; gap: 2px; }
.opinion-card-head strong, .opinion-card-head small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.opinion-card-head strong { color: #176cb9; }
.opinion-card-head small { color: var(--muted); font-size: 9px; }
.opinion-card blockquote { margin: 0; padding: 12px 14px; color: #3f4e64; background: var(--amber-soft); border-left: 3px solid var(--amber); border-radius: 0 9px 9px 0; line-height: 1.5; }
.opinion-trainer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.opinion-trainer > div:first-child { display: grid; gap: 2px; }
.opinion-trainer small { color: var(--muted); }
.opinion-card > .row-link { justify-self: end; }
.betting-workspace { min-width: 0; overflow: hidden; }
.betting-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.betting-table { width: 100%; min-width: 1050px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.betting-table th { padding: 10px 9px; color: #d9e3ef; background: var(--navy-800); border-right: 1px solid rgba(255,255,255,.08); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; white-space: nowrap; }
.betting-table td { padding: 10px 9px; border-right: 1px solid #e6ebf2; border-bottom: 1px solid #e4e9f0; vertical-align: middle; }
.betting-table tbody tr:nth-child(even) { background: #f9fbfd; }
.betting-table tbody tr:hover { background: #f0f7f9; }
.betting-table tbody tr:last-child td { border-bottom: 0; }
.horses-betting-table th:nth-child(1) { width: 55px; }
.horses-betting-table th:nth-child(2) { width: 80px; }
.horses-betting-table th:nth-child(3) { width: 180px; }
.horses-betting-table th:nth-child(4) { width: 160px; }
.horses-betting-table th:nth-child(5), .horses-betting-table th:nth-child(6), .horses-betting-table th:nth-child(7), .horses-betting-table th:nth-child(8) { width: 80px; }
.horses-betting-table th:nth-child(9) { width: 85px; }
.horses-betting-table th:nth-child(10) { width: 70px; }
.betting-rank { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; color: var(--teal-dark); background: var(--teal-soft); }
.score.secondary { color: #7452b8; }
.peno-table { min-width: 1180px; }
.peno-table th:nth-child(1) { width: 85px; }
.peno-table th:nth-child(2) { width: 80px; }
.peno-table th:nth-child(3) { width: 175px; }
.peno-table th:nth-child(4), .peno-table th:nth-child(5), .peno-table th:nth-child(7), .peno-table th:nth-child(8), .peno-table th:nth-child(9) { width: 70px; }
.peno-table th:nth-child(6) { width: 105px; }
.peno-table th:nth-child(10) { width: 260px; }
.peno-table th:nth-child(11) { width: 70px; }
.peno-table tr.peno-selected { background: #f2fbf6; }
.incident-pair { display: flex; gap: 4px; }
.incident-pair span { min-width: 40px; padding: 5px; display: grid; justify-items: center; border-radius: 7px; background: var(--surface-soft); font-weight: 850; }
.incident-pair small { color: var(--muted); font-size: 7px; font-weight: 600; }
.peno-reason { display: block; color: #a33c45; font-size: 9px; line-height: 1.4; }
.peno-reason.valid { color: #15724f; font-weight: 750; }
.crack-grid { padding: 17px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.crack-card { min-width: 0; padding: 15px; display: grid; gap: 13px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, white, #fbfdff); }
.crack-card:hover { transform: translateY(-2px); border-color: #9db5ca; box-shadow: var(--shadow-md); }
.crack-head { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.crack-head > div { min-width: 0; display: grid; gap: 2px; }
.crack-head strong, .crack-head small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.crack-head strong { color: #176cb9; }
.crack-head small { color: var(--muted); font-size: 9px; }
.confluence-count { min-width: 47px; padding: 6px; display: grid; justify-items: center; color: #805716; background: var(--amber-soft); border-radius: 9px; font-size: 17px; font-weight: 900; }
.confluence-count small { color: #946a28; font-size: 7px; text-transform: uppercase; }
.crack-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.crack-metrics > span { padding: 8px; display: grid; gap: 2px; border-radius: 8px; background: var(--surface-soft); }
.crack-metrics small { color: var(--muted); font-size: 8px; }
.crack-metrics strong { font-size: 15px; }
.signal-list { display: flex; flex-wrap: wrap; gap: 5px; }
.signal-list span { padding: 5px 7px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 7px; font-size: 8px; font-weight: 850; text-transform: uppercase; }
.crack-card > .row-link { justify-self: end; }
.archive-filter-panel { padding: 17px; }
.archive-filters { display: grid; grid-template-columns: 145px 145px 150px minmax(150px, 1fr) minmax(150px, 1fr) auto; gap: 10px; align-items: end; }
.archive-filters label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .35px; }
.archive-filters input, .archive-filters select { width: 100%; min-width: 0; height: 39px; padding: 0 10px; color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; }
.archive-filters input:focus, .archive-filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,120,246,.1); }
.archive-filters .primary-button { height: 39px; white-space: nowrap; }
.archive-day { min-width: 0; display: grid; gap: 12px; }
.archive-day-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 0 2px; }
.archive-day-head h2 { margin: 3px 0 0; font-size: 19px; text-transform: capitalize; }
.archive-day-head > span { color: var(--muted); font-size: 11px; }
.archive-grid { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.archive-card { min-width: 0; padding: 16px; display: grid; gap: 12px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); transition: .18s ease; }
.archive-card:hover { transform: translateY(-2px); border-color: #9db5ca; box-shadow: var(--shadow-md); }
.archive-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.archive-card-head time { font-size: 17px; font-weight: 850; }
.archive-card-title { min-width: 0; display: grid; gap: 3px; }
.archive-card-title strong, .archive-card-title span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.archive-card-title strong { font-size: 15px; }
.archive-card-title span, .archive-card-meta { color: var(--muted); font-size: 11px; }
.archive-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.archive-arrival { margin: 0; padding: 11px; display: grid; gap: 7px; list-style: none; background: var(--surface-soft); border-radius: 10px; }
.archive-arrival li { min-width: 0; display: grid; grid-template-columns: 25px minmax(0, 1fr); align-items: center; gap: 8px; }
.archive-arrival li > span:last-child { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.archive-arrival strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.archive-arrival small { color: var(--muted); white-space: nowrap; font-size: 9px; }
.arrival-place { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: #59667a; background: #e7ebf1; font-weight: 900; font-size: 10px; }
.arrival-place.place-1 { color: #805716; background: #ffe7a9; }
.arrival-place.place-2 { color: #526174; background: #e1e7ee; }
.arrival-place.place-3 { color: #8a5534; background: #f1d7c7; }
.archive-no-result { padding: 18px; color: var(--muted); background: var(--surface-soft); border-radius: 10px; text-align: center; font-size: 11px; }
.archive-open { display: flex; align-items: center; justify-content: flex-end; gap: 7px; color: var(--blue); font-size: 10px; font-weight: 850; }
.archive-open b { font-size: 14px; }
.archive-result-panel { min-width: 0; overflow: hidden; }
.history-table { width: 100%; min-width: 760px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.history-table th:nth-child(1) { width: 75px; }
.history-table th:nth-child(2) { width: 55px; }
.history-table th:nth-child(3) { width: 190px; }
.history-table th:nth-child(4) { width: 190px; }
.history-table th:nth-child(5), .history-table th:nth-child(6) { width: 80px; }
.history-table th:nth-child(7) { width: 150px; }
.history-table th:nth-child(8) { width: 100px; }
.history-table th { padding: 10px 11px; color: #d9e3ef; background: var(--navy-800); border-right: 1px solid rgba(255,255,255,.08); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; white-space: nowrap; }
.history-table td { padding: 11px; border-right: 1px solid #e6ebf2; border-bottom: 1px solid #e4e9f0; vertical-align: middle; }
.history-table tbody tr:nth-child(even) { background: #f9fbfd; }
.history-table tbody tr:hover { background: #f0f7f9; }
.history-table tbody tr:last-child td { border-bottom: 0; }
.history-result { min-width: 35px; height: 31px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 9px; color: #59667a; background: #edf1f6; font-weight: 900; }
.history-result.podium.result-1 { color: #805716; background: #ffe7a9; }
.history-result.podium.result-2 { color: #526174; background: #e1e7ee; }
.history-result.podium.result-3 { color: #8a5534; background: #f1d7c7; }
.history-report { color: var(--green); }
.mobile-nav { display: none; }

.login-body { min-height: 100vh; background: var(--navy-950); }
.login-layout { width: 100%; max-width: none; min-height: 100vh; padding: 0; display: grid; grid-template-columns: minmax(420px, .95fr) minmax(480px, 1.05fr); }
.login-intro { padding: clamp(36px, 6vw, 88px); display: flex; flex-direction: column; justify-content: space-between; color: #dce6f4; background: radial-gradient(circle at 20% 18%, rgba(28,159,157,.24), transparent 30%), linear-gradient(145deg, #101a2c, #1c2e49); }
.login-brand { display: flex; align-items: center; gap: 11px; font-size: 20px; }
.login-brand > span:last-child { display: flex; }
.login-brand em { color: #72d2cb; font-style: normal; font-weight: 750; }
.login-intro h1 { max-width: 620px; margin: 12px 0 18px; color: white; font-size: clamp(40px, 5vw, 72px); line-height: .98; letter-spacing: -2.4px; }
.login-intro p { max-width: 590px; margin: 0; color: #9fb0c8; font-size: 16px; line-height: 1.65; }
.login-intro > small { color: #72849f; }
.heading-kicker.light { color: #71d4cd; }
.login-card-wrap { padding: 30px; display: grid; place-items: center; background: #eef2f7; }
.login-card { width: min(430px, 100%); padding: 36px; display: grid; gap: 20px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-md); }
.login-card h2 { margin: 6px 0 4px; font-size: 27px; letter-spacing: -.6px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 7px; color: #47556b; font-weight: 750; font-size: 11px; }
.login-card input { width: 100%; padding: 12px 13px; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; }
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,120,246,.1); }
.login-error { min-height: 18px; color: var(--red) !important; font-size: 11px; }
.login-submit { min-height: 47px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; color: white; background: linear-gradient(100deg, var(--teal), var(--blue)); border: 0; border-radius: 11px; cursor: pointer; font-weight: 800; }
.login-submit:disabled { opacity: .6; cursor: wait; }
.login-help { color: var(--muted); text-align: center; }

@media (max-width: 1180px) {
  .program-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runner-table th:nth-child(6), .runner-table td:nth-child(6), .runner-table th:nth-child(10), .runner-table td:nth-child(10) { display: none; }
  .runner-table { min-width: 760px; }
  .dashboard-row { grid-template-columns: minmax(170px, 1fr) repeat(2, minmax(80px, .5fr)) auto; }
  .dashboard-row .dashboard-cell.optional { display: none; }
  .archive-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-table { min-width: 820px; }
}

@media (max-width: 800px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main-column { margin: 0; }
  .main-column { max-width: 100vw; }
  .topbar { height: 61px; padding: 0 15px; }
  .topbar-context, .profile-button div { display: none; }
  .mobile-brand { padding: 0; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; }
  main { padding: 19px 14px 88px; }
  .page-heading { align-items: flex-start; }
  .date-pill { display: none; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary-card { min-height: 87px; padding: 13px; }
  .summary-card strong { font-size: 21px; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .program-grid { grid-template-columns: 1fr; padding: 12px; }
  .course-nav { top: 69px; grid-template-columns: 1fr 1fr; }
  .course-nav-current { grid-column: 1 / -1; grid-row: 1; }
  .course-nav button { grid-row: 2; }
  .course-hero { grid-template-columns: 1fr; }
  .course-identity { padding: 19px; }
  .course-facts { border-left: 0; border-top: 1px solid var(--line); }
  .view-toggle { display: none; }
  .mobile-nav { position: fixed; z-index: 40; left: 10px; right: 10px; bottom: 9px; height: 62px; padding: 5px; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(24,36,58,.96); backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.08); border-radius: 17px; box-shadow: 0 12px 30px rgba(17,26,42,.28); }
  .mobile-nav a, .mobile-nav button { display: grid; place-content: center; justify-items: center; gap: 2px; color: #94a4bb; border: 0; border-radius: 12px; background: transparent; }
  .mobile-nav a.active { color: white; background: rgba(48,145,151,.2); }
  .mobile-nav span { font-size: 18px; }
  .mobile-nav small { font-size: 9px; }
  .toast-region { left: 14px; right: 14px; bottom: 82px; }
  .toast { min-width: 0; max-width: none; }
  .runner-table { min-width: 670px; }
  .runner-table th:nth-child(8), .runner-table td:nth-child(8), .runner-table th:nth-child(9), .runner-table td:nth-child(9) { display: none; }
  .dashboard-row { grid-template-columns: 1fr auto; }
  .dashboard-row .dashboard-cell { display: none; }
  .journal-form { grid-template-columns: 1fr 1fr; }
  .analysis-tabs { display: flex; overflow-x: auto; }
  .analysis-tabs button { min-width: 145px; flex: 0 0 auto; }
  .analysis-filters { grid-template-columns: 1fr 150px; }
  .analysis-filters .primary-button { grid-column: 1 / -1; }
  .opinion-grid { grid-template-columns: 1fr; padding: 12px; }
  .crack-grid { grid-template-columns: 1fr; padding: 12px; }
  .archive-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archive-filters .primary-button { grid-column: 1 / -1; }
  .archive-grid { grid-template-columns: 1fr; }
  .history-table { min-width: 650px; }
  .history-table th:nth-child(7), .history-table td:nth-child(7) { display: none; }
  .login-layout { grid-template-columns: 1fr; min-height: 100vh; }
  .login-intro { display: none; }
  .login-card-wrap { min-height: 100vh; padding: 18px; }
  .login-card { padding: 27px 22px; }
}

@media (max-width: 480px) {
  .page-heading h1 { font-size: 26px; }
  .summary-card span { font-size: 9px; }
  .summary-card small { font-size: 9px; }
  .filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .filter-button { white-space: nowrap; }
  .course-nav { padding: 8px; gap: 7px; }
  .course-nav button { padding: 5px 8px; }
  .course-nav button strong { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .journal-form { grid-template-columns: 1fr; }
  .journal-form .wide { grid-column: auto; }
  .analysis-filters { grid-template-columns: 1fr; }
  .analysis-filters .primary-button { grid-column: auto; }
  .opinion-trainer { align-items: flex-start; flex-direction: column; }
  .archive-filters { grid-template-columns: 1fr; }
  .archive-filters .primary-button { grid-column: auto; }
}
