/* =========================================================================
   Board results (boardresults.js): the Results drawer's Boards view and the
   board designer's Results and 3-D modes. Theme tokens only (tokens.css),
   so both themes follow; the map's colours are the data and do not.
   ========================================================================= */

.board-results { min-width: 0; }

.brv { display: flex; flex-direction: column; gap: 10px; min-width: 0; color: var(--ink); }
.brv.outdated .brv-stage, .brv.outdated .brv-legend { filter: saturate(.55); opacity: .82; }

.brv-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brv-title { font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.brv-board { font-weight: 600; max-width: 320px; }
.brv-badge {
    font-size: 11px; padding: 2px 7px; border-radius: var(--radius);
    background: var(--ok-pale); color: var(--ok); border: 1px solid var(--ok-line); white-space: nowrap;
}
.brv-badge.stale { background: var(--amber-pale); color: var(--amber-deep); border-color: var(--amber-line); font-weight: 600; }
.brv-badge.muted { background: var(--field); color: var(--ink-soft); border-color: var(--rule); }
.brv-head .grow, .brv-tools .grow { flex: 1 1 0; min-width: 0; }
.brv-views { flex: none; }
.brv-views .seg-btn { flex: none; padding: 5px 14px; }
.brv-views .seg-btn:disabled { opacity: .45; cursor: not-allowed; }
.brv-open { white-space: nowrap; }

.brv-tools {
    display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap;
    padding: 6px 8px; background: var(--field); border: 1px solid var(--rule); border-radius: var(--radius);
    font-size: 12px; color: var(--ink-soft);
}
.brv-ctl { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.brv-ctl[hidden] { display: none; }
.brv-ctl select { font-size: 12px; padding: 3px 22px 3px 6px; }
.brv-check { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; }
.brv-cam { display: inline-flex; border: 1px solid var(--rule-firm); border-radius: var(--radius); overflow: hidden; }
.brv-cam button { border: 0; border-right: 1px solid var(--rule-firm); border-radius: 0; background: var(--panel); padding: 3px 9px; font-size: 11.5px; }
.brv-cam button:last-child { border-right: 0; }
.brv-cam button:hover { background: var(--field-2); }
.brv-csv { font-size: 12px; padding: 3px 10px; }

.brv-body { display: grid; grid-template-columns: minmax(380px, 1.6fr) minmax(280px, 1fr); gap: 14px; align-items: start; min-width: 0; }
.brv-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.brv-side { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.brv-view { display: flex; gap: 10px; min-width: 0; align-items: stretch; }
.brv-stage {
    position: relative; flex: 1 1 auto; min-width: 0; height: 340px;
    border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
    background:
        radial-gradient(circle at 1px 1px, var(--grid) 1px, transparent 0) 0 0 / 18px 18px,
        var(--canvas);
}
.brv-stage[data-view="3d"] { background: var(--solid-back, var(--canvas)); }
.brv-stage canvas { display: block; }
.brv-stage .solid-canvas { width: 100%; height: 100%; outline: none; }
.brv-map { position: absolute; inset: 0; cursor: crosshair; }
.brv-tip {
    position: absolute; z-index: 3; pointer-events: none; min-width: 120px; max-width: 220px;
    padding: 6px 8px; font-size: 11.5px; line-height: 1.45;
    background: rgb(var(--glass) / .96); color: var(--ink);
    border: 1px solid var(--rule-firm); border-radius: var(--radius); box-shadow: var(--float-shadow);
}
.brv-tip b { font-family: var(--mono); font-weight: 600; }
.brv-tip span { color: var(--ink-soft); }

.brv-legend { flex: none; width: 62px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 11px; color: var(--ink-soft); }
.brv-legend-title { font-weight: 600; color: var(--ink-mid); }
.brv-legend-bar { position: relative; flex: 1 1 auto; display: flex; gap: 6px; min-height: 120px; width: 100%; }
.brv-legend-bar > i { display: block; width: 14px; border: 1px solid var(--rule-firm); border-radius: 1px; }
.brv-legend-ticks { position: relative; flex: 1; }
.brv-legend-ticks span { position: absolute; left: 0; transform: translateY(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--ink-mid); white-space: nowrap; }
.brv-legend-ticks span::before { content: ""; position: absolute; left: -8px; top: 50%; width: 5px; border-top: 1px solid var(--line-strong); }
.brv-legend-note { font-size: 10px; line-height: 1.25; color: var(--ink-faint); }

.brv-readout { font-size: 12px; color: var(--ink-mid); min-height: 18px; font-variant-numeric: tabular-nums; }
.brv-readout b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.brv .muted, .brv-readout .muted { color: var(--ink-faint); }

.brv-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.brv-kpi { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brv-kpi span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.brv-kpi b { font-family: var(--mono); font-size: 15px; font-weight: 600; white-space: nowrap; }
.brv-kpi small { font-size: 11px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brv-kpi.bad { border-color: var(--bad-line); background: var(--bad-pale); }
.brv-kpi.bad b { color: var(--danger); }
.brv-kpi.warn { border-color: var(--amber-line); background: var(--amber-pale); }
.brv-kpi.warn b { color: var(--amber-deep); }

.brv-card { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); padding: 8px 10px; min-width: 0; }
.brv-card h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-mid); }
.brv-card h4 small { font-weight: 400; color: var(--ink-faint); margin-left: 6px; }
.brv-note { margin: 6px 0 0; font-size: 11px; line-height: 1.45; color: var(--ink-faint); }

table.brv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.brv-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-mid); padding: 3px 6px; border-bottom: 1px solid var(--rule-firm); white-space: nowrap; }
table.brv-table td { padding: 3px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.brv-table .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.brv-table td small { display: block; font-size: 10.5px; color: var(--ink-faint); }
table.brv-table tr.sum td { font-weight: 600; background: var(--field); }
table.brv-table tr.bad td { color: var(--danger); }
table.brv-table tr.muted td { color: var(--ink-faint); }
table.brv-table tr[data-brv-layer], table.brv-table tr[data-part] { cursor: pointer; }
table.brv-table tr[data-brv-layer]:hover td, table.brv-table tr[data-part]:hover td { background: var(--field); }
table.brv-table tr.on td, table.brv-table tr.sel td { background: var(--brand-pale); }
table.brv-table tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
table.brv-table td.margin.bad { color: var(--danger); font-weight: 700; background: var(--bad-pale); }
table.brv-table td.margin.warn { color: var(--amber-deep); font-weight: 600; }
table.brv-table td.margin.ok { color: var(--ok); }
table.brv-table td.ref { font-weight: 600; }
.brv-scroll { overflow: auto; max-height: 320px; }
.brv-parts-table th { position: sticky; top: 0; background: var(--panel); z-index: 1; }

/* In the drawer: shorter, and one column when the drawer is narrow. */
.brv-drawer .brv-stage { height: 300px; }
@media (max-width: 1250px) { .brv-body { grid-template-columns: minmax(0, 1fr); } }

/* In the board designer: the panel takes the stage's place below its tools. */
.pcb-mode { flex: none; }
.pcb-mode .seg-btn { flex: none; padding: 5px 12px; overflow: visible; }
.pcb-mode .seg-btn:disabled { opacity: .45; cursor: not-allowed; }
.brv-stale-dot { color: var(--amber); font-size: 9px; vertical-align: 2px; margin-left: 2px; }
.pcb-results { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px 16px; }
.pcb-results[hidden] { display: none; }
.pcb-stage.brv-mode > .pcb-canvas, .pcb-stage.brv-mode > .pcb-foot,
.pcb-stage.brv-mode > .pcb-stack, .pcb-stage.brv-mode > .pcb-import { display: none !important; }
.pcb-stage.brv-mode > .pcb-tools > :not(#pcb-mode):not(.grow) { display: none !important; }
.brv-designer .brv-stage { height: min(60vh, 560px); }
.brv-designer .brv-body { grid-template-columns: minmax(420px, 1.8fr) minmax(280px, 1fr); }
/* The designer's centre column is narrower than the window: the figures go
   under the map when the two will not fit side by side, rather than off the
   edge behind a sideways scroll. */
.brv-designer { container-type: inline-size; }
@container (max-width: 720px) { .brv-designer .brv-body { grid-template-columns: minmax(0, 1fr); } }

table.brv-table td.split { white-space: nowrap; font-size: 11.5px; }
.brv-split-item { display: inline-flex; align-items: center; gap: 3px; margin-right: 8px; font-family: var(--mono); color: var(--ink-mid); }
.brv-split-item i { display: inline-block; height: 7px; background: var(--warm); opacity: .7; border-radius: 1px; }
