/* g8r-specific pieces on top of qw-ui-kit. Nothing here names a color: it all reads the kit's theme
   tokens (docs/spec.md sec. 10); the Theme page's saved overrides ride in on <html> (qw_ui_kit.init_app tokens=). */
:root { --g8r-gap: 16px; }

.legend-key { border-left: 10px solid var(--legend, var(--outline-strong)); }

.fields { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; }
.fields.stacked { flex-direction: column; flex-wrap: nowrap; align-items: stretch; max-width: 28em; }
.fields.stacked select[multiple] { width: 100%; }
.fields.stacked .qw-field { margin: 0; }
.fields.stacked + .inline { margin-top: 12px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.opt { display: block; margin: 4px 0; }
.seg { display: inline-flex; }
.seg label { padding: 4px 14px; border: 1px solid var(--outline-strong); cursor: pointer; background: var(--surface-container); }
.seg label:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.seg label:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.seg label + label { border-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.logo-prev { height: 36px; width: auto; background: var(--primary); padding: 6px 10px; border-radius: var(--radius-md); display: block; }
dl.kv { display: grid; grid-template-columns: 10rem 1fr; gap: 4px 16px; margin: 0; }
dl.kv dt { color: var(--on-surface-variant); }
dl.kv dd { margin: 0; }
.qw-table .qw-actions form { margin: 0; }

/* Live: nothing here scrolls. Charge rack = 16 cards, 8 rows x 2 columns, filling what the header leaves (no outer card).
   Type scales with the window height so 8 rows stay readable at any size. */
.g8r-rack-id { margin: 0 0 4px; font-size: 12px; color: var(--on-surface-variant); }
.g8r-rack-card { display: flex; flex-direction: column; min-height: 0; }
.rack { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(var(--rows, 8), minmax(0, 1fr)); gap: 8px 12px; }
.slotcard { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px; box-sizing: border-box; min-height: 0; min-width: 0; overflow: hidden;
            padding: 3px 6px; border: 1px solid var(--outline); border-radius: var(--radius-md); background: var(--surface-container); }
.slot-tile { min-height: 0; min-width: 0; }
.slot-plot { min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.slot-stack { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; justify-content: space-between; min-height: 0;
              padding-left: 6px; border-left: 4px solid var(--outline-strong); font-size: clamp(11px, 1.5vh, 15px); line-height: 1.1; overflow: hidden; }
.slot-stack.active { border-left-color: var(--ok); }
.slot-stack.done { border-left-color: var(--primary); }
.slot-stack.unknown { border-left-color: var(--warn); }
.slot-loc { flex: none; font-size: clamp(10px, 1.35vh, 13px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-name { font-size: clamp(10px, 1.35vh, 13px); flex: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-name.unknown { color: var(--warn); }
.slot-name.dim { color: var(--on-surface-variant); font-weight: 400; }
.slot-vals { display: flex; flex-direction: column; gap: 1px; font-variant-numeric: tabular-nums; }
.slot-vals b { font-size: clamp(12px, 1.75vh, 19px); font-weight: 600; }
.slot-state { flex: none; font-size: clamp(9px, 1.15vh, 12px); color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The rack tile is five lines (location, battery, V A, Ah DCR, state): the four readings sit two by two so all of it fits a card's height. */
.rack .slot-vals { display: grid; grid-template-columns: auto auto; column-gap: 6px; justify-content: start; }
.rack .slot-vals b { font-size: clamp(11px, 1.55vh, 17px); }
.slot-stack.empty { opacity: .6; }
.stale .slotcard { opacity: .55; }
/* Discharge rig: one row (the slot card, then the tiles), the plot in its own card below it. */
.g8r-rig { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.g8r-rig-row { flex: none; display: flex; gap: 12px; align-items: stretch; }
.slotcard.g8r-rig-slot { display: block; flex: none; width: 260px; height: 76px; padding: 4px 8px; }
.g8r-rig-slot .slot-stack { font-size: 15px; align-items: center; justify-content: center; text-align: center; gap: 2px; border-left-width: 0; }
.g8r-rig-slot .slot-vals { flex-direction: row; gap: 10px; justify-content: center; }
.g8r-rig-slot .slot-vals b { font-size: 15px; }
.g8r-rig-state { height: 100%; }
.g8r-rig-slot .slot-name { font-size: 16px; }
.g8r-rig-slot .slot-state { font-size: 13px; }
.g8r-rig-tiles { flex: 1 1 0; min-width: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g8r-rig-tiles .qw-tile { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding-top: 4px; padding-bottom: 4px; }
.g8r-rig-tiles .qw-tile > * { text-align: center; justify-content: center; }
.g8r-rig-plotcard { flex: 1 1 0; min-height: 240px; display: flex; padding: 8px; }
.g8r-rig-plot { flex: 1 1 auto; min-width: 0; min-height: 0; }
.g8r-rig-plot .qw-plot { height: 100%; }
@media (max-width: 900px) { .rack { grid-template-columns: 1fr; } .g8r-rig-row { flex-wrap: wrap; } .g8r-rig-tiles { grid-template-columns: repeat(2, 1fr); flex-basis: 100%; } }
.field-label { color: var(--on-surface-variant); font-size: 12px; }
.logo-prev[hidden] { display: none; }
.g8r-scroll { overflow-x: auto; }
/* The kit's filter bar is a column for a side panel; on a full-width card the filters sit side by side. */
.g8r-row-filters .qw-filters { flex-direction: row; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.g8r-row-filters .qw-filters .qw-field { flex: 1 1 14em; max-width: 24em; }

/* Records and Battery pages (three panes): the middle pane is a column that never scrolls. Every plot in it (volts, amps, the DCR dots) shares
   the height the tools and tiles leave, so none can run over another; min-height 0 beats the kit's 240px floor, which is what made them
   spill over each other on a short window. */
.qw-pane-main .qw-pane-body { display: flex; flex-direction: column; gap: 8px; overflow-x: hidden; overflow-y: auto; }
.qw-pane-main .qw-pane-body > * { flex: none; }
/* 190px floor: on a short window the pane scrolls inside itself rather than squeeze a plot to a sliver whose ticks run together. */
.qw-pane-main .qw-pane-body > .qw-plot { flex: 1 1 0; min-height: 190px; overflow: hidden; }
.qw-pane-main .qw-pane-body > [hidden] { display: none; }
.g8r-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.g8r-legend:empty { display: none; }
.g8r-designation { flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px; margin: 0; }
.g8r-designation label { margin: 0; white-space: nowrap; }
.qw-pane-filters > .qw-field { margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.qw-pane-side .qw-daterange { display: flex; gap: 8px; }
.qw-pane-side .qw-daterange .qw-field { flex: 1 1 0; min-width: 0; }
.qw-pane-filters > .qw-field { flex-direction: row; }
.qw-pane-main .qw-tile-value { white-space: nowrap; }
/* The list is as wide as its columns (the kit sizes it max-content): nothing in it wraps, so it never scrolls sideways. */
.qw-pane-side .qw-table th, .qw-pane-side .qw-table td { white-space: nowrap; }
.qw-pane-side .qw-table td:first-child { text-align: center; }
.qw-pane-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--outline); }
.qw-pane-side.collapsed .qw-pane-foot { display: none; }
.qw-pane-side .qw-filters { flex-direction: column; }
.g8r-bulk { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
/* A clicked record: its row and its trace are the same red (the theme's highlight color). */
.qw-pane-side .qw-table tbody tr.selected, .qw-pane-side .qw-table tbody tr.selected td {
  background: color-mix(in srgb, var(--highlight) 22%, transparent); color: var(--on-surface); font-weight: 600; }
.qw-pane-side .qw-table tbody tr.selected td:first-child { box-shadow: inset 4px 0 0 var(--highlight); }
/* The Battery page's stat tiles are one row; the designation tile holds the control itself. */
/* The middle pane is narrow, so the six tiles wrap into rows of whatever fits (never overlap); the date and the designation get the room to read. */
.g8r-battery-tiles { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; }
.g8r-battery-tiles .qw-tile-value { white-space: normal; overflow-wrap: anywhere; text-align: center; }
.g8r-battery-tiles .qw-tile-unit { font-size: .7rem; margin-left: 2px; }
.g8r-battery-tiles .qw-tile { padding: 8px 8px; min-width: 0; }
.g8r-battery-tiles .qw-tile-value { font-size: 1.15rem; }
.g8r-battery-tiles .qw-tile { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 2px; }
.g8r-battery-tiles .qw-tile > * { text-align: center; justify-content: center; }
.g8r-mode { cursor: help; text-decoration: underline dotted; }
.g8r-plot-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.g8r-plot-tools .qw-plot-tools { display: flex; gap: 12px; align-items: center; }
/* The rulers card fills the right pane; the pane's own head and collapse button replace the card's summary. */
.g8r-pane-rulers .qw-rulers { border: 0; padding: 0; margin: 0; }
.g8r-pane-rulers .qw-rulers > summary { display: none; }
.g8r-pane-rulers .qw-pane-head .qw-pane-title { order: 0; }

/* Batteries table: tags one per line in small monospace; the hand-set marker beside a designation */
.g8r-taglist { display: flex; flex-direction: column; gap: 1px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; }
.g8r-search { max-width: 24em; margin-bottom: 8px; }
.qw-about { display: grid; grid-template-columns: 10rem 1fr; gap: 4px 24px; margin: 12px 0 0; }
.qw-about dd { margin: 0; }

/* Settings > Devices: the enrollment QR (always black on white, so any camera reads it) */
.g8r-qr { display: inline-block; background: white; padding: 8px; border-radius: 8px; }
.g8r-qr svg { display: block; width: min(260px, 70vw); height: auto; }
.g8r-qr-url { word-break: break-all; font-size: 11px; }
/* The phone page: one column, big touch targets */
.g8r-phone { max-width: 32rem; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; padding: 8px; }
.g8r-phone .qw-card { display: flex; flex-direction: column; gap: 10px; }
.g8r-phone .qw-input, .g8r-phone .qw-select, .g8r-phone .qw-btn { font-size: 1.05rem; min-height: 2.75rem; box-sizing: border-box; width: 100%; }
.g8r-phone-row { display: flex; gap: 8px; }
.g8r-phone-row .qw-input { flex: 1 1 auto; width: auto; min-width: 0; }
.g8r-phone-row .qw-btn { width: auto; }
.g8r-phone-form { display: flex; flex-direction: column; gap: 10px; }
.g8r-uid { font-family: var(--font-mono, ui-monospace, monospace); }

/* Settings pages whose table fills the page and scrolls inside its card (the page does not scroll) */
.g8r-stack { display: flex; flex-direction: column; min-height: 0; }
.g8r-stack > .qw-card:not(.g8r-fillcard), .g8r-stack > .qw-callout { flex: none; }
.g8r-fillcard { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
.g8r-fillbody { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.g8r-fillbody > .qw-table-box { flex: 1 1 auto; }
.g8r-tag-battery { display: inline-flex; align-items: center; gap: 8px; }
/* Settings > Devices > Enroll a phone: the QR left, its caption, address and warnings stacked right */
.g8r-enroll { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.g8r-enroll-text { flex: 1 1 16em; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.g8r-enroll-text p { margin: 0; }
.g8r-about-group { margin: 16px 0 0; font-weight: 400; }

/* Batteries ranking and Attention (pass 6B): the amber warning beside a designation, the inline designation dropdown, tab tools */
.g8r-desig { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g8r-tabtools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.g8r-threshold { margin: 0 0 8px; }
.g8r-overdue-intro { display: flex; align-items: center; gap: 12px; }      /* Retest all sits at the right of the bubble */
.g8r-overdue-intro .qw-alert-text { flex: 1; }
.g8r-overdue-intro .qw-btn { flex: none; }

/* Pass 6D: the list's header filters stay compact so every column fits the left pane; the rulers table scrolls sideways in its pane */
.g8r-pane-list .qw-filter-dates { display: flex; flex-direction: column; gap: 3px; }
.g8r-pane-list .qw-filter-dates .qw-input { width: 9.6em; min-width: 0; padding-left: 4px; padding-right: 2px; font-size: 12px; }
.g8r-pane-list .qw-filter-range .qw-input { width: 4.2em; min-width: 0; }
.g8r-pane-list .qw-table th, .g8r-pane-list .qw-table td { padding-left: 6px; padding-right: 6px; }
.g8r-pane-rulers .qw-pane-body { overflow-x: auto; }
.g8r-pane-rulers .qw-table th, .g8r-pane-rulers .qw-table td { white-space: nowrap; padding-left: 6px; padding-right: 6px; }

/* Batteries table: the Attention glyphs, the New battery button row */
.g8r-attn { display: inline-flex; align-items: center; text-decoration: none; }
.g8r-weeks { width: 3.2rem; text-align: center; }        /* one digit, 1 to 9 */
.g8r-beak-cell { display: inline-flex; align-items: center; gap: 8px; }
.g8r-beak-cell .qw-input { width: 7rem; }
/* Theme > Mode */
.g8r-radios { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.g8r-radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
/* About: a short intro, a row of tiles for the application, a full-width table for what it is built on */
.g8r-about-intro { margin: 0 0 12px; }
.g8r-about-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g8r-about-tiles .qw-tile-value { font-size: 1.25rem; }
@media (max-width: 600px) { .g8r-about-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.g8r-deps td.g8r-ver { font-variant-numeric: tabular-nums; white-space: nowrap; }
.g8r-deps .g8r-muted { color: var(--on-surface-variant); }

/* Pass 7 (#71): the record table fills the list pane and scrolls inside it, both ways, so a narrow pane gets a horizontal scrollbar at its
   foot instead of cutting DCR off; the rulers table fills its pane and scrolls only when it runs out of room. */
.g8r-pane-list > .qw-pane-body { display: flex; flex-direction: column; overflow: hidden; }
.g8r-pane-list #g8r-list { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.g8r-pane-list #g8r-list > .g8r-bulk, .g8r-pane-list #g8r-list > p { flex: none; }
.g8r-pane-list #g8r-list > .qw-table-box { flex: 1 1 auto; min-height: 0; height: auto; }
.g8r-pane-rulers > .qw-pane-body { display: flex; flex-direction: column; overflow: hidden; }
.g8r-pane-rulers .qw-rulers { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.g8r-pane-rulers .qw-rulers > * { flex: none; }
.g8r-pane-rulers .qw-rulers > .qw-table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; }
.g8r-pane-list.collapsed > .qw-pane-body, .g8r-pane-rulers.collapsed > .qw-pane-body { display: none; }

/* A side-menu page whose content is a few cards: as wide as its prose, not the window (the kit's content-width rule for pages with no menu). */
.g8r-fit { max-width: 60rem; }
.g8r-row-actions { display: flex; gap: 8px; align-items: center; }
.slot-flag { grid-column: 1 / -1; color: var(--warn); font-weight: 600; font-size: clamp(9px, 1.15vh, 12px); }
.g8r-pill.warn { color: var(--warn); font-weight: 600; }
.g8r-slotcal { display: flex; gap: 4px; flex-wrap: wrap; }
.g8r-slotcal .qw-input { width: 9em; }
.g8r-muted { color: var(--on-surface-variant); }
.g8r-login { display: grid; gap: 12px; max-width: 320px; }
.g8r-login label { display: grid; gap: 4px; }
.g8r-login .qw-btn { justify-self: start; }
