/* ==========================================================================
   ROLE: STANDARD - the only stylesheet. Screens use its classes; never add a <style>
   block or style= to a page. A missing component is added here, once.

   app.css — Symphony's entire design system in one file: reset, every
   reusable component (buttons, badges, cards, tables, forms, modals, toasts),
   and every shell-specific rule (rail, sliding module panel, topbar, document
   window, tabs, fieldset groups, dashboard, lookup popups).

   Load order: css/tokens.css -> css/themes/<theme>.css -> css/app.css.

   Every color, font, radius, shadow, text size, spacing, icon size and control
   height here is a var() from tokens.css. To reskin Symphony, add a theme;
   never edit a value in this file to do it. The literal sizes that remain are
   structural layout (panel widths, column widths, breakpoints) or decorative
   geometry — not things a theme should change.

   No utility classes. Name a class for what it means, not what it does.
   ========================================================================== */

/* ===== 0. Shell layout dimensions (structural, not theme) ================= */
:root {
  --topbar-h: 2.75rem;
  --rail-w: 3.5rem;
  --rail-item-h: 2.75rem;
  --panel-w: 13.5rem;
}

/* ===== 1. Reset ============================================================ */
*, ::before, ::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; tab-size: 4; }
body { margin: 0; line-height: inherit; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; margin: 0; }
p, dl, dd, ul, ol, figure, blockquote, pre, hr { margin: 0; }
ul, ol { list-style: none; padding: 0; }
a { color: inherit; text-decoration: inherit; }
b, strong { font-weight: 600; }
table { border-collapse: collapse; border-color: inherit; text-indent: 0; }
button, input, select, textarea { font-family: inherit; font-size: 100%; line-height: inherit; color: inherit; margin: 0; padding: 0; }
button, select { text-transform: none; }
button, [type="button"], [type="submit"] { -webkit-appearance: button; background-color: transparent; background-image: none; cursor: pointer; }
:disabled { cursor: default; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { opacity: 1; }
img, svg, video, canvas { display: block; vertical-align: middle; }
img, video { max-width: 100%; height: auto; }
[hidden] { display: none; }

/* ===== 2. Base type ========================================================= */
html { font-family: var(--font-sans); font-size: var(--root-size); color-scheme: var(--color-scheme); }
body { background: var(--page-bg); color: var(--slate-700); font-size: var(--text-13); line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--slate-900); }
/* Serif headings: page/card/modal titles only. Nav, buttons, labels, table headers stay sans. */
.page-title, .card-title, .modal-title, .empty-state .title, .brand-name { font-family: var(--font-serif); font-weight: 500; }
/* Codes and IDs (PO no., refs, item codes, user ids) — always .mono. Plex Mono's dotted zero
   keeps 0 and O apart when codes are read aloud or retyped; a decided rule, don't move codes to sans. */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
/* Amounts, quantities, dates — the theme decides the face (--font-numeric); digits stay equal-width. */
.numeric { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }

/* Text roles: muted (placeholders, dashes) < secondary (notes) < strong (key values) */
.text-muted     { color: var(--slate-400); }
.text-secondary { color: var(--slate-500); }
.text-strong    { color: var(--slate-900); }
.brand-accent   { color: var(--brand-600); }
.link { color: var(--brand-700); font-weight: 500; font-size: var(--text-14); }
.link:hover { text-decoration: underline; }
/* A drill-down that acts (loads a screen) is a <button>; it just looks like a link. */
.link-button { padding: 0; border: 0; background: none; font: inherit; color: var(--brand-700); font-weight: 500; text-align: left; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.link-button:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }

/* ===== 3. Layout helpers (named by role) ===================================== */
.section-spaced { margin-top: var(--space-12); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.stack-sm > * + * { margin-top: var(--space-8); }
.inline-group { display: inline-flex; align-items: center; gap: var(--space-8); }
.form-row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-16); }
.icon-muted { width: var(--icon-md); height: var(--icon-md); color: var(--slate-400); flex-shrink: 0; }
/* A server-refreshable field group that must not disturb its parent's grid. */
.refresh-unit { display: contents; }
/* Text that is read by screen readers, voice control and AI agents but not shown on screen —
   the native-HTML way to name an icon-only button (preferred over aria-label). The one
   deliberate exception to "no utility classes": .sr-only is the name every tool expects. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Page layouts: how a screen arranges its cards, panels or fieldsets. These three cover
   every page; a page never defines its own grid. Columns come from the space available,
   not the screen size, so the same layout works in the app, a document window and a phone.
     .layout-split       main column + side column (2:1), stacked below 1024px
     .layout-grid        equal tiles, as many 15rem columns as fit (stat cards, small cards)
     .layout-grid-wide   equal panels, as many 26rem columns as fit (cards, fieldsets)
     .span-all           a child of a layout that takes the whole row */
.layout-split, .layout-grid, .layout-grid-wide { display: grid; gap: var(--space-12); }
.layout-split      { grid-template-columns: minmax(0,1fr); }
.layout-grid       { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.layout-grid-wide  { grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.span-all          { grid-column: 1 / -1; }
@media (min-width: 1024px) { .layout-split { grid-template-columns: minmax(0,2fr) minmax(20rem,1fr); } }

/* ===== 4. Page header ======================================================= */
.page-header   { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-12); margin-bottom: var(--space-14); }
.page-title    { font-size: var(--text-18); font-weight: 500; letter-spacing: -.01em; color: var(--slate-900); line-height: 1.25; }
.page-subtitle { margin-top: var(--space-2); font-size: var(--text-13); color: var(--slate-500); }
.page-actions  { display: flex; gap: var(--space-6); flex-shrink: 0; }

/* ===== 5. Cards ============================================================= */
.card        { background: var(--surface); border: 1px solid var(--slate-200); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); padding: var(--space-8) var(--space-14); border-bottom: 1px solid var(--slate-200); min-height: var(--control-lg); }
.card-title  { font-size: var(--text-14); font-weight: 500; color: var(--slate-900); }
.card-body   { padding: var(--space-14); }
.card-footer { padding: var(--space-8) var(--space-14); border-top: 1px solid var(--slate-200); background: var(--slate-50); }

/* ===== 6. Buttons ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-6); height: var(--control-md); padding: 0 var(--space-12);
       font-size: var(--text-13); font-weight: 500; line-height: 1; border-radius: var(--radius-ctl); border: 1px solid transparent;
       cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s; }
.btn:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 1px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: var(--icon-sm); height: var(--icon-sm); flex-shrink: 0; }

.btn-primary        { background: var(--brand-600); border-color: var(--brand-600); color: var(--on-brand); }
.btn-primary:hover  { background: var(--brand-700); border-color: var(--brand-700); }
.btn-secondary      { background: var(--surface); border-color: var(--slate-300); color: var(--slate-700); }
.btn-secondary:hover{ background: var(--slate-50); border-color: var(--slate-400); color: var(--slate-900); }
.btn-ghost          { background: transparent; color: var(--slate-600); }
.btn-ghost:hover    { background: var(--slate-100); color: var(--slate-900); }
.btn-danger         { background: var(--danger-600); border-color: var(--danger-600); color: var(--on-brand); }
.btn-danger:hover   { background: var(--danger-700); border-color: var(--danger-700); }
.btn-success        { background: var(--success-500); border-color: var(--success-500); color: var(--on-brand); }
.btn-success:hover  { background: var(--success-600); border-color: var(--success-600); }
.btn-sm { height: var(--control-xs); padding: 0 var(--space-8); font-size: var(--text-12); }
.btn-lg { height: var(--control-lg); padding: 0 var(--space-16); font-size: var(--text-14); }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-top: var(--space-12); }

.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--control-sm); height: var(--control-sm); padding: 0;
            border-radius: var(--radius-ctl); border: 1px solid transparent; background: transparent; color: var(--slate-500);
            cursor: pointer; transition: background-color .12s, color .12s; }
.btn-icon:hover        { background: var(--slate-100); color: var(--slate-900); }
.btn-icon.danger:hover { background: var(--danger-tint); color: var(--danger-600); }
.btn-icon:disabled, .btn-icon:disabled:hover { opacity: .3; cursor: not-allowed; background: transparent; color: var(--slate-500); }
.btn-icon svg { width: var(--icon-md); height: var(--icon-md); }

/* ===== 7. Forms ============================================================== */
.label { display: block; font-size: var(--text-12); font-weight: 500; color: var(--slate-600); margin-bottom: var(--space-4); }
.label .req { color: var(--danger-600); margin-left: var(--space-2); }

.input, .select, .textarea {
  display: block; width: 100%; font: inherit; font-size: var(--text-13); color: var(--slate-900); background-color: var(--surface);
  border: 1px solid var(--slate-300); border-radius: var(--radius-ctl); padding: 0 var(--space-8); height: var(--control-md);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 4rem; padding: var(--space-6) var(--space-8); line-height: 1.45; }
.textarea-sm { min-height: 3rem; }
/* Chevron drawn with two gradients so its color follows the theme (an SVG data URI can't read var()). */
.select { padding-right: var(--space-28); appearance: none; -webkit-appearance: none; background-repeat: no-repeat;
          background-image: linear-gradient(45deg, transparent 50%, var(--slate-500) 50%), linear-gradient(135deg, var(--slate-500) 50%, transparent 50%);
          background-position: right calc(var(--space-8) + var(--space-5)) center, right var(--space-8) center;
          background-size: var(--space-5) var(--space-5); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 1px var(--brand-600); }
.input::placeholder, .textarea::placeholder { color: var(--slate-400); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background-color: var(--slate-100); color: var(--slate-500); cursor: not-allowed; }
.input-sm, .select-sm { height: var(--control-xs); font-size: var(--text-12); padding-top: 0; padding-bottom: 0; padding-left: var(--space-6); }
.input.mono, .td-num .input { font-family: var(--font-mono); }
.input-num { text-align: right; }
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--danger-600); }
.help-text  { margin-top: var(--space-4); font-size: var(--text-11); color: var(--slate-500); }
.error-text { margin-top: var(--space-4); font-size: var(--text-11); color: var(--danger-600); }

.checkbox    { width: var(--icon-sm); height: var(--icon-sm); accent-color: var(--brand-600); cursor: pointer; }
.check-label { display: inline-flex; align-items: center; gap: var(--space-6); font-size: var(--text-13); color: var(--slate-700); cursor: pointer; }

.field { margin-bottom: var(--space-10); }
.form-grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: var(--space-10) var(--space-14); }
@media (min-width: 768px) {
  .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* Only span on multi-column grids — spanning a 1-column grid would create phantom columns. */
  .field-span-2 { grid-column: span 2; }
  .field-span-4 { grid-column: span 4; }
}

/* Autosave indicator, written by js/actionflow.js showSaveIndicator(). */
.save-indicator { position: absolute; top: 50%; right: var(--space-8); transform: translateY(-50%);
                  width: var(--icon-xl); height: var(--icon-xl); display: flex; align-items: center; justify-content: center;
                  border-radius: 9999px; color: var(--on-brand); font-size: var(--text-12); font-weight: 700; line-height: 1;
                  pointer-events: none; }
.save-indicator.is-saving { border: 2px solid var(--brand-500); border-right-color: transparent; animation: af-spin .7s linear infinite; }
.save-indicator.is-ok     { background: var(--success-500); }
.save-indicator.is-error  { background: var(--danger-600); }
.save-indicator.is-fading { opacity: 0; transition: opacity .5s cubic-bezier(.4,0,.2,1); }
@keyframes af-pulse { 50% { opacity: .5; } }
.field-wrap { position: relative; }
.field-wrap .save-indicator { width: var(--icon-md); height: var(--icon-md); font-size: var(--text-10); right: var(--space-6); }
.field-wrap:has(.select) .save-indicator { right: var(--space-28); }

/* ===== 8. Tables ============================================================= */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--table-text-size); }
.table thead th { background: var(--slate-50); color: var(--slate-500); font-family: var(--font-mono); font-size: var(--text-11); font-weight: 500;
                  letter-spacing: .06em; text-transform: uppercase; text-align: left; padding: var(--space-6) var(--space-12); border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.table tbody td, .table tbody th { padding: var(--table-row-py) var(--space-12); color: var(--slate-700); border-bottom: 1px solid var(--slate-100); vertical-align: middle; line-height: 1.35; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover td, .table tbody tr:hover th { background: var(--brand-50); }
.table tbody tr[data-action-type] { cursor: pointer; }
.table tbody tr.selected td, .table tbody tr.selected th { background: var(--warning-tint); }
.table tfoot td, .table tfoot th { border-top: 1px solid var(--slate-200); padding: var(--table-row-py) var(--space-12); font-weight: 500; }
/* Codes (PO no., refs, item codes) stay monospace; amounts and dates follow --font-numeric. */
.table .td-primary { font-family: var(--font-mono); font-weight: 500; color: var(--slate-900); }
.table .td-primary, .table td.mono { font-size: var(--table-mono-size); }
.table .td-num     { text-align: right; font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.table .th-num     { text-align: right; }
.table .td-actions { text-align: right; white-space: nowrap; padding-top: var(--space-2); padding-bottom: var(--space-2); padding-left: var(--space-8); }
/* List pages put the actions column first (v33 convention), so it aligns left. */
.table .td-actions.lead { text-align: left; }
.table .td-actions .btn-icon { opacity: .7; width: var(--table-action-size); height: var(--table-action-size); }
.table tbody tr:hover .td-actions .btn-icon { opacity: 1; }
.table .td-actions .btn-icon:disabled, .table tbody tr:hover .td-actions .btn-icon:disabled { opacity: .3; }
.table-dense tbody td, .table-dense tbody th { padding: var(--space-4) var(--space-10); }
/* A real <button> so it is announced and focusable as clickable; reset to look like header text. */
.th-sort { display: inline-flex; align-items: center; gap: var(--space-4); cursor: pointer; user-select: none;
           font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit; color: inherit;
           background: none; border: 0; padding: 0; }
.th-sort:hover  { color: var(--slate-800); }
.th-sort.active { color: var(--brand-700); }
.th-sort svg { width: var(--icon-xs); height: var(--icon-xs); }
.row-num { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; color: var(--slate-400); font-size: var(--text-11); }
/* Fixed column widths (structural). */
.col-num     { width: 3rem; }
.col-actions { width: 5rem; }
.col-actions.wide { width: 7rem; }
.col-code    { width: 5.5rem; }
.col-pick    { width: 4.5rem; }


/* ===== 9. Results card: search panel ============================================ */
/* A results card is .card > search panel (pages/_ui/_searchpanel.cfm) > .card-header with
   the count and actions > table, tree or empty state > .pagination (styleguide.md section 5).
   The panel follows the card's rounded corners. */
.search-panel { border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.search-panel:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.search-panel:last-child { border-bottom: 0; border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.search-panel > summary { list-style: none; }
.search-panel > summary::-webkit-details-marker { display: none; }
.search-panel .sp-head { display: flex; align-items: center; gap: var(--space-8); padding: var(--space-6) var(--space-14); font-size: var(--text-12); font-weight: 500; color: var(--slate-600); cursor: pointer; }
.search-panel .sp-head svg { width: var(--icon-sm); height: var(--icon-sm); }
.search-panel .sp-head svg:last-child { margin-left: auto; transition: transform .15s; }
.search-panel:not([open]) > summary svg:last-child { transform: rotate(-90deg); }
.search-panel .sp-body { padding: var(--space-4) var(--space-14) var(--space-10); display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-8) var(--space-12); }
@media (min-width: 768px) { .search-panel .sp-body { grid-template-columns: repeat(6, minmax(0,1fr)); } }
.search-panel .sp-actions { display: flex; align-items: flex-end; gap: var(--space-6); }

/* ===== 10. Pagination ========================================================= */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-8);
              padding: var(--space-6) var(--space-14); border-top: 1px solid var(--slate-200); font-family: var(--font-mono); font-size: var(--text-12); color: var(--slate-500); }
.pagination .pages { display: flex; gap: var(--space-2); }
.pagination .page-btn { min-width: var(--control-xs); height: var(--control-xs); padding: 0 var(--space-6); display: inline-flex; align-items: center; justify-content: center;
                        border-radius: var(--radius-ctl); border: 1px solid transparent; color: var(--slate-600); background: transparent;
                        cursor: pointer; font: inherit; }
.pagination .page-btn:hover  { background: var(--slate-100); color: var(--slate-900); }
.pagination .page-btn.active { background: var(--brand-600); color: var(--on-brand); }
.pagination .page-btn svg { width: var(--icon-sm); height: var(--icon-sm); }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; }
/* Non-clickable page indicator (ellipsis, "3 / 12"). */
.pagination .page-btn.is-static, .pagination .page-btn.is-static:hover { cursor: default; background: transparent; color: var(--slate-600); }

/* ===== 11. Badges ============================================================= */
.badge { display: inline-flex; align-items: center; gap: var(--space-5); padding: 0 var(--space-6); border-radius: var(--radius-ctl);
         font-size: var(--text-11); font-weight: 500; line-height: 1.125rem; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: var(--space-5); height: var(--space-5); border-radius: 9999px; background: currentColor; opacity: .7; }
.badge-neutral   { background: var(--slate-100); color: var(--slate-600);  border-color: var(--slate-200); }
.badge-draft     { background: var(--warning-tint); color: var(--warning-ink); border-color: var(--warning-border); }
.badge-submitted { background: var(--info-tint); color: var(--info-ink); border-color: var(--info-border); }
.badge-info      { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.badge-approved  { background: var(--success-tint); color: var(--success-ink); border-color: var(--success-border); }
.badge-rejected  { background: var(--danger-tint); color: var(--danger-700); border-color: var(--danger-border); }

/* ===== 12. Stat cards ============================================================ */
.stat-card { display: flex; align-items: flex-start; gap: var(--space-12); padding: var(--space-14); background: var(--surface); border: 1px solid var(--slate-200);
             border-radius: var(--radius-card); transition: border-color .12s, box-shadow .12s; }
.stat-card[data-action-type]       { cursor: pointer; }
.stat-card[data-action-type]:hover { border-color: var(--brand-500); box-shadow: var(--shadow-raise); }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--icon-2xl); height: var(--icon-2xl); border-radius: var(--radius-ctl);
             background: var(--brand-50); color: var(--brand-600); flex-shrink: 0; }
.stat-icon svg { width: var(--icon-md); height: var(--icon-md); }
.stat-icon.amber   { background: var(--warning-tint); color: var(--warning-ink); }
.stat-icon.emerald { background: var(--success-tint); color: var(--success-ink); }
.stat-icon.sky     { background: var(--info-tint); color: var(--info-ink); }
.stat-label { font-size: var(--text-12); color: var(--slate-500); font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: var(--text-22); font-weight: 600; color: var(--slate-900); letter-spacing: -.02em; line-height: 1.2; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.stat-delta { font-family: var(--font-mono); font-size: var(--text-11); color: var(--slate-500); margin-top: var(--space-2); }

/* ===== 13. Empty state ========================================================= */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-32) var(--space-16); color: var(--slate-500); }
.empty-state.compact { padding: var(--space-20) var(--space-16); }
.empty-state svg    { width: var(--icon-2xl); height: var(--icon-2xl); color: var(--slate-300); margin-bottom: var(--space-8); }
.empty-state .title { font-size: var(--text-14); font-weight: 600; color: var(--slate-800); }
.empty-state .text  { margin-top: var(--space-2); font-size: var(--text-13); max-width: 28rem; }
.empty-state .btn   { margin-top: var(--space-12); }

/* ===== 14. Stepper (approval progress) =========================================== */
.stepper { display: flex; flex-direction: column; }
.stepper.horizontal { flex-direction: row; gap: var(--space-20); }
.step { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-5) 0; color: var(--slate-600); font-size: var(--text-13); position: relative; }
/* Vertical connector between stacked steps; geometry follows the 1.375rem dot. */
.step + .step::before { content: ""; position: absolute; left: .6875rem; top: -.3125rem; height: var(--space-8); width: 1px; background: var(--slate-300); }
.stepper.horizontal .step + .step::before { display: none; }
.step-dot { width: 1.375rem; height: 1.375rem; border-radius: 9999px; border: 1.5px solid var(--slate-300); display: inline-flex; align-items: center;
            justify-content: center; font-family: var(--font-mono); font-size: var(--text-11); font-weight: 600; color: var(--slate-500); background: var(--surface); flex-shrink: 0; }
.step-dot svg { width: var(--icon-xs); height: var(--icon-xs); }
.step-done            { color: var(--slate-500); }
.step-done .step-dot  { background: var(--brand-600); border-color: var(--brand-600); color: var(--on-brand); }
.step-active          { color: var(--slate-900); font-weight: 500; }
.step-active .step-dot{ border-color: var(--brand-600); color: var(--brand-700); background: var(--brand-50); }

/* ===== 15. Modal (ui.js showConfirm override) =================================== */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--space-16);
                  background: rgba(var(--overlay-rgb), .5); animation: af-fade .12s ease; }
.modal { width: 100%; max-width: 24rem; background: var(--surface); border: 1px solid var(--slate-200); border-radius: var(--radius-card); box-shadow: var(--shadow-modal); padding: var(--space-18) var(--space-20); animation: af-pop .15s ease; }
.modal-title   { font-size: var(--text-15); font-weight: 600; color: var(--slate-900); }
.modal-text    { margin-top: var(--space-6); font-size: var(--text-13); color: var(--slate-600); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-6); margin-top: var(--space-16); }

/* ===== 16. Toasts (ui.js replaces native alert()) ================================ */
/* The stack itself lets clicks through: a faded .toast-auto keeps its size (visibility:hidden),
   and without this the empty stack box covered the topbar icons (Log off) until a reload. */
.toast-stack { position: fixed; top: var(--space-12); right: var(--space-12); z-index: 60; display: flex; flex-direction: column; gap: var(--space-6); width: min(22rem, calc(100vw - 2 * var(--space-12))); pointer-events: none; }
.toast-stack .toast { pointer-events: auto; }
.toast { display: flex; align-items: flex-start; gap: var(--space-8); padding: var(--space-8) var(--space-10); background: var(--surface); border: 1px solid var(--slate-200);
         border-left: 3px solid var(--brand-600); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); font-size: var(--text-13); color: var(--slate-700); animation: af-slide .15s ease; }
.toast-ok    { border-left-color: var(--success-500); }
.toast-error { border-left-color: var(--danger-600); }
.toast svg { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; margin-top: var(--space-1); }
.toast-ok svg    { color: var(--success-500); }
.toast-error svg { color: var(--danger-600); }
.toast .close { margin-left: auto; color: var(--slate-400); cursor: pointer; background: none; border: 0; padding: 0; line-height: 1; }
.toast .close:hover { color: var(--slate-700); }
/* Server-rendered success toast (pages/nav/demo-flash.cfm): fades out by CSS after 4s, no JS */
.toast-auto { animation: af-slide .15s ease, af-toast-out .4s ease 4s forwards; }
@keyframes af-toast-out { to { opacity: 0; transform: translateX(8px); visibility: hidden; } }
#flash-stack { display: contents; }

/* ===== 16a. Busy (js/actionflow.js startBusy) ===================================== */
/* The one spinner. The engine puts it in the control that started a request, in place of
   its icon, after 300ms (at once for an upload); the autosave dot's saving state looks the
   same. Drawn in the control's own text colour, so it suits every button and theme.
   `rotate`, not `transform`: the autosave dot is already positioned with a transform. */
.spinner { display: inline-block; flex-shrink: 0; width: var(--icon-sm); height: var(--icon-sm); border: 2px solid currentColor; border-right-color: transparent;
           border-radius: 9999px; animation: af-spin .7s linear infinite; }
.spinner + svg { display: none; }
.btn-icon .spinner, .btn-lookup .spinner, .nav-item .spinner { width: var(--icon-md); height: var(--icon-md); }
.rail-item .spinner { width: var(--icon-lg); height: var(--icon-lg); }
[data-action-type][aria-busy="true"], label[aria-busy="true"] { cursor: progress; }
@keyframes af-spin { to { rotate: 360deg; } }

/* ===== 17. View transition ======================================================== */
#app-view > * { animation: af-fade .12s ease; }
@keyframes af-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes af-pop   { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes af-slide { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

/* ===== 18. Key/value list + section title ========================================== */
.kv    { display: grid; grid-template-columns: minmax(7rem, 10rem) 1fr; gap: var(--space-4) var(--space-12); font-size: var(--text-13); margin-top: var(--space-12); }
.kv dt { color: var(--slate-500); }
.kv dd { color: var(--slate-900); font-weight: 500; }
.kv dd.mono { font-family: var(--font-mono); }
/* A literal sample (file format, code) shown as typed. */
.code-sample { margin: var(--space-8) 0; padding: var(--space-10) var(--space-12); font-family: var(--font-mono); font-size: var(--text-12); background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius-ctl); white-space: pre; overflow-x: auto; }
.section-title { font-family: var(--font-mono); font-size: var(--text-11); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400); margin-bottom: var(--space-6); }

/* ===== 19. Auth / login ============================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand { background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand-900) 100%); color: var(--on-brand); padding: var(--space-40) var(--space-48);
              display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
/* Decorative circles — geometry, not theme. */
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border-radius: 9999px; background: rgba(var(--on-brand-rgb), .05); }
.auth-brand::before { right: var(--space-32); top: -10rem; width: 18rem; height: 18rem; }
.auth-brand::after  { right: -8rem; bottom: -8rem; width: 24rem; height: 24rem; background: rgba(var(--on-brand-rgb), .06); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand-mark { width: 2.5rem; height: 2.5rem; background: var(--surface); padding: 3px; }
.auth-brand .brand-name { color: var(--on-brand); font-size: var(--text-16); }
.auth-brand .brand-sub  { color: var(--brand-200); }
.auth-brand h1 { font-family: var(--font-serif); font-weight: 500; font-size: var(--text-28); line-height: 1.2; letter-spacing: -.01em; color: var(--on-brand); margin-top: var(--space-48); max-width: 24rem; }
.auth-brand ul { margin-top: var(--space-20); }
.auth-brand li { display: flex; gap: var(--space-10); align-items: flex-start; font-size: var(--text-14); color: rgba(var(--on-brand-rgb), .82); margin-top: var(--space-10); }
.auth-brand li svg { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; margin-top: var(--space-2); color: var(--brand-200); }
.auth-brand .foot { font-family: var(--font-mono); font-size: var(--text-11); color: rgba(var(--on-brand-rgb), .55); margin-top: var(--space-32); }
.auth-form { background: var(--surface); display: flex; align-items: center; justify-content: center; padding: var(--space-40) var(--space-24); }
.auth-form .box { width: 100%; max-width: 22rem; }
.auth-form h2 { font-family: var(--font-serif); font-weight: 500; font-size: var(--text-22); color: var(--slate-900); }
.auth-form .lead { color: var(--slate-500); margin: var(--space-4) 0 var(--space-20); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-brand { display: none; } }

/* ===== 20. Topbar & brand ============================================================ */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 20; display: flex; align-items: center; gap: var(--space-10);
          padding: 0 var(--space-12); background: var(--surface); border-bottom: 1px solid var(--slate-200); }
.topbar .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--control-md); height: var(--control-md); border-radius: var(--radius-ctl);
                    border: 0; background: transparent; color: var(--slate-500); cursor: pointer; }
.topbar .menu-btn:hover { background: var(--slate-100); color: var(--slate-900); }
.topbar .menu-btn svg { width: var(--icon-lg); height: var(--icon-lg); }

.brand      { display: flex; align-items: center; gap: var(--space-8); text-decoration: none; }
.brand-mark { width: var(--control-xs); height: var(--control-xs); border-radius: var(--radius-ctl); background: var(--surface); padding: 2px;
              display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-weight: 600; color: var(--slate-900); font-size: var(--text-14); letter-spacing: -.01em; line-height: 1.1; }
.brand-sub  { font-family: var(--font-mono); font-size: var(--text-10); color: var(--brand-600); letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; margin-top: var(--space-2); }

.company-switch { position: relative; margin-left: var(--space-12); }
.company-switch .select { height: var(--control-sm); font-size: var(--text-12); width: 14rem; padding-left: var(--space-28); }
.company-switch svg { position: absolute; width: var(--icon-sm); height: var(--icon-sm); left: var(--space-8); top: 50%; transform: translateY(-50%); color: var(--slate-400); pointer-events: none; }
.global-search { position: relative; margin-left: var(--space-12); }
.global-search .input { height: var(--control-sm); width: 16rem; padding-left: var(--space-28); font-size: var(--text-12); }
.global-search svg { position: absolute; left: var(--space-8); top: 50%; transform: translateY(-50%); width: var(--icon-sm); height: var(--icon-sm); color: var(--slate-400); }
.global-search kbd { position: absolute; right: var(--space-6); top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: var(--text-10); color: var(--slate-400); border: 1px solid var(--slate-200); border-radius: var(--radius-ctl); padding: 0 var(--space-4); background: var(--surface); }

.topbar-user { margin-left: auto; display: flex; align-items: center; gap: var(--space-8); }
.topbar-user .tb-icons   { display: flex; gap: var(--space-2); }
/* Theme menu: a native <details> dropping down from its top-bar icon. */
.theme-menu { position: relative; }
.theme-menu > summary { list-style: none; cursor: pointer; }
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu-list { position: absolute; right: 0; top: calc(100% + var(--space-4)); z-index: 30; display: grid; min-width: 10rem; padding: var(--space-4);
                   background: var(--surface); border: 1px solid var(--slate-200); border-radius: var(--radius-card); box-shadow: var(--shadow-raise); }
.theme-option { padding: var(--space-6) var(--space-10); text-align: left; font-size: var(--text-13); color: var(--slate-700); background: none; border-radius: var(--radius-ctl); cursor: pointer; }
.theme-option:hover { background: var(--slate-100); color: var(--slate-900); }
.theme-option[aria-current="true"] { color: var(--brand-700); font-weight: 600; }
.topbar-user .who        { text-align: right; line-height: 1.15; }
.topbar-user .who .name  { font-size: var(--text-12); font-weight: 600; color: var(--slate-800); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user .who .id    { font-family: var(--font-mono); font-size: var(--text-11); color: var(--slate-500); }
.avatar { width: var(--control-sm); height: var(--control-sm); border-radius: var(--radius-ctl); background: var(--brand-100); color: var(--brand-800); display: inline-flex;
          align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--text-11); font-weight: 600; flex-shrink: 0; }

/* ===== 21. Nav items (module panel) ==================================================== */
.nav-item { display: flex; align-items: center; gap: var(--space-8); width: 100%; padding: var(--space-5) var(--space-10); margin-bottom: 1px; border-radius: var(--radius-ctl);
            color: var(--slate-600); font-size: var(--text-13); font-weight: 500; text-decoration: none; background: transparent; border: 0; cursor: pointer;
            text-align: left; white-space: nowrap; position: relative; transition: background-color .1s, color .1s; }
.nav-item:hover { background: var(--slate-100); color: var(--slate-900); }
.nav-item svg   { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; color: var(--slate-400); transition: color .1s; }
.nav-item:hover svg { color: var(--slate-600); }
.nav-item.active     { background: var(--brand-50); color: var(--brand-700); }
.nav-item.active svg { color: var(--brand-600); }
.nav-item.active::before { content: ""; position: absolute; left: calc(-1 * var(--space-6)); top: var(--space-4); bottom: var(--space-4); width: 3px; background: var(--brand-600); }
.nav-item.danger:hover     { background: var(--danger-tint); color: var(--danger-600); }
.nav-item.danger:hover svg { color: var(--danger-600); }

.nav-badge:empty { display: none; }
.nav-badge { margin-left: auto; min-width: 1.125rem; height: 1.125rem; padding: 0 var(--space-5); border-radius: var(--radius-ctl); background: var(--brand-600); color: var(--on-brand);
             font-family: var(--font-mono); font-size: var(--text-10); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

/* ===== 22. Module rail ==================================================================== */
.sy-rail { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--rail-w); background: var(--brand-900); z-index: 12; overflow-y: auto; padding: var(--space-6) var(--space-4); scrollbar-width: none; }
.sy-rail::-webkit-scrollbar { display: none; }
.rail-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); width: 100%; height: var(--rail-item-h); border-radius: var(--radius-ctl); color: rgba(var(--on-brand-rgb), .62); border: 0; background: transparent; cursor: pointer; text-decoration: none; position: relative; }
.rail-item svg { width: var(--icon-lg); height: var(--icon-lg); }
.rail-item span { font-family: var(--font-mono); font-size: var(--text-9); letter-spacing: .04em; text-transform: uppercase; line-height: 1; }
.rail-item:hover { background: rgba(var(--on-brand-rgb), .08); color: var(--on-brand); }
.rail-item.active, .rail-item[aria-expanded="true"] { background: var(--brand-600); color: var(--on-brand); }
.rail-item:focus-visible { outline: 2px solid var(--on-brand); outline-offset: -2px; }
.rail-item .nav-badge { position: absolute; top: var(--space-2); right: var(--space-4); margin: 0; min-width: var(--icon-sm); height: var(--icon-sm); font-size: var(--text-9); background: var(--warning-500); color: var(--slate-900); }
.rail-sep { height: 1px; background: rgba(var(--on-brand-rgb), .1); margin: var(--space-6) var(--space-8); }

/* ===== 23. Module panel (slides over the content, never pushes it) ========================= */
.sy-panel { position: fixed; top: var(--topbar-h); left: var(--rail-w); bottom: 0; width: var(--panel-w); background: var(--surface); border-right: 1px solid var(--slate-200);
            z-index: 11; overflow-y: auto; padding: var(--space-8) var(--space-8) var(--space-16); box-shadow: var(--shadow-modal);
            transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
body.flyout-open .sy-panel { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }
.sy-panel-close { position: absolute; top: var(--space-8); right: var(--space-8); }
.sy-panel .panel-title { font-family: var(--font-serif); font-size: var(--text-15); font-weight: 500; color: var(--slate-900); padding: var(--space-8) var(--space-10) var(--space-4); }
.sy-panel .panel-sub { font-family: var(--font-mono); font-size: var(--text-10); color: var(--slate-400); padding: 0 var(--space-10) var(--space-8); text-transform: uppercase; letter-spacing: .06em; }
.sy-panel .nav-item { padding: var(--space-4) var(--space-10); font-weight: 400; font-size: var(--text-13); }
.sy-panel .nav-item.active { font-weight: 500; }
.sy-panel .nav-item .lock { margin-left: auto; width: var(--icon-xs); height: var(--icon-xs); color: var(--slate-300); }
.sy-panel .group-toggle { display: flex; align-items: center; width: 100%; padding: var(--space-8) var(--space-10) var(--space-2); background: none; border: 0; cursor: pointer; font-family: var(--font-mono); font-size: var(--text-10); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400); }
.sy-panel .group-toggle svg { margin-left: auto; width: var(--icon-xs); height: var(--icon-xs); }
/* Collapsible groups are native <details>/<summary> (no JS) */
.sy-panel details > summary { list-style: none; }
.sy-panel details > summary::-webkit-details-marker { display: none; }
.sy-panel details:not([open]) > summary svg { transform: rotate(-90deg); }

/* Click-away layer behind the panel */
.sy-backdrop { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; left: var(--rail-w); z-index: 10; background: rgba(var(--overlay-rgb), .28);
               opacity: 0; pointer-events: none; transition: opacity .2s ease; }
body.flyout-open .sy-backdrop { opacity: 1; pointer-events: auto; }

.sy-main { margin-left: var(--rail-w); padding: calc(var(--topbar-h) + var(--space-12)) var(--space-16) var(--space-16); min-height: 100vh; }

/* ===== 24. Breadcrumb ===================================================================== */
.crumbs { display: flex; align-items: center; gap: var(--space-6); font-family: var(--font-mono); font-size: var(--text-11); text-transform: uppercase; letter-spacing: .06em; color: var(--slate-400); margin-bottom: var(--space-4); }
.crumbs svg { width: var(--icon-xs); height: var(--icon-xs); }
.crumbs b { color: var(--slate-600); font-weight: 500; }

/* ===== 25. Lookups ========================================================== */
/* A joined control group: [prefix] [code] [name] [button|suffix]. Only the ends keep rounded corners. */
.lookup { display: flex; }
.lookup > :not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.lookup > :not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.lookup .lookup-code   { width: 7rem; flex: none; }
.lookup .lookup-prefix { width: 5rem; flex: none; }
.lookup .btn-lookup, .lookup .lookup-suffix { display: inline-flex; align-items: center; justify-content: center; width: var(--control-md); height: var(--control-md); border: 1px solid var(--slate-300); border-left: 0; border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; background: var(--slate-50); color: var(--slate-600); flex-shrink: 0; }
.lookup .btn-lookup { cursor: pointer; }
.lookup .btn-lookup:hover { background: var(--brand-50); color: var(--brand-700); }
.lookup .btn-lookup svg { width: var(--icon-sm); height: var(--icon-sm); }
.lookup .input-sm + .btn-lookup { height: var(--control-xs); }
.field-wrap:has(.btn-lookup) .save-indicator { right: calc(var(--control-md) + var(--space-6)); }

/* Lookup / search-select popup: the div starts empty and ActionFlow fills it. The core
   (v1.10.0) does not show/hide targets itself, so :empty does it. Its parent needs
   .af-popup-anchor. */
.af-popup-anchor { position: relative; }
.af-popup { position: absolute; z-index: 40; top: 100%; left: 0; margin-top: var(--space-4); }
.af-popup:empty { display: none; }
.af-popup-end { left: auto; right: 0; }
.lookup-panel { width: 30rem; border: 1px solid var(--slate-200); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-raise); }
.lookup-panel .lp-head { display: flex; gap: var(--space-6); padding: var(--space-8) var(--space-10); border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.lookup-panel .lp-head .input { height: var(--control-xs); font-size: var(--text-12); }
.lookup-panel .table-wrap { max-height: 14rem; overflow-y: auto; }
.lookup-panel .table-dense tbody td, .table-dense tbody th { padding: var(--space-4) var(--space-10); }
.lookup-panel .pagination { padding: var(--space-4) var(--space-10); }
@media (max-width: 720px) { .lookup-panel { width: min(30rem, calc(100vw - 2 * var(--space-16))); } }

/* ===== 26. Document window ================================================================= */
.doc { max-width: 70rem; margin: 0 auto; border: 1px solid var(--slate-200); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-modal); }
.doc.flat { box-shadow: none; }
.doc-head { display: flex; align-items: center; gap: var(--space-12); padding: var(--space-10) var(--space-14); border-bottom: 1px solid var(--slate-200); }
.doc-head .doc-title { font-family: var(--font-serif); font-size: var(--text-16); font-weight: 500; color: var(--slate-900); }
.doc-head .doc-ref { font-family: var(--font-mono); font-size: var(--text-12); color: var(--slate-500); }
.doc-head .doc-actions { margin-left: auto; display: flex; gap: var(--space-6); }
.tabs { display: flex; gap: var(--space-2); padding: 0 var(--space-14); border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.tab { padding: var(--space-8) var(--space-12); font-size: var(--text-13); font-weight: 500; color: var(--slate-500); border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--slate-800); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); background: var(--surface); }
.tab .cnt { font-family: var(--font-mono); font-size: var(--text-10); color: var(--slate-400); margin-left: var(--space-4); }
.doc-body { padding: var(--space-14); }
.doc-body .input[readonly], .doc-body .textarea[readonly] { background-color: var(--slate-50); color: var(--slate-700); cursor: default; }
/* Line entry strip: item code, description, UOM, charge code, qty, unit price, actions. */
.entry-strip { display: grid; grid-template-columns: 9rem minmax(0,1fr) 7rem 10rem 6rem 7rem auto; gap: var(--space-8); align-items: end; padding: var(--space-10) var(--space-14); background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius-card); margin-bottom: var(--space-10); }

/* Attachments: a native file input behind its label (the label is the button). */
.file-pick input:focus-visible + .btn { outline: 2px solid var(--brand-600); outline-offset: 1px; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-6); }
.file-list li { display: flex; align-items: center; gap: var(--space-8); }
.file-list svg { width: var(--icon-sm); height: var(--icon-sm); }

/* Standalone document window (doc.cfm): topbar only, no rail or module panel. */
.doc-window { padding: calc(var(--topbar-h) + var(--space-12)) var(--space-16) var(--space-16); min-height: 100vh; }
.doc-window .doc { max-width: none; box-shadow: none; }
.doc-window-shell .topbar .brand-sub { color: var(--slate-400); }

/* Field groups inside a document tab — the v33 fieldset/legend pattern, restyled. */
.fset { min-width: 0; margin: 0; padding: var(--space-4) var(--space-14) var(--space-8); border: 1px solid var(--slate-200); border-radius: var(--radius-card); background: var(--surface); }
.fset > legend { display: flex; align-items: center; gap: var(--space-4); margin-left: calc(-1 * var(--space-2)); padding: 0 var(--space-6); font-family: var(--font-mono); font-size: var(--text-11); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-700); }
.fset > legend .req { color: var(--danger-600); font-weight: 700; }
.fset-muted { background: var(--slate-50); }
.fset .field:last-child { margin-bottom: var(--space-2); }
.stack { display: grid; gap: var(--space-4); }

/* ===== 26a. Printable document (pages/purchasing/po-print.cfm) ============================ */
.print-actions { display: flex; align-items: center; gap: var(--space-12); max-width: 52rem; margin: 0 auto var(--space-12); }
.print-doc { max-width: 52rem; margin: 0 auto; padding: var(--space-32); background: var(--surface); border: 1px solid var(--slate-200); border-radius: var(--radius-card); font-size: var(--text-13); color: var(--slate-900); }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-24); padding-bottom: var(--space-16); border-bottom: 2px solid var(--slate-900); }
.print-title { margin: 0; font-family: var(--font-serif); font-size: var(--text-22); font-weight: 600; }
.print-sub { color: var(--slate-500); font-size: var(--text-12); }
.print-meta { display: grid; grid-template-columns: auto auto; gap: var(--space-2) var(--space-12); margin: 0; }
.print-meta dt { color: var(--slate-500); }
.print-meta dd { margin: 0; font-weight: 500; }
.print-parties { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-24); padding: var(--space-16) 0; }
.print-label { display: block; font-family: var(--font-mono); font-size: var(--text-10); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-500); margin-bottom: var(--space-2); }
.print-notes .print-label { display: inline; margin-right: var(--space-6); }
.print-strong { font-weight: 600; }
.print-table { margin-top: var(--space-8); }
.print-notes { display: grid; gap: var(--space-4); margin-top: var(--space-16); }
.print-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-24); margin-top: var(--space-48); font-size: var(--text-12); color: var(--slate-600); }
.print-sign-line { display: block; height: var(--space-40); border-bottom: 1px solid var(--slate-400); margin-bottom: var(--space-4); }
/* What reaches paper: only the document. Window chrome, buttons and toasts stay on screen. */
@media print {
  body { background: var(--surface); }
  .topbar, .print-actions, .toast-stack { display: none; }
  .doc-window { padding: 0; min-height: 0; }
  .print-doc { max-width: none; padding: 0; border: 0; }
  .print-table thead { display: table-header-group; }
  .print-table tr { break-inside: avoid; }
}

/* The decision being made, above an approval inbox. */
.decision-panel { border-color: var(--brand-200); box-shadow: var(--shadow-raise); }

/* ===== 26c. Grid entry (pages/costing/budget-edit.cfm) ================================== */
.grid-entry td { padding: var(--space-2) var(--space-4); }
.grid-entry .input { width: 6.5rem; }
.grid-row-head { text-align: left; white-space: nowrap; font-weight: 500; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.grid-add-select { width: 20rem; }

/* Payment matching (pages/accounting/payment-match.cfm). */
.match-totals { max-width: 22rem; }
.match-totals dd { text-align: right; }
.match-pay { width: 9rem; }

/* ===== 26b. Reports ===================================================================== */
.col-share { width: 14rem; white-space: nowrap; }
.share-meter { width: 8rem; height: var(--space-8); vertical-align: middle; }
.share-meter::-webkit-meter-bar { background: var(--slate-100); border: 0; border-radius: var(--radius-ctl); }
.share-meter::-webkit-meter-optimum-value { background: var(--brand-500); border-radius: var(--radius-ctl); }
.share-meter::-moz-meter-bar { background: var(--brand-500); }
/* Any screen prints without the app around it or its search panel. */
@media print {
  .sy-rail, .sy-panel, .sy-backdrop, .page-actions, .search-panel { display: none; }
  .sy-main { margin: 0; padding: 0; }
}

/* ===== 26d. Calendar, comparison matrix, tree ============================================ */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { padding: var(--space-6); font-size: var(--text-11); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); border-bottom: 1px solid var(--slate-200); }
.cal-day { height: 6.5rem; vertical-align: top; padding: var(--space-4); border: 1px solid var(--slate-100); }
.cal-out { background: var(--slate-50); color: var(--slate-400); }
.cal-today { box-shadow: inset 0 0 0 2px var(--brand-500); }
.cal-date { font-family: var(--font-numeric); font-size: var(--text-12); font-weight: 600; margin-bottom: var(--space-2); }
.cal-items { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.cal-item { display: block; width: 100%; padding: var(--space-1) var(--space-4); border: 0; border-radius: var(--radius-ctl); background: var(--brand-50); color: var(--brand-800);
            font: inherit; font-size: var(--text-11); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-item:hover { background: var(--brand-100); }
.cal-item:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 1px; }
.compare-sup { max-width: 9rem; white-space: normal; }
.compare-best { background: var(--success-tint); color: var(--success-ink); font-weight: 600; }
.compare tbody .grid-row-head, .compare tfoot .grid-row-head { white-space: normal; min-width: 14rem; }
.tree, .tree ul { list-style: none; margin: 0; padding-left: var(--space-16); }
.tree { padding-left: 0; }
.tree li { padding: var(--space-1) 0; font-size: var(--text-13); }
.tree summary { cursor: pointer; font-weight: 500; }
.tree summary:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.tree-leaf { padding-left: var(--space-14); }
.tree-num { color: var(--slate-500); font-size: var(--text-11); margin-right: var(--space-4); }
.tree-amt { color: var(--slate-600); margin-left: var(--space-6); }

/* ===== 26e. Charts (js/chart.js) ============================================================ */
/* The chart draws into this box; its height is the chart's height. Colours are --chart-*. */
.chart { position: relative; height: 16rem; }

/* ===== 27. Dashboard widgets =============================================================== */
.quick-links { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-8); }
.quick-link { display: flex; align-items: center; font-family: inherit; text-align: left; gap: var(--space-8); padding: var(--space-8) var(--space-10); border: 1px solid var(--slate-200); border-radius: var(--radius-card); background: var(--surface); font-size: var(--text-13); font-weight: 500; color: var(--slate-700); cursor: pointer; }
.quick-link:hover { border-color: var(--brand-500); color: var(--brand-700); }
.quick-link svg { width: var(--icon-md); height: var(--icon-md); color: var(--brand-600); }
.task-list { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.task { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-6) 0; border-bottom: 1px solid var(--slate-100); font-size: var(--text-13); }
.task:last-child { border-bottom: 0; }
.task .due { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-11); color: var(--slate-500); }

/* ===== 28. Small-screen / motion overrides ================================================= */
@media (prefers-reduced-motion: reduce) { .sy-panel, .sy-backdrop { transition: none; } }
/* reduced motion: the spinner fades in and out in place instead of turning */
@media (prefers-reduced-motion: reduce) { .spinner, .save-indicator.is-saving { animation: af-pulse 2s ease-in-out infinite; } }
@media (max-width: 640px) { :root { --panel-w: calc(100vw - var(--rail-w)); } .global-search, .company-switch { display: none; } }

/* ===== 29. Reference page chrome (pages/dev/reference.cfm) ================================== */
.demo-section { scroll-margin-top: 4rem; }
.swatch-caption { font-size: var(--text-12); font-weight: 600; color: var(--slate-500); margin-bottom: var(--space-4); }
.swatch-row { display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); gap: var(--space-8); margin-bottom: var(--space-12); }
.swatch { height: 2.5rem; border-radius: var(--radius-card); border: 1px solid rgba(var(--overlay-rgb), .06); }
.swatch-label { font-size: var(--text-11); color: var(--slate-500); margin-top: var(--space-4); font-family: var(--font-mono); }
/* Deliberately NOT tokenized: reproduces v33's old look for side-by-side legacy comparison. */
.legacy { display: inline-block; padding: var(--space-2) var(--space-8); font: 10pt calibri, sans-serif; border-radius: 3px; }
/* The real .auth layout, boxed at card size instead of full-screen. */
.auth.login-preview { min-height: 22rem; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--slate-200); }
.login-preview .auth-brand { padding: var(--space-28); }
.login-preview .auth-form { padding: var(--space-28); }
.icon-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr)); gap: var(--space-4); }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding: var(--space-8) var(--space-4); border: 1px solid transparent; border-radius: var(--radius-ctl); }
.icon-cell:hover { border-color: var(--slate-200); background: var(--slate-50); }
.icon-cell svg { width: var(--icon-xl); height: var(--icon-xl); color: var(--slate-700); }
.icon-cell span { font-family: var(--font-mono); font-size: var(--text-10); color: var(--slate-400); text-align: center; word-break: break-all; line-height: 1.2; }
