/* Lightweight RP-influenced styling — dark theme.
   Deep navy page background, high-contrast text, accent-tinted winners. */

:root {
  /* Surface */
  --rp-bg:      #0e1624;   /* page background */
  --rp-surface: #1a2336;   /* cards, tables */
  --rp-surface-2:#22304a;  /* hover / sub-rows */
  --rp-border:  #2c3a55;
  --rp-dark:    #0b1320;   /* deeper than bg, used for header */
  --rp-accent:  #f0b232;

  /* Text */
  --rp-text:    #e8edf6;   /* primary text */
  --rp-text-2:  #a9b3c8;   /* secondary text */
  --rp-muted:   #6f7c97;   /* tertiary / labels */

  /* Links */
  --rp-link:        #79b4ff;
  --rp-link-hover:  #b9d6ff;

  /* Winners / placed accents (warm, on dark) */
  --rp-pos1:    #3a2d10;   /* gold tint  */
  --rp-pos2:    #2e2918;   /* silvery    */
  --rp-pos3:    #2a251a;   /* bronzy     */

  /* Chips */
  --rp-status-bg: #4a3300;
  --rp-status-fg: #ffd58a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--rp-bg);
  color: var(--rp-text);
  font-size: 14px;
  line-height: 1.45;
}

a       { color: var(--rp-link); text-decoration: none; }
a:hover { color: var(--rp-link-hover); text-decoration: underline; }

/* ---------- header ---------- */
header {
  background: var(--rp-dark);
  color: var(--rp-text);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rp-border);
}
header .brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
}
header .brand a { color: var(--rp-text); }
header form { margin: 0; }
header input[type="search"] {
  background: var(--rp-surface-2);
  color: var(--rp-text);
  border: 1px solid var(--rp-border); border-radius: 3px;
  padding: 6px 10px; font-size: 14px; width: 240px;
}
header input[type="search"]::placeholder { color: var(--rp-muted); }
header nav { font-size: 13px; }
header nav a { color: var(--rp-link); margin-left: 14px; }

/* ---------- primary site tabs (Racing | Options) ---------- */
.site-tabs {
  display: flex;
  gap: 2px;
  background: var(--rp-dark);
  padding: 0 16px;
  border-bottom: 1px solid var(--rp-border);
}
.site-tabs a {
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--rp-text-2);
  border-bottom: 3px solid transparent;
  text-decoration: none;
}
.site-tabs a:hover {
  color: var(--rp-text);
  background: var(--rp-surface);
  text-decoration: none;
}
.site-tabs a.active {
  color: var(--rp-accent);
  background: var(--rp-surface);
  border-bottom-color: var(--rp-accent);
}

/* ---------- secondary sub-tabs (Data entry | Symbol summary) ---------- */
.sub-tabs {
  display: flex;
  gap: 2px;
  background: var(--rp-surface);
  padding: 0 18px;
  border-bottom: 1px solid var(--rp-border);
}
.sub-tabs a {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-text-2);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.sub-tabs a:hover { color: var(--rp-text); text-decoration: none; }
.sub-tabs a.active {
  color: var(--rp-accent);
  border-bottom-color: var(--rp-accent);
}

/* ---------- breadcrumb ---------- */
.crumbs {
  background: var(--rp-surface);
  border-bottom: 1px solid var(--rp-border);
  padding: 7px 20px;
  font-size: 13px;
  color: var(--rp-text-2);
}
.crumbs a { color: var(--rp-link); }
.crumbs .sep { margin: 0 8px; color: var(--rp-muted); }
.crumbs .here { color: var(--rp-text); font-weight: 600; }

main { max-width: 1180px; margin: 18px auto; padding: 0 16px; }

h1, h2, h3, h4 { margin: 16px 0 8px 0; color: var(--rp-text); }
h1 { font-size: 22px; }
h2 { font-size: 18px; color: var(--rp-text); border-bottom: 2px solid var(--rp-border); padding-bottom: 4px; }
h3 { font-size: 15px; }

.muted   { color: var(--rp-text-2); }
.tag     { display: inline-block; background: var(--rp-surface-2);
           color: var(--rp-text); border-radius: 3px;
           padding: 1px 7px; margin-right: 5px; font-size: 12px;
           border: 1px solid var(--rp-border); }
.tag.gbr { background: #1d3a5e; border-color: #244a73; }
.tag.ire { background: #1d4a2d; border-color: #245a37; }
.tag.fr  { background: #5a4419; border-color: #735420; }
.tag.usa { background: #5a1d20; border-color: #732428; }
.tag.win   { background: #1d4a2d; border-color: #2e7d46; color: #d7f5e0; font-weight: 600; }
.tag.place { background: #3a2c5e; border-color: #5a4a86; color: #e6ddff; font-weight: 600; }
.tag.dom   { background: #8a6d00; border-color: #b8901a; color: #fff4cc; font-weight: 700; }
.status  { display: inline-block; background: var(--rp-status-bg);
           color: var(--rp-status-fg); border-radius: 3px; padding: 1px 6px;
           text-transform: uppercase; font-weight: 600; font-size: 11px; }

/* ---------- calendar (index page) ---------- */
.calendar {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.calendar-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.calendar-nav h2 {
  margin: 0; font-size: 22px;
  color: var(--rp-text);
  border: none; padding: 0;
}
.calendar-pickers {
  display: flex; gap: 8px; align-items: center;
}
.calendar-pickers select {
  background: var(--rp-surface-2);
  color: var(--rp-text);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.calendar-pickers select:hover { background: var(--rp-surface); }
.calendar-pickers select:focus {
  outline: 2px solid var(--rp-accent); outline-offset: -2px;
}
.calendar-pickers select option[data-empty="1"] { color: var(--rp-muted); }
.calendar-arrow {
  display: inline-block;
  background: var(--rp-surface-2);
  color: var(--rp-text);
  font-size: 18px;
  font-weight: 700;
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 4px 14px;
  text-decoration: none;
}
.calendar-arrow:hover {
  background: var(--rp-accent);
  color: var(--rp-bg);
  text-decoration: none;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-grid .dow {
  text-align: center;
  font-size: 11px;
  color: var(--rp-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 0 8px 0;
}
.calendar-cell {
  background: var(--rp-surface-2);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 6px;
  min-height: 72px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  color: var(--rp-text-2);
  text-decoration: none;
}
.calendar-cell.outside { opacity: 0.35; }
.calendar-cell.empty   { /* no racing — show day number, muted */ }
.calendar-cell.today {
  outline: 2px solid var(--rp-accent);
  outline-offset: -2px;
}
.calendar-cell.has-racing {
  background: var(--rp-pos1);
  color: var(--rp-text);
  cursor: pointer;
}
.calendar-cell.has-racing:hover {
  background: #5a4520;
  text-decoration: none;
}
.calendar-cell .day-num {
  font-weight: 700;
  font-size: 18px;
  color: var(--rp-text);
}
.calendar-cell.empty .day-num { color: var(--rp-text-2); font-weight: 500; }
.calendar-cell .race-count,
.calendar-cell .meeting-count {
  font-size: 11px;
  color: var(--rp-accent);
  margin-top: 1px;
}
.calendar-cell .meeting-count { color: var(--rp-text-2); }

/* CURRENT cards (today + tomorrow): white background, black text so the
   not-historic days stand out. Rules come after .has-racing / child colours
   and add a class for specificity, so they win for racing AND empty cells.
   Historic days keep the colours defined above. */
.calendar-cell.current {
  background: #ffffff;
  color: #000000;
  border-color: #c9c9c9;
}
.calendar-cell.current.has-racing:hover {
  background: #f0f0f0;          /* keep it light on hover, not the brown */
}
.calendar-cell.current .day-num,
.calendar-cell.current .race-count,
.calendar-cell.current .meeting-count {
  color: #000000;
}
.calendar-cell.current.outside { opacity: 0.55; }   /* still readable when greyed */

/* ---------- index page ---------- */
.summary {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.summary .stat { display: flex; flex-direction: column; }
.summary .stat .n  { font-size: 22px; font-weight: 700; color: var(--rp-text); }
.summary .stat .l  { font-size: 12px; color: var(--rp-text-2); text-transform: uppercase; letter-spacing: 0.04em; }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
}
table.data th {
  text-align: left; background: var(--rp-surface-2);
  padding: 6px 8px;
  border-bottom: 1px solid var(--rp-border);
  font-size: 12px; text-transform: uppercase;
  color: var(--rp-text-2); font-weight: 600;
}
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--rp-border); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--rp-surface-2); }

/* ---------- race page header ---------- */
.race-head {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.race-head .top {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.race-head .time   { font-size: 26px; font-weight: 700; color: var(--rp-text); }
.race-head .course { font-size: 20px; font-weight: 600; }
.race-head .date   { color: var(--rp-text-2); }
.race-head .name   { margin-top: 4px; font-size: 17px; font-style: italic; }
.race-head .meta   { color: var(--rp-text-2); margin-top: 8px; font-size: 13px; }
.race-head .meta span { margin-right: 14px; }

.race-nav { margin: 12px 0; font-size: 13px; }
.race-nav a { margin-right: 10px; }
.race-nav .current { font-weight: 700; color: var(--rp-text); }

/* ---------- runner table ---------- */
table.runners {
  width: 100%;
  border-collapse: collapse;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
}
table.runners th {
  background: var(--rp-surface-2);
  text-align: left; padding: 6px 6px;
  border-bottom: 2px solid var(--rp-border);
  font-size: 11px; color: var(--rp-text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
table.runners th.num, table.runners td.num { text-align: right; }
table.runners td  { padding: 6px 6px; vertical-align: top; }
table.runners tr.main { border-top: 1px solid var(--rp-border); }
table.runners tr.main:first-child { border-top: none; }
table.runners td.pos {
  font-weight: 700; font-size: 18px; color: var(--rp-text);
  width: 44px;
}
table.runners td.pos .draw {
  font-size: 11px; color: var(--rp-text-2); vertical-align: super; margin-left: 2px;
}
table.runners td.beaten { color: var(--rp-text-2); width: 36px; font-size: 12px; }
table.runners td.horse  { min-width: 180px; }
table.runners td.horse .horse-name { font-weight: 600; font-size: 15px; }
table.runners td.horse .country    { color: var(--rp-text-2); font-size: 12px; margin-left: 4px; }
table.runners td.horse .pedigree   { color: var(--rp-text-2); font-size: 11px; margin-top: 1px; }
table.runners td.horse .breeding   { color: var(--rp-muted); font-size: 11px; margin-top: 1px; }
table.runners td.horse .breeding .cs { color: var(--rp-text-2); text-transform: uppercase; margin-right: 3px; }
table.runners td.horse .breeding .ped-link { color: var(--rp-link); }
table.runners td.horse .breeding .ped-link:hover { color: var(--rp-link-hover); }

/* External Racing Post link badge */
.rp-ext {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  color: var(--rp-accent);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 0 5px; margin-left: 4px;
  text-decoration: none; white-space: nowrap;
}
.rp-ext:hover { background: var(--rp-accent); color: var(--rp-bg); text-decoration: none; }
table.runners td.jockey .label,
table.runners td.trainer .label    { color: var(--rp-text-2); font-size: 11px; margin-right: 3px; }
table.runners td.rating { text-align: right; font-variant-numeric: tabular-nums; }
table.runners td.sp     { font-weight: 600; }
/* Racecard betting-forecast columns (Fcst = fractional tissue, Fcst BSP =
   decimal/Betfair conversion). Accent the price, tabular figures. */
table.runners td.fcst   { font-weight: 600; color: var(--rp-accent); font-variant-numeric: tabular-nums; }

/* Modelled BSP columns (predicted win/place BSP from the pre-race model). */
table.runners th.modelled { color: var(--rp-accent); }
table.runners td.modelled { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.runners td.modelled .mprice { font-weight: 600; }
table.runners td.modelled .macc  { color: var(--rp-muted, #888); margin-left: .25em; font-size: .85em; }
table.runners td.modelled .mband { display: block; color: var(--rp-muted, #888); font-size: .75em; }
.race-head .model-acc { margin-top: .35em; font-size: .9em; }

table.runners tr.winner td { background: var(--rp-pos1); }
table.runners tr.placed2 td { background: var(--rp-pos2); }
table.runners tr.placed3 td { background: var(--rp-pos3); }

table.runners tr.comment td {
  background: var(--rp-surface-2); color: var(--rp-text-2); font-size: 12px;
  padding: 4px 14px 8px 60px; font-style: italic;
}

/* ---------- non-runners ---------- */
.non-runners { margin: 18px 0 6px 0; }
.non-runners h2 { margin-bottom: 6px; }
.non-runners h2 .muted { font-weight: 400; font-size: 14px; }
.nr-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 10px;
}
.nr-list li {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--rp-surface); border: 1px solid var(--rp-border);
  border-radius: 4px; padding: 4px 10px; font-size: 13px;
}
.nr-list .horse-name { font-weight: 600; }
.nr-list .nr-reason  { color: var(--rp-text-2); font-size: 12px; }

/* ---------- stats tabs + per-runner history strip ---------- */
.stat-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0 0 0;
  border-bottom: 2px solid var(--rp-border);
}
.stat-tabs .tab {
  background: var(--rp-surface-2);
  border: 1px solid var(--rp-border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rp-text-2);
  cursor: pointer;
  font-family: inherit;
}
.stat-tabs .tab:hover { background: var(--rp-surface); color: var(--rp-text); }
.stat-tabs .tab.active {
  background: var(--rp-surface);
  color: var(--rp-accent);
  border-color: var(--rp-border);
  border-top: 2px solid var(--rp-accent);
  border-bottom: 2px solid var(--rp-surface);
  position: relative; bottom: -2px;
}

table.runners tr.stats-panel td {
  background: var(--rp-surface-2);
  border-top: 1px dashed var(--rp-border);
  padding: 6px 14px 8px 60px;
  font-size: 12px;
  color: var(--rp-text-2);
}
.stat-pane .label {
  display: inline-block;
  color: var(--rp-text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 6px;
  vertical-align: middle;
}
.stat-pane .figure {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 2px 6px;
  margin: 0 2px;
  color: var(--rp-text);
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.stat-pane .figure.empty { color: var(--rp-text-2); font-weight: 400; background: var(--rp-surface-2); }
.stat-pane .bests {
  margin-left: 18px;
  color: var(--rp-text-2);
  font-size: 12px;
}
.stat-pane .bests strong { color: var(--rp-text); font-size: 13px; }

/* ---------- ratings-history table (below the race card) ---------- */
table.ratings-history {
  width: 100%;
  border-collapse: collapse;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  margin-top: 0;
}
table.ratings-history th {
  background: var(--rp-surface-2);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rp-border);
  font-size: 11px;
  color: var(--rp-text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.ratings-history th.num { text-align: right; }
table.ratings-history tr.subhead th {
  font-size: 10px;
  text-transform: none;
  border-bottom: 2px solid var(--rp-border);
  padding: 2px 8px 4px;
  color: var(--rp-text-2);
}
table.ratings-history td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rp-border);
  vertical-align: middle;
}
table.ratings-history tr:last-child td { border-bottom: none; }
table.ratings-history tr:hover td { background: var(--rp-surface-2); }
table.ratings-history td.horse {
  min-width: 200px;
  font-weight: 600;
}
table.ratings-history td.horse .prev-pos {
  color: var(--rp-text-2);
  font-weight: 600;
  margin-right: 4px;
  font-variant-numeric: tabular-nums;
}
table.ratings-history td.horse .country {
  color: var(--rp-text-2);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}
table.ratings-history td.figure {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--rp-text);
  width: 56px;
}
table.ratings-history td.figure.empty { color: var(--rp-text-2); font-weight: 400; }
table.ratings-history td.figure.best {
  background: #3a2d10;
  color: var(--rp-text);
}
/* Clickable last-6 cells: cursor + hover ring + corner arrow */
table.ratings-history td.figure.clickable {
  cursor: pointer;
  transition: background 0.1s, outline-color 0.1s;
  position: relative;
}
table.ratings-history td.figure.clickable:hover {
  background: var(--rp-pos1);
  outline: 1px solid var(--rp-accent);
  outline-offset: -1px;
}
table.ratings-history td.figure.clickable:hover::after {
  content: '↗';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: var(--rp-accent);
  opacity: 0.85;
}

/* ---------- history table (horse/person profile) ---------- */
table.history {
  width: 100%;
  border-collapse: collapse;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
}
table.history th {
  background: var(--rp-surface-2);
  text-align: left; padding: 6px 8px;
  border-bottom: 2px solid var(--rp-border);
  font-size: 11px; color: var(--rp-text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
table.history td { padding: 6px 8px; border-bottom: 1px solid var(--rp-border); vertical-align: top; }
table.history tr:last-child td { border-bottom: none; }
table.history td.pos { font-weight: 700; color: var(--rp-text); }
table.history tr.winner td { background: var(--rp-pos1); }

/* ---------- person summary ---------- */
.person-summary {
  display: flex; gap: 24px;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 4px;
  padding: 14px;
  margin-bottom: 14px;
}
.person-summary .stat { display: flex; flex-direction: column; align-items: center; }
.person-summary .stat .n { font-size: 22px; font-weight: 700; color: var(--rp-text); }
.person-summary .stat .l { font-size: 12px; color: var(--rp-text-2); text-transform: uppercase; }

/* ---------- options paste form ---------- */
.options-form {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 4px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.options-form .field { margin-bottom: 12px; }
.options-form label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rp-text-2);
  margin-bottom: 4px;
}
.options-form label.inline {
  display: inline; text-transform: none; letter-spacing: 0;
  color: var(--rp-text); margin-left: 6px; font-size: 14px;
}
.options-form textarea,
.options-form input[type="text"],
.options-form input[type="date"] {
  background: var(--rp-surface-2);
  color: var(--rp-text);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.options-form textarea {
  width: 100%;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  resize: vertical;
}
.options-form .row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.options-form button {
  background: var(--rp-accent);
  color: var(--rp-bg);
  border: none;
  border-radius: 3px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.options-form button:hover { background: #ffc94d; }

.banner {
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.banner.ok    { background: #16331f; border: 1px solid #245a37; color: #b7e6c5; }
.banner.error { background: #3a1d20; border: 1px solid #732428; color: #f3c0c4; }

.raw-text {
  background: var(--rp-dark);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--rp-text-2);
  max-height: 320px;
  overflow: auto;
}

/* ---------- options summary ---------- */
.options-form select {
  background: var(--rp-surface-2);
  color: var(--rp-text);
  border: 1px solid var(--rp-border);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.sig {
  display: inline-block;
  border-radius: 3px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sig.buying  { background: #16331f; color: #7fe0a0; border: 1px solid #245a37; }
.sig.selling { background: #3a1d20; color: #f3a0a6; border: 1px solid #732428; }
.sig.neutral { background: var(--rp-surface-2); color: var(--rp-text-2); border: 1px solid var(--rp-border); }

table.data td.num  { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num  { text-align: right; }
table.data td.buy  { color: #7fe0a0; }
table.data td.sell { color: #f3a0a6; }

/* ---------- watchlist flag button ---------- */
.flag-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  color: var(--rp-muted);
  font-family: inherit;
}
.flag-btn:hover { color: var(--rp-accent); }
.flag-btn.on { color: var(--rp-accent); }

/* ---------- legend / explainer box ---------- */
.legend {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-left: 3px solid var(--rp-accent);
  border-radius: 4px;
  padding: 10px 16px;
  margin: 14px 0;
  font-size: 13px;
  color: var(--rp-text-2);
}
.legend ul { margin: 6px 0; padding-left: 18px; }
.legend li { margin: 3px 0; }
.legend b { color: var(--rp-text); }

/* ---------- sortable table headers ---------- */
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-th:hover { color: var(--rp-text); }
th.sortable-th .sort-ind { color: var(--rp-accent); font-size: 10px; }

/* ---------- footer ---------- */
footer { text-align: center; color: var(--rp-text-2); font-size: 12px; padding: 24px 0; }

/* ── Horse profile: full-record key/value table + point-in-time notice ── */
table.kv {
  border-collapse: collapse;
  margin: 10px 0 14px 0;
  font-size: 13px;
}
table.kv th, table.kv td {
  text-align: left;
  padding: 4px 12px 4px 0;
  vertical-align: top;
}
table.kv th {
  color: var(--rp-text-2);
  font-weight: 600;
  white-space: nowrap;
  padding-right: 8px;
}
table.kv td { color: var(--rp-text); padding-right: 22px; }

p.notice {
  background: var(--rp-surface-2);
  border-left: 3px solid var(--rp-accent);
  color: var(--rp-text);
  padding: 8px 12px;
  border-radius: 3px;
  margin: 8px 0 14px 0;
  font-size: 13px;
}

/* ---------- authentication: login page + logout button ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}
.login-card {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 6px;
  padding: 28px 32px;
  width: 320px;
  max-width: 90vw;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: 0.04em; }
.login-card input[type="email"],
.login-card input[type="password"] {
  background: var(--rp-surface-2);
  color: var(--rp-text);
  border: 1px solid var(--rp-border); border-radius: 3px;
  padding: 8px 10px; font-size: 14px; box-sizing: border-box;
}
.user-box button.linkish {
  background: none; border: none; color: var(--rp-link);
  cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}
.user-box button.linkish:hover { color: var(--rp-link-hover); }

/* ---------- Models tab: registry grid + cards + tags ---------- */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 1rem;
}
.model-card {
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.model-thumb {
  display: block;
  background: var(--rp-dark);
  border-bottom: 1px solid var(--rp-border);
}
.model-thumb img { display: block; width: 100%; height: 160px; object-fit: cover; object-position: top; }
.model-thumb-missing {
  height: 160px; display: flex; align-items: center; justify-content: center;
  color: var(--rp-muted); font-size: 13px;
}
.model-card-body { padding: 10px 14px 14px; }
.model-card-body h2 { font-size: 16px; }
.model-card-body h2 a { color: var(--rp-text); }
.model-link { font-weight: 600; font-size: 13px; }
.tag {
  display: inline-block; font-size: 11px; line-height: 1.6;
  padding: 0 7px; border-radius: 10px; margin-right: 2px;
  background: var(--rp-surface-2); color: var(--rp-text-2);
  border: 1px solid var(--rp-border);
}
.tag-latest { background: #1e3a1e; color: #8fe08f; border-color: #2c5a2c; }
.tag-live   { background: #3a2d10; color: #ffd58a; border-color: #6a5018; }
.tag-superseded { background: #3a1e1e; color: #e08f8f; border-color: #5a2c2c; }
