/* ==========================================================================
   Responsive layer. Loads LAST, after style.css / social.css / v2.css / page CSS.
   It changes composition (layout, sizing, navigation), never the colour system or type.

   Device model (content-driven; the numbers are where the layout actually breaks):
     phone    <= 767px    bottom nav + compact header, cards instead of wide tables, sheets instead of dialogs
     tablet   768-960px   overlay drawer navigation, 2-column dashboards, tables scroll with a pinned first column
     laptop   961-1279px  icon rail (expandable), full tables
     desktop  >= 1280px   full sidebar, multi-column workspaces
     wide     >= 1600px   content is centred and capped so lines stay readable
   (style.css / v2.css keep the existing 960px drawer switch and 1100px dashboard collapse.)

   Sections: 1 tokens  2 shell  3 phone navigation  4 touch  5 forms  6 tables  7 dialogs and sheets
             8 pages  9 wide screens  10 motion, print
   ========================================================================== */

/* ---- 1. tokens ---------------------------------------------------------- */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --bn-h: 62px;                                   /* phone bottom navigation */
  --gut: clamp(14px, 2.6vw + 6px, 36px);          /* page side padding, fluid */
  --stack: clamp(14px, 1.4vw + 8px, 24px);        /* gap between page blocks */
  --tap: 44px;                                    /* minimum touch target */
}
html { scroll-padding-top: calc(var(--top-h) + 24px); }
body { overflow-x: clip; }                         /* a stray wide child can never produce a sideways page scroll */
img, video, svg, canvas { max-width: 100%; }
img { height: auto; }
main { overflow-wrap: anywhere; }
main :where(code, pre, .mono) { overflow-wrap: anywhere; }
pre, .log { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
h1 { font-size: clamp(26px, 1.6vw + 20px, 34px); overflow-wrap: anywhere; }
.page-head { gap: 12px var(--stack); }
.page-head > * { min-width: 0; }

/* pieces that only exist for narrower layouts */
.top-brand, .bottom-nav, .drawer-close, .menu-theme { display: none; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-row .brand { min-width: 0; }

/* ---- 2. shell ------------------------------------------------------------ */
.topbar { gap: 8px; }
.crumbs { flex: 1 1 auto; }
.top-actions { flex: none; }
.crumbs .cur { max-width: 100%; }

/* main column: let the grid cell shrink, keep the sticky header inside it */
.main-col { min-width: 0; }

/* tablet and below (the drawer): navigation floats over content */
@media (max-width: 960px) {
  :root { --gut: clamp(14px, 3vw, 28px); }
  nav.side { width: min(86vw, 320px); height: 100dvh; padding-top: calc(14px + var(--safe-t)); padding-bottom: calc(12px + var(--safe-b)); padding-left: calc(10px + var(--safe-l)); overscroll-behavior: contain; visibility: hidden; transition: transform .22s var(--ease), visibility 0s linear .22s; }
  html[data-drawer="open"] nav.side { visibility: visible; transition-delay: 0s; }
  .drawer-close { display: inline-grid; }
  .scrim { transition: opacity .2s; }
  html[data-drawer="open"] body { overflow: hidden; }
  .topbar { margin: calc(8px + var(--safe-t)) calc(var(--gut) - 2px) 0; top: calc(8px + var(--safe-t)); }
  main { padding: 18px var(--gut) 56px; }
  nav.side a.nav, nav.side .nav { min-height: var(--tap); }
}

/* ---- 3. phone navigation and header ---------------------------------------- */
@media (max-width: 767.98px) {
  :root { --top-h: 52px; --gut: 14px; }
  .tablet-only { display: none !important; }
  .top-brand { display: grid; flex: none; }
  .top-brand .mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--on-accent); background: var(--grad-accent, var(--accent)); }
  .top-brand:hover { text-decoration: none; }
  .topbar { margin: calc(6px + var(--safe-t)) 8px 0; top: calc(6px + var(--safe-t)); padding: 0 6px 0 8px; border-radius: 18px; gap: 8px;
    background: var(--surface); }
  /* only the current page title on a phone; the trail lives in the drawer */
  .crumbs > :not(.cur) { display: none; }
  .crumbs .cur { font-size: 16px; }
  .top-actions { gap: 2px; }
  .top-actions > [data-theme-toggle] { display: none; }
  .menu-theme { display: flex; }
  .search-btn { width: var(--tap); height: var(--tap); min-width: 0; padding: 0; justify-content: center; border: 0; background: none; border-radius: 12px; color: var(--muted); }
  .search-btn:hover { background: var(--accent-soft); }

  main { padding: 14px var(--gut) calc(var(--bn-h) + var(--safe-b) + 28px); }
  .claude { font-size: 12.5px; padding: 8px 12px; margin-bottom: 14px; border-radius: 14px; align-items: flex-start; }
  .claude .dot { margin-top: 5px; }

  .bottom-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 6px calc(6px + var(--safe-r)) calc(6px + var(--safe-b)) calc(6px + var(--safe-l)); gap: 2px;
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px -18px rgba(33, 27, 66, .35); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 50px; padding: 4px 2px;
    border: 0; border-radius: 14px; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0; line-height: 1.1;
    box-shadow: none; filter: none; transform: none; text-decoration: none; position: relative; -webkit-tap-highlight-color: transparent; }
  .bottom-nav a:hover, .bottom-nav button:hover { background: none; color: var(--text); filter: none; transform: none; box-shadow: none; }
  .bottom-nav a:active, .bottom-nav button:active { background: var(--sunken); transform: none; }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav .ico { width: 22px; height: 22px; }
  .bottom-nav .on { color: var(--accent-text); background: var(--accent-soft); }
  .bottom-nav .on .ico { stroke-width: 2.1; }
  #toasts { right: 12px; left: 12px; max-width: none; bottom: calc(var(--bn-h) + var(--safe-b) + 12px); }
  html[data-drawer="open"] .bottom-nav { visibility: hidden; }
}
@media (max-width: 359.98px) {
  .bottom-nav a, .bottom-nav button { font-size: 10.5px; }
  .crumbs .cur { font-size: 15px; }
}

/* ---- 4. touch: 44px targets, no hover-only affordances --------------------- */
@media (pointer: coarse) {
  button, .btn { min-height: var(--tap); }
  button.sm, .btn.sm { min-height: 40px; padding-inline: 14px; }
  .icon-btn { width: var(--tap); height: var(--tap); }
  .chip { min-height: 40px; display: inline-flex; align-items: center; }
  .tabs a, .tabs button { min-height: var(--tap); display: inline-flex; align-items: center; }
  .menu-panel a, .menu-panel button { min-height: var(--tap); }
  .mini-list a, .rank-item { min-height: var(--tap); }
  details.sec > summary { min-height: var(--tap); align-items: center; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { min-height: var(--tap); align-items: center; }
  .check-list label { min-height: 40px; align-items: center; }
  [data-tilt] { transform: none !important; }      /* tilt is a mouse effect */
  .agent-card:hover, .scard:hover, a.step:hover, .rank-item:hover { transform: none; }
  :where(.toast button) { min-width: var(--tap); min-height: var(--tap); }
  #palette li.item { min-height: var(--tap); }
}

/* ---- 5. forms ------------------------------------------------------------- */
@media (max-width: 767.98px) {
  /* 16px stops iOS zooming the page when an input is focused */
  input, select, textarea { font-size: 16px; min-height: var(--tap); width: 100%; max-width: 100%; }
  input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 0; }
  input[type="file"] { padding: 9px 10px; }
  textarea { min-height: 120px; }
  form.filters, .pbar, .pbar form { align-items: stretch; }
  form.filters > *, .pbar > * { flex: 1 1 100%; }
  form.filters label, .stack label, .form-grid label { font-size: 13px; }
  form.filters { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .row, .row2, .page-head .actions { gap: 8px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > button, .page-head .actions > form { flex: 1 1 140px; }
  .page-head .actions form button { width: 100%; justify-content: center; }
  .dlg-foot button, .dlg-foot .btn { flex: 1 1 0; justify-content: center; }
  .rte .ed { min-height: 160px; }
  dl.facts, .kv { gap: 2px 0; }
  dl.facts dd, .kv dd { margin-bottom: 8px; }
  .panel, .pcard { padding: 16px; }
  details.sec > summary { padding: 13px 14px; flex-wrap: wrap; }
  details.sec > .body { padding: 2px 14px 14px; }
  .item-edit { padding: 12px; }
  .empty { padding: 26px 16px; }
  pre.md { padding: 14px; }
}
/* validation: always visible text next to the field, never colour alone */
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--danger); }
.err, em.err { overflow-wrap: anywhere; }

/* ---- 6. tables ------------------------------------------------------------- */
/* responsive.js wraps every table.t in .tscroll and copies each header into its cells as data-label */
.tscroll { position: relative; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; border-radius: var(--radius-m); max-width: 100%; }
.tscroll > table.t { min-width: 100%; width: max-content; max-width: none; }
.tscroll:not(.stacked) > table.t { min-width: 640px; }
.tscroll table.t th:first-child, .tscroll table.t td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.tscroll table.t th:first-child { background: var(--surface-2); z-index: 2; }
.tscroll table.t tbody tr:hover td:first-child { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
/* edge fades tell people there is more to scroll to */
.tscroll::before, .tscroll::after { content: ""; position: sticky; top: 0; z-index: 3; display: block; width: 22px; height: 0; pointer-events: none; }
.t-fade { position: relative; }
.t-fade::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 28px; pointer-events: none; opacity: 0; transition: opacity .15s;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 14%, transparent)); border-radius: 0 var(--radius-m) var(--radius-m) 0; }
.t-fade.can-r::after { opacity: 1; }
.t-hint { display: none; font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.t-fade.can-r + .t-hint, .t-fade.can-l + .t-hint { display: block; }
.t th, .t td { overflow-wrap: anywhere; }
.t th { white-space: nowrap; overflow-wrap: normal; }
.t td code { overflow-wrap: anywhere; }
@media (min-width: 768px) { .t .hide-m { display: table-cell; } }  /* tablets have the room; only phones drop columns */

/* phones: a record per row, not a squeezed grid */
@media (max-width: 767.98px) {
  .tscroll.stacked { overflow: visible; border-radius: 0; }
  .tscroll.stacked > table.t { width: 100%; min-width: 0 !important; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; }
  table.t.stack { border: 0; background: none; box-shadow: none; border-radius: 0; overflow: visible; }
  table.t.stack thead { display: none; }  /* each cell carries its own label (td::before) */
  table.t.stack tbody { display: flex; flex-direction: column; gap: 10px; }
  table.t.stack tr { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--lift); padding: 12px 14px; }
  table.t.stack td { grid-template-columns: minmax(78px, 32%) minmax(0, 1fr); gap: 4px 12px; align-items: baseline; border: 0; font-size: 14px; text-align: left; }
  table.t.stack td + td { border-top: 1px dashed var(--line); }
  table.t.stack td::before { content: attr(data-label); font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
  table.t.stack td[data-label=""] { display: block; }
  table.t.stack td[data-label=""]::before { display: none; }
  table.t.stack td:first-child { font-size: 15px; }
  table.t.stack td.num { text-align: left; }
  table.t.stack .hide-m { display: grid; }
  table.t.stack td[data-label=""].hide-m { display: block; }
  table.t.stack tbody tr:hover td { background: none; }
  table.t.stack td form, table.t.stack td .row { display: flex; flex-wrap: wrap; gap: 8px; }
  table.t.stack td > .runway { width: auto; }
  table.t.stack td button, table.t.stack td .btn { flex: 1 1 auto; justify-content: center; }
  table.t.stack td input, table.t.stack td select { width: 100%; }
  .tscroll:not(.stacked) > table.t { min-width: 560px; }
}

/* generic card lists keep two lines of title readable */
.agent-grid, .sfeed, .pgrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
@media (max-width: 767.98px) { .agent-grid, .sfeed, .pgrid { grid-template-columns: 1fr; gap: 12px; } }

/* ---- 7. dialogs: centred on desktop, sheets on phones ------------------------ */
dialog { max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; }
@media (max-width: 767.98px) {
  dialog { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: var(--safe-b); max-height: calc(100dvh - var(--safe-t) - 12px); }
  dialog[open] { animation: sheet-up .22s var(--ease); }
  dialog::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 8px auto 0; }
  /* extensive content takes the whole screen */
  dialog.modal, dialog.drawer, dialog[data-full], #palette { margin: 0; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; padding-top: var(--safe-t); }
  dialog.modal::before, dialog.drawer::before, dialog[data-full]::before, #palette::before { display: none; }
  #palette ul { max-height: none; }
  #palette .pal-in { padding: 12px 14px; } #palette input { font-size: 16px; min-height: var(--tap); }
  #palette .pal-foot { display: none; }
  .dlg-body { padding: 18px 18px 6px; } .dlg-foot { padding: 12px 18px calc(14px + var(--safe-b)); position: sticky; bottom: 0; background: var(--surface); }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } }
/* tablets: drawers and modals keep a comfortable width */
@media (min-width: 768px) and (max-width: 960px) { dialog { max-width: min(620px, calc(100vw - 48px)); } }

/* ---- 8. page patterns -------------------------------------------------------- */
/* tabs scroll sideways with snap instead of wrapping or clipping */
.tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { scroll-snap-align: start; flex: none; }
@media (max-width: 767.98px) {
  .tabs { width: auto; margin: 10px calc(var(--gut) * -1) 16px; padding: 5px var(--gut); border-radius: 0; background: var(--sunken); }
  .tabs a, .tabs button { padding: 8px 16px; }
}

/* dashboard */
@media (max-width: 767.98px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px 14px 12px; border-radius: 18px; }
  .stat .lbl { font-size: 12.5px; gap: 6px; line-height: 1.25; }
  .stat .v { margin-top: 10px; } .num-xl { font-size: clamp(32px, 11vw, 40px); }
  .stat .foot { font-size: 12px; margin-top: 6px; }
  .hero { padding: 24px 20px; border-radius: 24px; min-height: 0; gap: 4px; margin-bottom: 14px; }
  .hero h1 { font-size: clamp(30px, 9vw, 38px); margin: 8px 0 10px; }
  .hero p { font-size: 15px; margin-bottom: 16px; }
  .hero .cta { gap: 10px; } .hero .cta > button, .hero .cta > .btn { flex: 1 1 140px; justify-content: center; }
  .scene { display: none; }                                        /* decorative 3D scene: costs GPU and screen height on a phone */
  .dash-cols { gap: 18px; } h2 { margin: 24px 0 10px; }
  .rank-item { padding: 12px; gap: 12px; border-radius: 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px 14px; } .kpi b { font-size: 26px; }
  .flow .step { min-width: 0; }
  .cvpage { padding: 20px 16px; }
}
@media (max-width: 359.98px) { .stat-grid { gap: 8px; } .stat { padding: 12px 11px; } .stat .lbl .ico { display: none; } .hero { padding: 20px 16px; } }
@media (min-width: 768px) and (max-width: 960px) { .scene { height: 210px; } .hero { padding: 32px 30px; } }

/* agent workflows: a left-to-right flow becomes a numbered vertical sequence on phones */
@media (max-width: 767.98px) {
  .flow { flex-direction: column; counter-reset: stp; position: relative; padding-left: 18px; }
  .flow::before { content: ""; position: absolute; left: 11px; top: 14px; bottom: 14px; width: 2px; background: var(--line-strong); }
  .flow .step { flex: none; width: 100%; margin: 0 0 10px; counter-increment: stp; position: relative; }
  .flow .step::before { content: counter(stp); position: absolute; left: -18px; top: 12px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
    font: 600 11px var(--mono); background: var(--accent); color: var(--on-accent); transform: translateX(-4px); box-shadow: 0 0 0 4px var(--bg); }
  .flow .arrow { display: none; }
  .timeline li { padding-left: 40px; } .timeline .tl-title { font-size: 14.5px; }
  .log { font-size: 12px; max-height: 240px; }
  .kv { grid-template-columns: 1fr; }
}
/* long agent / activity logs: scroll inside the box, never the page */
.log, pre.md { -webkit-overflow-scrolling: touch; }

/* the two-column page layout stacks, details panel moves under the main content */
@media (max-width: 960px) { .cols { gap: var(--stack); } .dash-cols { gap: var(--stack); } }

/* ---- 9. big screens ------------------------------------------------------------ */
@media (min-width: 1600px) {
  :root { --gut: 44px; }
  main { max-width: 1520px; }
  .topbar { max-width: 1520px; }
  .agent-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
@media (min-width: 961px) { main, .topbar { margin-inline: auto; } .topbar { width: calc(100% - 48px); } }
@media (min-width: 2200px) { html { font-size: 16px; } main { max-width: 1680px; } .topbar { max-width: 1680px; } }

/* ---- 10. motion and print ------------------------------------------------------ */
@media (max-width: 767.98px) {
  /* decoration that costs battery on phones */
  body::before { position: absolute; }
  nav.side, .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; }
  nav.side { background: var(--surface); }
  .agent-card, .scard, .flow .step, .rank-item { transition: none; }
}
.scard, .agent-card, .rank-item { content-visibility: auto; contain-intrinsic-size: auto 220px; }
@media (prefers-reduced-motion: reduce) {
  nav.side, .scrim, dialog[open], .menu.open .menu-panel { transition: none !important; animation: none !important; }
  .tscroll, html { scroll-behavior: auto; }
}
@media print { .bottom-nav, .drawer-close, .top-brand { display: none !important; } main { padding: 0 !important; } .tscroll { overflow: visible; } }

/* ---- 11. filter sheet (generated by responsive.js for GET filter forms below 961px) -------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.filter-bar[hidden] { display: none; }
.filter-open { position: relative; }
.filter-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.filter-restore { font-size: 13.5px; }
dialog.filter-sheet { padding: 0; width: min(440px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: var(--radius-l) 0 0 var(--radius-l); }
dialog.filter-sheet[open] { display: flex; flex-direction: column; animation: drawer-in .22s var(--ease); }
dialog.filter-sheet::before { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + var(--safe-t)) 8px 10px 18px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { margin: 0; font-size: 17px; }
dialog.filter-sheet form.filters { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: none; padding: 16px 18px; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 12px; overscroll-behavior: contain; }
dialog.filter-sheet form.filters > label, dialog.filter-sheet form.filters > * { width: 100%; flex: none; }
dialog.filter-sheet form.filters label { font-size: 13px; }
dialog.filter-sheet form.filters input, dialog.filter-sheet form.filters select { width: 100% !important; min-height: var(--tap); font-size: 16px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.sheet-foot > * { flex: 1 1 0; justify-content: center; }
@keyframes drawer-in { from { transform: translateX(28px); opacity: .5; } }
@media (max-width: 767.98px) {
  dialog.filter-sheet { width: 100%; margin: auto 0 0; height: auto; max-height: calc(100dvh - var(--safe-t) - 8px); border-radius: 22px 22px 0 0; }
  dialog.filter-sheet[open] { animation: sheet-up .22s var(--ease); }
  dialog.filter-sheet::before { display: block; }
  .sheet-head { padding-top: 6px; }
}
@media (min-width: 961px) { .filter-bar { display: none; } }
@media (pointer: fine) { .t-hint { display: none !important; } }

/* ---- 12. fixes from device review ----------------------------------------------------------------------------- */
/* v2's glowing button shadow must not leak onto icon-only controls */
.icon-btn, .search-btn { box-shadow: none; background-image: none; }
.icon-btn:hover { box-shadow: none; }
.topbar .icon-btn, .topbar .search-btn { background-color: transparent; }
.topbar .icon-btn:hover, .topbar .search-btn:hover { background-color: var(--accent-soft); }
@media (max-width: 767.98px) {
  .bottom-nav { padding-inline: calc(2px + var(--safe-l)) calc(2px + var(--safe-r)); }
  .bottom-nav a, .bottom-nav button { font-size: 10.5px; }
  .hero .cta > button, .hero .cta > .btn { flex: 1 1 100%; }
}
/* a shorter label where six tabs would otherwise be truncated */
@media (max-width: 389.98px) {
  .bottom-nav span.short { font-size: 0; }
  .bottom-nav span.short::after { content: attr(data-short); font-size: 10.5px; }
}

@media (max-width: 960px) {
  .search-btn { width: var(--tap); min-width: 0; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .scene { height: 180px; }
}

/* ---- 13. grid tracks must be allowed to shrink (a wide table or code line must scroll inside its box, not stretch the page) --- */
.cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.cols > *, .dash-cols > *, .side-stack > * { min-width: 0; }
@media (max-width: 960px) { .cols, .dash-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 767.98px) {
  table.t.stack td input, table.t.stack td select { width: 100% !important; }
  table.t.stack td .row, table.t.stack td form.row { align-items: center; }
}
.top-brand { width: var(--tap); height: var(--tap); place-items: center; }
@media (pointer: coarse) {
  .t td a, .mini-list a, .crumbs a { display: inline-block; padding-block: 10px; }
  .t td a.pill, .t td a:has(.pill) { padding-block: 4px; }
}
select { max-width: 100%; text-overflow: ellipsis; }
.row > select, .row2 > select { min-width: 0; flex: 1 1 180px; }
@media (max-width: 767.98px) {
  .tscroll.stacked { overflow-x: clip; }
  table.t.stack td label { width: auto; white-space: nowrap; }
  table.t.stack td input[type="number"] { width: auto !important; flex: 1 1 70px; }
}
/* stacked cells: label in a left gutter, any number of child nodes flow in the right (the classic robust pattern) */
@media (max-width: 767.98px) {
  table.t.stack td { display: block; position: relative; padding: 7px 0 7px calc(30% + 8px); min-height: 30px; }
  table.t.stack td::before { position: absolute; left: 0; top: 9px; width: 30%; padding: 0; overflow-wrap: normal; }
  table.t.stack td[data-label=""], table.t.stack td:first-child { padding-left: 0; }
  table.t.stack td:first-child::before { display: none; }
  table.t.stack td:first-child { padding-bottom: 9px; }
  table.t.stack td form, table.t.stack td .row { display: flex; }
}
@media (max-width: 767.98px) { .tscroll.stacked table.t th:first-child, .tscroll.stacked table.t td:first-child { position: static; box-shadow: none; background: none; } }

/* touch sizing for fields and the opportunity workspace controls (tablet included) */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]), select { min-height: var(--tap); }
  .seg a, .tb, .sel-box { min-width: var(--tap); min-height: var(--tap); display: inline-grid; place-items: center; }
  .oq-search input { min-height: var(--tap); }
}
@media (max-width: 767.98px) { .oc-grid { grid-template-columns: minmax(0, 1fr); } .oc { min-width: 0; } }

/* scroll hints: fade the scrolling edge with a mask (an overlay would scroll away with the content) */
.t-fade::after { display: none; }
.t-fade.can-r:not(.can-l) { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.t-fade.can-l:not(.can-r) { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 32px), transparent); }
.t-fade.can-l.can-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); }

@media (max-width: 767.98px) { table.t.stack .pill { white-space: normal; max-width: 100%; } }

/* top bar: breadcrumbs left, search centred, actions right */
.topbar > .crumbs, .topbar > .top-actions { flex: 1 1 0; min-width: 0; }
.topbar > .top-actions { justify-content: flex-end; margin-left: 0; }
.topbar > .search-btn { flex: 0 1 420px; width: 420px; max-width: 100%; justify-content: flex-start; }
@media (max-width: 720px) { .topbar > .search-btn { flex: none; width: var(--tap); } }

/* notifications popup */
.notif-panel { width: 360px; max-width: calc(100vw - 16px); padding: 0; overflow: hidden; }
.notif-h { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif-list { max-height: 60vh; overflow: auto; }
.notif-menu .notif-item { display: block; width: 100%; padding: 9px 14px; border-radius: 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-t { font-size: 13.5px; font-weight: 600; } .notif-b { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif-m { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.notif-empty { padding: 18px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.notif-menu a.notif-all { justify-content: center; border-radius: 0; padding: 10px; font-weight: 600; color: var(--accent-text); }
@media (max-width: 720px) { .notif-panel { position: fixed; left: 8px; right: 8px; top: 56px; width: auto; } }

/* search truly centred in the bar (independent of what is left/right of it) */
@media (min-width: 961px) {
  .topbar > .search-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); flex: none; width: min(420px, 34vw); margin: 0; }
  .topbar > .crumbs { max-width: calc(50% - min(210px, 17vw) - 80px); flex: 0 1 auto; }
  .topbar > .top-actions { margin-left: auto; flex: none; }
}
