/* ─────────────────────────────────────────────────────────────────────────
   app.css — composite, app-level layout & data surfaces: the responsive app
   shell (sidebar ≥768px / menu-button drawer <768px), data tables (list +
   matrix modes), the ledger rows (Today, Requests, Customers), the filter bar,
   KPI tiles, the login card, and view/edit toggles.
   var(--token) only.
   ───────────────────────────────────────────────────────────────────────── */

/* ═══════════════ App shell ════════════════════════════════════════════════
   Mobile-first: one column under a slim top bar whose menu button opens the
   sidebar as a drawer (app.js toggles body.nav-open). At ≥768px the top bar
   drops out and the sidebar is a sticky left rail. Full-height uses 100dvh
   (100vh fallback first); content pads the iOS home-bar inset. */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }

.main {
  min-width: 0; width: 100%;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}

.mobile-topbar {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3); min-height: 52px;
  background: var(--bg-page); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.nav-toggle {
  position: relative; display: inline-grid; place-items: center;
  width: var(--control-min); height: var(--control-min); border-radius: var(--radius-sm);
  color: var(--text);
}
.nav-toggle:hover { background: var(--bg-sunken); text-decoration: none; }
.nav-toggle .nav-badge { position: absolute; top: 4px; right: 2px; }

/* The sidebar: hidden on phones until the menu opens it as a drawer. */
.sidebar {
  display: none; flex-direction: column;
  background: var(--color-primary); color: var(--color-on-primary);
  padding: var(--space-4) 0;
}
.nav-open .sidebar {
  display: flex; position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
  width: min(280px, 85vw); overflow-y: auto; box-shadow: var(--shadow-lg);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}
.nav-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(20, 25, 32, .45); }
.nav-backdrop[hidden] { display: none; }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-5) var(--space-5); font-weight: 700; font-size: var(--fs-lg); }
.sidebar-brand a { color: var(--color-on-primary); }
.sidebar-brand a:hover { text-decoration: none; opacity: .9; }
.sidebar-nav { display: flex; flex-direction: column; }
.nav-link {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--control-min); padding: var(--space-2) var(--space-5);
  color: rgba(255, 255, 255, .8); font-size: var(--fs-sm); font-weight: 500;
  border-left: 3px solid transparent; white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link .ico { width: 20px; height: 20px; flex: none; opacity: .85; }
.nav-link .nav-label { flex: 1 1 auto; min-width: 0; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: var(--color-on-primary); text-decoration: none; }
.nav-link:active { background: rgba(255, 255, 255, .12); }
.nav-link.active { background: rgba(255, 255, 255, .1); color: var(--color-on-primary); border-left-color: var(--color-accent); }
.nav-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-on-accent);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.sidebar-user { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding: var(--space-4) var(--space-5) var(--space-2); border-top: 1px solid rgba(255, 255, 255, .1); }
.sidebar-user-name { font-size: var(--fs-sm); font-weight: 600; color: var(--color-on-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-logout { font-size: var(--fs-xs); color: rgba(255, 255, 255, .65); }
.sidebar-user-name:hover, .sidebar-user-logout:hover { color: var(--color-on-primary); }
/* Sign out is a POST form (CSRF), its button set exactly like the link beside it. */
.sidebar-user-signout { display: contents; }
button.sidebar-user-logout { padding: 0; text-align: left; line-height: inherit; }

@media (min-width: 768px) {
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
  .mobile-topbar, .nav-backdrop { display: none; }
  .main { padding: var(--space-5); padding-bottom: var(--space-6); }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
  .nav-open .sidebar { position: sticky; width: auto; box-shadow: none; }
}

/* ═══════════════ Data tables ══════════════════════════════════════════════
   Two modes share .data-table (ported from farmbelt §10–11):
     • LIST tables (default): each <tr> is an independent record. Below 640px
       every row reflows into a labeled card (labels from data-label attrs).
     • MATRIX tables (.data-table--matrix): schedules/financial grids where
       rows × columns are one structure — these keep the grid, scroll
       horizontally inside .table-scroll, and pin a sticky first column.
   Only the .col-primary cell wraps; identifiers, numbers, dates, badges and
   .col-actions stay on one line. */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable; scrollbar-width: thin;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-raised);
}
.table-scroll::-webkit-scrollbar { height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: var(--bg-sunken); border-radius: 5px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }

.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-table); }
.data-table thead th {
  padding: var(--space-2) var(--space-2); text-align: left;
  font-weight: 600; font-size: var(--fs-table-head); text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-soft); border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.data-table td { padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-sunken) 60%, transparent); }   /* zebra */
.data-table tbody tr:hover { background: var(--bg-sunken); cursor: pointer; }
.data-table tbody tr:nth-child(even):hover { background: var(--bg-sunken); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num, .data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Only .col-primary wraps; everything else holds one line. */
.data-table th:not(.col-primary):not(.col-actions),
.data-table td:not(.col-primary):not(.col-actions) { white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }

/* Sortable headers — click to sort; the [aria-sort] arrow is the state. */
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable[aria-sort="ascending"]::after  { content: " ↑"; color: var(--color-primary); }
.data-table th.sortable[aria-sort="descending"]::after { content: " ↓"; color: var(--color-primary); }

/* Whole-row click target (stretched-link): the .table-link inside .col-primary
   overlays the entire <tr>; other interactive cells sit above via z-index. */
.data-table tbody tr { position: relative; }
.data-table tbody .col-primary .table-link { position: relative; z-index: 2; font-weight: 600; color: var(--text); }
.data-table tbody .col-primary .table-link::before { content: ""; position: absolute; inset: 0; z-index: 1; }
.data-table tbody td a:not(.table-link),
.data-table tbody td button,
.data-table tbody td input,
.data-table tbody td select,
.data-table tbody td form,
.data-table tbody td.col-actions { position: relative; z-index: 2; }
.data-table tbody tr:focus-within { background: var(--bg-sunken); outline: 2px solid var(--color-accent); outline-offset: -2px; }

/* The headline column absorbs slack, then truncates rather than forcing the
   table wider than the viewport (auto-layout truncation idiom). */
@media (min-width: 641px) {
  .data-table .col-primary { width: 100%; max-width: 0; }
  .data-table td.col-primary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ── Matrix mode: sticky first column while scrolling across columns ────────*/
.data-table--matrix th:first-child,
.data-table--matrix td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--bg-raised);
  box-shadow: 8px 0 8px -8px rgba(15, 23, 42, .1);
}
.data-table--matrix thead th:first-child { z-index: 2; background: var(--bg-sunken); }

/* ── List mode → cards on phones (matrix tables opt out) ───────────────────*/
@media (max-width: 640px) {
  .data-table:not(.data-table--matrix) { border: 0; background: transparent; }
  .data-table:not(.data-table--matrix) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .data-table:not(.data-table--matrix) tbody tr {
    display: grid; grid-template-columns: 1fr; gap: var(--space-1);
    margin-bottom: var(--space-3); padding: var(--space-3) var(--space-4);
    background: var(--bg-raised); border: 1px solid var(--border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  }
  .data-table:not(.data-table--matrix) tbody tr:nth-child(even),
  .data-table:not(.data-table--matrix) tbody tr:hover { background: var(--bg-raised); }
  .data-table:not(.data-table--matrix) tbody td {
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3);
    border: 0; padding: 1px 0; text-align: right; min-width: 0;
    font-size: var(--fs-sm); color: var(--text-soft); white-space: normal;
  }
  .data-table:not(.data-table--matrix) tbody td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); opacity: .8;
  }
  /* headline cell = card title */
  .data-table:not(.data-table--matrix) tbody td.col-primary,
  .data-table:not(.data-table--matrix) tbody td:first-child {
    display: block; text-align: left; font-size: var(--fs-md); font-weight: 600; color: var(--text);
    padding: 0 0 var(--space-2); margin-bottom: var(--space-2); border-bottom: 1px solid var(--border);
  }
  .data-table:not(.data-table--matrix) tbody td.col-primary::before,
  .data-table:not(.data-table--matrix) tbody td:first-child::before { content: none; }
  /* actions cell = card footer */
  .data-table:not(.data-table--matrix) tbody td.col-actions {
    display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap;
    padding: var(--space-3) 0 0; margin-top: var(--space-2); border-top: 1px solid var(--border);
  }
  .data-table:not(.data-table--matrix) tbody td.col-actions::before { content: none; }
  .data-table:not(.data-table--matrix) tbody td:empty { display: none; }
}

/* ═══════════════ Filter bar (search + selects + count, ONE live row) ══════*/
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.filter-bar .search {
  flex: 1 1 200px; display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-3); min-height: var(--control-compact);
  background: var(--bg-page); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.filter-bar .search .ico { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.filter-bar .search input { border: none; min-height: auto; padding: 0; background: none; }
.filter-bar .search input:focus { outline: none; }
.filter-bar select, .filter-bar input[type="search"] { width: auto; min-width: 150px; flex: 0 0 auto; min-height: var(--control-compact); }
.filter-count { margin: 0; align-self: center; white-space: nowrap; color: var(--text-soft); font-size: var(--fs-sm); }
@media (max-width: 560px) { .filter-bar .search { flex-basis: 100%; } .filter-bar select { flex: 1 1 auto; } }

/* Overflow → modal (JS toggles .filters-collapsed / .filters-open on the shell; see
   initFilterbars in app.js). Inline while the row fits; a "Filters" button + centered
   modal when a control would wrap. */
.filterbar-shell { position: relative; margin-bottom: var(--space-4); }
.filterbar-shell > .filter-bar { margin-bottom: 0; }
.filter-trigger, .filter-foot, .filter-backdrop { display: none; }
.filter-badge {
  display: inline-flex; min-width: 1.25rem; justify-content: center;
  padding: 0 .35rem; border-radius: var(--radius-pill);
  background: var(--color-primary); color: var(--color-on-primary);
  font-size: var(--fs-xs); line-height: 1.4;
}
.filters-collapsed > .filter-bar { display: none; }
.filters-collapsed .filter-trigger { display: inline-flex; }
.filters-collapsed.filters-open .filter-backdrop {
  display: block; position: fixed; inset: 0; z-index: 60; background: rgba(20, 25, 32, .45);
}
.filters-collapsed.filters-open .filter-bar {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--space-3);
  position: fixed; inset: 0; margin: auto; z-index: 61;
  width: min(420px, calc(100vw - 2 * var(--space-4))); max-height: 86vh; overflow-y: auto;
  background: var(--bg-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--space-5);
}
.filters-collapsed.filters-open .filter-bar .search,
.filters-collapsed.filters-open .filter-bar select { width: 100%; min-width: 0; flex: none; }
.filters-collapsed.filters-open .filter-count { display: none; }
.filters-collapsed.filters-open .filter-foot {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding-top: var(--space-3); border-top: 1px solid var(--border);
}

/* ═══════════════ KPI tiles ════════════════════════════════════════════════
   Container-query ready: the grid establishes a query container, and the card
   restacks itself when ITS OWN width drops below 260px (not the viewport's). */
.kpi-grid {
  display: grid; gap: var(--space-4); margin-bottom: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  container-type: inline-size;
}
.kpi-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
a.kpi-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi-label { order: 1; font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); line-height: 1.25; }
.kpi-value { order: 2; font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-card--warn   .kpi-value { color: var(--st-warning-fg); }
.kpi-card--danger .kpi-value { color: var(--st-danger-fg); }
@container (max-width: 260px) {
  .kpi-card { padding: var(--space-3) var(--space-4); }
  .kpi-value { font-size: var(--fs-xl); }
}

/* ═══════════════ View ⇄ Edit toggle ═══════════════════════════════════════
   Detail pages ship both the read view and the edit form; JS flips which is
   shown by toggling .is-hidden on the paired .js-view / .js-edit blocks AND
   body.is-editing. Edit controls keep their own display (inline buttons stay
   inline) - a blanket display:block here is what kept them from ever showing. */
body:not(.is-editing) .js-edit { display: none; }
.is-editing .js-view { display: none; }

/* ═══════════════ Login (the one bespoke branded surface) ══════════════════*/
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-4); background: var(--color-primary); }
.login-card {
  width: 100%; max-width: 380px;
  padding: var(--space-6);
  background: var(--bg-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.login-card h1 { text-align: center; font-size: var(--fs-xl); margin-bottom: var(--space-5); }
.login-card .form-group:last-of-type { margin-bottom: var(--space-4); }
.login-card .btn { width: 100%; }
.demo-creds { margin-top: var(--space-4); padding: var(--space-3); background: var(--bg-sunken); border-radius: var(--radius-sm); font-size: var(--fs-xs); color: var(--text-soft); text-align: center; }

/* ═══════════════ No-JS flash notice ═══════════════════════════════════════*/
.flash-noscript {
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  background: var(--st-warning-bg); color: var(--st-warning-fg);
  border: 1px solid color-mix(in srgb, var(--st-warning-fg) 30%, transparent);
  border-radius: var(--radius-sm); font-size: var(--fs-sm);
}

/* ═══════════════ Shell internals (added for templates/layout.php) ═════════*/
/* Mobile topbar brand (shown <768px). */
.mobile-topbar-brand { font-weight: 700; font-size: var(--fs-lg); color: var(--text); letter-spacing: -.01em; }
.mobile-topbar-brand:hover { text-decoration: none; }

/* Header row inside .main that holds the global .app-search. */
.main-header { margin-bottom: var(--space-4); }

/* Page header (pageHeader() helper) — list/dashboard title block. Title (+ optional
   subtitle) sits left; the primary CTA is pinned top-right; margin below separates it
   from the content (KPIs, tabs, tables). Without this the ported classes are unstyled
   and everything stacks left and touches. */
.admin-content-header { margin-bottom: var(--space-5); }
.admin-content-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3) var(--space-4); flex-wrap: wrap;
}
.admin-content-header h1 { font-size: var(--fs-h1); line-height: 1.15; }
.admin-content-header p { margin-top: var(--space-1); color: var(--text-muted); font-size: var(--fs-sm); }
.admin-content-header .btn { flex: none; }
/* Right-side action cluster in a page header (e.g. tabbed Settings: Edit/Cancel/Save). */
.admin-content-header-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }

/* Right-aligned tabular-number table cell. */
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ═══════════════ Login brand + demo block (login.php) ═════════════════════*/
main.login-card { margin: var(--space-7) auto; }   /* center when used as the page's <main> */
.login-brand { text-align: center; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; letter-spacing: .02em; color: var(--text); margin-bottom: var(--space-5); }
.login-demo { margin-top: var(--space-4); padding: var(--space-3); background: var(--bg-sunken); border-radius: var(--radius-sm); font-size: var(--fs-xs); color: var(--text-soft); text-align: center; }

/* Demo credentials on the login card - staging only (guarded by IS_PRODUCTION). */
.login-creds { text-align: left; }
.login-creds-title { font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); margin-bottom: var(--space-2); }
.login-creds p { margin: 0 0 var(--space-1); }
.login-creds p span { display: inline-block; font-family: var(--font-mono); color: var(--text); }
.login-creds p span + span { margin-left: var(--space-2); color: var(--text-soft); }
.login-creds-sub { color: var(--text-muted); }

/* ── Simpler detail pages (2026-10-06) ───────────────────────────────────────
   Inside a record's tabs, sections are flat: a small title over a rule, no box
   around them (they were cards inside the page card). Fields sit in a grid of
   label-over-value cells instead of one per full-width row; long free text
   (.is-wide) spans the row. One rule for every detail page. */
.tab-panel > .card { background: transparent; border: 0; box-shadow: none; border-radius: 0; }
.tab-panel > .card + .card { margin-top: var(--space-6); }
.tab-panel > .card > .card-header {
  padding: 0 0 var(--space-2); border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
}
.tab-panel > .card > .card-body { padding: var(--space-4) 0 0; }
.tab-panel[data-tab-panel="job"] > .card > .card-body,
.tab-panel[data-tab-panel="job"] > .card > .card-body > form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4) var(--space-6); align-items: start;
}
.tab-panel[data-tab-panel="job"] > .card > .card-body > * + * { margin-top: 0; }
.tab-panel[data-tab-panel="job"] > .card > .card-body > form { grid-column: 1 / -1; }
.tab-panel .form-group { margin: 0; min-width: 0; }
.tab-panel .form-group .form-label { display: block; margin-bottom: 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.tab-panel .form-group > div { overflow-wrap: anywhere; }
.tab-panel .form-group.is-wide, .tab-panel[data-tab-panel="job"] .card-body > form:not(#job-form) { grid-column: 1 / -1; }

/* Dashboard: the table sits on the page. */
.dash-recent { margin-top: var(--space-5); }

/* One-row detail header: record name + its reference, actions right. */
.page-action-bar-title { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
.page-action-bar-title h1 { margin: 0; font-size: var(--fs-h2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-action-bar-title .mono { font-size: var(--fs-sm); white-space: nowrap; }
/* ═══════════════ Products (admin_products.php / admin_product.php) ══════════*/
/* The photo preview: same 4:3 crop the public /print page applies, so what the
   shop sees here is what a customer sees there. */
.product-photo { margin: 0 0 var(--space-4); max-width: 420px; }
.product-photo img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--bg-sunken); }
/* A service mark at a fixed height - the width follows the product's own shape. */
.product-mark { display: inline-flex; vertical-align: middle; }
.product-mark svg { height: 28px; width: auto; }
.product-photo-upload { margin-bottom: var(--space-2); }
.product-photo-upload .form-label { margin: 0; }
.product-photo-upload input[type="file"] { min-width: 0; flex: 1 1 220px; }
/* Sort-order inputs hold a few digits, never a full-width field. */
.input-order { width: 6.5rem; max-width: 100%; text-align: right; }

/* ═══════════════ Ledger lists (Today, Requests, Customers) ═════════════════
   Ported from the ameliasbyeat admin: a pill search, date presets, status pills
   with counts, uppercase day headings with a count, and rows on one grid with
   thin rules. The whole row opens the record (app.js clicks its [data-lg-open]);
   a customer's name inside a row is its own link to the customer. */
.lg-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); flex-wrap: wrap; margin: 0 0 var(--space-3); }
.lg-find {
  flex: 1 1 260px; display: flex; align-items: center; gap: var(--space-2);
  max-width: 460px; min-height: var(--control-compact); margin: 0; padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--bg-page); color: var(--text-muted);
}
.lg-find input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: var(--fs-md); color: var(--text); min-height: 0; padding: 0; }
.lg-find:focus-within { border-color: var(--color-accent); }
.lg-tools { display: flex; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; }
.lg-presets, .lg-pills { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.lg-presets::-webkit-scrollbar, .lg-pills::-webkit-scrollbar { display: none; }
.lg-pills { gap: var(--space-1); margin: 0 0 var(--space-2); padding-bottom: 2px; }
.lg-preset {
  display: inline-flex; align-items: center; gap: var(--space-1); flex: none;
  min-height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); color: var(--text-soft); white-space: nowrap; text-decoration: none;
}
.lg-preset:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.lg-preset.is-on { background: var(--color-primary); color: var(--color-on-primary); }
.lg-preset.is-on .lg-count { background: rgba(255, 255, 255, .2); color: var(--color-on-primary); }
.lg-count {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--slate-100); color: var(--text-soft);
  font-size: var(--fs-xs); line-height: 18px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums;
}
.lg-dim { color: var(--text-muted); font-size: var(--fs-sm); }
.lg-empty { padding: var(--space-5) var(--space-1); color: var(--text-soft); }

.lg-section {
  display: flex; align-items: baseline; gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-1); font-family: inherit; line-height: 1.4;
  font-size: var(--fs-table-head); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
}
.lg-section:first-child { margin-top: var(--space-1); }
.lg-section .lg-count { letter-spacing: 0; }
.lg-section a { color: inherit; }

.lg-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.lg-row {
  position: relative; display: grid; align-items: center; gap: var(--space-1) var(--space-4);
  min-height: 52px; padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border); background: var(--bg-page);
}
.lg-row.is-link { cursor: pointer; }
.lg-row.is-link:hover { background: var(--bg-sunken); }
.lg-row:focus-within { background: var(--bg-sunken); }
/* New in the last 24 hours and still waiting: a bar down the left edge. */
.lg-row.is-new { box-shadow: inset 3px 0 0 var(--color-accent); padding-left: var(--space-4); }
.lg-name, .lg-cell { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); color: var(--text); }
.lg-name__text { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
a.lg-cust { align-self: flex-start; font-weight: 600; color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a.lg-cust:hover { text-decoration-color: currentColor; }
.lg-open { color: inherit; text-decoration: none; min-width: 0; }
.lg-open:hover { text-decoration: none; }
.lg-open.lg-dim { color: var(--text-soft); overflow-wrap: anywhere; }
.lg-row.is-link:hover .lg-open .lg-name__text { text-decoration: underline; text-underline-offset: 3px; }
.lg-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: var(--fs-sm); }
.lg-tag { display: inline-block; margin-left: var(--space-2); padding: 0 7px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 500; color: var(--text-soft); white-space: nowrap; vertical-align: 1px; }
.lg-warn { color: var(--st-danger-fg); font-weight: 600; }
.lg-cell.lg-num { align-items: flex-end; }
.lg-head .lg-num { font-size: inherit; }
.page-action-bar-actions { flex-wrap: wrap; justify-content: flex-end; }
.page-action-bar-actions form { margin: 0; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }

/* One status per row: a dot and the word. */
.lg-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text); white-space: nowrap; }
.lg-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.lg-state--new::before       { background: var(--color-accent); }
.lg-state--reviewing::before,
.lg-state--quoted::before    { background: var(--st-warning-fg); }
.lg-state--approved::before,
.lg-state--in_production::before { background: var(--st-info-fg); }
.lg-state--ready::before     { background: var(--st-success-fg); }
.lg-state--completed         { color: var(--text-soft); }
.lg-state--waiting::before  { background: transparent; box-shadow: inset 0 0 0 2px var(--st-warning-fg); }
.lg-state--cancelled         { color: var(--text-muted); }
.lg-state--cancelled::before { background: var(--border-strong); }

/* Column headers for a sortable ledger (Customers). */
.lg-head { display: grid; gap: var(--space-4); padding: 0 var(--space-2) var(--space-1); font-size: var(--fs-table-head); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.lg-head a { color: inherit; white-space: nowrap; }
.lg-head a.is-on { color: var(--text); }
.lg-head a.is-on[data-dir="asc"]::after  { content: " ↑"; }
.lg-head a.is-on[data-dir="desc"]::after { content: " ↓"; }

/* Row shapes, sized to the LIST's width (a container query), not the viewport's:
   the same request row runs full width on Requests and in a half column on a
   customer's page. Narrow: the name on top, the status beside it, the rest
   dropped. A sortable head sits with its list inside .lg-table. */
.lg-list, .lg-table { container-type: inline-size; }
.lg-row--req, .lg-row--cust, .lg-row--job { grid-template-columns: minmax(0, 1fr) auto; }
.lg-row--req > .lg-hide-sm, .lg-row--cust > .lg-hide-sm, .lg-row--job > .lg-hide-sm, .lg-head { display: none; }
.lg-row--req .lg-num, .lg-row--job .lg-num { white-space: nowrap; }
@container (min-width: 620px) {
  .lg-row--req  { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) 150px 120px 88px; }
  .lg-row--cust, .lg-head--cust { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) 120px 80px 104px 104px; }
  .lg-row--job  { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 150px 120px; }
  .lg-row--req > .lg-hide-sm, .lg-row--cust > .lg-hide-sm, .lg-row--job > .lg-hide-sm { display: flex; }
  .lg-head { display: grid; }
  .lg-head .lg-num { text-align: right; }
}
@media (min-width: 768px) {
  .lg-pills { flex-wrap: wrap; overflow: visible; }
}

/* ═══════════════ Kebab menu ([data-menu]) ══════════════════════════════════
   A button that opens a small list of secondary actions under it. app.js
   toggles [hidden] on the panel; click outside or Esc closes. */
.menu { position: relative; display: inline-flex; }
.menu-btn { width: var(--control-dense); padding: 0; font-size: 20px; line-height: 1; }
.menu-panel {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 50; min-width: 220px;
  display: flex; flex-direction: column; padding: var(--space-1);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.menu-panel[hidden] { display: none; }
.menu-panel form { margin: 0; display: contents; }
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 36px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text);
  font: inherit; font-size: var(--fs-sm); text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.menu-item:hover { background: var(--bg-sunken); text-decoration: none; }
.menu-item--danger { color: var(--st-danger-fg); }
.menu-sep { height: 1px; margin: var(--space-1) 0; background: var(--border); }

/* ═══════════════ Detail pages: tags, contact line, stat line ═══════════════*/
.page-action-bar-title .lg-tag { margin-left: 0; align-self: center; }
.contact-line { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-2); font-size: var(--fs-sm); }
.contact-line a { color: var(--text); }
.stat-line { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin: 0 0 var(--space-4); font-size: var(--fs-sm); color: var(--text-soft); }
.stat-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-line .sep { color: var(--border-strong); }
.split { display: grid; gap: var(--space-5); }
.split > * { min-width: 0; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-7); align-items: start; } }
.top-list { list-style: none; margin: 0; padding: 0; counter-reset: top; }
.top-list li { display: flex; align-items: baseline; gap: var(--space-3); padding: var(--space-2) var(--space-1); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.top-list li::before { counter-increment: top; content: counter(top); min-width: 1.2em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.top-list .grow { min-width: 0; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); margin: 0; font-size: var(--fs-sm); border-top: 1px solid var(--border); }
.facts dt, .facts dd { margin: 0; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.facts dt { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; }
.facts dd { overflow-wrap: anywhere; white-space: pre-line; }
.note-form { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }
.note-form .btn { justify-self: start; }

/* Today: three short queues. */
.today-alert { margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid color-mix(in srgb, var(--st-danger-fg) 35%, transparent); border-radius: var(--radius-md); background: var(--st-danger-bg); color: var(--st-danger-fg); font-size: var(--fs-sm); }
.today-alert a { color: inherit; font-weight: 600; }
.today-alert ul { margin: var(--space-1) 0 0; padding-left: var(--space-4); }

/* Settings: Website copy editor. */
.copy-group + .copy-group { margin-top: var(--space-6); }
.copy-field .form-help { margin-top: 2px; }
.copy-field.is-changed .form-label::after { content: " · changed"; color: var(--color-accent); font-weight: 600; }
.logo-wall { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.logo-wall li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--space-2) var(--space-4); align-items: center; padding: var(--space-3) var(--space-1); border-bottom: 1px solid var(--border); }
.logo-wall .logo-box { display: grid; place-items: center; width: 96px; height: 56px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-raised); }
.logo-wall .logo-box img { max-width: 88px; max-height: 48px; object-fit: contain; }
.logo-wall .logo-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.logo-wall .logo-actions form { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.logo-wall .logo-actions input[type="file"] { max-width: 220px; font-size: var(--fs-sm); }
.logo-wall .is-hidden-client { opacity: .55; }
@media (min-width: 768px) {
  .logo-wall li { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .logo-wall .logo-actions { grid-column: auto; justify-content: flex-end; }
}

/* ═══════════════ Jacket · Invoices · Price book (0009) ═════════════════════
   Chips: a radio/checkbox the size of a fingertip, styled as a pill. The paper
   jacket is a checklist of boxes, and the screen keeps it one tap per box. */
.chip-set { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); }
.chip { position: relative; display: inline-flex; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--bg-surface); color: var(--text); font-size: var(--fs-sm); white-space: nowrap;
}
.chip input:checked + span { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.chip input[value=""]:checked + span { background: var(--bg-sunken); border-color: var(--border-strong); color: var(--text-soft); font-weight: 400; }

.jacket-note { margin: 0 0 var(--space-3); font-size: var(--fs-sm); color: var(--text-soft); }
.jacket-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .jacket-grid { grid-template-columns: 1fr 1fr; } .jacket-span { grid-column: 1 / -1; } }
.jacket-grid > .card { margin: 0; }
.jacket-fields { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.jacket-fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.jacket-fields--3 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.jacket-fields .form-group, .price-fields .form-group { margin: 0; }
.jacket-fields .is-wide, .price-fields .is-wide { grid-column: 1 / -1; }
.jacket-title { font-size: var(--fs-lg); font-weight: 600; }

.tray { margin-bottom: var(--space-5); border-color: var(--color-accent); }
.inv-status { display: inline-block; padding: 1px var(--space-2); border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--bg-sunken); color: var(--text-soft); }
.inv-status--sent { background: var(--st-info-bg); color: var(--st-info-fg); }
.inv-status--paid { background: var(--st-success-bg); color: var(--st-success-fg); }
.inv-status--void { text-decoration: line-through; }
tr.is-muted td { color: var(--text-muted); }

.money-input { display: inline-flex; align-items: center; gap: 2px; }
.money-input > span { color: var(--text-soft); }
.money-input .form-input { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.money-input--pct .form-input { width: 4.5rem; }

.price-fields { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tier-table { max-width: 560px; }
.tier-table td { vertical-align: middle; }
.tier-table .form-input { max-width: 10rem; }
.price-try { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.price-try .form-label { margin: 0; }
.price-try .form-input { width: 8rem; }
.price-try-out { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }

.invoice-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.invoice-head { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 760px) { .invoice-head { grid-template-columns: 1fr 1fr; } .invoice-strip { grid-column: 1 / -1; } }
.invoice-head .form-group { margin: 0; }
.invoice-strip { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.invoice-lines td { vertical-align: top; }
.invoice-lines .col-qty { width: 6rem; }
.invoice-lines .col-qty .form-input { width: 5.5rem; text-align: right; }
.invoice-lines .col-primary .form-input { width: 100%; min-width: 16rem; }
.line-hint { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-soft); white-space: normal; }
.line-hint:empty { display: none; }
.invoice-lines tfoot td { border: 0; padding-block: var(--space-1); font-variant-numeric: tabular-nums; }
.totals-label { text-align: right; font-weight: 600; }
.totals-grand td { font-size: var(--fs-md); font-weight: 700; border-top: 2px solid var(--text) !important; }
.card-header .btn { margin-left: auto; }
/* A job's production status on the quote / invoice Jacket tab, at the right. */
.entered-pill { display: inline-flex; align-items: center; gap: var(--space-1); }
.card-header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); font-weight: 400; }
/* A chip group's Custom box opens when Custom is picked (no JS needed). */
.chip-group { margin: 0 0 var(--space-3); }
.chip-group .chip-set { margin: 0; }
.chip--custom span { border-style: dashed; }
.chip-custom-input { display: none; max-width: 32rem; margin-top: var(--space-2); }
.chip-group:has([data-custom-chip]:checked) .chip-custom-input { display: block; }
.jacket-rebuild { margin-left: var(--space-2); vertical-align: baseline; }
.call-flag { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); background: var(--st-warning-bg); color: var(--st-warning-fg); font-size: var(--fs-xs); font-weight: 600; }

/* ── Board: the desk trays as columns. Each header is the tray's paper label;
   each card is a jacket with one button for its next step. Columns scroll
   sideways on a phone, one tray per screen. */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-3); scroll-snap-type: x mandatory; }
.board-col { display: flex; flex-direction: column; min-width: 0; padding: var(--space-3); border-radius: var(--radius-md); background: var(--bg-sunken); scroll-snap-align: start; }
.board-tray {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong); border-radius: 2px; background: var(--bg-surface);
  font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--text);
}
.board-tray b { font-family: var(--font-body); font-size: var(--fs-sm); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.board-cards { display: flex; flex-direction: column; gap: var(--space-2); }
.board-empty { margin: 0; padding: var(--space-4) 0; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.bcard { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); box-shadow: var(--shadow-sm, none); }
.bcard-link { display: flex; flex-direction: column; gap: 2px; width: 100%; color: inherit; text-decoration: none; }
.bcard-link:hover .bcard-who { text-decoration: underline; }
.bcard-who { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.bcard-what { font-size: var(--fs-sm); color: var(--text); overflow-wrap: anywhere; }
.bcard-meta { font-size: var(--fs-xs); color: var(--text-soft); }
.bcard-late { color: var(--st-danger-fg); font-weight: 600; }
.bcard form { margin: 0; }
/* Waiting on the customer: still on the board, visibly not the shop's move. */
.bcard--paused { background: transparent; border-style: dashed; box-shadow: none; }
.bcard--paused .bcard-who, .bcard--paused .bcard-what { color: var(--text-soft); }

/* ── Request = jacket page: header controls, job strip, invoice button ─────── */
.header-controls { display: inline-flex; align-items: center; gap: var(--space-2); }
.header-controls form { margin: 0; }
.status-select { min-height: 36px; padding-block: 0; font-size: var(--fs-sm); font-weight: 600; width: auto; }
.status-select--quoted, .status-select--reviewing { color: var(--st-info-fg); }
.status-select--approved, .status-select--in_production { color: var(--st-warning-fg); }
.status-select--ready, .status-select--completed { color: var(--st-success-fg); }
.status-select--waiting { color: var(--text-soft); }
.status-select--cancelled { color: var(--text-muted); }
.btn-archive { border: 1px solid var(--st-danger-fg); background: transparent; color: var(--st-danger-fg); font-weight: 600; }
.btn-archive:hover { background: var(--st-danger-bg); }
.status-archived { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.btn-invoice { min-height: 44px; padding-inline: var(--space-5); font-size: var(--fs-md); font-weight: 700; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent); }
.converted-note { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--st-success-bg); color: var(--st-success-fg); font-size: var(--fs-sm); font-weight: 600; }

.job-strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
.job-strip form { margin: 0; }
.job-pill {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--bg-surface);
  color: var(--text); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; cursor: pointer;
}
.job-pill:hover { border-color: var(--color-primary); }
.job-pill.is-active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.job-pill.is-archived { opacity: .55; }
.job-pill-meta { font-size: var(--fs-xs); font-weight: 400; opacity: .75; }
.job-pill--add { width: 40px; padding: 0; justify-content: center; font-size: 1.35rem; font-weight: 400; line-height: 1; border-style: dashed; font-family: inherit; }

.jacket-panel { margin: 0 0 var(--space-4); }
.jacket-readonly .chip input:not(:checked) + span { opacity: .45; }
.jacket-readonly .chip-custom-input, .jacket-readonly .jacket-rebuild { display: none; }
.jacket-readonly .chip-group:has([data-custom-chip]:checked) .chip-custom-input { display: block; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.dialog-card-title { margin: 0; padding: var(--space-5) var(--space-5) 0; font-family: var(--font-body); font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; }
.dialog-card-title + p { padding-top: var(--space-2) !important; }
@media (max-width: 720px) { .header-controls { flex-wrap: wrap; } .btn-invoice { width: 100%; justify-content: center; } }
.nav-group { display: block; margin: var(--space-4) 0 var(--space-1); padding: 0 var(--space-5); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.lg-new { white-space: nowrap; }
.doc-preview-wrap { overflow-x: auto; margin: 0 0 var(--space-4); padding: var(--space-4) 0; background: var(--bg-sunken); border-radius: var(--radius-md); }
.doc-preview { display: block; width: 8.6in; height: 11.2in; margin: 0 auto; border: 0; background: transparent; }
.jacket-read .facts { grid-template-columns: 160px minmax(0, 1fr); }
.jacket-read-empty { margin: 0; }
.art-upload { margin: 0 0 var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); } .art-upload-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; } .art-upload-row .form-input { flex: 1 1 240px; }

/* ── The jacket on screen (templates/jacket_form.php): the paper's sections in
   the paper's order, as cards with tap-to-pick chips. ───────────────────── */
.jform { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 980px) { .jform { grid-template-columns: 1fr 1fr; } .jform-span { grid-column: 1 / -1; } }
.jform > .card { margin: 0; }
.jform-fields { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.jform-fields--2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.jform-fields--3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-top: var(--space-3); }
.jform-fields .form-group { margin: 0; }
.jform-fields .is-wide, .jform .form-group.is-wide { grid-column: 1 / -1; }
.jform .card-body > .form-group { margin: 0 0 var(--space-3); }
.jform-machines { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.jform-machine .chip { margin-bottom: var(--space-2); }
.jform-machine .form-group { margin: 0 0 var(--space-2); }
.note-lines { display: flex; flex-direction: column; gap: 4px; }
.note-lines .note-line { min-height: 36px; }
.jform-readonly .chip input:not(:checked) + span { opacity: .4; }
.jform-readonly .form-input:placeholder-shown { opacity: .5; }
.jk-sheet-tools { margin: 0 0 var(--space-2); text-align: right; font-size: var(--fs-sm); }
.jk-sheet-tools a { color: var(--text-soft); }

/* ── Quote / invoice on screen (templates/doc_form.php) ───────────────────── */
.docform { display: grid; gap: var(--space-4); }
.docform > .card { margin: 0; }
.docform-parties { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 760px) { .docform-parties { grid-template-columns: 1fr 1fr; } .docform-strip { grid-column: 1 / -1; } }
.docform-parties .form-group { margin: 0; }
.docform-strip { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.answer-note { margin: 0 0 var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.answer-note--approved { background: var(--st-success-bg); color: var(--st-success-fg); }
.answer-note--changes { background: var(--st-warning-bg); color: var(--st-warning-fg); }
.answer-quote { display: block; margin-top: 4px; font-style: italic; }
.share-line { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); font-size: var(--fs-sm); color: var(--text-soft); }
.share-url { flex: 1; max-width: 560px; font-size: var(--fs-sm); }

/* ── Price book: one screen of cards, lines of "this many for this much" ──── */
.pb-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); }
.pb-search { flex: 1 1 220px; max-width: 320px; }
.pb-add { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.pb-add .form-input { width: 260px; max-width: 100%; }
.pb-add .form-select { width: auto; max-width: 220px; }
.pb-list { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
.pb-item { margin: 0; padding: var(--space-3) var(--space-4); scroll-margin-top: 90px; }
.pb-item:target { box-shadow: 0 0 0 2px var(--color-primary); }
.pb-head { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.pb-name { flex: 1; font-weight: 600; }
.pb-product { width: 40%; min-width: 0; font-size: var(--fs-sm); }
.pb-del { flex: none; color: var(--text-muted); }
.pb-lines { width: 100%; border-collapse: collapse; }
.pb-lines th { padding: 0 var(--space-1) var(--space-1); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-align: left; }
.pb-lines td { padding: 2px var(--space-1); vertical-align: middle; }
.pb-lines td:first-child .form-input { width: 7rem; }
.pb-lines .money-input .form-input { width: 7.5rem; }
.pb-each { font-size: var(--fs-xs); color: var(--text-soft); white-space: nowrap; }
.pb-source { margin: var(--space-2) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 640px) { .pb-list { grid-template-columns: 1fr; } .pb-add { margin-left: 0; } }

/* ── Product > Pricing: quantity / unit price / total rows ─────────────────── */
.pt { margin: 0 0 var(--space-4); max-width: 640px; }
.pt-head { gap: var(--space-3); }
.pt-name { flex: 1; font-weight: 600; }
.pt-table { width: 100%; border-collapse: collapse; margin: var(--space-2) 0 var(--space-3); }
.pt-table th { padding: var(--space-1) var(--space-4); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-align: left; }
.pt-table td { padding: 3px var(--space-4) 3px; }
.pt-table td:first-child .form-input { width: 8rem; }
.pt-table .money-input .form-input { width: 8rem; }
.pt-table td:last-child { width: 1%; padding-left: 0; }
.pt-source { margin: 0 var(--space-4) var(--space-3); font-size: var(--fs-xs); color: var(--text-muted); }
.pt-empty { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pt-empty p { margin: 0; color: var(--text-soft); }
.pt-another { margin: 0 0 var(--space-4); }
@media (max-width: 560px) { .pt-table td, .pt-table th { padding-inline: var(--space-2); } .pt-table td:first-child .form-input, .pt-table .money-input .form-input { width: 5.5rem; } }

/* ── List pages: ONE sticky toolbar - the page's search, the dropdowns that
   matter, the count, and the primary action at the far right. ───────────── */
.filterbar-shell, .lg-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3); padding: var(--space-3) 0;
  background: var(--bg-page); border-bottom: 1px solid var(--border);
}
.filterbar-shell > .filter-bar { flex: 1 1 auto; margin: 0; flex-wrap: nowrap; }
.filter-bar .search { flex: 0 1 340px; }
.filter-bar select { min-width: 140px; }
.filter-note { color: var(--text-muted); }
.filterbar-actions { flex: none; display: flex; gap: var(--space-2); margin-left: auto; }
.filterbar-actions form { margin: 0; }
.lg-top .lg-find { flex: 0 1 340px; }
.lg-top .lg-new { margin-left: auto; }
.dense > .admin-content-header { margin-bottom: var(--space-2); }
@media (max-width: 720px) {
  .filterbar-shell > .filter-bar { flex-wrap: wrap; }
  .filter-bar .search, .lg-top .lg-find { flex: 1 1 100%; }
}

/* ── Tighter detail-page chrome (owner, 2026-10-06: "so much unused space") ──
   The sticky header is one compact row; its buttons are the compact size; a
   tab strip with a single tab is not drawn - there is nothing to switch to. */
.page-action-bar { margin-bottom: var(--space-3); }
@media (min-width: 768px) { .page-action-bar { padding: var(--space-2) 0; } }
.page-action-bar .btn { min-height: 36px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.page-action-bar .btn-invoice { min-height: 38px; padding: 0 var(--space-4); font-size: var(--fs-sm); box-shadow: none; }
.page-action-bar .status-select { min-height: 36px; }
.page-action-bar-title h1 { font-size: var(--fs-xl); }
.tabs { margin-bottom: var(--space-3); }
.tabs:has(> .tab:only-child) { display: none; }
.bar-gap { width: var(--space-3); flex: none; }

/* ── Lists: bigger text (owner, 2026-10-06), and a row's Archive button ────── */
:root { --fs-table: 0.92rem; --fs-table-head: 0.72rem; }
.lg-row { font-size: var(--fs-md); }
.lg-row .lg-dim { font-size: var(--fs-sm); }
.lg-act { justify-content: flex-end; }
.lg-act form { margin: 0; }
.row-action { width: 1%; text-align: right; }
.row-action form { margin: 0; }
.lg-new { display: inline-flex; gap: var(--space-2); margin-left: auto; }
.lg-row--req.lg-row--arch { grid-template-columns: minmax(0, 1fr) auto auto; }
@container (min-width: 620px) { .lg-row--req.lg-row--arch { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) 196px 120px 88px auto; } }
/* The row's status dropdown (Requests list): fits "Waiting on customer". */
.lg-row .status-pick { margin: 0; }
.lg-row .status-select { max-width: 100%; }
/* Phone: the dropdown takes its own full line under the name, Archive stays
   beside the name - a dropdown as wide as "Waiting on customer" squeezed the
   name to a letter a line. */
@container (max-width: 619.98px) {
  .lg-row--req.lg-row--arch { grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row dense; }
  .lg-row--req .lg-cell--pick { grid-column: 1 / -1; }
  .lg-row--req .lg-cell--pick .status-pick, .lg-row--req .lg-cell--pick .status-select { width: 100%; }
}

/* ── Form grids (quote / invoice Customer card, the jacket's cards): fields
   side by side line up - no stacked-field top margin inside a grid, labels
   on one baseline, every box the same height (the date box included). ─── */
.docform-parties .form-group, .docform-strip .form-group,
.jform-fields .form-group, .jform-fields--2 .form-group, .jform-fields--3 .form-group { margin: 0 !important; }
.docform-parties, .docform-strip { align-items: start; }
.docform-parties { row-gap: var(--space-3); }
.docform .form-label, .jform .form-label { display: block; margin: 0 0 4px; line-height: 1.3; }
.docform .form-input, .jform .form-input { height: 40px; min-height: 40px; padding-block: 0; }
.docform .form-textarea { min-height: 96px; }
.docform input[type="date"], .jform input[type="date"] { line-height: 40px; }
.docform-strip { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.invoice-lines td { vertical-align: middle; }
.invoice-lines tfoot td { vertical-align: middle; }
.invoice-lines td:last-child { width: 1%; }
.page-action-bar-title .status-pick { margin: 0; align-self: center; }
.page-action-bar-title .status-select { min-height: 32px; font-size: var(--fs-sm); }
.status-select--sent { color: var(--st-info-fg); }
.status-select--paid { color: var(--st-success-fg); }

/* ── The share window (quote / invoice, after a send) ─────────────────────── */
.share-dialog { width: min(560px, calc(100vw - 32px)); }
.share-lead { margin: 0 0 var(--space-3); color: var(--text-soft); }
.share-option { padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.share-h { display: block; margin-bottom: var(--space-2); font-weight: 700; font-size: var(--fs-sm); }
.share-row { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.share-row .form-input { flex: 1; min-width: 0; height: 38px; font-size: var(--fs-sm); }
.share-to { flex: 1; min-width: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* ── Customers: the picker on a request / quote / invoice, and the dialog ── */
.customer-picker { position: relative; margin: 0 0 var(--space-4); max-width: 40rem; }
.customer-picker-row { display: flex; gap: var(--space-2); align-items: center; }
.customer-picker-row .form-input { flex: 1; min-width: 0; }
.customer-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: var(--space-1) 0 0; padding: var(--space-1) 0; list-style: none;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 18rem; overflow: auto; }
.customer-results li { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); cursor: pointer; }
.customer-results li:hover, .customer-results li:focus { background: var(--bg-sunken); }
.customer-results li span { font-size: var(--fs-sm); color: var(--text-soft); }
.customer-results .customer-none { cursor: default; color: var(--text-soft); }
dialog.customer-dialog { max-width: 40rem; width: calc(100vw - 2 * var(--space-4)); }
.customer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.customer-grid .customer-wide { grid-column: 1 / -1; }
.customer-pair { display: grid; grid-template-columns: 5rem 1fr; gap: var(--space-3); }
.lg-add { margin-left: auto; }
@media (max-width: 560px) { .customer-grid { grid-template-columns: 1fr; } }

/* ── Delivery tab on a request ── */
.delivery-form { max-width: 40rem; }
.delivery-row { display: grid; grid-template-columns: 1fr 5rem 7rem; gap: var(--space-3); }
.delivery-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
@media (max-width: 560px) { .delivery-row { grid-template-columns: 1fr 1fr; } .delivery-row .form-group:first-child { grid-column: 1 / -1; } }

/* ═══════════════ Order inbox (/admin/inbox) ═════════════════════════════════
   The email beside the proposed jacket. Every box the AI filled is badged
   (.ai-from) with its quote under it (.ai-evidence); low-confidence boxes get
   an amber edge so a person checks them before "Create request". */
.lg-row--inbox { grid-template-columns: minmax(0, 1fr) auto; }
.lg-row--inbox > .lg-hide-sm { display: none; }
@container (min-width: 620px) {
  .lg-row--inbox { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) 140px 110px; }
  .lg-row--inbox > .lg-hide-sm { display: flex; }
}
.inline-form { display: inline-flex; margin: 0; }
.inbox-status { margin: 0 0 var(--space-2); }
.inbox-split { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
.inbox-split > * { min-width: 0; }
@media (min-width: 1200px) {
  .inbox-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: start; }
  .inbox-mail { position: sticky; top: var(--space-4); max-height: calc(100vh - 2 * var(--space-4)); overflow: auto; }
}
.inbox-mail { margin: 0; }
.inbox-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-1) var(--space-3); margin: 0 0 var(--space-3); font-size: var(--fs-sm); }
.inbox-meta dt { color: var(--text-muted); }
.inbox-meta dd { margin: 0; overflow-wrap: anywhere; }
.inbox-h { margin: var(--space-4) 0 var(--space-2); font-size: var(--fs-table-head); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.inbox-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: 1.55; padding: var(--space-3); background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inbox-files, .inbox-trail { list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
.inbox-files li { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); padding: var(--space-1) 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.inbox-trail li { padding: 2px 0; }
.inbox-step { margin: 0 0 var(--space-4); }
.inbox-step p { margin: 0 0 var(--space-2); }
.inbox-step p:last-child { margin-bottom: 0; }
.inbox-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.inbox-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.inbox-create { display: flex; justify-content: flex-end; margin: var(--space-4) 0 0; }

.ai-from {
  display: inline-block; margin-left: var(--space-2); padding: 0 7px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; letter-spacing: 0; text-transform: none; vertical-align: 1px; white-space: nowrap;
  background: var(--st-info-bg); color: var(--st-info-fg); cursor: help;
}
.ai-from--low    { background: var(--st-warning-bg); color: var(--st-warning-fg); }
.ai-from--header { background: var(--slate-100); color: var(--text-soft); }
.chip-group > .ai-from { margin: 0 0 var(--space-1); }
.inbox-verdict .ai-from, .inbox-step .ai-from { margin-left: 0; }
.ai-evidence { display: block; margin-top: var(--space-1); font-size: var(--fs-xs); font-style: italic; color: var(--text-soft); overflow-wrap: anywhere; }
.is-ai--low > .form-input { border-color: var(--st-warning-fg); background: var(--st-warning-bg); }
.is-ai--low > .chip-set, .note-lines.is-ai--low { box-shadow: inset 3px 0 0 var(--st-warning-fg); padding-left: var(--space-3); border-radius: var(--radius-sm); }

/* ═══ Lists: the one pager (templates/pager.php) ══════════════════════════ */
.pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: var(--space-4) 0 0; font-size: var(--fs-sm); color: var(--text-soft); }
.pager-links { display: inline-flex; align-items: center; gap: var(--space-2); }
.pager-page { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager .is-disabled { opacity: .45; pointer-events: none; }

/* Sortable ledger heads (Customers): they look clickable, the sorted one says
   which way; on a narrow list the head is a row of "Sort" chips instead of
   vanishing (it used to be display:none below 620px - no way to sort). */
.lg-head a { cursor: pointer; text-decoration: none; }
.lg-head a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.lg-head a:not(.is-on)::after { content: " \2195"; opacity: .35; }
.lg-head-label { display: none; }
@container (max-width: 619.98px) {
  .lg-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); padding-bottom: var(--space-2); }
  .lg-head-label { display: inline; color: var(--text-muted); }
  .lg-head .lg-num { text-align: left; }
}

/* Who has a job: under the status on a row, in a card's meta, the header pick. */
.lg-with, .bcard-with { font-size: var(--fs-xs); white-space: nowrap; }
.lg-preset--mine { margin-right: var(--space-2); border: 1px solid var(--border-strong); }
.assign-pick { margin: 0; }
.assign-select { font-weight: 500; color: var(--text-soft); max-width: 12rem; }
.assign-select.is-set { color: var(--text); font-weight: 600; }

/* Board on a phone: the trays stack and each folds away (<details>), so the
   page never scrolls sideways; from 768px they are the columns, always open. */
.board-sum { display: block; list-style: none; }
.board-sum::-webkit-details-marker { display: none; }
.board-col > .board-sum .board-tray { margin-bottom: var(--space-3); }
.board-col:not([open]) > .board-sum .board-tray { margin-bottom: 0; }
@media (max-width: 767.98px) {
  .board { display: flex; flex-direction: column; gap: var(--space-3); overflow: visible; scroll-snap-type: none; padding-bottom: 0; }
  .board-col { scroll-snap-align: none; }
  .board-sum { cursor: pointer; }
  .board-sum .board-tray::after { content: "\25BE"; margin-left: var(--space-2); color: var(--text-soft); font-size: var(--fs-sm); }
  .board-col:not([open]) .board-sum .board-tray::after { content: "\25B8"; }
  .board-sum .board-tray > span { flex: 1; }
}
@media (min-width: 768px) {
  .board { max-width: 100%; overscroll-behavior-x: contain; }
  .board-sum { pointer-events: none; }
}

/* Signed out mid-edit / typing to put back (app.js): above the page, never
   instead of it - the form stays exactly as it was. */
.session-banner {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--st-warning-fg); border-radius: var(--radius-md);
  background: var(--st-warning-bg); color: var(--text); font-size: var(--fs-sm);
}
.session-banner[hidden] { display: none; }
.session-banner > span { flex: 1 1 260px; }
.session-banner a { color: inherit; text-decoration: underline; font-weight: 600; }

/* ── Inbox > Set up ── */
.setup { display: flex; flex-direction: column; gap: var(--space-4); max-width: 46rem; }
.setup .card-header { justify-content: space-between; }
.setup-state { font-size: var(--fs-sm); font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; }
.setup-state--on { color: var(--st-success-fg); background: var(--st-success-bg); }
.setup-state--off { color: var(--text-soft); }
.setup-form { margin-top: var(--space-3); }
.setup-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.setup-row .setup-port { max-width: 7rem; }
.setup-actions { display: flex; gap: var(--space-2); }
.setup-list { padding-left: 1.25rem; }
.setup-list li + li { margin-top: var(--space-2); }
dialog.inbox-add { max-width: 40rem; width: calc(100vw - 2 * var(--space-4)); }
@media (max-width: 560px) { .setup-row { grid-template-columns: 1fr; } }

/* A sent / paid quote or invoice is a record: its fields read as text, not inputs. */
.invoice-fieldset[disabled] .form-input,
.invoice-fieldset[disabled] .form-textarea,
.invoice-fieldset[disabled] .form-select { background: var(--bg-sunken); border-color: transparent; color: var(--text); box-shadow: none; cursor: default; }
.invoice-fieldset[disabled] [data-line-add], .invoice-fieldset[disabled] [data-line-remove] { display: none; }

/* ── Products > Online ordering ── */
.ordering-table .ordering-route { text-align: center; width: 6.5rem; }
.ordering-table .ordering-note { min-width: 18rem; }
.ordering-table .ordering-note .form-input { width: 100%; }
.ordering-table .ordering-group th { text-align: left; background: var(--bg-sunken); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.ordering-table tr.is-dim td { color: var(--text-soft); }
.ordering-table tr.is-invalid td { background: var(--st-danger-bg); }
.ordering-tick { display: inline-flex; padding: var(--space-2); cursor: pointer; }
.ordering-tick input { width: 1.1rem; height: 1.1rem; }

/* ── Sticky page header: tabs + the page's Save stay in reach while the
   table scrolls (Products, Settings). Below the phone top bar on phones. ── */
:root { --stick-top: 52px; }
@media (min-width: 768px) { :root { --stick-top: 0px; } }
.admin-content-header {
  position: sticky; top: var(--stick-top); z-index: 25;
  background: var(--bg-page); padding-block: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.admin-content-header ~ .filterbar-shell { top: calc(var(--stick-top) + var(--ach-h, 0px)); }

/* ── Designer template manager (Products > Online ordering > Templates) ──
   Big previews, the whole card is the switch: on = blue edge + tick, off =
   faded. Drag to reorder. */
.tpl-open { margin-left: var(--space-1); }
/* Wide (the base dialog caps at 460px), and only the middle scrolls: the
   title and Save stay on screen however many templates there are. */
dialog.tpl-dialog { max-width: 68rem; width: calc(100vw - 2 * var(--space-4)); max-height: 92vh; max-height: 92dvh; overflow: hidden; }
.tpl-dialog > form { max-height: inherit; height: 100%; }
.tpl-dialog > form > .dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tpl-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.tpl-count { font-size: var(--fs-sm); font-weight: 600; color: var(--color-accent); }
.tpl-words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); padding: 0; border: 0; }
.tpl-words legend { font-weight: 700; margin-bottom: var(--space-2); }
.tpl-word { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--fs-sm); color: var(--text-soft); }
.tpl-word--wide { grid-column: 1 / -1; }
.tpl-hint { margin: 0 0 var(--space-3); font-size: var(--fs-sm); color: var(--text-soft); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); list-style: none; margin: 0; padding: 0; }
.tpl-grid.is-tall { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.tpl-card { position: relative; border: 2px solid var(--border); border-radius: var(--radius-md); background: var(--bg-raised); opacity: .45; transition: opacity .15s, border-color .15s, box-shadow .15s; }
.tpl-card.is-on { opacity: 1; border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
.tpl-card.is-dragging { opacity: .25; }
.tpl-card[draggable="true"] { cursor: grab; }
.tpl-pick { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2); cursor: pointer; }
.tpl-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-pick:focus-within { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.tpl-thumb { display: block; background: var(--bg-sunken); border-radius: 4px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tpl-thumb svg { display: block; width: 100%; height: auto; }
.tpl-name { font-weight: 600; font-size: var(--fs-sm); padding-right: 1.6rem; }
.tpl-state { position: absolute; top: var(--space-1); right: var(--space-1); width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--bg-raised); }
.tpl-card.is-on .tpl-state { border-color: var(--color-accent); background: var(--color-accent); }
.tpl-card.is-on .tpl-state::after { content: ""; position: absolute; left: .38rem; top: .14rem; width: .35rem; height: .65rem; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tpl-move { display: flex; justify-content: space-between; padding: 0 var(--space-1) var(--space-1); }
.tpl-move .btn { min-height: 0; padding: 0 var(--space-2); }
.tpl-card--fixed { opacity: .8; cursor: default; border-style: dashed; box-shadow: none; }
.tpl-card--fixed .tpl-pick { cursor: default; }
.tpl-fixed-note { font-size: var(--fs-xs); color: var(--text-soft); }
@media (max-width: 560px) { .tpl-words { grid-template-columns: 1fr; } }

/* ── Products > Online ordering > Questions ── */
dialog.q-dialog { max-width: 52rem; width: calc(100vw - 2 * var(--space-4)); max-height: 92vh; max-height: 92dvh; overflow: hidden; }
.q-dialog > form { max-height: inherit; height: 100%; }
.q-dialog > form > .dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.q-words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.q-h { font-size: var(--fs-md); margin: 0 0 var(--space-2); }
.q-groups { display: grid; gap: var(--space-2); }
.q-group { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.q-group.is-on { border-color: var(--color-accent); }
.q-ask { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.q-chips { display: none; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }
.q-group.is-on .q-chips { display: flex; }
.q-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: var(--fs-sm); cursor: pointer; }
.q-chip:has(input:checked) { border-color: var(--color-accent); background: var(--bg-sunken); }
@media (max-width: 560px) { .q-words { grid-template-columns: 1fr; } }

/* Sign-in: the quiet "Forgot your password?" under the button. */
.login-alt { margin-top: var(--space-3); text-align: center; font-size: var(--fs-sm); }
.login-lead { margin: 0 0 var(--space-4); color: var(--text-soft); font-size: var(--fs-sm); text-align: center; }
.staff-link p { margin: 0 0 var(--space-2); }
.staff-link .form-input { flex: 1 1 22rem; font-family: var(--font-mono, monospace); font-size: var(--fs-xs); }
