/* components.css — Acquiro360 design system component layer (RFC §4, C2).
 *
 * Reads var(--*) from tokens.css only. NO raw colour or px literals here
 * (TestCSS_NoRawValues; allowed px outside tokens.css: 1/2/999, plus
 * 480/768/1024 inside @media conditions).
 *
 * Organised by layer (not by component) so the system scales:
 *   §1 Shell selectors    — .app, .topbar, .sidebar, .nav-item, .menu-btn,
 *                            .nav-backdrop, .theme-toggle, .eyebrow, .main…
 *                            (rules only; HTML wiring lands in C2.5)
 *   §2 Form controls       — .btn (+ variants), .select, .input
 *   §3 Status & tags       — .pill (+ variants), .tag, .delta, .delta-cell
 *   §4 Data display        — .table-card, .table-scroll, table.data,
 *                            .cell-*, .metric-strip, .table-foot, .pager,
 *                            .filterbar, .chip-count
 *   §5 Feedback            — .banner (+ severity), .toast, .empty
 *   §6 Containers          — .card, .segmented, .tabs
 *   §7 Responsive          — ONE @media block per breakpoint:
 *                              1024 — metric-strip 4→2 cols
 *                               768 — drawer + touch + filter-stack +
 *                                     card-collapse + .table--matrix +
 *                                     band-row exceptions
 *                               480 — metric-strip 2→1 + topbar trim
 */


/* ============================================================
 * §1 SHELL SELECTORS
 * Rules only — HTML wiring lands in C2.5 (base.html + nav.html).
 * ============================================================ */

.app  { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
.body { display: grid; grid-template-columns: var(--w-sidebar) 1fr; overflow: hidden; }
/* Anonymous routes (e.g. /, /auth/error) render no <aside class="sidebar">.
   Collapse the grid so the empty 248px column does not push content right. */
.body:not(:has(.sidebar)) { grid-template-columns: 1fr; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-4);
  height: var(--h-topbar); padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: var(--bw) solid var(--border);
}
.brand   { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-bold); letter-spacing: .04em; }
.spacer  { flex: 1; }
.eyebrow {
  font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-faint); font-family: var(--font-mono);
}

/* Topbar-anchored icon buttons. Touch sizing applied ≤768px in §7. */
.menu-btn,
.theme-toggle {
  display: none; place-items: center;
  padding: var(--sp-2); border-radius: var(--r-md);
  border: var(--bw) solid var(--border); background: var(--surface-2);
  color: var(--text-muted); cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.theme-toggle { display: grid; }   /* always visible */
.menu-btn:hover,
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"]  .theme-toggle .i-sun  { display: block; }
[data-theme="dark"]  .theme-toggle .i-moon { display: none; }
[data-theme="light"] .theme-toggle .i-sun  { display: none; }
[data-theme="light"] .theme-toggle .i-moon { display: block; }

.sidebar {
  border-right: var(--bw) solid var(--border);
  background: var(--surface);
  padding: var(--sp-4) var(--sp-3);
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); color: var(--text-muted);
  font-size: var(--fs-sm); position: relative; cursor: pointer;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.nav-item + .nav-item { margin-top: 2px; }
.nav-item:hover { color: var(--text); background: var(--surface-hover); }
.nav-item .dot {
  width: var(--dot); height: var(--dot);
  border-radius: var(--r-pill); background: currentColor; opacity: .45;
}
.nav-item.active { color: var(--text); background: var(--accent-dim); font-weight: var(--fw-medium); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0;
  top: var(--dot); bottom: var(--dot);
  width: var(--bar); border-radius: var(--r-pill); background: var(--accent);
}
.nav-item.active .dot { background: var(--accent); opacity: 1; }

/* Hidden by default; revealed ≤768px in §7. */
.nav-backdrop { display: none; }

.main { overflow-y: auto; padding: var(--sp-6) var(--sp-6) var(--sp-8); }
.wrap { margin: 0 auto; }

.page-head    { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.page-head h1 { margin-top: var(--sp-2); }
.page-head .sub   { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--sp-2); }
.page-head .sub b { color: var(--text); font-weight: var(--fw-medium); }
.head-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

.section     { margin-top: var(--sp-8); }
.section > .eyebrow { margin-bottom: var(--sp-3); }
.section-rule { height: var(--bw); background: var(--border); margin: var(--sp-8) 0 0; }

/* Section-heading spacing — base.css zeroes all heading margins so the
   reset is uniform. Restore top room only when a heading follows another
   sibling (i.e. a real section break, never the first heading of its
   container). */
.main * + h2 { margin-top: var(--sp-6); }
.main * + h3 { margin-top: var(--sp-6); }
.main * + h4 { margin-top: var(--sp-5); }
.main * + h5 { margin-top: var(--sp-4); }

/* Staggered entrance — one orchestrated load, not scattered micro-fluff.
   translateY in em so the gate stays clean and the motion auto-scales. */
@keyframes rise { from { opacity: 0; transform: translateY(.4em); } to { opacity: 1; transform: none; } }
.rise { animation: rise .42s var(--ease) both; }


/* ============================================================
 * §2 FORM CONTROLS
 * ============================================================ */

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  border: var(--bw) solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.btn:hover     { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active    { transform: translateY(1px); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary        { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: var(--fw-bold); }
.btn--primary:hover  { background: var(--accent); filter: brightness(1.06); }
.btn--ghost          { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover    { color: var(--text); background: var(--surface-hover); }
.btn--danger         { color: var(--negative); border-color: var(--border); }
.btn--danger:hover   { background: var(--negative-dim); border-color: var(--negative); }
.btn--icon           { padding: var(--sp-2); }

/* Inputs — base. .input width override below. */
.select,
.input {
  font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--text);
  background: var(--surface-2); border: var(--bw) solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3);
  appearance: none; cursor: pointer; min-width: var(--w-select);
}
.select:hover,
.input:hover { border-color: var(--border-strong); }
.input            { cursor: text; min-width: var(--w-input); }
.input::placeholder { color: var(--text-faint); }

/* Picker-bearing input types own a native indicator (calendar / clock /
   colour swatch) that `appearance: none` above would strip alongside the
   default chrome — leaving users no affordance to open the picker. Restore
   the platform UI for these types only; text inputs keep the flattened look
   needed for iOS Safari normalisation. */
.input[type="date"],
.input[type="datetime-local"],
.input[type="time"],
.input[type="month"],
.input[type="week"],
.input[type="color"] {
  appearance: auto;
  cursor: pointer;
}

/* Select caret art — em-based positioning so the chevron auto-scales with
   the select's own font-size; theme color preserved via var(--text-faint).
   This is the Rev 7 (c) drift: replaces preview's 5/9/14px magic numbers. */
.select {
  background-image:
    linear-gradient(45deg,  transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 1em) center, calc(100% - .65em) center;
  background-size: .35em .35em, .35em .35em;
  background-repeat: no-repeat;
  padding-right: var(--sp-6);
}

/* Form layout primitives — used by long-form pages to group fields into
   labelled sections that lay out two-up on wide viewports and collapse to a
   single column under ~720px via the auto-fit grid. */
.form-section { margin-top: var(--sp-6); }
.form-section + .form-section {
  border-top: var(--bw) solid var(--border);
  padding-top: var(--sp-6);
}
.form-section > .eyebrow { margin-bottom: var(--sp-3); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.form-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.form-field > .input,
.form-field > .select { width: 100%; min-width: 0; }

.field-help { color: var(--text-muted); font-size: var(--fs-sm); }


/* ============================================================
 * §3 STATUS & TAGS
 * ============================================================ */

.pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
  letter-spacing: .03em; text-transform: uppercase;
  padding: var(--sp-1) var(--sp-2); border-radius: var(--r-pill);
  border: var(--bw) solid var(--border); color: var(--text-muted);
  background: var(--surface-2);
}
.pill .led {
  width: var(--dot); height: var(--dot);
  border-radius: var(--r-pill); background: currentColor;
}
.pill--live          { color: var(--positive); border-color: var(--accent-line); }
.pill--live .led {
  background: var(--positive);
  box-shadow: 0 0 0 0 var(--positive);
  animation: ping 1.6s var(--ease) infinite;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0          var(--accent-glow); }
  70%  { box-shadow: 0 0 0 var(--dot) transparent; }
  100% { box-shadow: 0 0 0 0          transparent; }
}
.pill--running       { color: var(--info);     border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.pill--ok            { color: var(--positive); }
.pill--failed        { color: var(--negative); border-color: color-mix(in srgb, var(--negative) 45%, transparent); }
.pill--queued        { color: var(--warning); }

.tag {
  font-family: var(--font-mono); font-size: var(--fs-2xs);
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  border: var(--bw) solid var(--border); color: var(--text-muted); background: var(--surface-2);
}

.delta {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-2); border-radius: var(--r-pill);
}
.delta--up   { color: var(--positive);   background: var(--accent-dim); }
.delta--down { color: var(--negative);   background: var(--negative-dim); }
.delta--flat { color: var(--text-faint); background: var(--surface-2); }

.delta-cell {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.delta-cell.up   { color: var(--positive); }
.delta-cell.down { color: var(--negative); }
.delta-cell.flat { color: var(--text-faint); }


/* ============================================================
 * §4 DATA DISPLAY
 * ============================================================ */

.table-card {
  margin-top: var(--sp-4);
  border: var(--bw) solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; background: var(--surface);
}
.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data thead th {
  position: sticky; top: 0;
  text-align: left; font-weight: var(--fw-bold); font-size: var(--fs-2xs);
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-faint); background: var(--surface-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--bw) solid var(--border);
  white-space: nowrap;
}
table.data thead th.sortable       { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--text-muted); }
table.data thead th .sort          { color: var(--accent); margin-left: var(--sp-1); }

table.data td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--bw) solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
table.data tbody tr                                  { transition: background-color var(--dur) var(--ease); }
table.data tbody tr:hover                            { background: var(--surface-hover); }
table.data tbody tr:last-child td                    { border-bottom: 0; }
table.data tbody tr.is-selected                      { background: var(--accent-dim); }
table.data tbody tr.is-selected td:first-child       { box-shadow: inset var(--bar) 0 0 var(--accent); }
table.data tbody tr.is-attention td:first-child      { box-shadow: inset var(--bar) 0 0 var(--accent-line); }
table.data tbody tr.is-running                       { background: var(--accent-dim); }
table.data tbody tr.is-running td:first-child        { box-shadow: inset var(--bar) 0 0 var(--accent); }

.cell-num    { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.cell-strong { color: var(--text); font-weight: var(--fw-medium); }
.cell-muted  { color: var(--text-muted); }

table.data thead th.cell-num { text-align: right; }

/* Inline row-action group — keeps Edit / Toggle / Trigger / Force-clear
   buttons side-by-side with a token gap. inline-flex so the parent <td>
   stays a table-cell on desktop; the mobile collapse rule turns the td
   into a flex container, where this child reflows naturally. */
.row-actions {
  display: inline-flex; gap: var(--sp-2);
  flex-wrap: wrap; align-items: center;
}

/* Band row — a <tr> whose single <th colspan="N"> labels the group of data
   rows that follow (process status: prompt-universe name). Default browser
   styling centers and bolds the cell; this rule turns it into a readable
   left-aligned section header sitting on a soft surface tone. The mobile
   collapse rule in §7 layers its own band-card style on top. */
table.data tbody tr > th[colspan]:only-child {
  text-align: left; font-weight: var(--fw-bold);
  color: var(--text); background: var(--surface-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--bw) solid var(--border);
}

.table-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-top: var(--bw) solid var(--border);
  color: var(--text-muted); font-size: var(--fs-xs);
}
.pager           { display: flex; gap: var(--sp-1); }
.pager .pg       { padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm); cursor: pointer; font-family: var(--font-mono); }
.pager .pg:hover { background: var(--surface-hover); color: var(--text); }
.pager .pg.active { background: var(--accent-dim); color: var(--accent); }

/* Metric strip */
.metric-strip {
  margin-top: var(--sp-5);
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: var(--bw) solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden;
}
/* Narrow variant — pack the available width across the rendered metrics
   instead of reserving 4 fixed slots. Used when a strip carries fewer than
   four KPIs (e.g. weekly_report domain deep-dive: 2 metrics). */
.metric-strip--narrow { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.metric                    { padding: var(--sp-4) var(--sp-5); border-right: var(--bw) solid var(--border); }
.metric:last-child         { border-right: 0; }
.metric .label             { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-xs); }
.metric .val               { display: flex; align-items: baseline; gap: var(--sp-2); margin-top: var(--sp-2); }
.metric .val .n            { font-family: var(--font-mono); font-size: var(--fs-3xl); font-weight: var(--fw-medium); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .val .u            { color: var(--text-faint); font-size: var(--fs-md); }
.metric .foot              { margin-top: var(--sp-2); color: var(--text-faint); font-size: var(--fs-xs); }

/* Filter bar */
.filterbar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3); margin-top: var(--sp-4);
  border: var(--bw) solid var(--border); border-radius: var(--r-lg);
  background: var(--surface);
}
.filterbar .spacer { min-width: var(--sp-4); }
.chip-count        { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); padding: 0 var(--sp-2); }

/* Inline monospace block — operator log commands, copy-paste shell snippets. */
.code-block {
  background: var(--surface-2); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); margin: var(--sp-2) 0 0;
  overflow-x: auto; white-space: pre;
  font-size: var(--fs-xs);
}

/* Universe-configurations trigger card — section spacing + log list reset. */
.uc-trigger        { margin-bottom: var(--sp-4); }
.uc-trigger p      { margin: var(--sp-3) 0 var(--sp-1); }
.uc-log-list       { list-style: none; padding: 0; margin: var(--sp-2) 0 0; }
.uc-log-list > li  { margin-bottom: var(--sp-3); }


/* ============================================================
 * §5 FEEDBACK
 * ============================================================ */

.banner {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: var(--bw) solid var(--border); background: var(--surface-2);
  font-size: var(--fs-sm); margin-bottom: var(--sp-3);
}
.banner .ic { flex-shrink: 0; margin-top: 1px; }
.banner b   { font-weight: var(--fw-bold); }
.banner--ok        { border-color: var(--accent-line); background: var(--accent-dim); }
.banner--ok    .ic { color: var(--positive); }
.banner--info      { border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.banner--info  .ic { color: var(--info); }
.banner--warn      { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.banner--warn  .ic { color: var(--warning); }
.banner--error     { border-color: color-mix(in srgb, var(--negative) 45%, transparent); background: var(--negative-dim); }
.banner--error .ic { color: var(--negative); }

.toast {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--surface-2); border: var(--bw) solid var(--border-strong);
  box-shadow: var(--shadow-pop); font-size: var(--fs-sm);
}
.toast .led { width: var(--dot); height: var(--dot); border-radius: var(--r-pill); background: var(--positive); }

.empty {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  border: var(--bw) dashed var(--border-strong); border-radius: var(--r-lg);
}
.empty .glyph { font-size: var(--fs-2xl); color: var(--text-faint); }
.empty h3     { margin: var(--sp-3) 0 var(--sp-2); font-size: var(--fs-md); font-weight: var(--fw-bold); }
.empty p      { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }


/* ============================================================
 * §6 CONTAINERS
 * ============================================================ */

.card { border: var(--bw) solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: var(--sp-5); }

.charts-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.chart-card   { border: var(--bw) solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: var(--sp-5); }
.chart-head   { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
/* Chart.js with responsive:true + maintainAspectRatio:false sizes the canvas
   from its parent. The parent MUST be position:relative with explicit height,
   otherwise canvas and parent enter a resize feedback loop. */
.chart-canvas-wrap { position: relative; height: var(--h-chart-canvas); }

.segmented {
  display: inline-flex; padding: 2px;
  border: var(--bw) solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2);
}
.segmented button {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--text-muted); background: transparent; border: 0;
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-sm); cursor: pointer;
}
.segmented button.active { background: var(--accent-dim); color: var(--accent); }

.tabs { display: flex; gap: var(--sp-1); border-bottom: var(--bw) solid var(--border); }
.tab {
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-muted); font-size: var(--fs-sm); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: var(--fw-medium); }


/* ============================================================
 * §7 RESPONSIVE
 * Three canonical breakpoints. All overrides live here so the
 * "what changes at each width" picture is one screen.
 * ============================================================ */

/* ---------- 1024px : metric-strip 4→2 columns + charts-strip 2→1 ---------- */
@media (max-width: 1024px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(1),
  .metric:nth-child(2) { border-bottom: var(--bw) solid var(--border); }

  .charts-strip { grid-template-columns: 1fr; }
}

/* ---------- 768px : drawer + touch + filter-stack + card-collapse ---------- */
@media (max-width: 768px) {
  .menu-btn { display: grid; }

  /* Sidebar becomes off-canvas drawer. */
  .body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--h-topbar); bottom: 0; left: 0;
    width: var(--w-sidebar); z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
  }
  .app[data-nav="open"] .sidebar { transform: none; box-shadow: var(--shadow-pop); }

  .nav-backdrop {
    display: block; position: fixed;
    inset: var(--h-topbar) 0 0 0; z-index: 30;
    background: var(--overlay); opacity: 0; pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }
  .app[data-nav="open"] .nav-backdrop { opacity: 1; pointer-events: auto; }

  .main             { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .page-head        { flex-direction: column; align-items: flex-start; }
  .head-actions     { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }

  /* WCAG 2.5.5 touch targets — same Tier-2 remap mechanism as the
     deferred density axis, triggered by viewport instead of attribute. */
  .btn, .select, .input, .nav-item, .theme-toggle { min-height: var(--h-touch); }
  .nav-item { padding: var(--sp-3); }

  /* Filter bar stacks vertically. */
  .filterbar .select,
  .filterbar .input { flex: 1 1 100%; min-width: 0; }

  /* Form grid collapses to a single column. */
  .form-grid { grid-template-columns: minmax(0, 1fr); }

  /* --- Default card-collapse — opt out via .table--matrix --- */
  .table-card { border: 0; border-radius: 0; background: transparent; overflow: visible; }

  table.data:not(.table--matrix) thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  table.data:not(.table--matrix),
  table.data:not(.table--matrix) tbody,
  table.data:not(.table--matrix) tr,
  table.data:not(.table--matrix) td { display: block; width: 100%; }
  table.data:not(.table--matrix) tr {
    border: var(--bw) solid var(--border); border-radius: var(--r-md);
    margin: var(--sp-3) 0; background: var(--surface);
    overflow: hidden;
  }
  table.data:not(.table--matrix) tbody tr.is-selected                  { box-shadow: inset var(--bar) 0 0 var(--accent); }
  table.data:not(.table--matrix) tbody tr.is-selected td:first-child   { box-shadow: none; }
  table.data:not(.table--matrix) tbody tr.is-attention                 { box-shadow: inset var(--bar) 0 0 var(--accent-line); }
  table.data:not(.table--matrix) tbody tr.is-attention td:first-child  { box-shadow: none; }
  table.data:not(.table--matrix) tbody tr.is-running                   { box-shadow: inset var(--bar) 0 0 var(--accent); }
  table.data:not(.table--matrix) tbody tr.is-running td:first-child    { box-shadow: none; }
  table.data:not(.table--matrix) td {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-4); text-align: right;
    padding: var(--sp-2) var(--sp-5) var(--sp-2) var(--sp-4);
    border: 0; border-bottom: var(--bw) solid var(--border);
  }
  table.data:not(.table--matrix) tr td:last-child { border-bottom: 0; }
  table.data:not(.table--matrix) td::before {
    content: attr(data-label);
    color: var(--text-faint); font-family: var(--font-mono);
    font-size: var(--fs-2xs); letter-spacing: var(--track-label);
    text-transform: uppercase; text-align: left; flex-shrink: 0;
  }

  /* --- Band-row exception : <tr><th colspan="N">…</th></tr> stays a
     full-width band, not a labelled card. Detection mirrors
     TestTables_DataLabelCoverage.isBandRow (only :has() can express this
     without forcing a marker class on every band <tr>). --- */
  table.data:not(.table--matrix) tr:has(> th[colspan]:only-child) {
    display: block; width: 100%;
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-2);
    border: var(--bw) solid var(--border); border-radius: var(--r-md);
    margin: var(--sp-3) 0;
  }
  table.data:not(.table--matrix) tr:has(> th[colspan]:only-child) > th {
    display: block; text-align: left;
    padding: 0; border: 0;
    color: var(--text); font-weight: var(--fw-bold); font-size: var(--fs-sm);
    text-transform: none; letter-spacing: normal;
  }

  /* --- Matrix exception : keep table layout, horizontal scroll, sticky
     first column (Brand). RFC §4.7 single documented opt-out, scoped at
     mentions_history (C4). --- */
  .table-scroll:has(> table.data.table--matrix) { overflow-x: auto; }
  table.data.table--matrix th:first-child,
  table.data.table--matrix td:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
  }
  table.data.table--matrix thead th:first-child { background: var(--surface-2); }

  .table-foot { flex-direction: column; gap: var(--sp-3); align-items: flex-start; }
}

/* ---------- 480px : metric-strip 2→1 + topbar trim ---------- */
@media (max-width: 480px) {
  .metric-strip { grid-template-columns: 1fr; }
  .metric       { border-right: 0 !important; border-bottom: var(--bw) solid var(--border); }
  .metric-strip .metric:last-child { border-bottom: 0; }
  .topbar       { gap: var(--sp-2); padding: 0 var(--sp-3); }
}
