/* ═══════════════════════════════════════════════════════════════════════════
   QProcess — Project-specific overrides
   Extends ras-base.css. Load AFTER ras-base.css.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── QProcess button colour tokens ── */
:root {
    --btn-timefig:   #e9c46a;
    --btn-tfreport:  #f4a261;
    --btn-qreport:   #e76f51;
}

/* ── Coloured action buttons ── */
.btn-timefig  { background: var(--accent-teal); color: #04201e; }
.btn-tfreport { background: var(--accent-blue); color: #fff; }
.btn-qreport  { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent-blue); }
.btn-fcf      { background: #e9c46a; color: #201a04; }

/* Keep action group baseline-aligned with the filter selects */
.qp-action-group { padding-bottom: 2px; }

/* ── Race number pills ── */
.race-pills {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.race-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--accent-blue);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.race-pill:hover   { background: #388bfd; }
.race-pill.active  { background: var(--accent-teal); }
.race-pill.no-data { background: var(--bg-hover); color: var(--text-secondary); cursor: default; }

/* ── Race header bar ── */
.race-header-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
}

/* Race number — very large */
.rhb-num {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-teal);
    line-height: 1;
    letter-spacing: -0.03em;
    white-space: nowrap;
    flex: none;
}

/* Compact FCF editor widget — lives in the header bar */
.rhb-fcw {
    display: flex;
    align-items: stretch;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-primary);
}
.rhb-fcw-btns {
    display: flex;
    flex-direction: column;
    flex: none;
}
.rhb-fcw-btn {
    flex: 1;
    width: 22px;
    border: none;
    background: #7ecb7e;
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.1s;
}
.rhb-fcw-btn:hover { background: #5db85d; }
.rhb-fcw-btns .rhb-fcw-btn:first-child { border-bottom: 1px solid rgba(255,255,255,0.3); }
.rhb-fcw-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3px 6px;
    gap: 1px;
}
.rhb-fcw-input {
    width: 52px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 18px;
    font-weight: 700;
    color: #f5c518;
    text-align: center;
    padding: 0;
    cursor: text;
}
.rhb-fcw-input:focus { background: var(--bg-hover); border-radius: 3px; }
.rhb-fcw-lbl {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.rhb-fcw-save {
    border: none;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 7px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: background 0.1s, color 0.1s;
}
.rhb-fcw-save:hover { background: var(--accent-teal); color: #fff; }

.rhb-link {
    cursor: pointer;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 6px 9px;
    line-height: 1;
    flex: none;
    margin-left: auto;
    text-decoration: none;
}
.rhb-link:hover { background: var(--accent-teal); color: #fff; }

/* Collapse toggle button */
.rhb-toggle {
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 4px 8px;
    line-height: 1;
    flex: none;
    margin-left: 0;
}
.rhb-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Collapsed state — hides middle panels, runners float up */
.race-body-cols.rbc-collapsed { display: none; }

/* Main block — course + race name, takes remaining space */
.rhb-main {
    flex: 1 1 0;
    min-width: 0;
}
.rhb-course {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.rhb-country {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}
.rhb-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-top: 2px;
}
.rhb-conds {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 6px;
}
.rhb-time {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}
.rhb-flags {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 12px;
}
.rhb-flag-lbl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Right-hand pills — prize / SOT / surface */
.rhb-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: none;
    white-space: nowrap;
}
.rhb-pill-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.rhb-pill-lbl {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* SOT coloured badge */
.rhb-sot-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    white-space: nowrap;
}

/* ── Race header: expanded card style ── */
.race-header-new {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 10px;
}
.rh-top        { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rh-title-line { display: flex; align-items: baseline; gap: 8px; }
.rh-num        { font-size: 15px; font-weight: 700; color: var(--accent-teal); }
.rh-venue      { font-size: 15px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.rh-name       { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.rh-sub        { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.02em; }

/* ── Race header: compact single-line banner ── */
.race-header-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
}
.race-header-line .rh-num    { color: var(--accent-teal); font-weight: 700; font-size: 14px; }
.race-header-line .rh-venue  { color: var(--text-primary); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.03em; }
.race-header-line .rh-sep    { color: var(--text-secondary); }
.race-header-line .rh-name   { color: var(--text-primary); font-weight: 600; font-size: 13px; text-transform: uppercase;
                                overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.race-header-line .rh-cond   { color: var(--text-secondary); font-size: 11px; flex: 1 1 auto;
                                overflow: hidden; text-overflow: ellipsis; }
.race-header-line .surface-badge { margin-left: auto; flex: none; }

/* ── Surface / track badge ── */
.surface-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
    white-space: nowrap;
}
.surface-badge.turf { background: #2e7d32; }
.surface-badge.aw   { background: #5c3d8f; }
.surface-badge.sand { background: #b5651d; }
.surface-badge.dirt { background: #5d4037; }

/* ── Race body: analysis panel full width ── */
.race-body-cols { margin-bottom: 6px; }
.race-body-right { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }

/* ── Race info grid (4-column cells) ── */
.race-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.race-info-cell {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.race-info-cell:nth-child(4n)        { border-right: none; }
.race-info-cell:nth-last-child(-n+5) { border-bottom: none; }

.race-info-value           { color: var(--value-blue); font-weight: 600; font-size: 13px; display: block; }
.race-info-value.plain     { color: var(--text-primary); }
.race-info-value.highlight { color: var(--btn-timefig); }
.race-info-label           { color: var(--text-secondary); font-size: 10px; display: block; margin-top: 1px; }

/* 5-column last row variant */
.race-info-row5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 4px 4px;
}
.race-info-row5 .race-info-cell { border-bottom: none; }

/* ── Runner sub-tabs (Q Processing / Timeform Ratings) ── */
.rt-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.rt-tab {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.rt-tab:hover  { color: var(--text-primary); }
.rt-tab.active {
    color: var(--accent-teal);
    background: var(--bg-primary);
    border-color: var(--border);
    border-bottom-color: var(--bg-primary);
    margin-bottom: -1px;
}
.rt-pane        { display: none; }
.rt-pane.active { display: block; }
.rt-scroll      { overflow-x: auto; }

/* Tabbed right panel insets */
.rt-panel .qp-tab-content { padding: 4px; }
.rt-panel .qp-tabs         { padding: 0 6px; }
.rt-panel .qp-table th    { padding: 2px 6px; }
.rt-panel .qp-table td    { padding: 1px 6px; }

/* ── Dense runner table ── */
.runner-table { font-size: 11px; table-layout: fixed; }
.runner-table th { padding: 4px 7px; font-size: 10px; }
.runner-table td { padding: 3px 7px; }
.runner-table tbody tr:hover td { background: var(--bg-hover); }

/* Vertical group separators */
.runner-table th.bl, .runner-table td.bl { border-left:  2px solid var(--border); }
.runner-table th.br, .runner-table td.br { border-right: 2px solid var(--border); }

/* Slight red tinge marking a 60+ day gap before that run (first-up indicator) */
.runner-table td.tint-red { background: rgba(224, 75, 75, 0.18); }
.runner-table tbody tr:hover td.tint-red { background: rgba(224, 75, 75, 0.28); }

/* Finish-position badge */
.fp-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 700;
    text-align: center;
    font-size: 10px;
}
.runner-table tbody tr:first-child .fp-badge { background: var(--btn-timefig); color: #000; }

.runner-table .horse-name { color: var(--text-primary); font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.runner-table .horse-meta { color: var(--text-secondary); font-size: 10px; margin-left: 6px; white-space: nowrap; }
.runner-table td.jk       { color: var(--text-secondary); text-transform: capitalize; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.runner-table td.com      { color: var(--text-secondary); max-width: 220px; white-space: normal; }
.runner-table td.rat-this { color: var(--accent-teal); font-weight: 700; }
.runner-table td.num      { color: var(--text-primary); }
.runner-table td.dt       { color: var(--text-secondary); white-space: nowrap; }

/* Summary panel — highlight columns (FCF / HFA / RTF / Time) */
.qp-table td.sum-val { color: #fff; font-weight: 600; }

/* Overround footer */
.runner-table tfoot .rt-foot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-weight: 700;
    color: var(--accent-teal);
    background: var(--bg-secondary);
}

/* Fixed leading columns (FP, Horse, Age, Sex, BP, Jockey, WT) */
.runner-table th:nth-child(1), .runner-table td:nth-child(1) { width: 42px;  min-width: 42px; }
.runner-table th:nth-child(2), .runner-table td:nth-child(2) { width: 180px; min-width: 180px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.runner-table th:nth-child(3), .runner-table td:nth-child(3) { width: 3ch; min-width: 3ch; max-width: 3ch; }
.runner-table th:nth-child(4), .runner-table td:nth-child(4) { width: 2ch; min-width: 2ch; max-width: 2ch; }
.runner-table th:nth-child(5), .runner-table td:nth-child(5) { width: 3ch; min-width: 3ch; max-width: 3ch; }
.runner-table th:nth-child(6), .runner-table td:nth-child(6) { width: 140px; min-width: 140px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.runner-table th:nth-child(7), .runner-table td:nth-child(7) { width: 5ch; min-width: 5ch; max-width: 5ch; }
.runner-table th.col-div, .runner-table td.col-div { width: 7ch; min-width: 7ch; max-width: 7ch; }

/* ══ TimeFig modal ══ */
#timefig-modal .modal-content  { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); }
#timefig-modal .modal-header,
#timefig-modal .modal-footer   { border-color: var(--border); }
#timefig-modal .modal-title    { color: var(--text-primary); font-size: 16px; font-weight: 700; }
#timefig-modal .btn-close      { filter: invert(1) grayscale(1) brightness(1.6); }

/* ══ FCF modal (GetWHFA slider, ported from legacy QProcess Race screen) ══ */
#fcf-modal .modal-content  { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); }
#fcf-modal .modal-header,
#fcf-modal .modal-footer   { border-color: var(--border); }
#fcf-modal .modal-title    { color: var(--text-primary); font-size: 16px; font-weight: 700; }
#fcf-modal .btn-close      { filter: invert(1) grayscale(1) brightness(1.6); }

.fcf-layout { display: flex; gap: 18px; align-items: flex-start; }
.fcf-side   { display: flex; flex-direction: column; gap: 8px; width: 110px; flex-shrink: 0; }
.fcf-main   { flex: 1; min-width: 0; }
.fcf-select {
    width: 100%;
    background: var(--input-bg, #1e2330);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    text-align: right;
    padding: 2px 6px;
}
.fcf-mse {
    background: #e8e022;
    color: #111;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 6px;
    border-radius: 3px;
    text-align: center;
}

.tf-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.tf-scroll  { overflow-x: auto; }

.tf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
}
.tf-table th {
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 11px;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
}
.tf-table td                    { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.tf-table tbody tr:hover td     { background: var(--bg-hover); }
.tf-table .r                    { text-align: right; }
.tf-table .l                    { text-align: left; }
.tf-table .b                    { font-weight: 700; color: var(--accent-teal); }
.tf-table th.sep, .tf-table td.sep { border-left: 1px solid var(--border); }
.tf-table .tf-applyrow td       { border-bottom: none; background: transparent; }
.tf-table tfoot .tf-foot td     { font-weight: 700; padding-top: 8px; color: var(--accent-teal); }

.tf-going-input {
    width: 56px;
    text-align: right;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 13px;
}
.tf-note { margin: 12px 0 0; font-size: 11px; color: var(--text-secondary); }

.tf-footer                            { display: flex; justify-content: space-between; align-items: center; }
.tf-footer-left, .tf-footer-right     { display: flex; gap: 10px; align-items: center; }
.tf-range {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    width: 160px;
}

/* ══ Reference / comparison panels (Times, Times-FCF, Avg Rat) ══ */
.ref-panel       { padding: 4px 0; }
.ref-header      { font-size: 12px; font-weight: 700; color: var(--accent-teal); margin-bottom: 6px; }
.ref-subheader   { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin: 8px 0 4px; }
.ref-table       { max-width: 340px; }

.admin-reference-panel { font-size: 12px; padding: 8px 4px; }
.admin-reference-meta  { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 5px 18px; margin: 0 0 10px; }
.admin-reference-meta div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.admin-reference-meta dt { color: var(--text-secondary); text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; }
.admin-reference-meta dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.admin-reference-table { width: 100%; margin-bottom: 10px; }
.admin-reference-table td:nth-child(2) { color: var(--text-secondary); }
.admin-reference-notice { color: var(--accent-teal); margin: 0 0 8px; }
.admin-reference-error { color: #ff8b8b; margin: 0 0 8px; }
.admin-reference-progress { margin-left: 8px; font-size: 11px; }

/* ══ Avg Rat tab ══ */
.avg-rat-panel   { font-size: 12px; }

.ar-filters      { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 8px; align-items: center; font-size: 11px; }
.ar-filter-lbl   { color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.ar-filter-val   { color: var(--text-primary); font-weight: 600; }
.ar-filter-band  { opacity: 0.4; }
.ar-band-active  { opacity: 1; color: var(--accent-teal); }

.ar-table        { max-width: 280px; margin-bottom: 10px; }
.ar-col-current  { background: rgba(52, 199, 180, 0.08); color: var(--accent-teal) !important; font-weight: 700 !important; }
.ar-table td.lbl { color: var(--text-secondary); font-size: 11px; }

/* Distribution bar */
.ar-dist-wrap         { margin-top: 8px; max-width: 340px; }
.ar-dist-label        { font-size: 11px; color: var(--text-primary); margin-bottom: 5px; }
.ar-dist-range        { color: var(--text-secondary); font-weight: 400; }
.ar-dist-bar-outer    { position: relative; height: 8px; background: var(--bg-hover); border-radius: 4px; overflow: visible; margin-bottom: 2px; }
.ar-dist-bar-fill     { position: absolute; left: 0; top: 0; height: 100%; background: var(--accent-teal); border-radius: 4px 0 0 4px; opacity: 0.5; }
.ar-dist-marker       { position: absolute; top: -3px; width: 3px; height: 14px; background: #fff; border-radius: 2px; transform: translateX(-50%); }
.ar-dist-axis         { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
