/* X-tream Business System — standalone admin (ported from the Muse system).
   Clean white background, near-black text, orange accent (#ea580c). */
:root{
  --bs-accent:#ea580c; --bs-accent-hi:#f97316; --bs-accent-soft:#fdf0e4;
  --bs-ink:#17181c; --bs-muted:#5b6470; --bs-line:#e4e4e7; --bs-bg:#ffffff;
  --bs-soft:#fafafa; --bs-green:#15803d; --bs-red:#b91c1c; --bs-amber:#b45309;
}
*{box-sizing:border-box}
body.bs-body{margin:0;background:var(--bs-bg);color:var(--bs-ink);
  font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;font-size:15px}
.bs-shell{display:grid;grid-template-columns:232px 1fr;min-height:100vh}
.bs-side{border-right:1px solid var(--bs-line);padding:18px 14px;position:sticky;top:0;height:100vh;overflow-y:auto;background:#fff}
.bs-side .bs-logo{width:158px;display:block;margin:2px 6px 6px}
.bs-side .bs-sysname{font-weight:700;font-size:13.5px;color:var(--bs-ink);margin:0 6px 2px}
.bs-side .bs-role{margin:0 6px 14px;font-size:12.5px;color:var(--bs-muted)}
.bs-role b{color:var(--bs-accent)}
.bs-nav a{display:block;padding:8px 10px;border-radius:8px;color:var(--bs-ink);font-weight:600;font-size:14.5px;text-decoration:none}
.bs-nav a:hover{background:var(--bs-soft);text-decoration:none}
.bs-nav a.on{background:var(--bs-accent-soft);color:var(--bs-accent)}
.bs-nav .bs-nav-sep{border-top:1px solid var(--bs-line);margin:10px 4px}
.bs-main{padding:24px 30px 60px;min-width:0}
.bs-main h1{font-size:24px;margin:0 0 4px}
.bs-main h2{font-size:18px;margin:26px 0 10px}
.bs-main h3{font-size:15.5px;margin:18px 0 8px}
.bs-sub{color:var(--bs-muted);margin:0 0 16px}
a{color:var(--bs-accent);text-decoration:none}
a:hover{text-decoration:underline}
.bs-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:14px;margin:16px 0}
.bs-card{border:1px solid var(--bs-line);border-radius:12px;padding:16px 18px;background:#fff}
.bs-card .v{font-size:23px;font-weight:700}
.bs-card .l{color:var(--bs-muted);font-weight:600;font-size:13.5px}
.bs-card .s{color:var(--bs-muted);font-size:13px;margin-top:2px}
.bs-panel{border:1px solid var(--bs-line);border-radius:12px;padding:18px 20px;margin:16px 0;background:#fff}
.bs-table{width:100%;border-collapse:collapse;font-size:14.5px}
.bs-table th,.bs-table td{padding:8px 10px;border-bottom:1px solid var(--bs-line);text-align:left;vertical-align:top}
.bs-table th{color:var(--bs-muted);font-weight:600;font-size:13px}
.bs-table tr:hover td{background:var(--bs-soft)}
.num{text-align:right !important;font-variant-numeric:tabular-nums;white-space:nowrap}
.bs-badge{display:inline-block;padding:2px 9px;border-radius:999px;font-size:12px;font-weight:700;background:#f1f1f4;color:var(--bs-ink)}
.bs-badge.open{background:#fdf0e4;color:var(--bs-accent)}
.bs-badge.overdue{background:#fdecec;color:var(--bs-red)}
.bs-badge.done{background:#e5f4ea;color:var(--bs-green)}
.bs-badge.void{background:#ececf0;color:var(--bs-muted)}
.bs-badge.info{background:#e7f3fb;color:#0b4a6b}
.btn{display:inline-block;height:38px;line-height:38px;padding:0 16px;border-radius:9px;border:none;
  background:var(--bs-accent);color:#fff;font-weight:600;font-size:14.5px;cursor:pointer;text-align:center}
.btn:hover{text-decoration:none;background:var(--bs-accent-hi)}
.btn.ghost{background:#fff;color:var(--bs-ink);border:1px solid #cbd5e1}
.btn.ghost:hover{background:var(--bs-soft)}
.btn.small{height:32px;line-height:32px;padding:0 12px;font-size:13px}
.btn.danger{background:#fff;color:var(--bs-red);border:1px solid #e5b4b4}
.btn.danger:hover{background:#fdf1f1}
.btn:disabled{background:#c9ced6;cursor:not-allowed}
.bs-form{display:flex;flex-direction:column;gap:12px;max-width:640px}
.bs-form label{display:flex;flex-direction:column;gap:5px;font-weight:600;font-size:14px}
.bs-form .row2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.bs-form .row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px}
input,select,textarea{border:1px solid #cbd5e1;border-radius:9px;padding:9px 11px;font-size:14.5px;font-family:inherit;background:#fff;color:var(--bs-ink)}
input:focus,select:focus,textarea:focus{outline:2px solid var(--bs-accent);outline-offset:0;border-color:var(--bs-accent)}
.bs-inline{display:inline-flex;gap:8px;align-items:center;flex-wrap:wrap}
.bs-inline input,.bs-inline select{padding:7px 9px}
.bs-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:14px 0}
.bs-toolbar form{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.bs-tabs{display:flex;gap:6px;flex-wrap:wrap;margin:12px 0}
.bs-tabs a{padding:6px 13px;border:1px solid var(--bs-line);border-radius:999px;font-weight:600;font-size:13.5px;color:var(--bs-ink)}
.bs-tabs a.on{background:var(--bs-accent);border-color:var(--bs-accent);color:#fff}
.bs-tabs a:hover{text-decoration:none}
.muted{color:var(--bs-muted)}
.error{color:var(--bs-red);font-weight:600}
.ok-msg{color:var(--bs-green);font-weight:600}
.bs-note-warn{color:var(--bs-amber);font-weight:600}
.bs-menu-btn{display:none}
.bs-kv{display:grid;grid-template-columns:170px 1fr;gap:5px 16px;font-size:14.5px}
.bs-kv dt{color:var(--bs-muted);font-weight:600}
.bs-kv dd{margin:0;min-width:0;overflow-wrap:anywhere}
.bs-login-wrap{min-height:100vh;display:flex;align-items:flex-start;justify-content:center;background:var(--bs-soft);padding:56px 16px}
.bs-login{width:100%;max-width:400px;background:#fff;border:1px solid var(--bs-line);border-radius:14px;padding:28px 30px}
.bs-login img{height:46px;margin-bottom:6px}
.bs-flash{border:1px solid #bfe3cc;background:#eefaf1;color:var(--bs-green);border-radius:10px;padding:10px 14px;font-weight:600;margin:12px 0}
.bs-warn{border:1px solid #f0dcbb;background:#fdf6e9;color:var(--bs-amber);border-radius:10px;padding:10px 14px;font-weight:600;margin:12px 0}
.bs-scroll{overflow-x:auto}
@media (max-width:860px){
  .bs-shell{display:block}
  /* the sidebar becomes a sticky top bar with a collapsible Menu */
  .bs-side{position:sticky;top:0;z-index:40;height:auto;max-height:100dvh;overflow-y:auto;
    border-right:none;border-bottom:1px solid var(--bs-line);padding:10px 14px;background:#fff}
  .bs-side .bs-logo{width:118px;margin:0}
  .bs-side .bs-sysname{margin:2px 0 0;font-size:13px}
  .bs-side .bs-role{margin:2px 0 8px}
  .bs-menu-btn{display:flex;align-items:center;justify-content:center;width:100%;min-height:44px;
    padding:10px 18px;border-radius:9px;border:1px solid #cbd5e1;background:#fff;color:var(--bs-ink);
    font-weight:700;font-size:15px;font-family:inherit;cursor:pointer}
  .bs-menu-btn:hover{background:var(--bs-soft)}
  .bs-nav{display:none;margin-top:8px}
  .bs-side.nav-open .bs-nav{display:block}
  .bs-nav a{display:flex;align-items:center;min-height:44px;padding:10px 12px;font-size:15px}
  .bs-main{padding:18px 16px 48px}
  .bs-form .row2,.bs-form .row3{grid-template-columns:1fr}
  .bs-kv{grid-template-columns:120px 1fr}
}

/* ------------------------------------------------------------------ */
/* Phone layout (<=680px): stacked sections, stacked table rows with
   labels (labels are copied onto cells by the layout script), big tap
   targets, full-width inputs, and no page-level sideways scrolling.
   Wide numeric tables (.bs-wide: profit months, reports, sent-mail)
   keep their contained in-card sideways scroll instead.             */
@media (max-width:680px){
  html,body{overflow-x:clip;overflow-x:hidden}
  .bs-main{padding:14px 12px 44px}
  .bs-main h1{font-size:21px}
  .bs-main h2{font-size:17px;margin:22px 0 8px}
  .bs-panel{padding:14px}
  .bs-cards{grid-template-columns:1fr;gap:10px;margin:12px 0}
  .bs-card{padding:13px 14px}
  .bs-card .v{font-size:20px}

  /* tap targets + inputs (16px inputs also stop focus zoom) */
  .btn{min-height:44px;height:auto;line-height:1.3;display:inline-flex;align-items:center;justify-content:center;padding:10px 16px}
  .btn.small{min-height:44px;padding:9px 14px;font-size:13.5px}
  .bs-tabs{gap:6px}
  .bs-tabs a{min-height:44px;display:inline-flex;align-items:center;padding:8px 14px;font-size:14px}
  input,select,textarea{font-size:16px;min-height:44px;padding:10px 11px}
  textarea{min-height:0}
  .bs-inline input,.bs-inline select{min-height:44px;padding:9px 10px}
  .bs-toolbar{gap:8px;margin:10px 0}
  .bs-toolbar form{flex:1 1 100%}
  .bs-toolbar form input{flex:1;min-width:0}
  .bs-form{max-width:none}

  /* record lists stack: label left, value right */
  .bs-kv{grid-template-columns:1fr;gap:2px 0}
  .bs-kv dd{margin:0 0 9px}

  /* collapsible panels (Monthly Profit real-number + breakdown) */
  details.bs-panel{padding:14px}
  details.bs-panel>summary{min-height:44px;display:flex;align-items:center;flex-wrap:wrap;gap:2px 6px;
    font-size:16px !important;line-height:1.35;padding:4px 0}

  /* tables: stacked label:value rows */
  .bs-table,.bs-table tbody,.bs-table tr,.bs-table td{display:block;width:100%}
  .bs-table tr:first-child{display:none}
  .bs-table tr{border-bottom:2px solid var(--bs-line);padding:7px 0}
  .bs-table tr:hover td{background:transparent}
  .bs-table td{border-bottom:none;display:flex;justify-content:space-between;align-items:baseline;flex-wrap:wrap;
    gap:6px 16px;padding:5px 2px;text-align:left;overflow-wrap:anywhere}
  .bs-table td::before{content:attr(data-label);font-weight:600;color:var(--bs-muted);font-size:12.5px;flex:none}
  .bs-table td.num{text-align:right !important;white-space:normal}
  .bs-table td[colspan]{display:block}
  .bs-table td[colspan]::before{content:none}
  .bs-table td form{margin-left:auto}
  /* opt-out: wide numeric tables keep a contained sideways scroll */
  .bs-wide{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .bs-wide .bs-table{display:table;width:100%}
  .bs-wide .bs-table tbody{display:table-row-group}
  .bs-wide .bs-table tr{display:table-row;border-bottom:none;padding:0}
  .bs-wide .bs-table tr:first-child{display:table-row}
  .bs-wide .bs-table td{display:table-cell;width:auto;border-bottom:1px solid var(--bs-line);
    padding:8px 10px;text-align:left}
  .bs-wide .bs-table td.num{text-align:right !important;white-space:nowrap}
  .bs-wide .bs-table td::before{content:none}
  .bs-wide .bs-table td form{margin-left:0}

  /* sign-in card */
  .bs-login-wrap{padding:22px 12px}
  .bs-login{padding:22px 18px}

  /* sideways-scroll hardening: nothing on the page may be wider than the
     screen — grid/flex children give up their intrinsic minimum width and
     long unbroken strings (emails, refs, file names, URLs) wrap anywhere */
  .bs-main{min-width:0}
  .bs-panel,.bs-card{min-width:0}
  .bs-card .v{overflow-wrap:anywhere}
  .bs-kv{grid-template-columns:1fr;min-width:0}
  .bs-kv dd{min-width:0;overflow-wrap:anywhere}
  .bs-table td>*{min-width:0}
  .bs-table td a{overflow-wrap:anywhere}
  .bs-toolbar>*{min-width:0}
  .bs-scroll{max-width:100%}
  img,svg{max-width:100%}
  input,select,textarea{max-width:100%}
  pre{white-space:pre-wrap;overflow-wrap:anywhere}
  details.bs-panel>summary>*{min-width:0}
}

/* Search suggestions (typeahead) */
.bs-suggest-host{position:relative}
.bs-suggest{position:absolute;z-index:80;background:var(--hatch-widget-surface,#fff);border:1px solid #c9d2dd;border-radius:10px;box-shadow:0 10px 28px rgba(16,24,40,.18);max-height:352px;overflow:auto}
.bs-suggest-item{min-height:44px;display:flex;align-items:center;gap:10px;padding:10px 12px;cursor:pointer;font-size:14px}
.bs-suggest-item:hover,.bs-suggest-item.on{background:#eef4fb}
.bs-suggest-sub{margin-left:auto;color:#68707d;font-size:12px;white-space:nowrap}

/* Monthly Profit glance lines + nested folds (v32) */
.gl-line{border-top:1px solid var(--bs-line);padding:10px 0}
.gl-line:first-of-type{border-top:none}
.gl-head{display:flex;align-items:baseline;gap:4px 10px;flex-wrap:wrap}
.gl-label{font-weight:700}
.gl-count{font-size:13px}
.gl-value{margin-left:auto;font-weight:700;font-size:17px;white-space:nowrap}
.gl-fold{margin-top:6px}
.gl-fold>summary{cursor:pointer;padding:6px 0;min-height:32px}

/* ---- v35 corporate invoice document (screen + print page) ---- */
.invdoc { background:#fff; color:#111; border:1px solid #d4d4d8; border-radius:6px; padding:22px 24px; margin:14px 0; font-size:13px; line-height:1.45; }
.invdoc-head { display:flex; justify-content:space-between; gap:18px; align-items:flex-start; }
.invdoc-logo { max-width:190px; max-height:64px; display:block; margin-bottom:8px; }
.invdoc-co-lines { color:#333; font-size:12px; }
.invdoc-co-lines strong { color:#111; font-size:13px; }
.invdoc-word { font-size:34px; font-weight:800; letter-spacing:2px; text-align:right; line-height:1; }
.invdoc-meta { border-collapse:collapse; margin-top:8px; margin-left:auto; font-size:11.5px; }
.invdoc-meta td { border:1px solid #9ca3af; padding:3px 9px; }
.invdoc-meta td:first-child { background:#f3f4f6; font-weight:700; letter-spacing:.4px; }
.invdoc-meta td:last-child { text-align:right; min-width:92px; }
.invdoc-rule { height:4px; background:#c8102e; margin:14px 0; }
.invdoc-boxes { display:flex; gap:10px; }
.invdoc-box { flex:1; border:1px solid #9ca3af; min-width:0; }
.invdoc-bar { background:#111; color:#fff; font-weight:700; font-size:11.5px; letter-spacing:.6px; padding:5px 9px; }
.invdoc-bar.blue { background:#1d4e9e; }
.invdoc-boxbody { padding:8px 9px; font-size:12.5px; }
.invdoc-strip { width:100%; border-collapse:collapse; margin-top:10px; font-size:12px; }
.invdoc-strip td { border:1px solid #9ca3af; padding:5px 7px; vertical-align:top; }
.invdoc-strip td span { display:block; font-size:9.5px; font-weight:700; letter-spacing:.5px; color:#555; }
.invdoc-items { width:100%; border-collapse:collapse; margin-top:12px; font-size:12.5px; }
.invdoc-items th { background:#111; color:#fff; text-align:left; padding:6px 7px; font-size:11px; letter-spacing:.4px; }
.invdoc-items td { border-bottom:1px solid #e5e7eb; padding:6px 7px; vertical-align:top; }
.invdoc-items .num, .invdoc-totals .num, .invdoc-strip .num { text-align:right; }
.invdoc-items td.bo { color:#c8102e; font-weight:700; }
.invdoc-note { color:#555; font-size:11.5px; }
.invdoc-sumline { display:flex; justify-content:space-between; gap:12px; margin-top:8px; font-size:12px; color:#333; }
.invdoc-lower { display:flex; gap:16px; margin-top:14px; align-items:flex-start; }
.invdoc-paybox { flex:1.35; border:1px solid #9ca3af; padding:10px 12px; font-size:12.5px; position:relative; }
.invdoc-paytitle { font-weight:800; letter-spacing:.6px; font-size:11.5px; margin-bottom:6px; }
.invdoc-qr { position:absolute; top:10px; right:10px; width:86px; height:86px; border:1.5px dashed #9ca3af; color:#666; font-size:10.5px; text-align:center; padding-top:22px; box-sizing:border-box; }
.invdoc-qr span { font-weight:700; }
.invdoc-totals { flex:1; border-collapse:collapse; font-size:12.5px; }
.invdoc-totals td { padding:4px 8px; border-bottom:1px solid #e5e7eb; }
.invdoc-totals .invdoc-tot td { font-weight:700; }
.invdoc-totals .invdoc-due td { background:#111; color:#fff; font-weight:800; font-size:14px; border-bottom:none; }
.invdoc-dueby { color:#c8102e; font-weight:700; text-align:right; }
.invdoc-terms { font-size:11px; color:#444; margin-top:14px; }
.invdoc-sign { display:flex; justify-content:space-between; gap:14px; margin-top:16px; font-size:12px; }
.invdoc-detach { border-top:2px dashed #9ca3af; margin-top:18px; padding-top:6px; font-size:11px; color:#555; text-align:center; }
.invdoc-stub { display:flex; justify-content:space-between; gap:16px; margin-top:8px; font-size:12.5px; }
.invdoc-stub-co span { font-weight:700; letter-spacing:.5px; text-transform:uppercase; font-size:11px; }
.invdoc-stub-t { border-collapse:collapse; }
.invdoc-stub-t td { padding:3px 8px; }
.invdoc-stub-t td:first-child { font-weight:700; font-size:11px; letter-spacing:.4px; }
.invdoc-stub-t td:last-child { text-align:right; }
/* Phone view of the invoice document — SCREEN ONLY. These rules never
   apply to print, so the printed invoice keeps the exact v35 corporate
   layout at any paper size. (v38: before this, the 8-across meta strip
   overflowed the paper on a phone — its cells' minimum contents alone
   total ~425px against ~340px of paper — and the items table needed
   sideways scrolling; the totals block also shrank to fit-content and
   hugged the left when stacked.) */
@media screen and (max-width: 720px) {
  .invdoc { padding:16px 14px; }
  .invdoc-head, .invdoc-boxes, .invdoc-lower, .invdoc-stub, .invdoc-sign, .invdoc-sumline { flex-direction:column; }
  .invdoc-lower { align-items:stretch; }
  .invdoc-word { text-align:left; }
  .invdoc-meta { margin-left:0; }
  .invdoc-qr { position:static; margin-top:8px; }

  /* meta strip becomes a 2-column grid: every label and value fully
     visible, nothing clipped, no sideways scroll */
  .invdoc-strip { display:block; border-top:1px solid #9ca3af; border-left:1px solid #9ca3af; }
  .invdoc-strip tbody { display:block; }
  .invdoc-strip tr { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .invdoc-strip td { display:block; border:none; border-right:1px solid #9ca3af; border-bottom:1px solid #9ca3af; min-width:0; overflow-wrap:anywhere; }

  /* items become stacked label/value rows: the line-number and UOM
     (always EA) cells drop out, an empty item-no. cell drops out, and
     the description leads each item — all figures stay on screen */
  .invdoc-items { display:block; width:100%; }
  .invdoc-items thead { display:none; }
  .invdoc-items tbody { display:block; }
  .invdoc-items tr { display:block; border-bottom:2px solid #e5e7eb; padding:8px 0 6px; }
  .invdoc-items tr:last-child { border-bottom:none; }
  .invdoc-items td { display:flex; justify-content:space-between; align-items:baseline; gap:8px 14px;
    border-bottom:none; padding:3px 0; text-align:right; min-width:0; overflow-wrap:anywhere; }
  .invdoc-items td::before { font-weight:700; font-size:10.5px; letter-spacing:.5px; color:#555; text-align:left; flex:none; }
  .invdoc-items td:nth-child(1), .invdoc-items td:nth-child(4) { display:none; }
  .invdoc-items td:nth-child(2):empty { display:none; }
  .invdoc-items td:nth-child(2)::before { content:'ITEM NO.'; }
  .invdoc-items td:nth-child(3) { display:block; text-align:left; padding:0 0 4px; }
  .invdoc-items td:nth-child(3)::before { content:none; }
  .invdoc-items td:nth-child(5)::before { content:'ORDERED'; }
  .invdoc-items td:nth-child(6)::before { content:'SHIPPED'; }
  .invdoc-items td:nth-child(7)::before { content:'B/O'; }
  .invdoc-items td:nth-child(8)::before { content:'UNIT PRICE'; }
  .invdoc-items td:nth-child(9)::before { content:'EXT. AMOUNT'; }

  /* totals span the full paper width when stacked, so the AMOUNT DUE
     bar and the right-aligned amounts line up with the document */
  .invdoc-totals { width:100%; }
}
/* Phone view of the PO and quote documents (v45) — SCREEN ONLY, same
   approach as the invoice above: the shared .invdoc rules stack the
   boxes, turn the meta strip into a 2-column grid and stack the items;
   only the stacked-item labels differ, because the PO/quote items table
   has QTY / UNIT PRICE / EXT. AMOUNT in columns 5-7 where the invoice
   has ORDERED / SHIPPED / B-O. These selectors carry one more class
   than the invoice rules, so they win for .podoc / .qtdoc only. */
@media screen and (max-width: 720px) {
  .podoc .invdoc-items td:nth-child(5)::before, .qtdoc .invdoc-items td:nth-child(5)::before { content:'QTY'; }
  .podoc .invdoc-items td:nth-child(6)::before, .qtdoc .invdoc-items td:nth-child(6)::before { content:'UNIT PRICE'; }
  .podoc .invdoc-items td:nth-child(7)::before, .qtdoc .invdoc-items td:nth-child(7)::before { content:'EXT. AMOUNT'; }
}
@media print {
  .invdoc { border:none; padding:0; margin:0; }
  .invdoc-items { font-size:11.5px; }
}
/* v35 searchable product picker (invoice forms) */
.prodsearch { position:relative; }
.prodsearch .prod-results { position:absolute; left:0; right:0; top:100%; z-index:40; background:#fff; border:1px solid #9ca3af; border-radius:6px; box-shadow:0 8px 22px rgba(0,0,0,.18); max-height:260px; overflow:auto; }
.prodsearch .prod-results button { display:block; width:100%; text-align:left; background:none; border:none; border-bottom:1px solid #eee; padding:8px 10px; font-size:13px; cursor:pointer; color:#111; }
.prodsearch .prod-results button:hover, .prodsearch .prod-results button.hl { background:#eef4ff; }
.prodsearch .prod-results .ps-sku { color:#666; font-size:11.5px; }
.prodsearch .prod-results .ps-stock { float:right; color:#666; font-size:11.5px; }
.prodsearch { display:block; position:relative; }
.prodsearch .prod-results[hidden] { display:none; }
