/* CloudPearl ERP — QBO-style shell (Phase 1 skeleton).
   Look: light grey content area, white cards, dark left nav, QBO-green accent. */
:root {
    --qbo-green: #2ca01c;
    --cp-blue: #2e6da4; /* CloudPearl product blue (avatar, #051) */
    --qbo-green-dark: #248517;
    --nav-bg: #393a3d;
    --nav-bg-hover: #4a4b4e;
    --page-bg: #f4f5f8;
    --card-bg: #ffffff;
    --text: #393a3d;
    --muted: #6b6c72;
    --border: #d4d7dc;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--page-bg);
    color: var(--text);
}
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 228px; flex: 0 0 228px;
    background: var(--nav-bg); color: #fff;
    display: flex; flex-direction: column; padding: 14px 0;
}
.brand { font-size: 20px; font-weight: 700; padding: 4px 20px 14px; }
.brand span { color: #8bd181; font-weight: 400; }
.create-btn {
    margin: 0 16px 14px; padding: 8px 0; text-align: center;
    background: var(--qbo-green); color: #fff; border-radius: 20px;
    text-decoration: none; font-weight: 600; font-size: 14px;
}
.create-btn:hover { background: var(--qbo-green-dark); }
/* + New menu (step 20) */
.new-menu { position: relative; display: flex; flex-direction: column; }
.new-menu .create-btn { border: none; cursor: pointer; font-family: inherit; width: calc(100% - 32px); }
.new-menu-panel {
    /* #084: FIXED, not absolute — the panel lives inside .sidebar,
       whose overflow-x:hidden clipped the 480px panel at the
       sidebar's 228px edge (the panel "opened but was cut off by
       the main panel"). Fixed positioning escapes every ancestor's
       overflow and stacking context; the anchor numbers track the
       +New button's spot at the top of the bar (brand + button).
       z-index 300 sits above the sidebar (60), the mobile backdrop
       (55), sticky tab strips (20) and the item dropdown (200). */
    position: fixed; top: 108px; left: 16px; z-index: 300; width: 480px; max-width: 86vw;
    max-height: calc(100vh - 128px); overflow-y: auto;
    background: #fff; color: #1d1f24; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 14px 16px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px 18px;
}
.new-menu-panel[hidden] { display: none; }
.new-menu-head {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin-bottom: 4px;
}
.new-menu-group a {
    display: block; padding: 4px 2px; color: #1d1f24; text-decoration: none; font-size: 14px;
}
.new-menu-group a:hover { color: var(--qbo-green-dark); text-decoration: underline; }
/* Global search (step 20) */
.topbar-search { margin: 0; }
.search-group { margin-top: 14px; }
.search-group h3 { margin: 0 0 6px; font-size: 15px; }
.search-hits { list-style: none; margin: 0 0 4px; padding: 0; }
.search-hits li { padding: 3px 0; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav a {
    display: block; padding: 9px 20px; color: #e8e9ea;
    text-decoration: none; font-size: 14px;
}
.nav a:hover { background: var(--nav-bg-hover); }
.nav a.active { background: var(--nav-bg-hover); border-left: 3px solid var(--qbo-green); padding-left: 17px; }
.sidebar-foot { margin-top: auto; padding: 12px 20px 0; font-size: 12px; color: #b7b8ba; }

/* Main */
.main { flex: 1; padding: 0 28px 28px; min-width: 0; }
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap;
    padding: 18px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
/* #057 breadcrumbs: a full-width second row inside the topbar —
   Module › Section › Current; links back to each level; wraps on
   mobile, targets stay tappable. */
.crumbs { flex: 1 1 100%; order: 99; margin-top: 8px; }
.crumbs ol {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    list-style: none; margin: 0; padding: 0; font-size: 13px;
}
.crumbs a { color: var(--qbo-link, #2e6da4); text-decoration: none; padding: 2px 0; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .crumb-current { color: var(--text); font-weight: 600; }
.crumbs .crumb-sep { color: var(--muted); }
.topbar h1 { font-size: 22px; font-weight: 600; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar input[type="search"] {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 4px; width: 220px;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--cp-blue); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}

/* Cards & panels */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.card-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card-value { font-size: 28px; font-weight: 600; margin-top: 6px; }
.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 18px; margin-bottom: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.stats-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.stat-chip {
    background: var(--page-bg); border: 1px solid var(--border); border-radius: 16px;
    padding: 6px 14px; font-size: 13px;
}
.stat-chip b { color: var(--qbo-green-dark); margin-left: 4px; }

/* Round 5 #104/#105/#106: dashboard panels as aligned tables.
   One shared shape: fixed numeric columns so counts line up
   vertically across panels; numbers right-aligned with thousands
   separators (formatted server-side); zeros print as 0. */
.dash-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13.5px; }
.dash-table th, .dash-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dash-table thead th { color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--border); }
.dash-table td.num, .dash-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dash-table col.col-num { width: 118px; }
.dash-table col.col-pct { width: 96px; }
.dash-table tbody tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); }
.dash-table td.sub { padding-left: 26px; color: var(--muted); }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
/* #191: Department Performance cards — one card per department
   with a chart-palette accent on top; each counter group renders
   as horizontal bars (dashboard.js ranks a group biggest-first
   and scales its bars to the group's largest value). Processed
   reads green, Waiting now amber, the by-warehouse split grey —
   the dashboard's own palette, no new colours. */
.perf-stage {
    background: var(--page-bg); border: 1px solid var(--border);
    border-top: 3px solid var(--border); border-radius: 6px;
    padding: 12px 14px 14px;
}
.perf-stage.perf-sales { border-top-color: #2ca01c; }
.perf-stage.perf-qaqc { border-top-color: #9b6dd6; }
.perf-stage.perf-warehouse { border-top-color: #4e9af1; }
.perf-stage.perf-shipping { border-top-color: #3aa99e; }
.perf-stage.perf-manufacturing { border-top-color: #f2b134; }
.perf-stage.perf-purchasing { border-top-color: #e0654f; }
.perf-stage h3 { font-size: 15px; margin: 0 0 10px; }
.perf-group + .perf-group { margin-top: 12px; }
.perf-group-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); margin-bottom: 4px;
}
.perf-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: 13.5px; }
.perf-label { flex: 0 0 138px; }
.perf-locations .perf-label { color: var(--muted); }
.perf-track { flex: 1; background: #e3e6ea; border-radius: 4px; height: 12px; overflow: hidden; }
.perf-fill { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .35s ease; }
.perf-fill.processed { background: var(--qbo-green); }
.perf-fill.waiting { background: #f2b134; }
.perf-fill.by-location { background: #8a94a6; }
.perf-value { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.perf-value a { color: var(--qbo-green-dark); text-decoration: none; }
.perf-value a:hover { text-decoration: underline; }
@media (max-width: 480px) {
    .dash-table col.col-num { width: 84px; }
    .dash-table col.col-pct { width: 70px; }
    .perf-grid { grid-template-columns: 1fr; }
}

/* Phase 1 step 1: forms, tables, login, admin screens */
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.topbar-link { color: var(--qbo-green-dark); text-decoration: none; font-size: 14px; }
.topbar-link:hover { text-decoration: underline; }

/* Step 21 (§3.17): comms bells, inbox, threads, notifications */
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px;
    border-radius: 9px; background: #c62f3b; color: #fff; font-size: 11px;
    font-weight: 700; text-align: center; line-height: 18px; vertical-align: 2px; }
.tbl tr.unread td { font-weight: 600; background: #f4f9f2; }
.msg-body { white-space: pre-wrap; margin: 8px 0 4px; }
.msg-meta { color: var(--muted); font-size: 13px; }
.receipt-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.receipt-list li { display: inline; margin-right: 12px; }
.logout-form { display: inline; }
.link-btn { background: none; border: none; color: var(--qbo-green-dark); font-size: 14px; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.alert { border-radius: 4px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.alert.ok { background: #e6f4e3; border: 1px solid #9ccc8f; color: #205a14; }
.alert.err { background: #fbe7e7; border: 1px solid #e0a3a3; color: #7a1616; }
.alert.warn { background: #fdf3e0; border: 1px solid #e8c47c; color: #6d4c00; }

.btn {
    display: inline-block; padding: 7px 16px; border: 1px solid var(--border);
    background: #fff; color: var(--text); border-radius: 20px; font-size: 14px;
    text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--page-bg); }
.btn.primary { background: var(--qbo-green); border-color: var(--qbo-green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--qbo-green-dark); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.block { width: 100%; text-align: center; }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.form.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; max-width: 860px; }

/* #065 (round 4) root-cause hardening, all in the shared sheet:
   - .form.two-col's bare 1fr tracks let a long <select> option
     inflate its track past the panel (the QA/QC NCR form measured
     1465px wide at a 1440px viewport; supplier COAs the same at
     1280px). Tracks become minmax(0, 1fr) — the #021 treatment the
     .form.wide grids already had — and grid children may shrink.
   - fieldset defaults to min-content sizing and will not shrink
     around wide contents (the shipment edit form measured 825px
     at 390px); reset it globally (addr-block already had it).
   - a <select> sizes to its longest option; cap form controls at
     their container so one long option cannot push a page wide
     (the sample form's sales-order select measured 481px at 390px). */
.form.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.two-col > * { min-width: 0; }

/* Product form (#073/#074/#075): checkbox clusters and the
   BOM / Attributes row editors inside the tabbed form. */
.check-row { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.bom-row, .attr-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end;
    padding: 10px 0; border-bottom: 1px solid var(--line, #e3e6ea); }
.bom-row label, .attr-row label { display: flex; flex-direction: column; gap: 5px;
    font-size: 13px; font-weight: 600; }
fieldset { min-width: 0; }
/* (select cap applies to EVERY form, not just .form ones: bare
   .form-grid forms like Samples have no .form class, and their
   long-option selects measured 481px at a 390px viewport.) */
form select, form textarea { max-width: 100%; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form select,
.form input[type="date"], .form input[type="number"], .form textarea {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; font-weight: 400;
}
.form textarea { resize: vertical; min-height: 64px; font-family: inherit; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.panel.narrow { max-width: 640px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl.matrix td { text-align: center; }
.tbl.matrix td:first-child { text-align: left; font-weight: 600; }
/* #065 (round 4): action bars WRAP — an unwrapped flex row of
   buttons pushed narrow pages sideways (customer detail at 390px
   measured 706px wide before this). */
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; }

.badge { font-size: 12px; padding: 2px 9px; border-radius: 10px; background: var(--page-bg); border: 1px solid var(--border); }
.badge.on { background: #e6f4e3; border-color: #9ccc8f; color: #205a14; }
.badge.off { background: #f1f1f3; color: var(--muted); }
.badge.warn { background: #fdf3e0; border-color: #e3c07a; color: #7a5410; }
.badge.bad { background: #fbe7e7; border-color: #e0a3a3; color: #8c1d1d; }

.settings-list { list-style: none; margin: 0; padding: 0; }
.settings-list li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.settings-list li:last-child { border-bottom: none; }
.settings-list a { color: var(--qbo-green-dark); text-decoration: none; }
.settings-list a:hover { text-decoration: underline; }
.settings-list .badge { margin-left: auto; }

.filter-form { display: flex; gap: 10px; align-items: end; margin-bottom: 10px; }
/* #053: the one search box per list — prominent, grows into the
   toolbar's free space (min 220px, wraps under on mobile).
   #061 drive-by fix on the same surface: the flex sizing belongs
   on the LABEL (the form's row-axis flex item); on the input
   itself — a child of the label's COLUMN flex — "flex: 1 1 220px"
   resolved the 220px basis as HEIGHT, rendering a 220px-tall
   search box on every list. The input now simply fills its label. */
.filter-form label:has(.list-search) { flex: 1 1 220px; max-width: 460px; }
.filter-form > .list-search { flex: 1 1 220px; max-width: 460px; }
.filter-form .list-search { width: 100%; }
.filter-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.filter-form input, .filter-form select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; font-weight: 400; }

/* Step 3: Jobs (QBO Projects + Phases/Cost Codes) */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th { text-align: left; padding: 7px 10px; width: 190px; color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em; vertical-align: top; }
.kv td { padding: 7px 10px; }
.tbl td.num, .tbl th.num, .kv td.num { text-align: right; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.sub-form { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.sub-form h3 { margin: 0 0 10px; font-size: 15px; }

/* Step 2: Report Centre */
.report-list { list-style: none; margin: 0; padding: 0; }
.report-row {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 0; border-bottom: 1px solid var(--border);
}
.report-row:last-child { border-bottom: none; }
.report-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.report-main a { color: var(--qbo-green-dark); text-decoration: none; font-weight: 600; font-size: 14px; }
.report-main a:hover { text-decoration: underline; }
.report-desc { color: var(--muted); font-size: 13px; }
.report-row .badge { white-space: nowrap; }
.star-btn {
    background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
    color: var(--qbo-green-dark); padding: 2px 4px;
}
.inline-form { display: inline; }
.report-form { flex-wrap: wrap; }
.report-form input[type="date"] {
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px;
}

/* Step 2: print views (printing platform) */
.print-body { background: #e9eaee; }
.print-toolbar {
    max-width: 900px; margin: 18px auto 0; display: flex; gap: 10px; align-items: center;
}
.print-sheet {
    background: #fff; max-width: 900px; margin: 14px auto 30px; padding: 42px 48px;
    box-shadow: 0 1px 6px rgba(0,0,0,.18);
}
.print-header { border-bottom: 2px solid var(--text); padding-bottom: 14px; margin-bottom: 18px; }
.print-brand { display: flex; gap: 14px; align-items: flex-start; }
.print-logo { max-height: 56px; max-width: 180px; }
.print-company { font-size: 20px; font-weight: 700; }
.print-address { font-size: 13px; color: var(--muted); }
.print-title { font-size: 24px; margin: 16px 0 2px; }
.print-subtitle { color: var(--muted); margin: 0 0 4px; font-size: 14px; }
.print-footer {
    border-top: 1px solid var(--border); margin-top: 22px; padding-top: 8px;
    font-size: 12px; color: var(--muted);
}
@media print {
    .no-print, .print-toolbar { display: none !important; }
    .print-body { background: #fff; }
    .print-sheet { box-shadow: none; margin: 0; max-width: none; padding: 0; }
    /* #055: page numbers belong in the @page margin box — the only
       place counter(page) is real. 1-based, running across the
       whole printed document (batch printouts included), styled
       like the print footer (12px muted). */
    @page {
        margin: 18mm 14mm;
        @bottom-right {
            content: "Page " counter(page);
            font-size: 12px; color: #68707a;
        }
    }
}

/* #045: batch print — each selected document starts on its own page. */
.batch-doc + .batch-doc { margin-top: 28px; }
@media print {
    .batch-doc { break-inside: avoid-page; }
    .batch-doc + .batch-doc { break-before: page; margin-top: 0; }
}

/* #046: the Trafa print layout family (style key CP) — Trafa's current
   forms: stacked company block left + big title right, small-caps
   meta rows, description-led line grid, terms beside the totals,
   centred jurisdiction footer. */
.cp-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.cp-brand { font-size: 10.5pt; line-height: 1.45; }
.cp-brand .cp-name { font-size: 13pt; font-weight: 700; }
.cp-brand img.cp-logo { height: 34px; margin-bottom: 4px; }
.cp-title { font-size: 24pt; font-weight: 600; text-align: right; line-height: 1.05; white-space: pre-line; }
.cp-blocks { display: flex; gap: 32px; margin: 10px 0 14px; }
/* #135: on the CP samples the address blocks are boxed with the
   label on a light blue-grey band (verified by word positions +
   renders on TSO/TU/TPS-028103 and TUP-016761). */
.cp-block { flex: 1; font-size: 10.5pt; line-height: 1.4; border: 1px solid #c7d0da; padding: 0 10px 8px; }
.cp-block h4 { margin: 0 -10px 6px; padding: 3px 10px; background: #e9eff6; font-size: 9pt; letter-spacing: .08em; color: #31587f; text-transform: uppercase; }
/* #064: CP's PO headings are title case ("To:" / "Ship To:") — the
   sales documents' headings are the uppercase ones. */
.cp-po-blocks .cp-block h4 { text-transform: none; letter-spacing: normal; font-size: 10.5pt; color: var(--text); }
/* #064: the block NAME prints in the stored data's own casing, as
   in CP (Trafa's customers are stored in caps; the PO vendor in
   TUP-014193 is title case) — no forced uppercase. */
.cp-block .cp-block-name { font-weight: 600; }
.cp-side { flex: 0 0 auto; font-size: 10.5pt; line-height: 1.5; }
.cp-side .cp-side-label { font-size: 8.5pt; letter-spacing: .08em; color: #444; text-transform: uppercase; margin-right: 6px; }
/* #135: the meta rows sit in a bordered, lightly tinted band on
   the CP samples. */
.cp-meta { display: flex; gap: 26px; flex-wrap: wrap; border: 1px solid #c7d0da; background: #f2f6fa; padding: 6px 10px; margin-bottom: 6px; }
.cp-meta .cp-cell { min-width: 90px; }
.cp-meta .cp-k { display: block; font-size: 8.5pt; letter-spacing: .07em; color: #444; text-transform: uppercase; }
.cp-meta .cp-v { display: block; font-size: 11pt; font-weight: 600; }
table.cp-lines { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.cp-lines th { text-align: left; font-size: 9pt; letter-spacing: .06em; color: #444; text-transform: uppercase; border-bottom: 1.5px solid #333; padding: 4px 6px; }
table.cp-lines td { padding: 5px 6px; font-size: 10.5pt; border-bottom: 1px solid #ddd; }
table.cp-lines .num { text-align: right; }
.cp-under { display: flex; gap: 30px; margin-top: 12px; }
.cp-terms { flex: 1.5; font-size: 8pt; line-height: 1.5; text-align: justify; color: #222; }
.cp-totals { flex: 1; }
.cp-totals table { width: 100%; border-collapse: collapse; }
.cp-totals td { padding: 3px 6px; font-size: 10.5pt; }
.cp-totals .cp-tk { text-align: right; letter-spacing: .05em; color: #444; text-transform: uppercase; font-size: 9pt; }
.cp-totals .cp-tv { text-align: right; font-weight: 600; }
.cp-totals .cp-grand td { border-top: 1.5px solid #333; font-size: 12pt; }
.cp-sign { display: flex; gap: 60px; margin-top: 42px; font-size: 10.5pt; }
.cp-sign .cp-sign-line { flex: 1; border-top: 1px solid #333; padding-top: 4px; }
.cp-footer { margin-top: 26px; text-align: center; font-size: 8pt; line-height: 1.5; color: #333; }
.cp-po-top { text-align: right; font-size: 11pt; line-height: 1.5; }
.cp-po-title { text-align: center; font-size: 20pt; font-weight: 700; letter-spacing: .12em; margin: 8px 0 14px; text-transform: uppercase; }

/* Step 22: print templates (§3.18) — the sheet carries the resolved
   template's layout family as a class and its accent colour as the
   --tpl-accent variable (inline style from PrintTemplateView). The
   seeded Standard template adds neither, so its render is unchanged. */
.print-tpl-form { max-width: 900px; margin: 10px auto 0; }
.print-tpl-picker { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.print-tpl-picker select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; }
.print-footer-note { margin-bottom: 6px; font-size: 13px; color: var(--text); }
.print-sheet.tpl-compact { padding: 22px 26px; font-size: 12px; }
.print-sheet.tpl-compact .print-header { padding-bottom: 8px; margin-bottom: 10px; }
.print-sheet.tpl-compact .print-company { font-size: 16px; }
.print-sheet.tpl-compact .print-title { font-size: 18px; margin: 8px 0 2px; }
.print-sheet.tpl-compact .print-address { font-size: 11px; }
.print-sheet.tpl-compact table.tbl td, .print-sheet.tpl-compact table.tbl th { padding: 3px 6px; }
.print-sheet.tpl-compact table.kv td, .print-sheet.tpl-compact table.kv th { padding: 2px 6px; }
.print-sheet.tpl-compact .print-footer { margin-top: 12px; }
.print-sheet.tpl-branded .print-header { border-bottom: 4px solid var(--tpl-accent, var(--text)); }
.print-sheet.tpl-branded .print-company { color: var(--tpl-accent, var(--text)); }
.print-sheet.tpl-branded .print-footer { border-top: 2px solid var(--tpl-accent, var(--border)); }
.print-sheet.tpl-accented .print-header { border-bottom: 3px solid var(--tpl-accent, var(--text)); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 34px 38px; width: 380px; max-width: 92vw; }
.login-card h1 { font-size: 22px; margin: 0 0 18px; }
.login-brand { color: var(--text); padding: 0 0 10px; }
.login-brand span { color: var(--qbo-green); }
.login-card .form { max-width: none; }
.center { text-align: center; }

/* Step 6: clickable tiles (E-commerce landing, QA/QC landing) */
a.card.tile { text-decoration: none; color: inherit; display: block; }
a.card.tile:hover { border-color: var(--qbo-green); }

/* ==================================================================
   Change round 1 (2026-10-14, owner testing feedback)
   #002: the shared item typeahead. The dropdown is position:fixed —
   item-autocomplete.js sets its left/top/width inline — so it escapes
   the overflow clipping of the scrolling table containers below.
   #003: responsive pass. Desktop rendering above is unchanged;
   everything narrow-screen lives in the media query at the bottom.
   ================================================================== */
.item-ac-wrap { position: relative; display: block; }
.item-ac-list {
    position: fixed; z-index: 200; max-height: 42vh; overflow-y: auto;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 10px 28px rgba(0,0,0,.22); padding: 4px 0;
}
.item-ac-row { padding: 8px 12px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.item-ac-row .item-ac-head { display: block; }
.item-ac-row .item-ac-meta { display: block; color: var(--muted); font-size: 12px; }
.item-ac-row:hover, .item-ac-row.active { background: #eef6ec; }
/* #067: the browse list's honest cap note ("First 100 items — …"). */
.item-ac-foot { padding: 6px 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }

/* Wide tables scroll horizontally inside this wrapper (added by
   app-ui.js) instead of crushing their columns on narrow screens.
   When nothing overflows it is invisible, so desktop is unchanged. */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* #102 (round 5): the mirrored scrollbar above wide tables. */
.tbl-scroll-top { overflow-x: auto; overflow-y: hidden; height: 16px; -webkit-overflow-scrolling: touch; }
.tbl-scroll-top-fill { height: 1px; }
@media print { .tbl-scroll { overflow: visible; } .tbl-scroll-top { display: none; } }

/* ============ Change round 1: sidebar system (#010), topbar (#013),
   user menu (#012), column chooser (#015), totals (#007),
   addresses (#005), charts (#009), QC lots (#017), logos (#011) ====
   Desktop sidebar is fixed; main content offsets by margin, so the
   tucked strip and its hover-expand overlay never move content. */
.shell { display: block; }
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    overflow-y: auto; overflow-x: hidden;
    transition: width .18s ease, transform .2s ease;
}
.main { margin-left: 228px; transition: margin-left .18s ease; }
.brand { display: flex; align-items: center; }
.brand-chip {
    background: #fff; border-radius: 6px; padding: 4px 8px;
    display: inline-flex; align-items: center;
}
.brand-logo { height: 26px; width: auto; display: block; }
.brand-mark {
    display: none; width: 36px; height: 36px; border-radius: 6px;
    background: #fff; padding: 2px;
}
/* Company (tenant) logo (#019): top bar right cluster, logo only. */
.topbar-company-logo {
    height: 32px; width: auto; max-width: 150px; object-fit: contain;
    display: block; flex: 0 1 auto; min-width: 0;
}
/* #051: the account pill — [company logo] [initial avatar] as one
   tight pair at the far right of the bar (Gmail/CP pattern).
   #060: the pill IS the button (.user-chip.account-pill) — the whole
   [logo][initial] pair is one clickable control for the user menu. */
.user-chip.account-pill {
    display: inline-flex; align-items: center; gap: 10px;
    border: 1px solid var(--border); border-radius: 999px;
    background: #fff; padding: 4px 6px 4px 12px; flex: 0 0 auto;
}
.user-chip.account-pill:hover { background: #f6f7f9; }
.user-chip.account-pill:focus-visible { outline: 2px solid var(--cp-blue); outline-offset: 2px; }

/* Accordion groups */
.nav a { display: flex; align-items: center; gap: 10px; }
.nav .ic { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-group-head {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: none; border: 0; color: #e8e9ea; font: inherit;
    font-size: 14px; padding: 9px 20px; cursor: pointer; text-align: left;
}
.nav-group-head:hover { background: var(--nav-bg-hover); }
.nav-group-head .chev { margin-left: auto; width: 14px; height: 14px; flex-basis: 14px; transition: transform .15s; }
.nav-group.open .nav-group-head .chev { transform: rotate(90deg); }
.nav-sub { list-style: none; margin: 0; padding: 0; display: none; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { padding-left: 48px; font-size: 13.5px; }
/* #133: CP's sub-menu (tile) headings inside a module group —
   small muted caps labels; they hide with their list in the
   tucked strip and on narrow screens like the links do. */
.nav-sub-head {
    padding: 12px 20px 3px 48px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .09em; text-transform: uppercase; color: #9aa3ab;
}

/* Tucked strip + hover-expand (desktop only) */
@media (min-width: 861px) {
    html.sidebar-tucked .main { margin-left: 64px; }
    html.sidebar-tucked .sidebar { width: 64px; flex-basis: 64px; }
    html.sidebar-tucked .sidebar .lbl,
    html.sidebar-tucked .sidebar .chev { display: none; }
    html.sidebar-tucked .brand { justify-content: center; padding: 4px 0 14px; }
    html.sidebar-tucked .brand-chip { display: none; }
    html.sidebar-tucked .brand-mark { display: block; }
    html.sidebar-tucked .nav-sub { display: none !important; }
    html.sidebar-tucked .nav a,
    html.sidebar-tucked .nav-group-head { justify-content: center; padding-left: 0; padding-right: 0; }
    html.sidebar-tucked .nav a.active { border-left: none; box-shadow: inset 3px 0 0 var(--qbo-green); padding-left: 0; }
    html.sidebar-tucked .new-menu { align-items: center; }
    html.sidebar-tucked .new-menu .create-btn { width: 40px; margin: 0 auto 14px; border-radius: 50%; padding: 9px 0; }
    html.sidebar-tucked .sidebar-foot { display: none; }

    html.sidebar-tucked .sidebar.expanded { width: 228px; box-shadow: 4px 0 18px rgba(0,0,0,.3); }
    html.sidebar-tucked .sidebar.expanded .lbl { display: inline; }
    html.sidebar-tucked .sidebar.expanded .chev { display: block; }
    html.sidebar-tucked .sidebar.expanded .brand { justify-content: flex-start; padding: 4px 20px 14px; }
    html.sidebar-tucked .sidebar.expanded .brand-chip { display: inline-flex; }
    html.sidebar-tucked .sidebar.expanded .brand-mark { display: none; }
    html.sidebar-tucked .sidebar.expanded .nav a,
    html.sidebar-tucked .sidebar.expanded .nav-group-head { justify-content: flex-start; padding: 9px 20px; }
    html.sidebar-tucked .sidebar.expanded .nav-sub a { padding-left: 48px; }
    html.sidebar-tucked .sidebar.expanded .nav a.active { border-left: 3px solid var(--qbo-green); box-shadow: none; padding-left: 17px; }
    html.sidebar-tucked .sidebar.expanded .nav-group.open .nav-sub { display: block !important; }
    html.sidebar-tucked .sidebar.expanded .new-menu { align-items: stretch; }
    html.sidebar-tucked .sidebar.expanded .new-menu .create-btn { width: calc(100% - 32px); margin: 0 16px 14px; border-radius: 20px; }
}

/* Topbar (#013): [toggle][title][search] ... [actions] */
.topbar { justify-content: flex-start; gap: 12px; }
.sidebar-toggle {
    background: none; border: 0; cursor: pointer; padding: 8px;
    color: var(--text); display: inline-flex; border-radius: 6px; flex: 0 0 auto;
}
.sidebar-toggle:hover { background: #eceef1; }
.topbar-actions { margin-left: auto; }
.topbar-search input[type="search"] {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 4px; width: 250px;
}
.topbar-link { position: relative; }

/* #061: as-you-type global search dropdown (fed by /search/suggest;
   groups mirror the step-20 results page). */
.topbar-search { position: relative; }
.search-suggest {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 95;
    width: min(430px, calc(100vw - 32px)); max-height: 62vh; overflow-y: auto;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px;
}
.search-suggest[hidden] { display: none; }
.ss-group-head {
    font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
    letter-spacing: .05em; padding: 8px 10px 3px;
}
.ss-row {
    display: block; padding: 7px 10px; border-radius: 4px; color: var(--text);
    text-decoration: none; cursor: pointer;
}
.ss-row .ss-detail { display: block; font-size: 12px; color: var(--muted); }
.ss-row.active, .ss-row:hover { background: #f1f2f4; }
.ss-empty { padding: 10px; color: var(--muted); font-size: 13.5px; }
.ss-footer {
    display: block; padding: 8px 10px; margin-top: 4px; border-top: 1px solid var(--border);
    color: var(--cp-blue); font-size: 13.5px; cursor: pointer;
}
.ss-footer.active, .ss-footer:hover { background: #f1f2f4; }

/* #061: the live list search's clear (x) reset, injected by app-ui.js
   next to the input inside its label. */
.list-search-wrap { position: relative; display: inline-flex; align-items: center; }
.list-search-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1;
    padding: 4px 6px; cursor: pointer; border-radius: 50%;
}
.list-search-clear:hover { color: var(--text); background: #eceef1; }

/* User menu (#012) */
.user-menu { position: relative; }
.user-chip {
    background: none; border: 0; cursor: pointer; font: inherit;
    color: var(--text); padding: 6px 8px; border-radius: 6px;
}
.user-chip:hover { background: #eceef1; }
.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--cp-blue); color: #fff; font-weight: 600; font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center;
}
/* #051: the full name lives in the dropdown as its header line
   (Gmail/CP pattern) — the bar itself shows the initial only. */
.user-menu-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.user-menu-head .avatar { width: 36px; height: 36px; font-size: 15px; }
.user-menu-head .um-name { font-weight: 600; font-size: 14px; }
.user-menu-head .um-sub { color: var(--muted); font-size: 12px; }
.user-menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 90;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 210px; padding: 6px;
}
.user-menu-panel[hidden] { display: none; }
.user-menu-panel a, .user-menu-panel button {
    display: block; width: 100%; text-align: left; padding: 9px 10px;
    color: var(--text); text-decoration: none; background: none; border: 0;
    font: inherit; font-size: 14px; cursor: pointer; border-radius: 4px;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: #f1f2f4; }

/* Column chooser (#015) */
.cols-menu { position: relative; display: inline-block; }
.cols-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 215px; padding: 10px 12px;
    color: var(--text); text-align: left;
}
.cols-panel[hidden] { display: none; }
.cols-panel label { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; cursor: pointer; }
.cols-panel .btn { margin-top: 8px; }

/* Totals panel (#007) */
.totals-panel {
    margin: 14px 0 4px auto; max-width: 340px;
    background: #fbfbfc; border: 1px solid var(--border);
    border-radius: 6px; padding: 10px 14px;
}
.totals-row { display: flex; justify-content: space-between; gap: 18px; padding: 3px 0; font-size: 14px; }
.totals-row output { font-variant-numeric: tabular-nums; }
.totals-row.grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; }

/* Address blocks (#005/#016) */
.addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 10px 0; }
.addr-block { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
fieldset.addr-block { margin: 0; min-width: 0; }
.addr-block legend { font-weight: 600; padding: 0 4px; }
.addr-block h4 { margin: 0 0 6px; }
.addr-block label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.addr-block input { width: 100%; margin-top: 3px; color: var(--text); }
.addr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Address autocomplete dropdown (#129). The host is the street
   input's label (positioned); the list floats under the input. */
.addr-ac-host { position: relative; }
.addr-ac-host-wrap { display: block; }
.addr-ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
    margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff;
    border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 8px 24px rgba(20, 30, 50, .16); max-height: 240px; overflow-y: auto; }
.addr-ac-list li { padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
.addr-ac-list li.active, .addr-ac-list li:hover { background: #eef4fb; }
.addr-lines span { display: block; }
.print-addr .addr-block { border: none; padding: 0 12px 0 0; }

/* Collapsible address blocks (#155): title + name + chevron when
   collapsed; the full field set / address lines when open. The
   hidden state is keyed on html.addr-js (set by app-ui.js) so the
   blocks stay fully visible without JavaScript. Print templates
   never carry data-addr-collapsible and always print in full. */
.addr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.addr-head h3, .addr-head h4 { margin: 0; }
.addr-name { font-weight: 600; flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-toggle { flex: 0 0 auto; width: 24px; height: 24px; padding: 0;
    border: 1px solid var(--border); border-radius: 4px; background: transparent;
    color: var(--muted); cursor: pointer; line-height: 1; font-size: 13px; }
.addr-toggle:hover { color: var(--text); border-color: var(--muted); }
.addr-toggle .chev { display: inline-block; transition: transform .15s ease; }
[data-addr-collapsible].open .addr-toggle .chev { transform: rotate(180deg); }
html.addr-js [data-addr-collapsible]:not(.open) .addr-body,
html.addr-js [data-addr-collapsible]:not(.open) .addr-lines { display: none; }
html.addr-js [data-addr-collapsible]:not(.open) .addr-head { margin-bottom: 0; }

/* #158: the SO detail's disabled Status field — the app's form-field
   styling, greyed as a disabled control is. */
.kv input.status-field { padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 14px; font-weight: 600; width: 280px; max-width: 100%;
    background: #eef1f4; color: var(--muted); cursor: not-allowed; }

/* Status line on document forms (#006) */
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }

/* Item info in line rows (#004) */
.item-info { margin-top: 4px; }
.item-info .item-name { font-weight: 600; font-size: 13px; }
.item-info .item-desc, .line-desc { font-size: 12.5px; color: var(--muted); }
.item-info .item-meta { font-size: 12px; color: var(--muted); }
.line-total { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Dashboard charts (#009) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
/* Round 6 #125: Sales Order Stats + Orders by Stage pie — one row.
   Round 7 #149: Orders by Stage (bars) joins the row — three equal
   columns on desktop, two under 1200px, stacked on narrow screens. */
.dash-stats-row { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1200px) { .dash-stats-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .dash-stats-row { grid-template-columns: 1fr; } }
.chart { width: 100%; height: auto; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.bar-a { fill: var(--qbo-green); }
.bar-b { fill: #8a94a6; }
.bar-sales { fill: var(--qbo-green); }
.bar-aging { fill: #4e9af1; }
.bar-income { fill: var(--qbo-green); }
.bar-expense { fill: #e0654f; }
.bar-value { font-size: 12px; fill: var(--text); }
.bar-label { font-size: 12.5px; fill: var(--muted); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.swatch.bar-income { background: var(--qbo-green); }
.swatch.bar-expense { background: #e0654f; }
.doughnut-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.doughnut { width: 180px; flex: 0 0 180px; }
.doughnut-total { font-size: 13px; fill: var(--muted); }
.doughnut-total-v { font-size: 16px; font-weight: 700; fill: var(--text); }
.chart-legend { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.chart-legend li { padding: 3px 0; display: flex; gap: 6px; align-items: center; }
.chart-legend .swatch { margin: 0; }
.hbar-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13.5px; }
.hbar-label { flex: 0 0 150px; color: var(--muted); }
.hbar-track { flex: 1; background: #eceef1; border-radius: 4px; height: 14px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; }

/* #063 (round 4) — the HOME dashboard fits its screen again: the
   #026 pies were full-column SVGs with single-column legends
   (829px per panel at 1440). They now take the #059 module-strip
   treatment, and the other chart cards shed padding/height
   sensibly — chart TYPES, data, labels and values unchanged. All
   rules are scoped to the dashboard's own classes. */
.dash-cards .card { padding: 12px 14px; }
.dash-cards .card-value { font-size: 24px; margin-top: 4px; }
.chart-grid .chart-panel { padding: 14px 16px; }
.chart-grid-bars svg.chart { max-height: 190px; }
.chart-grid-bars .doughnut { width: 140px; flex: 0 0 140px; }
.compact-pies .doughnut-wrap { flex-wrap: nowrap; gap: 10px; align-items: flex-start; }
.compact-pies svg.chart { width: 120px; height: 120px; flex: 0 0 120px; }
.compact-pies .chart-legend {
    font-size: 11.5px; display: grid; grid-template-columns: auto auto;
    column-gap: 14px; row-gap: 0;
}
.compact-pies .chart-legend li { padding: 0 0 1px; }
.compact-pies .chart-legend .legend-total { margin-top: 2px; padding-top: 3px; }
@media (max-width: 860px) {
    /* One legend column on phones — two would squeeze the names. */
    .compact-pies .chart-legend { grid-template-columns: auto; }
    .compact-pies .doughnut-wrap { flex-wrap: wrap; }
}

/* QC lot approval (#017) */
.qc-line { border-top: 1px solid var(--border); padding: 10px 0; }
.qc-line:first-of-type { border-top: none; }
.qc-assign { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-top: 8px; }
.qc-assign label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.qc-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }
.coa-up { display: inline-flex; gap: 6px; align-items: center; }

/* Logos (#011) */
.login-logo { max-width: 230px; height: auto; }
.company-logo-preview { max-height: 70px; max-width: 280px; object-fit: contain; }
.logo-preview { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.shop-logo { max-height: 32px; max-width: 120px; object-fit: contain; margin-right: 8px; vertical-align: middle; }

/* ================================================================
   Change round 2 (2026-10-14)
   ================================================================ */

/* #021 — full-width document forms. The base .form cap (520px)
   stays for small single-purpose forms; composite document forms
   carry .wide and span the panel. .form-grid (the fields container
   on invoice / bill / PO / credit-memo forms) finally gets its
   grid: two columns on desktop. */
.form.wide { max-width: none; }
.form.wide.two-col, .form.wide .form.two-col { max-width: none; }
.form.wide .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.form.wide .form-grid > label { min-width: 0; }

/* Document head. #020 originally put the fields column BESIDE
   Bill To / Ship To (sales) or Remit To / Ship To (PO); #128
   (round 6, CP placement parity) restructures it: the party
   selector with the two address blocks stacked DIRECTLY BENEATH
   it forms the left column (.doc-party), the remaining header
   fields sit in the right column (.doc-fields). Narrow widths
   stack everything (see the 860px rules). */
.doc-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 14px 22px; align-items: start; }
.doc-head .doc-party { display: grid; gap: 14px; align-content: start; min-width: 0; }
.doc-head .doc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; min-width: 0; }
.doc-head .doc-fields.single { grid-template-columns: minmax(0, 1fr); }
.doc-head .doc-fields > label { min-width: 0; }
.doc-head .addr-block { margin: 0; min-width: 0; }
@media (max-width: 1200px) and (min-width: 861px) {
    .doc-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* #022 — smart line-grid proportions. Fixed layout; the
   description column takes whatever the named columns leave, qty
   stays compact, numerics right-align. Per-grid colgroups pick
   the columns they actually have. */
.tbl-lines { table-layout: fixed; width: 100%; }
.tbl-lines col.col-item { width: 16%; }
.tbl-lines col.col-desc { width: auto; }
.tbl-lines col.col-qty { width: 8%; }
.tbl-lines col.col-price { width: 11%; }
.tbl-lines col.col-disc { width: 8%; }
.tbl-lines col.col-tax { width: 8%; }
.tbl-lines col.col-amount { width: 12%; }
.tbl-lines col.col-uom { width: 7%; }
.tbl-lines col.col-class { width: 10%; }
.tbl-lines col.col-status { width: 11%; }
.tbl-lines col.col-check { width: 6%; }
.tbl-lines col.col-wide { width: 20%; }
.tbl-lines col.col-action { width: 44px; }
.tbl-lines td input:not([type="checkbox"]), .tbl-lines td select { width: 100%; min-width: 0; }
.tbl-lines td.num input { text-align: right; }

/* #023 — drag-resize handles on resizable tables. */
table[data-cols] th { position: relative; }
.col-resize-handle { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 3; }
.col-resize-handle:hover, .col-resize-handle.dragging { background: rgba(44, 160, 28, .25); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing * { cursor: col-resize !important; }

/* #026 — pie legend total row. */
.chart-legend .legend-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; font-weight: 600; }

/* #027 — module mini dashboards. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-card { margin-bottom: 0; }
.kpi-label { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { margin: 4px 0 2px; font-size: 26px; font-weight: 700; }
.kpi-sub { margin: 0; font-size: 12.5px; }

/* #059 — the module strip as a SLIM summary band (scoped: the home
   dashboard's full-size cards/charts keep the rules above). */
.module-strip {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 10px 14px; margin-bottom: 14px;
}
.module-strip .ms-row { display: flex; gap: 20px; align-items: center; }
.module-strip .ms-kpis {
    display: flex; flex-wrap: wrap; gap: 6px 26px; flex: 1 1 auto; min-width: 0;
}
.module-strip .ms-kpi { display: flex; flex-direction: column; line-height: 1.15; }
.module-strip .ms-kpi-value { font-size: 18px; font-weight: 700; }
.module-strip .ms-kpi-label {
    font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.module-strip .ms-kpi-sub { font-size: 11.5px; color: var(--muted); }
.module-strip .ms-chart { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; }
.module-strip .ms-chart-title {
    margin: 0; font-size: 11px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
}
.module-strip .pie-wrap { margin: 0; }
.module-strip .doughnut-wrap { flex-wrap: nowrap; gap: 10px; }
.module-strip svg.chart { width: 120px; height: 120px; flex: 0 0 120px; }
/* The legend is the strip's tall element (one row per slice) — in
   the strip it runs in TWO tight columns beside the thumbnail pie
   so a 9-slice chart stays ~5 rows tall. The home dashboard keeps
   the single-column legend. */
.module-strip .chart-legend {
    font-size: 11.5px; display: grid; grid-template-columns: auto auto;
    column-gap: 14px; row-gap: 0;
}
.module-strip .chart-legend li { padding: 0 0 1px; }
.module-strip .chart-legend .legend-total { margin-top: 2px; padding-top: 3px; }
.module-strip .ms-line {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
    margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border);
    font-size: 13px;
}
.module-strip .ms-line-label {
    font-size: 11px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em; margin-right: 2px;
}
.module-strip .ms-line .stat-chip { margin: 0; }
.module-strip .ms-link-item + .ms-link-item::before { content: "·"; margin-right: 8px; color: var(--muted); }
.module-strip .ms-links .ms-line-label:not(:first-child) { margin-left: 14px; }
@media (max-width: 860px) {
    .module-strip .ms-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .module-strip .ms-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
    .module-strip .ms-chart { align-items: center; }
}
.link-chip { text-decoration: none; color: inherit; }
.link-chip:hover { border-color: var(--qbo-green); }
.mod-links { list-style: none; margin: 0 0 14px; padding: 0; }
.mod-links li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.mod-links li:last-child { border-bottom: none; }

/* #028 — spec editor rows. */
.spec-editor-rows { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.spec-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: end; }
.spec-row label { min-width: 0; }
.spec-copy { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 10px 0; }
.spec-copy label { min-width: 0; }

/* #030 — in-page detail tabs. */
.tab-strip { position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; overflow-x: auto;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 6px; margin-bottom: 16px; scrollbar-width: thin; }
.tab-btn { flex: 0 0 auto; border: none; background: transparent; padding: 8px 14px;
    border-radius: 4px; font-size: 14px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tab-btn:hover { background: #f0f2f5; color: var(--text); }
.tab-btn.active { background: var(--qbo-green); color: #fff; font-weight: 600; }
.tab-badge { display: inline-block; margin-left: 7px; min-width: 18px; padding: 1px 5px;
    border-radius: 9px; background: #b7791f; color: #fff; font-size: 11px;
    font-weight: 700; text-align: center; vertical-align: 1px; }
.tab-btn.active .tab-badge { background: #fff; color: #b7791f; }
[data-tab-panel][hidden] { display: none !important; }



@media (max-width: 860px) {
    /* Sidebar becomes an off-canvas drawer (#010 unifies #003):
       hidden by default, slides in over a backdrop via the topbar
       hamburger (html.sidebar-open). */
    .sidebar { transform: translateX(-105%); width: 252px; }
    html.sidebar-open .sidebar { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.35); }
    .sidebar-backdrop {
        position: fixed; inset: 0; z-index: 55;
        background: rgba(20,20,25,.45);
    }
    .new-menu .create-btn { padding: 10px 0; }
    /* #084: with position:fixed (see base rule) left/right pin the
       panel to the viewport edges on phones — full width, on top. */
    .new-menu-panel { left: 8px; right: 8px; width: auto; max-width: none; }

    /* Topbar (#013): title + actions on row one, search wraps to
       a full-width second row so it stays reachable on phones. */
    .topbar-search { order: 3; flex: 1 1 100%; }
    .topbar-search input[type="search"] { width: 100%; }
    .tb-lbl { display: none; }

    /* Shrink-proof form controls (#003 overflow fix): selects and
       inputs may not force the column wider than the screen. */
    .form label, .filter-form label { min-width: 0; }
    .form select, .form textarea,
    .form input:not([type="checkbox"]):not([type="radio"]),
    .filter-form select, .filter-form input { min-width: 0; max-width: 100%; }

    .addr-grid { grid-template-columns: 1fr; }
    /* Round 2 mobile: document forms stack (#021), the doc head
       stacks fields over the address blocks (#020), and line grids
       keep their proportions inside the scroll wrapper (#022). */
    .form.wide .form-grid { grid-template-columns: 1fr; }
    .doc-head { grid-template-columns: 1fr; }
    .doc-head .doc-fields { grid-template-columns: 1fr; }
    .tbl-scroll .tbl-lines { min-width: 720px; }
    .spec-row { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .totals-panel { max-width: none; }
    .cols-panel { position: fixed; left: 12px; right: 12px; top: auto; }

    .main { margin-left: 0; padding: 0 12px 20px; }
    .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 12px 0 10px; margin-bottom: 14px; }
    .topbar h1 { font-size: 20px; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-actions { order: 2; flex-wrap: nowrap; gap: 8px 12px; margin-left: 0; }
    /* #019: company logo shrinks a step on phones so the user
       menu always stays on-screen; the search row (order 3)
       absorbs the remaining width pressure. */
    .topbar-company-logo { height: 28px; max-width: 100px; }
    .topbar-search { order: 3; flex: 1 1 100%; }
    .topbar input[type="search"] { width: 100%; }
    .panel { padding: 12px; }
    .panel.narrow { max-width: none; }

    /* Forms stack; two-column grids go single column. */
    .form { max-width: none; }
    .form.two-col { grid-template-columns: 1fr; max-width: none; }
    .filter-form { flex-wrap: wrap; }
    .filter-form label { flex: 1 1 140px; }
    .form-actions { flex-wrap: wrap; }

    /* 16px inputs stop iOS Safari's focus auto-zoom; ~40px targets. */
    .form input[type="text"], .form input[type="email"], .form input[type="password"],
    .form input[type="date"], .form input[type="number"], .form select, .form textarea,
    .filter-form input, .filter-form select,
    .topbar input[type="search"], .report-form input[type="date"],
    .print-tpl-picker select { font-size: 16px; }
    .btn { min-height: 40px; padding: 9px 18px; display: inline-flex; align-items: center; }
    .btn.small { min-height: 36px; }
    .item-ac-row { padding: 11px 12px; font-size: 15px; }

    .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .card-value { font-size: 24px; }
    .kv th { width: 38%; }
    .tbl-scroll .tbl { min-width: 560px; }
    .print-sheet { padding: 20px 16px; }
    .print-toolbar { flex-wrap: wrap; padding: 0 10px; }
    .login-card { padding: 26px 20px; }
}

/* #045: list batch print */
.batch-print-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.batch-check { width: 44px; text-align: center; }
.batch-print-one { font-size: 11px; }

/* #047: product labels */
.lbl-organic { padding: 0.14in 0.16in; text-align: center; font-family: Arial, sans-serif; }
.lbl-organic .lbl-product { font-size: 13pt; font-weight: 700; margin-bottom: 2px; }
.lbl-organic .lbl-code { font-size: 10pt; margin-bottom: 10px; }
.lbl-organic .lbl-row { display: flex; justify-content: space-between; font-size: 10pt; margin-top: 7px; }
.lbl-kosher { padding: 0.12in; text-align: center; font-family: Arial, sans-serif; }
.lbl-kosher .lbl-banner { width: 100%; height: 1.05in; object-fit: contain; }
.lbl-kosher .lbl-product { font-size: 20pt; font-weight: 700; margin-top: 8px; }
.lbl-kosher .lbl-name { font-size: 12pt; margin-bottom: 10px; }
.lbl-kosher .lbl-fields { font-size: 12.5pt; line-height: 1.65; text-align: left; margin: 0 0.25in; }
.lbl-kosher .lbl-kosher-mark { font-size: 17pt; font-weight: 700; letter-spacing: .25em; margin-top: 12px; }
.lbl-ship { padding: 0.18in 0.25in; font-family: Arial, sans-serif; }
.lbl-ship .lbl-banner { width: 100%; height: 1.35in; object-fit: contain; }
.lbl-ship .lbl-product { font-size: 30pt; font-weight: 700; margin-top: 6px; }
.lbl-ship .lbl-name { font-size: 15pt; margin-bottom: 12px; }
.lbl-ship .lbl-row { display: flex; gap: 60px; font-size: 15pt; margin-top: 9px; }
.lbl-ship .lbl-sn { position: absolute; right: 0.25in; bottom: 0.18in; font-size: 13pt; font-weight: 700; }

/* Round 4 #093: BOM selection preview (bom-preview.js) + #089:
   inside the two-col ticket form the preview and the actions span
   the full grid width. */
.bom-preview { border: 1px solid var(--border, #d7dce2); border-radius: 8px; padding: 10px 12px; }
.bom-preview h3 { margin: 0 0 8px; font-size: 14px; }
.form.two-col > .bom-preview, .form.two-col > .form-actions { grid-column: 1 / -1; }
tr.bom-preview-row td.bom-preview-cell { font-size: 12px; background: #f7f9fb; padding: 4px 10px; }

/* #138: colour chooser + swatches. */
.color-chooser { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.color-swatch, .color-swatch-live { display: inline-block; width: 14px; height: 14px;
    border: 1px solid #999; border-radius: 3px; vertical-align: -2px; margin-right: 4px;
    background: transparent; }
.color-chooser .color-new-fields input[type="color"] { width: 38px; height: 26px; padding: 0; }

/* #137: sortable column headers */
table.tbl th.sortable { cursor: pointer; }
table.tbl th.sortable:hover { text-decoration: underline; }
table.tbl th.sorted-asc::after, table.tbl th.sorted-desc::after {
    content: attr(data-sort-ind); margin-left: 4px; font-size: 10px; color: #2563eb;
}
