/* Bet Ticker – layered on Bootstrap 5.3. Colours are tokens so light and dark themes stay in step. */
:root,
[data-bs-theme="light"] {
    --bt-brand: #02a76a;
    --bt-brand-strong: #018656;
    --bt-brand-soft: #e3f6ee;
    --bt-header-bg: #0f1d17;
    --bt-header-fg: #f3f7f5;
    --bt-page-bg: #f3f5f4;
    --bt-panel-bg: #ffffff;
    --bt-border: #e1e6e3;
    --bt-muted: #6b7a73;
    --bt-row-hover: #f4f8f6;
    --bt-row-selected: #dff3ea;
    --bt-row-new: #fff4cc;
    --bt-alert: #d98a00;
    --bt-row-alert: #fff6e0;
    --bt-save: #0b7fa8;
    --bt-remove: #c43d3d;
    --bt-winner: #127a4b;
    --bt-winner-bg: #dcf3e7;
    --bt-placed: #1d5fae;
    --bt-placed-bg: #e1ecfa;
    --bt-beaten: #5f6b66;
    --bt-beaten-bg: #eceff0;
    --bt-nr: #8a5a00;
    --bt-nr-bg: #fbefd5;
    --bs-body-bg: var(--bt-page-bg);
    --bs-link-color: var(--bt-brand-strong);
    --bs-link-color-rgb: 1, 134, 86;
    --bs-link-hover-color: var(--bt-brand);
}

[data-bs-theme="dark"] {
    --bt-brand: #23c486;
    --bt-brand-strong: #3ad797;
    --bt-brand-soft: #123327;
    --bt-header-bg: #0a120e;
    --bt-header-fg: #e8efeb;
    --bt-page-bg: #111714;
    --bt-panel-bg: #18201c;
    --bt-border: #2a3530;
    --bt-muted: #93a39b;
    --bt-row-hover: #1f2924;
    --bt-row-selected: #183a2b;
    --bt-row-new: #3a3214;
    --bt-alert: #f2b230;
    --bt-row-alert: #33290f;
    --bt-save: #4fb8de;
    --bt-remove: #f07b7b;
    --bt-winner: #5ad49a;
    --bt-winner-bg: #173a2a;
    --bt-placed: #7fb2f0;
    --bt-placed-bg: #1b2c45;
    --bt-beaten: #a8b3ae;
    --bt-beaten-bg: #2a3330;
    --bt-nr: #f0c060;
    --bt-nr-bg: #3d3116;
    --bs-body-bg: var(--bt-page-bg);
    --bs-link-color: var(--bt-brand-strong);
    --bs-link-color-rgb: 58, 215, 151;
    --bs-link-hover-color: var(--bt-brand);
}

html, body { height: 100%; }

body.app {
    display: flex;
    flex-direction: column;
    background: var(--bt-page-bg);
    font-size: 0.9rem;
    font-feature-settings: "tnum" 1;
}

/* ---------- header ---------- */
.app-header {
    background: var(--bt-header-bg);
    color: var(--bt-header-fg);
    border-bottom: 3px solid var(--bt-brand);
}

.app-header .navbar { min-height: 52px; }

.app-header .navbar-brand {
    color: var(--bt-header-fg);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand-mark {
    width: 26px;
    height: 26px;
    padding: 3px;
    border-radius: 7px;
    background: var(--bt-brand);
    color: #fff;
}

.estate-pill {
    align-items: center;
    padding: 0.15rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
}

.btn-icon, .btn-user {
    color: var(--bt-header-fg);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg { width: 18px; height: 18px; }

.btn-icon:hover, .btn-user:hover, .btn-user.show {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-icon-sm svg { width: 16px; height: 16px; }

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--bt-brand-strong);
    --bs-btn-border-color: var(--bt-brand-strong);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--bt-brand);
    --bs-btn-hover-border-color: var(--bt-brand);
    --bs-btn-active-bg: var(--bt-brand-strong);
    --bs-btn-active-border-color: var(--bt-brand-strong);
    font-weight: 600;
}

.app-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- auth / message pages ---------- */
.app-auth .app-main,
.auth-card { margin: auto; }

.auth-card {
    width: min(440px, calc(100% - 32px));
    margin-block: 8vh;
    border-color: var(--bt-border);
    background: var(--bt-panel-bg);
}

/* ---------- ticker layout ---------- */
.ticker {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.85rem 1rem 1rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.25rem;
    padding: 0.65rem 0.85rem;
    background: var(--bt-panel-bg);
    border: 1px solid var(--bt-border);
    border-radius: 10px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bt-muted);
}

.toolbar-inputs .input-group { width: 140px; }
/* Room for six figures (e.g. 250000) beside the label, spinner arrows included. */
.toolbar-inputs .potential-filter { width: 190px; }
.toolbar-inputs .shop-search { width: 150px; }

.chip-group { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.7rem;
    border: 1px solid var(--bt-border);
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--bt-muted);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.chip:hover { border-color: var(--bt-brand); color: var(--bs-body-color); }

.btn-check:checked + .chip {
    background: var(--bt-brand-soft);
    border-color: var(--bt-brand);
    color: var(--bt-brand-strong);
    font-weight: 600;
}

.chip-all { font-weight: 600; margin-right: 0.15rem; }

.btn-check:focus-visible + .chip { outline: 2px solid var(--bt-brand); outline-offset: 2px; }

.toolbar-live { gap: 0.75rem; }

.alerts-button { display: inline-flex; align-items: center; gap: 0.35rem; }
.alerts-button svg { width: 15px; height: 15px; }
.alerts-button.is-on { border-color: var(--bt-alert); color: var(--bs-body-color); }

.alert-toast {
    background: color-mix(in srgb, var(--rule-colour, var(--bt-alert)) 14%, var(--bt-panel-bg));
    border-left: 4px solid var(--rule-colour, var(--bt-alert)) !important;
    color: var(--bs-body-color);
}

/* ---------- alert rule editor ---------- */
.rule-list { display: flex; flex-direction: column; gap: 0.75rem; }

.rule-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--bt-border);
    border-left: 4px solid var(--rule-colour, var(--bt-alert));
    border-radius: 8px;
    background: color-mix(in srgb, var(--rule-colour, var(--bt-alert)) 6%, transparent);
}

.rule-card.is-invalid { border-color: var(--bs-danger); border-left-color: var(--rule-colour, var(--bt-alert)); }
.rule-head { display: flex; align-items: center; gap: 0.5rem; }
.rule-head .rule-name { flex: 1; max-width: none; font-weight: 600; }
.rule-swatch { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; background: var(--rule-colour, var(--bt-alert)); }

.rule-colours { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

.colour-swatch {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: inset 0 0 0 2px var(--bt-panel-bg);
}

.colour-swatch.selected { border-color: var(--bs-body-color); }
.colour-swatch:focus-visible { outline: 2px solid var(--bt-brand); outline-offset: 2px; }

.rule-custom-colour { display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
.rule-colour-input { width: 30px; height: 26px; padding: 0; border: 1px solid var(--bt-border); border-radius: 6px; background: none; cursor: pointer; }
.rule-card textarea, .rule-card input { max-width: none; }

.toolbar-live .form-check-input:checked { background-color: var(--bt-brand-strong); border-color: var(--bt-brand-strong); }

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: var(--bt-brand);
    vertical-align: 1px;
    animation: pulse 2s ease-in-out infinite;
}

.is-paused .live-dot { background: var(--bt-muted); animation: none; }

.is-loading #refreshNow svg { animation: spin 0.9s linear infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }

.ticker-tabs { --bs-nav-underline-link-active-color: var(--bt-brand-strong); gap: 1.25rem; border-bottom: 1px solid var(--bt-border); }
.ticker-tabs .nav-link { color: var(--bt-muted); font-weight: 600; padding-bottom: 0.45rem; }
.ticker-tabs .nav-link.active { border-bottom-color: var(--bt-brand); }

.count-pill {
    display: inline-block;
    min-width: 1.6rem;
    margin-left: 0.3rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--bt-border);
    color: var(--bs-body-color);
    font-size: 0.75rem;
    text-align: center;
}

.nav-link.active .count-pill { background: var(--bt-brand-soft); color: var(--bt-brand-strong); }

.ticker-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px);
    gap: 0.75rem;
}

.table-panel, .detail-panel {
    min-height: 0;
    background: var(--bt-panel-bg);
    border-color: var(--bt-border);
    border-radius: 10px;
    overflow: hidden;
}

.table-panel { display: flex; flex-direction: column; }

.table-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; }

.table-footer:empty { display: none; }
.table-footer { padding: 0.4rem 0.75rem; border-top: 1px solid var(--bt-border); }

/* ---------- bet table ---------- */
.bet-table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--bt-row-hover);
    --bs-table-border-color: var(--bt-border);
    font-size: 0.84rem;
}

.bet-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bt-panel-bg);
    box-shadow: inset 0 -1px 0 var(--bt-border);
    border-bottom: 0;
    padding: 0.55rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bt-muted);
    white-space: nowrap;
}

.bet-table th[data-sort] { cursor: pointer; user-select: none; }
.bet-table th[data-sort]:hover { color: var(--bs-body-color); }
.bet-table th[data-sort]::after { content: ""; display: inline-block; width: 0.8em; margin-left: 0.25em; }
.bet-table th.sorted-asc::after { content: "▲"; font-size: 0.7em; }
.bet-table th.sorted-desc::after { content: "▼"; font-size: 0.7em; }
.bet-table th.sorted-asc, .bet-table th.sorted-desc { color: var(--bt-brand-strong); }

.bet-table td { padding: 0.4rem 0.55rem; vertical-align: middle; border-bottom-color: var(--bt-border); }
.bet-table tbody tr { cursor: pointer; }
.bet-table tbody tr.is-selected > * { --bs-table-bg-state: var(--bt-row-selected); box-shadow: inset 3px 0 0 var(--bt-brand); }
.bet-table tbody tr.is-selected > *:not(:first-child) { box-shadow: none; }
.bet-table tbody tr.is-new > * { animation: new-row 4s ease-out; }
.bet-table tbody tr.is-saving > *, .bet-table tbody tr.is-removing > * { opacity: 0.45; }

/* Rows matching an alert rule take that rule's colour (set per row as --rule-colour). */
.bet-table tbody tr.is-alert > * { --bs-table-bg-state: color-mix(in srgb, var(--rule-colour, var(--bt-alert)) 16%, transparent); }
.bet-table tbody tr.is-alert:hover > * { --bs-table-bg-state: color-mix(in srgb, var(--rule-colour, var(--bt-alert)) 26%, transparent); }
.bet-table tbody tr.is-alert > *:first-child { box-shadow: inset 4px 0 0 var(--rule-colour, var(--bt-alert)); }
.bet-table tbody tr.is-alert.is-selected > *:first-child { box-shadow: inset 3px 0 0 var(--bt-brand); }

/* Slips with several bets: one summary row that expands to show the bets. */
.bet-table tbody tr.slip-row > td { font-weight: 600; }
.bet-table tbody tr.slip-row:focus-visible { outline: 2px solid var(--bt-brand); outline-offset: -2px; }

.slip-toggle {
    display: inline-block;
    width: 0.9rem;
    margin-right: 0.3rem;
    color: var(--bt-muted);
    transition: transform 0.15s ease;
}

.slip-toggle::before { content: "▸"; }
.slip-row[aria-expanded="true"] .slip-toggle { transform: rotate(90deg); color: var(--bt-brand-strong); }

.slip-count {
    margin-right: 0.4rem;
    padding: 0.02rem 0.45rem;
    border-radius: 999px;
    background: var(--bt-brand-soft);
    color: var(--bt-brand-strong);
    font-size: 0.72rem;
    font-weight: 700;
}

.bet-table tbody tr.slip-child > * { --bs-table-bg-state: var(--bt-row-hover); font-size: 0.8rem; }
.bet-table tbody tr.slip-child > td:first-child { padding-left: 1.75rem; }
.bet-table tbody tr.slip-child.is-alert > * { --bs-table-bg-state: color-mix(in srgb, var(--rule-colour, var(--bt-alert)) 16%, transparent); }

@keyframes new-row { from { background-color: var(--bt-row-new); } to { background-color: transparent; } }

.bet-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bet-table .nowrap { white-space: nowrap; }
.bet-table .shop-cell { white-space: nowrap; font-weight: 500; }
.bet-table .wager-cell { max-width: 165px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet-table .customer-cell { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.bet-table .ids-cell { line-height: 1.2; color: var(--bt-muted); font-size: 0.78rem; }
.bet-table .sub { display: block; font-size: 0.74rem; color: var(--bt-muted); }
.bet-table .action-col { width: 1%; text-align: right; white-space: nowrap; }

.btn-save, .btn-unsave {
    --bs-btn-padding-y: 0.12rem;
    --bs-btn-padding-x: 0.6rem;
    --bs-btn-font-size: 0.78rem;
    font-weight: 600;
    border-radius: 6px;
}

.btn-save { --bs-btn-color: var(--bt-save); --bs-btn-border-color: var(--bt-save); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--bt-save); --bs-btn-hover-border-color: var(--bt-save); }
.btn-unsave { --bs-btn-color: var(--bt-remove); --bs-btn-border-color: var(--bt-remove); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--bt-remove); --bs-btn-hover-border-color: var(--bt-remove); }

.empty-state { padding: 3rem 1rem; text-align: center; }

/* ---------- detail panel ---------- */
.detail-panel { overflow-y: auto; }

.detail-placeholder {
    height: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--bt-muted);
    text-align: center;
}

.detail-placeholder svg { width: 44px; height: 44px; opacity: 0.6; }

.detail-content { padding: 1rem; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.85rem; }
.detail-shop { font-size: 1.05rem; font-weight: 700; }

.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.detail-stats > div { padding: 0.5rem 0.6rem; border: 1px solid var(--bt-border); border-radius: 8px; }
.detail-stats dt { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bt-muted); }
.detail-stats dd { margin: 0; font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.detail-heading {
    margin: 1rem 0 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bt-muted);
}

.selection-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }

.selection-list li:not(.small) {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--bt-border);
    border-radius: 8px;
}

.selection-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }

.selection-exposure {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.74rem;
    color: var(--bt-muted);
    text-align: left;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.selection-exposure:hover { color: var(--bt-brand-strong); }

/* ---------- notes ---------- */
.note-list { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.note-list li:not(.small) { padding: 0.45rem 0.6rem; border-left: 3px solid var(--bt-brand); background: var(--bt-row-hover); border-radius: 0 6px 6px 0; }
.note-text { font-size: 0.84rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-list .sub, .exposure-bets .sub { display: block; font-size: 0.72rem; color: var(--bt-muted); }
.note-form { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.note-form textarea { max-width: none; }

.note-badge {
    margin-left: 0.4rem;
    padding: 0.02rem 0.4rem;
    border-radius: 999px;
    background: var(--bt-brand-soft);
    color: var(--bt-brand-strong);
    font-size: 0.68rem;
    font-weight: 600;
}

/* ---------- exposure ---------- */
.exposure-search { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--bt-border); }
.exposure-search input { max-width: 420px; }
.exposure-table .selection-cell { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.exposure-bets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.exposure-bets button {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--bt-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    font-size: 0.82rem;
}
.exposure-bets button:hover { border-color: var(--bt-brand); background: var(--bt-row-hover); }
.exposure-bet-top { display: flex; justify-content: space-between; gap: 0.5rem; }

/* ---------- by race ---------- */
.race-table .sub { display: block; font-size: 0.74rem; color: var(--bt-muted); font-weight: 400; }
.runner-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.runner-toggle {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--bt-border);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    font-size: 0.82rem;
}
.runner-toggle:hover, .runner-toggle[aria-expanded="true"] { border-color: var(--bt-brand); background: var(--bt-row-hover); }
.runner-bar { display: block; height: 4px; margin: 0.35rem 0 0.25rem; border-radius: 2px; background: var(--bt-border); overflow: hidden; }
.runner-bar > span { display: block; height: 100%; background: var(--bt-brand); }
.runner-list .sub { display: block; font-size: 0.72rem; color: var(--bt-muted); }
.runner-list .exposure-bets { margin: 0.35rem 0 0.25rem 0.75rem; }

.selection-name { font-size: 0.84rem; }
.selection-meta { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.selection-price { font-weight: 700; font-variant-numeric: tabular-nums; }

.result-badge { padding: 0.08rem 0.45rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.result-winner { color: var(--bt-winner); background: var(--bt-winner-bg); }
.result-placed { color: var(--bt-placed); background: var(--bt-placed-bg); }
.result-beaten { color: var(--bt-beaten); background: var(--bt-beaten-bg); }
.result-nr { color: var(--bt-nr); background: var(--bt-nr-bg); }

.slip-frame {
    display: flex;
    justify-content: center;
    padding: 0.75rem;
    border: 1px dashed var(--bt-border);
    border-radius: 8px;
    background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(127, 127, 127, 0.04) 8px 16px);
}

.slip-frame img {
    max-width: 100%;
    background: #fff;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.25s ease;
}

.slip-frame img.rotated { transform: rotate(180deg); }

/* ---------- site sections (Live bets / Danger bets) ---------- */
.app-sections { flex-direction: row; gap: 0.15rem; }
.app-sections .nav-link {
    padding: 0.3rem 0.65rem;
    border-radius: 7px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}
.app-sections .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.app-sections .nav-link.active { color: #fff; background: rgba(255, 255, 255, 0.14); }

/* ---------- danger bets ---------- */
.shop-warnings {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--bt-alert);
    border-left-width: 4px;
    border-radius: 10px;
    background: var(--bt-row-alert);
    font-size: 0.84rem;
}

.setup-reason {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--bt-alert);
    border-left-width: 4px;
    border-radius: 8px;
    background: var(--bt-row-alert);
}

.bet-table .selection-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.slip-bets { display: flex; flex-direction: column; gap: 0.6rem; }
.slip-bet { padding: 0.6rem; border: 1px solid var(--bt-border); border-radius: 8px; }
.slip-bet.is-alerted { border-color: var(--bt-alert); box-shadow: inset 4px 0 0 var(--bt-alert); }
.slip-bet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; margin-bottom: 0.5rem; }
.slip-bet .selection-list li:not(.small) { padding: 0.4rem 0.5rem; }
.selection-sub { font-size: 0.72rem; color: var(--bt-muted); }

.wager-list { list-style: none; margin: 0.5rem 0 0; padding: 0; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.wager-list li + li { margin-top: 0.2rem; }

.status-badge {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: var(--bt-beaten-bg);
    color: var(--bt-beaten);
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
}

/* ---------- shop picker ---------- */
.shop-list { display: flex; flex-direction: column; gap: 0.15rem; overflow-y: auto; }
.shop-option { margin: 0; padding: 0.3rem 0.4rem 0.3rem 2rem; border-radius: 6px; cursor: pointer; }
.shop-option:hover { background: var(--bt-row-hover); }
.shop-option .form-check-input:checked { background-color: var(--bt-brand-strong); border-color: var(--bt-brand-strong); }

/* ---------- responsive ---------- */
@media (max-width: 1199.98px) {
    .ticker-body { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 1fr) auto; }
    .detail-panel { max-height: none; }
    .detail-placeholder { min-height: 120px; }
}

@media (max-width: 575.98px) {
    .ticker { padding: 0.6rem 16px 1rem; }
    .toolbar { gap: 0.6rem; }
    .toolbar-inputs .input-group, .toolbar-inputs .shop-search { width: 100%; }
    .detail-stats { grid-template-columns: 1fr 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .live-dot, .is-loading #refreshNow svg, .bet-table tbody tr.is-new > * { animation: none; }
}

/* ---------- admin ---------- */
.estate-switcher { margin-left: 0.5rem; }
.estate-switcher .form-select {
    width: auto;
    max-width: 12rem;
    padding-block: 0.2rem;
    font-size: 0.8rem;
    color: var(--bt-header-fg);
    background-color: transparent;
    border-color: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}
.estate-switcher .form-select option { color: var(--bs-body-color); background: var(--bt-panel-bg); }

.admin-page {
    width: min(1100px, 100%);
    margin-inline: auto;
    padding: 1rem;
}
.admin-page-narrow { width: min(720px, 100%); }
.admin-page .card { border-color: var(--bt-border); background: var(--bt-panel-bg); }
.admin-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--bs-secondary-color); }
.admin-history li + li { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--bt-border); }

/* Phones: the section links drop to their own row under the brand, switcher and account menu. */
@media (max-width: 575.98px) {
    .app-header .navbar { flex-wrap: wrap; row-gap: 0.35rem; }
    .app-header .app-sections { order: 3; width: 100%; margin-left: 0 !important; overflow-x: auto; }
    .app-sections .nav-link { white-space: nowrap; }
}

/* ---------- promotions ---------- */
.promotions-page { width: min(1400px, 100%); }
.promotion-tabs { flex-wrap: wrap; gap: 0.25rem; }
.promotion-tabs .nav-link { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.promotion-tabs .nav-link.active { background: var(--bt-brand-strong); }
.type-settings { border: 0; padding: 0; margin: 0; min-width: 0; }
.promo-choices {
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--bt-border);
    border-radius: 6px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    column-gap: 1.5rem;
    align-content: start;
}
.promo-choices [hidden] { display: none; }
.promo-shop-search { width: min(16rem, 100%); }

/* ---------- Slip search (Danger bets) and Posters ---------- */

.slip-search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.slip-search input[list] { width: 180px; }
.slip-search .slip-number { width: 120px; }

.posters-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.poster-workspace { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.poster-legend { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bt-muted); margin-bottom: 0.4rem; }
.poster-checks { display: flex; flex-direction: column; gap: 0.15rem; max-height: 14rem; overflow-y: auto; }
.poster-look { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.poster-look label { display: flex; align-items: center; gap: 0.4rem; }
.poster-look input[type="color"] { width: 2.25rem; height: 1.75rem; padding: 0; border: 1px solid var(--bt-border); border-radius: 6px; background: none; }
.poster-preview { padding: 0.75rem; position: sticky; top: 1rem; }
.poster-preview canvas { display: block; width: 100%; height: auto; border-radius: 6px; }
.poster-preview canvas.is-portrait { width: auto; max-width: 100%; max-height: calc(100vh - 8rem); margin: 0 auto; }

@media (max-width: 900px) {
    .poster-workspace { grid-template-columns: 1fr; }
    .poster-preview { position: static; order: -1; }
    .slip-search, .slip-search input[list] { width: 100%; }
    .slip-search input[list], .slip-search .slip-number { flex: 1 1 8rem; }
}

/* ---------- Screens ---------- */

.screens-tabs { margin-bottom: 0.5rem; }
.screens-status { min-height: 1.3rem; margin-bottom: 0.5rem; }
.screens-status.is-error { color: var(--bt-remove); font-weight: 600; }
.screens-status.is-ok { color: var(--bt-winner); font-weight: 600; }
.screens-narrow { max-width: 30rem; }
.screens-display-picker, .screens-subnav { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.screens-rows-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.screens-rows { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.screens-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.35rem 0.6rem; border: 1px solid var(--bt-border); border-radius: 8px; background: var(--bt-panel-bg); }
.screens-grip { color: var(--bt-muted); cursor: grab; }
.screens-row-name { flex: 1 1 14rem; min-width: 0; padding: 0; border: 0; background: none; color: inherit; text-align: left; font-size: 0.875rem; }
.screens-row-name:hover { text-decoration: underline; }
.screens-row-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.1rem; margin-left: auto; }
.screens-row-actions .btn { text-decoration: none; }
.screens-preview { margin-bottom: 0.75rem; }
.screens-media { display: block; max-width: 100%; max-height: 22rem; border-radius: 6px; }
.screens-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.15rem 0.75rem; margin-bottom: 0.5rem; font-size: 0.85rem; }
.screens-facts dt { color: var(--bt-muted); font-weight: 600; }
.screens-facts dd { margin: 0; overflow-wrap: anywhere; }
.screens-search { max-width: 18rem; }
.screens-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.6rem; }
.screens-card { overflow: hidden; }
.screens-card-media { display: flex; align-items: center; justify-content: center; height: 130px; background: var(--bt-page-bg); }
.screens-card-media .screens-media { width: 100%; height: 100%; max-height: none; object-fit: contain; border-radius: 0; }
.screens-section { margin-bottom: 0.6rem; }
.screens-setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.25rem 1rem; align-items: start; padding: 0.4rem 0; border-top: 1px solid var(--bt-border); }
.screens-setting:first-of-type { border-top: 0; }
.screens-setting-label { padding-top: 0.2rem; }
.screens-colour-text { max-width: 9rem; }
.screens-number { max-width: 8rem; }
.screens-meeting-type { max-width: 8rem; }
.screens-chips { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.screens-chip { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.45rem; border: 1px solid var(--bt-border); border-radius: 6px; font-size: 0.82rem; }
.screens-chip.is-selected { border-color: var(--bt-brand); background: var(--bt-brand-soft); }
.screens-chip-name { flex: 1 1 auto; min-width: 0; padding: 0; border: 0; background: none; color: inherit; text-align: left; overflow-wrap: anywhere; }
.screens-chip-x { width: 0.55rem; height: 0.55rem; }
.screens-raw { font-family: var(--bs-font-monospace); font-size: 0.78rem; margin-top: 0.25rem; }
.screens-quadrant, .screens-flags { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.screens-flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.screens-savebar { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; padding: 0.6rem 0.75rem; border: 1px solid var(--bt-border); border-radius: 8px; background: var(--bt-panel-bg); }
.screens-queue { padding: 0.6rem; border: 1px solid var(--bt-border); border-radius: 8px; background: var(--bt-panel-bg); overflow-x: auto; }
.screens-dialog { width: min(26rem, calc(100vw - 2rem)); padding: 1rem; border: 1px solid var(--bt-border); border-radius: 10px; background: var(--bt-panel-bg); color: inherit; }
.screens-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

@media (max-width: 720px) {
    .screens-setting { grid-template-columns: minmax(0, 1fr); }
}

/* Specials */
.specials-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 0.75rem; }
.special.special-rejected { opacity: 0.7; }
.special.special-approved { border-color: var(--bt-winner); }
.special-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.special-time { font-size: 0.75rem; font-weight: 600; color: var(--bt-muted); }
.special-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.special-badge { font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; background: var(--bt-beaten-bg); color: var(--bt-beaten); }
.special-badge.is-approved { background: var(--bt-winner-bg); color: var(--bt-winner); }
.special-badge.is-suggested { background: var(--bt-placed-bg); color: var(--bt-placed); }
.special-legs { list-style: none; padding: 0; margin: 0 0 0.5rem; font-size: 0.85rem; }
.special-legs li { display: flex; flex-wrap: wrap; gap: 0 0.25rem; padding: 0.2rem 0; border-bottom: 1px solid var(--bt-border); }
.special-leg-name { font-weight: 600; }
.special-leg-market { color: var(--bt-muted); flex: 1 1 auto; }
.special-leg-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.special-warning { color: var(--bt-nr); background: var(--bt-nr-bg); border-radius: 6px; padding: 0.3rem 0.5rem; }
.special-prices { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; font-variant-numeric: tabular-nums; }
.special-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.special-price { width: 6rem; }
.special-boost { width: 10.5rem; flex-wrap: nowrap; }
.specials-sport { width: auto; min-width: 9rem; }
.specials-search { width: 12rem; }
.specials-max { width: 6.5rem; }
.special-boost .form-control { min-width: 4.5rem; text-align: right; }

.specials-coupon .coupon-table input[type="text"] { min-width: 12rem; }
.specials-coupon .coupon-table .coupon-price { width: 6rem; min-width: 6rem; }
.specials-coupon .coupon-table .coupon-time { width: 7rem; }
.special-sent { font-size: 0.72rem; color: var(--bt-winner); font-weight: 600; }
.special-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.25rem; text-align: right; }
.special-badges .special-sent { flex: 0 0 100%; }
.special-built { font-size: 0.72rem; color: var(--bt-muted); }
.special-badge.is-won, .special-chip.is-won { background: var(--bt-winner-bg); color: var(--bt-winner); }
.special-badge.is-lost, .special-chip.is-lost { background: color-mix(in srgb, var(--bt-remove) 16%, transparent); color: var(--bt-remove); }
.special-badge.is-void, .special-chip.is-void { background: var(--bt-beaten-bg); color: var(--bt-beaten); }
.special-chip { font-size: 0.68rem; font-weight: 600; padding: 0 0.4rem; border-radius: 999px; white-space: nowrap; align-self: center; }
.special-leg-now { color: var(--bt-muted); font-variant-numeric: tabular-nums; }
.special-info { color: var(--bt-placed); background: var(--bt-placed-bg); border-radius: 6px; padding: 0.4rem 0.5rem; }
.special-info-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }

.specials-builder-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.specials-builder-cols > * { min-width: 0; }
.specials-builder-search { flex: 1 1 10rem; width: auto; min-width: 0; }
.specials-builder-results { max-height: 22rem; overflow-y: auto; }
.specials-builder .builder-event + .builder-event { margin-top: 0.6rem; }
.specials-builder .builder-event-head { font-size: 0.75rem; font-weight: 600; color: var(--bt-muted); }
.specials-builder .special-legs li { flex-wrap: nowrap; align-items: center; gap: 0.5rem; }
.specials-builder .builder-hit-what, .specials-builder .builder-leg-what { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.specials-builder .builder-add { flex: 0 0 auto; padding-block: 0.05rem; }
.specials-builder .builder-remove { flex: 0 0 auto; padding: 0 0.25rem; color: var(--bt-muted); }
.specials-builder-quote { font-variant-numeric: tabular-nums; }
@media (min-width: 992px) {
    .specials-builder-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; }
}

/* Price feed page */
.price-feed { width: min(1280px, 100%); }
.feed-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.feed-tabs { margin-bottom: 1rem; border-bottom-color: var(--bt-border); }
.feed-tabs .nav-link { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--bt-muted); }
.feed-tabs .nav-link.active { color: var(--bs-body-color); background: var(--bt-panel-bg); border-color: var(--bt-border) var(--bt-border) var(--bt-panel-bg); }
/* The light on a feed's tab: green fine, amber needs looked at, red off. Grey: not set up, or not checked yet. */
.feed-light { flex: none; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #9aa3ad; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.feed-light.is-green { background: #1e9e4a; }
.feed-light.is-amber { background: #f5a300; }
.feed-light.is-red { background: #d92d20; }
.feed-source { white-space: nowrap; }
.feed-source::before { content: "·"; margin-inline: 0.3rem; }
.feed-source > span { font-family: var(--bs-font-monospace); font-size: 0.8125rem; }
.feed-state { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 0.15rem 0.6rem; color: var(--bt-beaten); background: var(--bt-beaten-bg); }
.feed-state::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.feed-state.is-ok { color: var(--bt-winner); background: var(--bt-winner-bg); }
.feed-state.is-warn { color: var(--bt-nr); background: var(--bt-nr-bg); }
.feed-state.is-bad { color: #fff; background: var(--bt-remove); }
.feed-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin: 0 0 1rem; }
.feed-facts > div { border: 1px solid var(--bt-border); background: var(--bt-panel-bg); border-radius: 10px; padding: 0.7rem 0.9rem; }
.feed-facts dt { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bs-secondary-color); }
.feed-facts dd { margin: 0.1rem 0 0; font-size: 1.35rem; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.feed-facts dd.feed-sub { min-height: 1.2rem; margin: 0; font-size: 0.8125rem; font-weight: 400; color: var(--bs-secondary-color); overflow-wrap: anywhere; }
.feed-panel { border: 1px solid var(--bt-border); background: var(--bt-panel-bg); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; }
.feed-panel > header { display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--bt-border); }
.feed-count { font-size: 0.7rem; font-weight: 700; border-radius: 999px; padding: 0.05rem 0.5rem; color: var(--bt-beaten); background: var(--bt-beaten-bg); }
.feed-count:empty { display: none; }
.feed-count.is-bad { color: #fff; background: var(--bt-remove); }
.feed-empty { padding: 0.75rem 0.9rem !important; color: var(--bs-secondary-color); }
.feed-table { --bs-table-bg: transparent; }
.feed-table th { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bs-secondary-color); white-space: nowrap; }
.feed-table th, .feed-table td { padding: 0.45rem 0.6rem; border-color: var(--bt-border); }
.feed-table th:first-child, .feed-table td:first-child { padding-left: 0.9rem; }
.feed-table th:last-child, .feed-table td:last-child { padding-right: 0.9rem; }
.feed-table tbody tr:last-child td { border-bottom: 0; }
.feed-table tbody tr:hover td { background: var(--bt-row-hover); }
.feed-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--bs-secondary-color); }
.feed-race { white-space: nowrap; }
.feed-meeting { font-weight: 600; }
.feed-off, .feed-num { font-variant-numeric: tabular-nums; }
.feed-date { font-size: 0.75rem; color: var(--bs-secondary-color); }
.feed-to { white-space: nowrap; font-size: 0.875rem; }
.feed-changes { min-width: 16rem; }
.feed-price { display: inline-block; font-size: 0.8125rem; border: 1px solid var(--bt-border); border-radius: 6px; padding: 0.05rem 0.4rem; margin: 0.1rem 0.25rem 0.1rem 0; white-space: nowrap; }
.feed-price b { font-variant-numeric: tabular-nums; color: var(--bt-brand-strong); }
.feed-file { font-family: var(--bs-font-monospace); font-size: 0.75rem; color: var(--bs-secondary-color); max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-chip { display: inline-block; font-size: 0.7rem; font-weight: 600; border-radius: 999px; padding: 0.05rem 0.45rem; color: var(--bt-nr); background: var(--bt-nr-bg); }
.feed-chip.is-sent { color: var(--bt-winner); background: var(--bt-winner-bg); }
.feed-errors { margin: 0; }
.feed-error { display: grid; grid-template-columns: 4.5rem 4.75rem 1fr; gap: 0.6rem; align-items: baseline; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--bt-border); border-left: 3px solid var(--bt-remove); font-size: 0.875rem; }
.feed-error:last-child { border-bottom: 0; }
.feed-error.is-warning { border-left-color: var(--bt-alert); }
.feed-error .feed-level { justify-self: start; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; border-radius: 999px; padding: 0.05rem 0.45rem; color: #fff; background: var(--bt-remove); }
.feed-error.is-warning .feed-level { color: var(--bt-nr); background: var(--bt-nr-bg); }
@media (max-width: 575.98px) {
    .feed-error { grid-template-columns: auto 1fr; }
    .feed-error .feed-message { grid-column: 1 / -1; }
    .feed-facts { grid-template-columns: 1fr 1fr; }
}
.feed-error .feed-message { overflow-wrap: anywhere; white-space: pre-wrap; }
