/* ==========================================================================
   Robo2u Tools: app shell (app-shell.css?v=1)
   Load after tool.css. Turns a tool page into a focused web app: sticky
   toolbar, live KPI strip, tabbed views, editor and results panes, dense row
   editors and compact provenance chips. Light theme only.
   Heights come from app-shell.js, which writes --hdr (site header), --bar
   (sticky toolbar, 0 when it is static), --stat (KPI strip) and --tabbar
   (mobile bottom bar) on <html>. The values below are fallbacks.
   ========================================================================== */
:root {
  --hdr: 82px; --bar: 0px; --stat: 0px; --tabbar: 0px;
  --app-max: 1760px;
  --s0: 4px; --s1: 8px; --s2: 16px; --s3: 24px;
  --pane-bg: #fff; --pane-head: #f1f4f9; --pane-alt: #fbfcfe; --row-hover: #f6f8fc;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
}
@media (min-width: 761px) { :root { --bar: 57px; } }
@media (max-width: 760px) { :root { --tabbar: 57px; } }
:root { --app-top: calc(var(--hdr) + var(--bar) + var(--stat)); }
html.app-on { scroll-padding-top: calc(var(--hdr) + var(--bar) + var(--stat) + 8px); }

/* ---------- Workspace ---------- */
main.app {
  max-width: none; margin: 0; padding: 0 0 var(--s3);
  --gut: 24px;
  --inline: max(var(--gut), calc((100% - var(--app-max)) / 2));
}
@media (max-width: 760px) { main.app { --gut: 16px; } }
.app input[type=number], .app .kpi .v, .app table.data td, .app .num, .app .rowout b { font-variant-numeric: tabular-nums; }

/* ---------- Toolbar ---------- */
.app-bar {
  position: sticky; top: var(--hdr); z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2);
  min-height: 56px; padding: var(--s1) var(--inline);
  background: #fff; border-bottom: 1.5px solid var(--border);
}
.app-title { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.app-title h1 { margin: 0; font-size: 16px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; color: #0b1220; overflow-wrap: break-word; }
.app-title h1 .a { color: var(--accent); }
.app-lede { margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: #334155; overflow-wrap: break-word; }
.app-grow { flex: 1 1 0; min-width: 0; }
.app-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); min-width: 0; }
.app-actions .app-select, .app-bar select { padding: 6px 30px 6px 10px; font-size: 12.5px; font-weight: 600; min-height: 34px; border-radius: 8px; }
.app-bar .seg { padding: 2px; border-radius: 9px; }
.app-bar .seg button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.app-flash { font-size: 12px; font-weight: 700; color: var(--ok); }
.app-flash:empty { display: none; }

/* ---------- Tabs (top on desktop, bottom bar on phones) ---------- */
.app-tabs { display: inline-flex; align-items: center; gap: var(--s0); min-width: 0; }
.app-tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 12px; border-radius: 8px;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: #334155;
  background: transparent; border: 1.5px solid transparent; cursor: pointer; white-space: nowrap;
}
.app-tab:hover { color: #0b1220; background: #f1f5f9; }
.app-tab[aria-selected="true"] { color: var(--accent); background: #eff6ff; border-color: rgba(37,99,235,.45); }
.app-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-tab svg { width: 16px; height: 16px; flex: none; display: block; }
.app-tab .n { font-size: 10.5px; font-weight: 800; color: #475569; background: #eaeef4; border-radius: 999px; padding: 0 6px; }

/* ---------- KPI strip ---------- */
.app-status {
  position: sticky; top: calc(var(--hdr) + var(--bar)); z-index: 55;
  padding: var(--s1) var(--inline);
  background: #f6f8fb; border-bottom: 1.5px solid var(--border);
  box-shadow: 0 6px 12px -10px rgba(15,23,42,.25);
}
.app-status .kpis, .app-status .stats { display: flex; flex-wrap: wrap; gap: var(--s1); margin: 0; }
.app-status .kpi, .app-status .stat {
  flex: 1 1 160px; min-width: 0; max-width: 360px;
  display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 var(--s1);
  padding: 6px 12px; background: #fff; border: 1.5px solid var(--border); border-radius: 8px; box-shadow: none;
}
.app-status .kpi .k { grid-column: 1 / -1; font-size: 10px; letter-spacing: .08em; }
.app-status .kpi .v { font-size: 18px; margin: 0; line-height: 1.25; }
.app-status .kpi .u { font-size: 11px; }
.app-status .kpi .n { font-size: 10.5px; margin: 0; line-height: 1.35; align-self: center; }
.app-status .kpi .pill { justify-self: start; }
.app-status .kpi[data-status="bad"] { border-color: #dc2626; }
.app-status .kpi[data-status="warn"] { border-color: #d97706; }
.app-status .kpi[data-status="ok"] { border-color: #16a34a; }

/* ---------- Views ---------- */
.app-view { padding: var(--s2) var(--inline) 0; min-width: 0; }
.app-view[hidden] { display: none !important; }
.app-view > * + * { margin-top: var(--s2); }
.stack { display: grid; gap: var(--s2); min-width: 0; }
.stack > * { min-width: 0; }
.app-err { font-size: 12px; font-weight: 600; color: var(--bad); overflow-wrap: break-word; }
.app-err:empty { display: none; }

/* ---------- Panes ---------- */
.panes { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); align-items: start; }
.panes > * { min-width: 0; }
@media (min-width: 1024px) {
  .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .panes.edit-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .panes.res-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  /* Results stay in view while the editor scrolls. */
  .pane.stick {
    position: sticky; top: calc(var(--app-top) + var(--s2));
    max-height: calc(100dvh - var(--app-top) - var(--s3));
    display: flex; flex-direction: column;
  }
  .pane.stick > .pane-body { overflow: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
  .pane.stick .tablewrap { max-height: none; }
}
.pane {
  min-width: 0; background: var(--pane-bg);
  border: 1.5px solid var(--border); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.pane.alt { background: var(--pane-alt); }
.pane-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s0) var(--s1);
  min-height: 44px; padding: var(--s1) 12px;
  background: var(--pane-head); border-bottom: 1.5px solid var(--border);
  border-radius: 9px 9px 0 0;
}
.pane-head h2, .pane-head h3 { margin: 0; font-size: 12px; line-height: 1.3; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #0b1220; overflow-wrap: break-word; }
.pane-meta { font-size: 11.5px; color: #334155; overflow-wrap: break-word; min-width: 0; }
.pane-tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.pane-body { padding: 12px; min-width: 0; }
.pane-body.flush { padding: 0; }
.pane-body.flush > .tablewrap { border: 0; border-radius: 0 0 9px 9px; }
.pane-body > * + * { margin-top: 12px; }
.pane-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); padding: var(--s1) 12px; border-top: 1.5px solid var(--border); background: var(--pane-alt); border-radius: 0 0 9px 9px; }
.pane-sub { margin: var(--s2) 0 var(--s1); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #0b1220; }
.pane-body > .pane-sub:first-child { margin-top: 0; }
.pane-note { font-size: 11.5px; line-height: 1.5; color: #334155; overflow-wrap: break-word; margin: 0; }
.pane .gridf, .pane .subgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s1) 12px; }
.pane .field { margin-bottom: 0; gap: var(--s0); }

/* ---------- Dense row editor ----------
   Set the columns once on .rowlist with --cols. .rowhead and every .rowmain
   share it, so labels sit once at the top and values line up. */
.rowlist { --cols: minmax(0, 1fr); min-width: 0; container: rowlist / inline-size; }
.rowlist.roomy { container-name: rowroomy; }
.rowhead, .rowmain { display: grid; grid-template-columns: var(--cols); gap: var(--s1); align-items: center; }
.rowhead {
  padding: 6px 12px; background: #eef2f7; border-bottom: 1.5px solid var(--border-2);
  font-size: 10.5px; line-height: 1.25; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #0b1220;
}
.rowhead > * { min-width: 0; word-break: keep-all; overflow-wrap: normal; hyphens: none; }
.rowhead .r, .rowmain .r { text-align: right; }
.rowitem { position: relative; border-bottom: 1px solid #dde3eb; min-width: 0; }
.rowitem:last-child { border-bottom: 0; }
.rowitem:hover, .rowitem.open { background: var(--row-hover); }
.rowitem[data-status]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.rowitem[data-status="ok"]::before { background: #16a34a; }
.rowitem[data-status="warn"]::before { background: #d97706; }
.rowitem[data-status="bad"]::before { background: #dc2626; }
.rowmain { padding: 6px 12px; }
.rc { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s0); min-width: 0; }
.rc > :only-child, .rc > .rl + :last-child { grid-column: 1 / -1; }
.rc.ctl { display: flex; justify-content: flex-end; gap: var(--s0); }
.rc.subj { font-weight: 800; color: #0b1220; overflow-wrap: break-word; }
.rowidx { font-size: 12px; font-weight: 800; color: #0b1220; font-variant-numeric: tabular-nums; }
.rowlist input[type=number], .rowlist input[type=text], .rowlist select {
  width: 100%; min-width: 0; min-height: 32px; padding: 4px 8px;
  font-family: var(--mono); font-size: 13px; color: #0b1220; background: #fff;
  border: 1.5px solid var(--border-2); border-radius: 6px; outline: none;
}
.rowlist select { padding-right: 24px; }
.rowlist input:hover, .rowlist select:hover { border-color: var(--ink-line); }
.rowlist input:focus, .rowlist select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.22); }
.rowlist input.bad, .rowlist select.bad { border-color: #f87171; background: #fef2f2; }
.rowlist select:disabled { color: #475569; background: #f1f5f9; }
.rowlist .rv { font-size: 13px; font-weight: 700; color: #0b1220; overflow-wrap: break-word; }
/* Labels repeat per cell for phones and screen readers; the header row shows them on desktop. */
.rl { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #1e293b; overflow-wrap: break-word; }
.rowbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; padding: 0; border-radius: 6px;
  font-family: var(--mono); font-size: 15px; font-weight: 800; line-height: 1; color: #0b1220;
  background: #fff; border: 1.5px solid var(--border-2); cursor: pointer;
}
.rowbtn:hover { border-color: var(--ink-line); }
.rowbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rowbtn.del:hover { color: var(--bad); border-color: #f87171; }
.rowbtn svg { width: 14px; height: 14px; display: block; transition: transform .15s; }
.rowbtn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.rowbtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.rowout { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s0) 12px; padding: 0 12px 6px; font-size: 12px; line-height: 1.45; color: #1e293b; overflow-wrap: break-word; min-width: 0; }
.rowout:empty { display: none; }
.rowout b { color: #0b1220; }
.rowerr { padding: 0 12px 6px; font-size: 12px; font-weight: 600; color: var(--bad); overflow-wrap: break-word; }
.rowerr:empty { display: none; }
.rowmore { padding: var(--s1) 12px 12px; border-top: 1px dashed var(--border); background: #fff; }
.rowmore[hidden] { display: none; }
.rowfields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s1) 12px; align-items: end; }
.rowfields .field { margin-bottom: 0; gap: var(--s0); }
.rowfields .wide2 { grid-column: span 2; }
.rowempty { padding: var(--s2) 12px; font-size: 12.5px; color: #334155; }

/* ---------- Row or card, by list width ----------
   A .rowlist lays out as one line per item when it is at least 720px wide
   (960px for .rowlist.roomy) and as compact cards below that, so a narrow
   editor pane on a laptop gets cards too. */
@container rowlist (min-width: 720px) {
  .rowlist .rl { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap; }
}
@container rowroomy (min-width: 960px) {
  .rowlist .rl { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap; }
}
@container rowlist (max-width: 719.98px) {
  .rowhead { display: none; }
  .rowitem { margin: 0 var(--s1) var(--s1); border: 1.5px solid var(--border); border-radius: 10px; background: #fff; overflow: clip; }
  .rowitem:first-child, .rowhead + .rowitem { margin-top: var(--s1); }
  .rowitem:last-child { border-bottom: 1.5px solid var(--border); }
  .rowmain { position: relative; grid-template-columns: repeat(var(--mcols, 2), minmax(0, 1fr)); gap: var(--s1); padding: var(--s1) 10px; align-items: end; }
  .rowmain > .full, .rowmain > .subj { grid-column: 1 / -1; }
  .rc { row-gap: 2px; }
  .rc > .rl { grid-column: 1 / -1; }
  /* Row controls sit top right of the card, level with the first input. */
  .rowmain > .rc.ctl { position: absolute; top: calc(var(--s1) + 16px); right: 10px; }
  .rowmain:has(> .rc.ctl) > :first-child { padding-right: calc(var(--ctlw, 2) * 44px + 4px); }
  .rowmain .r { text-align: left; }
  .rowout, .rowerr { padding: 0 10px var(--s1); }
  .rowmore { padding: var(--s1) 10px 10px; }
  .rowfields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rowfields .wide2 { grid-column: 1 / -1; }
}
@container rowroomy (max-width: 959.98px) {
  .rowhead { display: none; }
  .rowitem { margin: 0 var(--s1) var(--s1); border: 1.5px solid var(--border); border-radius: 10px; background: #fff; overflow: clip; }
  .rowitem:first-child, .rowhead + .rowitem { margin-top: var(--s1); }
  .rowitem:last-child { border-bottom: 1.5px solid var(--border); }
  .rowmain { position: relative; grid-template-columns: repeat(var(--mcols, 2), minmax(0, 1fr)); gap: var(--s1); padding: var(--s1) 10px; align-items: end; }
  .rowmain > .full, .rowmain > .subj { grid-column: 1 / -1; }
  .rc { row-gap: 2px; }
  .rc > .rl { grid-column: 1 / -1; }
  /* Row controls sit top right of the card, level with the first input. */
  .rowmain > .rc.ctl { position: absolute; top: calc(var(--s1) + 16px); right: 10px; }
  .rowmain:has(> .rc.ctl) > :first-child { padding-right: calc(var(--ctlw, 2) * 44px + 4px); }
  .rowmain .r { text-align: left; }
  .rowout, .rowerr { padding: 0 10px var(--s1); }
  .rowmore { padding: var(--s1) 10px 10px; }
  .rowfields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rowfields .wide2 { grid-column: 1 / -1; }
}

/* ---------- Wrapping select (.pick) ----------
   A native select clips its chosen option to one line. .pick shows the full
   name as wrapping text and lays a transparent native select over it, so the
   picker stays native and the value is never cut. */
.pick {
  position: relative; display: flex; align-items: center; min-width: 0; width: 100%;
  min-height: 32px; padding: 4px 26px 4px 8px;
  font-size: 13px; line-height: 1.3; color: #0b1220;
  background: #fff; border: 1.5px solid var(--border-2); border-radius: 6px; cursor: pointer;
}
.pick::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px;
  border-right: 2px solid #334155; border-bottom: 2px solid #334155;
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.pick-text { min-width: 0; overflow-wrap: break-word; }
.pick > select, .rowlist .pick > select, .field .pick > select {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0;
  opacity: 0; cursor: pointer; font-size: 16px; border: 0; box-shadow: none;
}
.pick:hover { border-color: var(--ink-line); }
.pick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.22); }
.pick.bad, .pick:has(> select.bad) { border-color: #f87171; background: #fef2f2; }
.pick:has(> select:disabled) { color: #475569; background: #f1f5f9; cursor: default; }
.pick:has(> select:disabled)::after { display: none; }
.pick:has(> select:disabled) > select { cursor: default; }

/* ---------- Provenance chip ----------
   <button class="prov src" data-tip="..."> with a dot and a short label.
   .prov.dot shows the dot alone; the label stays in aria-label. */
.prov {
  position: relative; display: inline-flex; align-items: center; gap: 4px; flex: none;
  height: 18px; padding: 0 6px; margin: 0; border-radius: 999px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 800; letter-spacing: .04em; line-height: 1; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  color: #334155; background: #f1f5f9; border: 1.5px solid #a3afc2; cursor: pointer; vertical-align: 1px;
}
.prov::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.prov.src { color: #166534; background: #f0fdf4; border-color: #4ade80; }
.prov.asm { color: #92400e; background: #fffbeb; border-color: #f59e0b; }
.prov.ex  { color: #334155; background: #f1f5f9; border-color: #a3afc2; }
.prov.der { color: #1e40af; background: #eff6ff; border-color: #93c5fd; }
.prov:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.prov[aria-expanded="true"] { box-shadow: 0 0 0 2px rgba(37,99,235,.3); }
.prov.dot { width: 24px; height: 24px; padding: 0; justify-content: center; background: transparent; border: 0; }
.prov.dot::before { width: 9px; height: 9px; box-shadow: 0 0 0 1.5px #fff, 0 0 0 3px currentColor; }
.prov-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s0) 10px; font-size: 11px; color: #334155; }
.prov-legend .prov { cursor: default; }
.prov-pop {
  position: fixed; z-index: 200; max-width: min(360px, calc(100vw - 16px));
  padding: var(--s1) 10px; font-size: 12px; line-height: 1.5; color: #0b1220; overflow-wrap: break-word;
  background: #fff; border: 1.5px solid var(--border-2); border-radius: 8px;
  box-shadow: 0 10px 28px -12px rgba(15,23,42,.35);
}
.prov-pop[hidden] { display: none; }
.prov-pop q { display: block; quotes: none; font-style: italic; color: #334155; white-space: pre-line; }
.prov-pop a { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-weight: 700; text-decoration: none; }
.prov-pop a:hover { text-decoration: underline; }

/* ---------- Reference view ---------- */
.ref-toc { display: flex; flex-wrap: wrap; gap: var(--s1); }
.ref-toc button, .ref-toc a {
  display: inline-flex; align-items: center; min-height: 34px; padding: 4px 12px;
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: #0b1220; text-decoration: none;
  background: #fff; border: 1.5px solid var(--border-2); border-radius: 999px; cursor: pointer;
}
.ref-toc button:hover, .ref-toc a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Tablet: tabs stay on top, panes stack ---------- */
@media (max-width: 1023px) and (min-width: 761px) {
  .app-bar { gap: var(--s1) 12px; }
}
/* Tab icons are chrome; drop them where the toolbar would wrap. */
@media (max-width: 1279px) and (min-width: 761px) {
  .app-tab svg { display: none; }
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  /* The toolbar scrolls away; the KPI strip pins under the site nav. */
  .app-bar { position: static; padding: 12px var(--inline); gap: var(--s1); }
  .app-title { flex: 1 1 100%; }
  .app-title h1 { font-size: 17px; }
  .app-grow { display: none; }
  .app-actions { flex: 1 1 100%; }
  .app-actions > .app-select, .app-actions > select, .app-actions > .seg { flex: 1 1 100%; }
  .app-bar select, .app-actions .app-select { min-height: 40px; }
  .app-bar .seg button { min-height: 40px; }
  .btn.sm { min-height: 40px; }
  .app-actions .btn { flex: 1 1 0; }

  .app-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0;
    padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
    background: #fff; border-top: 1.5px solid var(--border-2);
    box-shadow: 0 -6px 16px -12px rgba(15,23,42,.3);
  }
  .app-tab {
    flex-direction: column; justify-content: center; gap: 2px;
    min-height: 56px; padding: 6px 4px; border: 0; border-radius: 0;
    font-size: 11px; white-space: normal; text-align: center; word-break: keep-all;
  }
  .app-tab svg { width: 20px; height: 20px; }
  .app-tab:hover { background: transparent; }
  .app-tab[aria-selected="true"] { background: #eff6ff; border: 0; }
  .app-tab[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .app-tab:focus-visible { outline-offset: -3px; }
  html.app-on body { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  html.app-on { scroll-padding-bottom: calc(var(--tabbar) + 8px); }

  .app-status { top: var(--hdr); padding: 6px var(--inline); }
  /* Every tile stays in view: a 2-column grid, the note wraps under the value. */
  .app-status .kpis, .app-status .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .app-status .kpi, .app-status .stat { min-width: 0; max-width: none; grid-template-columns: minmax(0, 1fr); padding: 4px 8px; }
  .app-status .kpi .k { font-size: 9.5px; }
  .app-status .kpi .v { font-size: 16px; }
  /* Pinned on a phone: label and value only. The notes repeat what the results pane shows. */
  .app-status .kpi .n { display: none; }
  .app-status .kpi .k { line-height: 1.25; }
  /* Five or six tiles: three columns, so the strip stays at two rows. */
  .app-status .kpis:has(> .kpi:nth-child(5)), .app-status .stats:has(> .stat:nth-child(5)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .app-view { padding-top: 12px; }
  .pane { border-radius: 10px; }
  .pane-head { min-height: 44px; }
  .pane-tools { margin-left: 0; width: 100%; }
  .pane-tools .btn { flex: 1 1 auto; }

  /* Rows: phone sizing. Layout (row or card) follows the list width below. */
  .rowlist input[type=number], .rowlist input[type=text], .rowlist select { min-height: 40px; font-size: 16px; }
  .rowbtn { width: 40px; height: 40px; }
  .pick { min-height: 40px; font-size: 15px; }
  .rowfields .field input, .rowfields .field select { min-height: 40px; font-size: 16px; }

  /* 40px tap area for chips without growing the row. */
  .prov.dot { width: 40px; height: 40px; }
  .prov:not(.dot)::after { content: ""; position: absolute; left: -6px; right: -6px; top: -12px; bottom: -12px; }
  .ref-toc button, .ref-toc a { min-height: 40px; }
  .prov-pop a { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) { .rowbtn svg { transition: none; } }
