/* qw-ui-kit: the shared QW app look. Rules are in docs/spec.md. Nothing here names a color; it all reads
   theme tokens (tokens.css supplies defaults). Class names are prefixed .qw- except the page frame. */

/* ---- Page frame: the page itself never scrolls; panels inside it do ------------------------------ */
html, body { margin: 0; height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; font-family: var(--font-sans); font-size: 14px; line-height: 1.4;
       background: var(--surface); color: var(--on-surface); }
a { color: var(--primary); }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; }
.qw-muted { color: var(--on-surface-variant); }
.qw-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.qw-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Header (fixed) and sub-nav: version on the right of the title banner ------------------------ */
.qw-head { flex: none; position: relative; z-index: 100; }
.qw-banner { display: flex; align-items: center; gap: 2px; padding: 0 12px; height: 42px; box-sizing: border-box;
             background: var(--primary); border-bottom: 1px solid var(--outline); color: var(--qw-banner-fg, var(--on-primary)); }
.qw-logo { height: 22px; width: auto; margin-right: 10px; display: block; }
/* Separate light and dark logos; the dark one falls back to the light one (the template only emits it when it differs). */
.qw-logo-dark { display: none; }
:root[data-theme="dark"] .qw-logo.has-dark { display: none; }
:root[data-theme="dark"] .qw-logo-dark { display: block; }
/* The mode button, next to the version: device, light, dark (Alt+M). */
.qw-modebtn { font: inherit; font-size: 14px; line-height: 1; width: 28px; height: 26px; padding: 0; margin-left: 10px; cursor: pointer; color: inherit;
              background: transparent; border: 1px solid currentColor; border-radius: var(--radius-md); opacity: .85; }
.qw-modebtn:hover { opacity: 1; background: rgba(127, 127, 127, .18); }
.qw-modebtn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.qw-site { font-weight: 800; font-size: 13px; margin-right: 14px; white-space: nowrap; }
.qw-spacer { flex: 1 1 auto; }
.qw-version { font-size: 12px; opacity: .85; white-space: nowrap; margin-left: 12px; }
.qw-link { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 42px; box-sizing: border-box;
          padding: 0 13px; font-size: 12.5px; font-weight: 600; color: var(--qw-banner-fg, var(--on-primary)); opacity: .72;
          text-decoration: none; white-space: nowrap; }
.qw-link:hover { opacity: 1; background: rgba(127, 127, 127, .18); }
.qw-link.current { opacity: 1; }
.qw-link.current::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: currentColor; }
.qw-link:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.qw-subnav { display: flex; align-items: center; gap: 2px; padding: 0 12px; height: 34px; box-sizing: border-box;
             background: var(--surface-container-low); border-bottom: 1px solid var(--outline); }
.qw-subnav .qw-link { height: 34px; color: var(--on-surface); opacity: .75; }
.qw-subnav .qw-link.current { opacity: 1; font-weight: 700; }
.qw-subnav .qw-link.current::after { background: var(--primary); }

/* ---- Main: fills what the header leaves; simple pages scroll `main` itself ------------------------ */
.qw-main { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 16px; box-sizing: border-box;
           display: flex; flex-direction: column; width: 100%; }
.qw-main > * { flex: none; }
.qw-main > .qw-fill { flex: 1 1 auto; min-height: 0; }
.qw-titlerow { display: flex; align-items: baseline; gap: 12px; }
.qw-titlerow h1 { flex: 1 1 auto; margin: 0 0 10px; }

/* ---- Cards: everything sits in a titled card -------------------------------------------------------- */
.qw-card { background: var(--surface-container); border: 1px solid var(--outline); border-radius: var(--radius-md);
           padding: 12px 16px; margin: 0 0 16px; box-sizing: border-box; }
.qw-card > h2:first-child { margin-top: 0; }

/* ---- Two-panel layout: collapsible scrolling list left, plot right ------------------------------- */
.qw-panes { display: flex; align-items: stretch; min-height: 0; gap: 10px; }
.qw-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; box-sizing: border-box;
           background: var(--surface-container); border: 1px solid var(--outline); border-radius: var(--radius-md); }
/* The list panel is as wide as its columns (no horizontal scroll) and the plot takes the rest of the full page width. */
.qw-pane-side { flex: 0 0 auto; width: var(--qw-side-w, max-content); max-width: 70%; }
.qw-pane-side .qw-pane-body { overflow-x: auto; }
.qw-pane-main { flex: 1 1 0; }
.qw-pane-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--outline); flex: none; }
.qw-pane-title { flex: 1 1 auto; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qw-pane-filters { flex: none; padding: 8px 10px; border-bottom: 1px solid var(--outline); }
.qw-pane-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 10px; }
.qw-pane-head [data-qw-collapse] { order: -1; flex: none; }   /* the toggle is first: at the left of the head, and at the TOP of the collapsed rail */
.qw-pane-side.collapsed { width: 34px; }
.qw-pane-side.collapsed .qw-pane-body, .qw-pane-side.collapsed .qw-pane-filters { display: none; }
.qw-pane-side.collapsed .qw-pane-head { flex-direction: column; justify-content: flex-start; align-items: center; border-bottom: 0; padding: 6px 2px; }
.qw-pane-side.collapsed .qw-pane-title { writing-mode: vertical-rl; }
.qw-plot { width: 100%; height: 100%; min-height: 240px; }

/* ---- Buttons: one primary style, a neutral default, danger in red ---------------------------------- */
.qw-btn { font: inherit; font-size: 13px; padding: 4px 12px; cursor: pointer; background: var(--surface-container);
          color: var(--on-surface); border: 1px solid var(--outline-strong); border-radius: var(--radius-md); }
.qw-btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--primary); }
.qw-btn:disabled { opacity: .55; cursor: default; }
.qw-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.qw-btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.qw-btn.primary:hover:not(:disabled) { background: var(--primary); filter: brightness(1.1); }
.qw-btn.danger { color: var(--error); border-color: var(--error); }
.qw-btn.danger:hover:not(:disabled) { background: var(--error-container); border-color: var(--error); }
.qw-btn.icon { padding: 2px 8px; }

/* ---- Forms ------------------------------------------------------------------------------------------ */
.qw-field { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
.qw-field > label { color: var(--on-surface-variant); font-size: 12px; }
.qw-help { color: var(--on-surface-variant); font-size: 12px; margin: 2px 0 0; }
.qw-input, .qw-select { font: inherit; padding: 3px 6px; box-sizing: border-box; min-height: 26px; color: var(--on-surface);
                        background: var(--surface); border: 1px solid var(--outline-strong); border-radius: var(--radius-md); }
.qw-input:focus-visible, .qw-select:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; }
/* number stepper: "touch" (big - / + beside the field) and "inline" (always-visible stacked arrows inside the right edge) */
.qw-stepper-wrap { display: inline-flex; flex-direction: column; gap: 2px; }
.qw-stepper { display: inline-flex; align-items: stretch; align-self: flex-start; }
.qw-stepper-input { -moz-appearance: textfield; appearance: textfield; text-align: center; min-width: 0; }
.qw-stepper-input::-webkit-outer-spin-button, .qw-stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qw-stepper-btn { font: inherit; cursor: pointer; color: var(--on-surface); background: var(--surface-container-low); border: 1px solid var(--outline-strong); padding: 0; }
.qw-stepper-btn:hover:not(:disabled) { background: var(--surface-hover); }
.qw-stepper-btn:active:not(:disabled) { background: var(--primary-container); color: var(--on-primary-container); }
.qw-stepper-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.qw-stepper-btn:disabled { opacity: .4; cursor: default; }
.qw-stepper.touch .qw-stepper-input { width: 6rem; min-height: 48px; font-size: 20px; border-radius: 0; border-left: 0; border-right: 0; }
.qw-stepper.touch .qw-stepper-btn { width: 52px; min-height: 48px; font-size: 26px; line-height: 1; }
.qw-stepper.touch .qw-stepper-btn.down { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.qw-stepper.touch .qw-stepper-btn.up { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.qw-stepper.inline { position: relative; }
.qw-stepper.inline .qw-stepper-input { width: 7rem; text-align: left; padding-right: 26px; }
.qw-stepper-arrows { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 22px; display: flex; flex-direction: column; }
.qw-stepper-arrows .qw-stepper-btn { flex: 1 1 0; min-height: 0; font-size: 8px; line-height: 1; border: 0; border-left: 1px solid var(--outline); background: var(--surface-container-low); }
.qw-stepper-arrows .qw-stepper-btn.up { border-bottom: 1px solid var(--outline); border-top-right-radius: calc(var(--radius-md) - 1px); }
.qw-stepper-arrows .qw-stepper-btn.down { border-bottom-right-radius: calc(var(--radius-md) - 1px); }
.qw-daterange { display: flex; gap: 8px; }
.qw-daterange > .qw-field { flex: 1 1 0; min-width: 0; margin: 0; }
.qw-filters { display: flex; flex-direction: column; gap: 8px; }
.qw-filters .qw-field { margin: 0; }

/* Toggle switch */
.qw-switch { position: relative; display: inline-block; width: 30px; height: 16px; flex: none; }
.qw-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.qw-switch span { position: absolute; inset: 0; background: var(--surface-container-low); border: 1px solid var(--outline-strong);
                  border-radius: 9px; transition: background .12s; pointer-events: none; }
.qw-switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 10px; height: 10px; border-radius: 50%;
                         background: var(--outline-strong); transition: transform .12s, background .12s; }
.qw-switch input:checked + span { background: var(--primary); border-color: var(--primary); }
.qw-switch input:checked + span::after { transform: translateX(14px); background: var(--on-primary); }
.qw-switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Excel-style multi-select dropdown */
.qw-multi { position: relative; }
.qw-multi-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 6px; text-align: left; }
.qw-multi-btn::after { content: "▾"; color: var(--on-surface-variant); }
.qw-multi-pop { position: absolute; z-index: 200; left: 0; right: 0; min-width: 180px; margin-top: 2px; background: var(--surface-container);
                border: 1px solid var(--outline-strong); border-radius: var(--radius-md); box-shadow: 0 4px 14px var(--shadow); }
.qw-multi-pop[hidden] { display: none; }
.qw-multi-pop.fixed { position: fixed; right: auto; margin-top: 0; }
.qw-multi-tools { display: flex; gap: 6px; padding: 6px; border-bottom: 1px solid var(--outline); }
.qw-multi-list { max-height: 220px; overflow: auto; padding: 4px 0; }
.qw-multi-opt { display: flex; align-items: center; gap: 8px; padding: 3px 10px; cursor: pointer; }
.qw-multi-opt:hover { background: var(--surface-hover); }

/* ---- Tables: every column sortable; heading over its numbers ------------------------------------- */
.qw-table { border-collapse: collapse; width: 100%; }
.qw-table th, .qw-table td { padding: 4px 10px; border-bottom: 1px solid var(--outline); text-align: left; white-space: nowrap; }
.qw-table thead th { position: sticky; top: 0; background: var(--surface-container-low); font-weight: 600; cursor: pointer; user-select: none; z-index: 1; }
.qw-table th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
.qw-table th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
.qw-table .num { text-align: right; }
.qw-table tbody tr:hover { background: var(--surface-hover); }
.qw-table tbody tr.selected, .qw-table tbody tr.selected td { background: var(--primary-container); color: var(--on-primary-container); font-weight: 400; }
.qw-table td.qw-actions, .qw-table th.qw-actions { width: 1%; text-align: center; cursor: default; }
.qw-table th.qw-actions::after { content: none; }

/* ---- Row actions menu (⋯) -------------------------------------------------------------------------- */
.qw-menu { position: fixed; z-index: 300; min-width: 150px; padding: 4px 0; background: var(--surface-container);
           border: 1px solid var(--outline-strong); border-radius: var(--radius-md); box-shadow: 0 4px 14px var(--shadow); }
.qw-menu button { display: block; width: 100%; text-align: left; font: inherit; padding: 5px 14px; background: transparent;
                  color: var(--on-surface); border: 0; cursor: pointer; }
.qw-menu button:hover, .qw-menu button:focus-visible { background: var(--surface-hover); outline: none; }
.qw-menu button.danger { color: var(--error); }

/* ---- Dialogs and toasts --------------------------------------------------------------------------- */
.qw-backdrop { position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; }
.qw-dialog { background: var(--surface-container); color: var(--on-surface); border: 1px solid var(--outline-strong);
             border-radius: var(--radius-md); box-shadow: 0 8px 28px var(--shadow); padding: 16px; width: min(28rem, 92vw);
             max-height: 90vh; overflow: auto; box-sizing: border-box; }
.qw-dialog.wide { width: min(46rem, 94vw); }
.qw-dialog h2 { margin-top: 0; }
.qw-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.qw-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
              max-width: min(26rem, 92vw); pointer-events: none; }
.qw-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 12px; border-radius: var(--radius-md);
            border: 1px solid var(--outline-strong); background: var(--surface-container); box-shadow: 0 4px 14px var(--shadow); }
.qw-toast.ok { background: var(--ok-container); color: var(--on-ok-container); border-color: var(--ok); }
.qw-toast.error { background: var(--error-container); color: var(--on-error-container); border-color: var(--error); }
.qw-toast.warn { background: var(--warn-container); color: var(--on-warn-container); border-color: var(--warn); }
.qw-toast.info { background: var(--info-container); color: var(--on-info-container); border-color: var(--info); }
.qw-toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.qw-toast-x { flex: none; font: inherit; line-height: 1; width: 22px; height: 22px; padding: 0; cursor: pointer; color: inherit; background: transparent;
              border: 0; border-radius: var(--radius-md); opacity: .7; }
.qw-toast-x:hover, .qw-toast-x:focus-visible { opacity: 1; background: var(--surface-hover); outline: none; }

/* Autosave confirmation: a small "saved" that fades out */
.qw-saved { font-size: 12px; color: var(--ok); opacity: 0; transition: opacity .25s; }
.qw-saved.on { opacity: 1; }
.qw-saved.error { color: var(--error); opacity: 1; }

/* ---- Stat tiles ------------------------------------------------------------------------------------- */
.qw-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.qw-tile { background: var(--surface-container); border: 1px solid var(--outline); border-radius: var(--radius-md); padding: 10px 12px; }
.qw-tile-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.qw-tile-unit { font-size: .9rem; font-weight: 400; color: var(--on-surface-variant); margin-left: 4px; }
.qw-tile-label { font-size: 12px; color: var(--on-surface-variant); margin-top: 2px; }
.qw-tile.empty .qw-tile-value { color: var(--on-surface-variant); }

/* ---- Callouts and pills ----------------------------------------------------------------------------- */
.qw-alert, .qw-callout { position: relative; padding: 8px 12px 8px 38px; border-radius: var(--radius-md); border: 1px solid var(--outline); margin: 8px 0; }
.qw-alert::before, .qw-callout::before { content: "i"; position: absolute; left: 12px; top: 9px; }
.qw-alert.info, .qw-callout.info { background: var(--info-container); color: var(--on-info-container); border-color: var(--info); }
.qw-alert.warn, .qw-callout.warn { background: var(--warn-container); color: var(--on-warn-container); border-color: var(--warn); }
.qw-alert.error, .qw-callout.error { background: var(--error-container); color: var(--on-error-container); border-color: var(--error); }
.qw-alert.ok, .qw-callout.ok { background: var(--ok-container); color: var(--on-ok-container); border-color: var(--ok); }
/* The standard status glyphs: a colored circle with a mark (OK white check on green, error white X on red, info white "i" on blue,
   warning black "!" on yellow). Callouts, toasts and status pills all use them. */
.qw-glyph, .qw-glyph, .qw-alert::before, .qw-callout::before { display: inline-flex; align-items: center; justify-content: center; flex: none; box-sizing: border-box; width: 18px; height: 18px;
  border-radius: 50%; vertical-align: -4px; font-size: 12px; font-weight: 800; line-height: 1; font-family: var(--font-sans);
  background: var(--glyph-info); color: var(--glyph-mark); }
.qw-glyph.ok, .qw-glyph.ok, .qw-alert.ok::before, .qw-callout.ok::before { background: var(--glyph-ok); }
.qw-glyph.error, .qw-glyph.error, .qw-alert.error::before, .qw-callout.error::before { background: var(--glyph-error); }
.qw-glyph.warn, .qw-glyph.warn, .qw-alert.warn::before, .qw-callout.warn::before { background: var(--glyph-warn); color: var(--glyph-mark-warn); }
.qw-glyph.ask, .qw-alert.ask::before, .qw-callout.ask::before { background: var(--glyph-ask); }
.qw-glyph.info, .qw-glyph.info, .qw-alert.info::before, .qw-callout.info::before { background: var(--glyph-info); }
.qw-glyph.ok::before, .qw-glyph.ok::before, .qw-alert.ok::before, .qw-callout.ok::before { content: "✓"; }
.qw-glyph.error::before, .qw-glyph.error::before, .qw-alert.error::before, .qw-callout.error::before { content: "✕"; }
.qw-glyph.info::before, .qw-glyph.info::before, .qw-alert.info::before, .qw-callout.info::before { content: "i"; font-style: normal; }
.qw-glyph.ask::before, .qw-alert.ask::before, .qw-callout.ask::before { content: "?"; font-style: normal; }
.qw-glyph.warn::before, .qw-glyph.warn::before, .qw-alert.warn::before, .qw-callout.warn::before { content: "!"; }
.qw-pill { display: inline-block; padding: 1px 10px; border-radius: 9999px; font-size: 12px; font-weight: 600;
           background: var(--surface-container-low); color: var(--on-surface-variant); border: 1px solid var(--outline); }
.qw-mark { display: inline-block; min-width: 1.2em; text-align: center; font-weight: 800; }
.qw-mark.ok { color: var(--ok); }
.qw-mark.nok { color: var(--error); }

/* Color pickers use the QW display widgets; this only lays the swatch beside its label. */
.qw-color-row { display: flex; align-items: center; gap: 8px; }

/* ---- Count pills on nav items ("Attention 5") ------------------------------------------------------- */
.qw-count { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9999px; box-sizing: border-box; text-align: center;
            font-size: 11px; font-weight: 700; line-height: 18px; background: var(--qw-banner-fg, var(--on-primary)); color: var(--primary); }
.qw-subnav .qw-count { background: var(--primary); color: var(--on-primary); }

/* ---- Theme settings page ------------------------------------------------------------------------------ */
.qw-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.qw-theme-row { display: grid; grid-template-columns: 16rem 9rem 7rem auto; justify-content: start; align-items: center; gap: 8px; margin: 6px 0; }
.qw-theme-label small { font-size: 11px; }
.qw-swatch { width: 28px; height: 28px; padding: 0; cursor: pointer; border: 1px solid var(--outline-strong); border-radius: var(--radius-md); }
.qw-swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.qw-hex.bad { border-color: var(--error); }
.qw-logo-box { display: flex; align-items: center; justify-content: center; width: 160px; height: 56px; margin: 4px 0 8px;
               background: var(--primary); border: 1px solid var(--outline); border-radius: var(--radius-md); }
.qw-logo-preview { max-width: 140px; max-height: 40px; }
.qw-theme-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qw-err { color: var(--error); }

/* ---- Rulers panel ------------------------------------------------------------------------------------ */
.qw-rulers > summary { cursor: pointer; list-style-position: inside; }
.qw-inline-h { display: inline; margin: 0; }
.qw-ruler-tools { display: flex; gap: 8px; margin: 8px 0; }
.qw-table-wrap { overflow: auto; max-height: 14rem; }
.qw-table.static thead th { cursor: default; }
.qw-narrow { max-width: 28rem; width: 100%; }

/* Glyphs are drawn with a background; make sure it prints. */
.qw-glyph, .qw-alert::before, .qw-callout::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Status pills carry a glyph; a pill is otherwise neutral. */
.qw-pill.status { display: inline-flex; align-items: center; gap: 6px; padding-left: 4px; }
.qw-pill.status .qw-glyph { width: 16px; height: 16px; font-size: 11px; vertical-align: 0; }

/* ---- Loading spinner and the busy overlay (a plot or a heavy table is building) -------------------------- */
.qw-spinner { display: inline-block; width: 22px; height: 22px; box-sizing: border-box; border-radius: 50%; border: 3px solid var(--outline-strong);
              border-top-color: var(--primary); animation: qw-spin .8s linear infinite; vertical-align: middle; }
@keyframes qw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .qw-spinner { animation-duration: 3s; } }
.qw-busy { position: relative; }
.qw-busy-overlay { position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
                   background: var(--surface); opacity: .88; color: var(--on-surface); }
.qw-busy-text { font-size: 13px; }

/* ---- Table: filter row under the headings, select all / clear all, units in the headings ------------------------ */
.qw-table-box { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.qw-table-tools { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; flex: none; }
.qw-table-scroll { overflow: auto; min-height: 0; flex: 1 1 auto; }
.qw-table .qw-filter-row th { top: var(--qw-head-h, 28px); cursor: default; font-weight: 400; padding: 3px 6px; background: var(--surface-container-low); z-index: 1;
                              border-bottom: 1px solid var(--outline-strong); }
.qw-table .qw-filter-row th::after { content: none; }
.qw-table .qw-filter-row .qw-input { width: 100%; min-width: 4.5rem; padding: 1px 4px; min-height: 22px; font-size: 12px; font-weight: 400; }
.qw-filter-range, .qw-daterange-pick.stack { display: flex; flex-direction: column; gap: 3px; }
.qw-table .qw-filter-row .qw-multi-btn { min-height: 22px; font-size: 12px; font-weight: 400; }
.qw-table th.qw-check, .qw-table td.qw-check { width: 1%; text-align: center; cursor: default; }
.qw-table th.qw-check::after { content: none; }
.qw-table td.qw-busy-cell, .qw-table tr.qw-row-busy td { background: var(--surface-hover); }

/* ---- Left menu page (GitHub-style), for settings with sub-sections ----------------------------------------------- */
.qw-menupage { display: flex; gap: 16px; min-height: 0; align-items: stretch; }
.qw-sidemenu { flex: none; width: 15rem; display: flex; flex-direction: column; gap: 2px; overflow: auto; padding-right: 4px; box-sizing: border-box; }
.qw-sidemenu-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--on-surface-variant); margin: 4px 8px 6px; }
.qw-sidemenu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: var(--radius-md);
                    color: var(--on-surface); text-decoration: none; font-size: 13.5px; position: relative; border: 0; background: transparent;
                    font-family: inherit; text-align: left; cursor: pointer; padding-left: 14px; }
.qw-sidemenu-item:hover { background: var(--surface-hover); }
.qw-sidemenu-item.current { font-weight: 700; background: var(--surface-container-low); }
.qw-sidemenu-item.current::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--primary); }
.qw-sidemenu-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.qw-sidemenu .qw-count { background: var(--primary); color: var(--on-primary); }
.qw-menupage-body { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; }
.qw-menupage-body > [hidden] { display: none; }
kbd, .qw-kbd { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; padding: 1px 6px; border: 1px solid var(--kbd-border);
          border-bottom-width: 2px; border-radius: var(--radius-md); background: var(--kbd-bg); color: var(--kbd-fg); }

/* ---- Resizable panes: a drag handle between two panels; the pane icon on the collapse button ------------------------ */
.qw-panes { gap: 0; }
.qw-panes > .qw-pane + .qw-pane { margin-left: 10px; }
.qw-panes > .qw-handle + .qw-pane { margin-left: 0; }
.qw-handle { flex: none; width: 10px; cursor: col-resize; position: relative; touch-action: none; }
.qw-handle::after { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: var(--outline); }
.qw-handle:hover::after, .qw-handle:focus-visible::after, .qw-handle.dragging::after { background: var(--primary); }
.qw-handle:focus-visible { outline: none; }
.qw-handle[hidden] { display: none; }
body.qw-resizing { cursor: col-resize; user-select: none; }
.qw-pane-sized { flex: 0 0 var(--qw-pane-w); width: var(--qw-pane-w); max-width: none; }
.qw-pane-sized.collapsed { flex: 0 0 34px; width: 34px; }
.qw-pane-icon { display: block; }
.qw-btn.icon .qw-pane-icon { margin: 1px 0; }

/* ---- Plots: reset button, fade controls, rulers summary ------------------------------------------------------------- */
.qw-plot-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 8px; font-size: 12px; color: var(--on-surface-variant); }
.qw-plot-tools label { display: inline-flex; align-items: center; gap: 6px; }
.qw-plot-tools input[type=range] { width: 8rem; accent-color: var(--primary); }
.qw-plot-tools input[type=number] { width: 4.5rem; }
.qw-ruler-times { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.qw-ruler-times b { font-weight: 600; }

/* ---- Color picker (the QW display-widgets interface: a value in, onChange out) --------------------------------------- */
.qw-colorpick { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.qw-colorpick input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--outline-strong); border-radius: var(--radius-md); background: transparent; cursor: pointer; }
.qw-colorpick .qw-swatch-open { height: 28px; }
.qw-swatches { position: fixed; z-index: 450; width: 15rem; padding: 8px; background: var(--surface-container); border: 1px solid var(--outline-strong);
               border-radius: var(--radius-md); box-shadow: 0 4px 14px var(--shadow); }
.qw-swatch-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--on-surface-variant); margin: 4px 0; }
.qw-swatch-row { display: flex; flex-wrap: wrap; gap: 4px; }
.qw-swatch-row .qw-swatch { width: 24px; height: 24px; font-size: 13px; font-weight: 800; line-height: 1; }
.qw-pane-filters:empty { display: none; }
.qw-menuroot { display: flex; flex-direction: column; min-height: 0; }
.qw-menuroot > .qw-menupage { flex: 1 1 auto; }
/* Each filter fills the cell under its own column (min over max), so it lines up with the heading and never widens the table past its data. */
.qw-table .qw-filter-row th { vertical-align: top; }
.qw-table .qw-filter-range .qw-input, .qw-table .qw-daterange-pick .qw-date-btn, .qw-table .qw-filter-row .qw-dropdown-btn { width: 100%; min-width: 4.2rem; }
.qw-table-box { max-width: 100%; }
.qw-table-box.fill { flex: 1 1 auto; height: 100%; }            /* fills its card; the scrollbars appear only when it runs out of room */
.qw-card.fill { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.qw-card.fill > .qw-table-box { flex: 1 1 auto; min-height: 0; }
.qw-table { width: 100%; }


/* ---- Alerts: info / success / error / warning bubbles (the callout markup is the same) ------------------------------------------------------ */
.qw-alert-text { min-width: 0; overflow-wrap: anywhere; }
.qw-alert-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.qw-alert-row > .qw-alert { flex: 1 1 0; min-width: 0; margin: 0; }          /* fills the space up to the button, wraps only when it runs out */
.qw-alert-row > :not(.qw-alert) { flex: none; margin-left: auto; }
/* The warning is a yellow TRIANGLE with a black "!" (the other three are circles). */
.qw-glyph.warn, .qw-alert.warn::before, .qw-callout.warn::before { border-radius: 0; clip-path: polygon(50% 4%, 100% 94%, 0 94%); padding-top: 5px; font-size: 11px; }

/* ---- Kit tooltips (replace the browser's title bubble; Plotly hover boxes are styled to match) ------------------------------------------------ */
.qw-tooltip { position: fixed; z-index: 600; max-width: min(22rem, 90vw); padding: 4px 8px; font-size: 12px; line-height: 1.35; pointer-events: none;
              white-space: pre-line; overflow-wrap: anywhere; background: var(--surface-container); color: var(--on-surface);
              border: 1px solid var(--outline-strong); border-radius: var(--radius-md); box-shadow: 0 2px 8px var(--shadow); }

/* ---- Dropdown (replaces <select>) and date picker ------------------------------------------------------------------------------------------- */
.qw-dropdown, .qw-datepick { position: relative; display: inline-block; }
.qw-dropdown.narrow { width: 14rem; }
.qw-dropdown-btn, .qw-date-btn { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 6px; text-align: left; cursor: pointer; }
.qw-dropdown-btn::after { content: "▾"; color: var(--on-surface-variant); }
.qw-date-btn.empty { color: var(--on-surface-variant); }
.qw-dropdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qw-dropdown-pop, .qw-calendar { position: fixed; z-index: 450; background: var(--surface-container); border: 1px solid var(--outline-strong);
                                 border-radius: var(--radius-md); box-shadow: 0 4px 14px var(--shadow); box-sizing: border-box; }
.qw-dropdown-pop[hidden], .qw-calendar[hidden] { display: none; }
.qw-dropdown-search { display: block; width: calc(100% - 12px); margin: 6px; }
.qw-dropdown-search[hidden] { display: none; }
.qw-dropdown-list { max-height: 14rem; overflow: auto; padding: 4px 0; }
.qw-dropdown-opt { padding: 4px 12px; cursor: pointer; white-space: nowrap; }
.qw-dropdown-opt:hover, .qw-dropdown-opt.active { background: var(--surface-hover); }
.qw-dropdown-opt.selected { background: var(--primary-container); color: var(--on-primary-container); }
.qw-dropdown-none { padding: 6px 12px; color: var(--on-surface-variant); }
.qw-calendar { width: 15.5rem; padding: 8px; }
.qw-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.qw-cal-title { font-weight: 600; }
.qw-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.qw-cal-dow { text-align: center; font-size: 11px; color: var(--on-surface-variant); padding: 2px 0; }
.qw-day { font: inherit; font-size: 12px; padding: 4px 0; cursor: pointer; background: transparent; color: var(--on-surface); border: 1px solid transparent; border-radius: var(--radius-md); }
.qw-day:hover:not(:disabled) { background: var(--surface-hover); }
.qw-day.out { color: var(--on-surface-variant); opacity: .6; }
.qw-day.today { border-color: var(--outline-strong); }
.qw-day.selected { background: var(--primary); color: var(--on-primary); opacity: 1; }
.qw-day:disabled { opacity: .3; cursor: default; }
.qw-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; }
.qw-cal-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.qw-daterange-pick { display: flex; gap: 8px; }
.qw-daterange-pick > .qw-datepick { flex: 1 1 0; min-width: 0; }
.qw-field > .qw-daterange-pick { align-items: stretch; }

/* ---- Multi-select: "Only this" beside each option ------------------------------------------------------------------------------------------- */
.qw-multi-text { flex: 1 1 auto; min-width: 0; }
.qw-only { font: inherit; font-size: 11px; padding: 0 6px; cursor: pointer; color: var(--primary); background: transparent; border: 0; opacity: 0; }
.qw-multi-opt:hover .qw-only, .qw-only:focus-visible { opacity: 1; }
.qw-only:hover { text-decoration: underline; }

/* ---- Content-width pages (v1.6): a page with no left side menu or panes sizes to its widest table or card and centers, like GitHub ------------- */
.qw-main:not(:has(> .qw-fill)):not(:has(.qw-panes)) { display: grid; grid-template-columns: minmax(min(100%, 22rem), max-content); justify-content: center; align-content: start; }
.qw-main:not(:has(> .qw-fill)):not(:has(.qw-panes)) > * { min-width: 0; }
.qw-main:not(:has(> .qw-fill)):not(:has(.qw-panes)) p, .qw-main:not(:has(> .qw-fill)):not(:has(.qw-panes)) .qw-help { max-width: 70ch; }   /* long prose must not widen the page */
/* Filter boxes are only as wide as what they hold. */
.qw-table .qw-filter-range .qw-input { width: 5.5rem; min-width: 0; max-width: 100%; }
.qw-table .qw-daterange-pick .qw-date-btn { width: 8.6rem; min-width: 0; max-width: 100%; }

/* ---- Pills with a named color set (v1.6): neutral, blue, green, amber, red, purple ------------------------------------------------------------ */
.qw-pill.blue   { background: var(--info-container); color: var(--on-info-container); border-color: var(--info); }
.qw-pill.green  { background: var(--ok-container); color: var(--on-ok-container); border-color: var(--ok); }
.qw-pill.amber  { background: var(--warn-container); color: var(--on-warn-container); border-color: var(--warn); }
.qw-pill.red    { background: var(--error-container); color: var(--on-error-container); border-color: var(--error); }
.qw-pill.purple { background: var(--ask-container); color: var(--on-ask-container); border-color: var(--glyph-ask); }
.qw-pill { white-space: nowrap; }
.qw-logo-none { margin: 0; }
.qw-clear-filters[hidden] { display: none; }
