/* Layout concept: a clean-room work surface. Cool, blue-biased neutrals; the logo's cyan used only for
   actions and state; tabular figures everywhere money appears; documents render as true A4 sheets. */
:root {
  --paper: #f3f7fa;
  --surface: #ffffff;
  --sunken: #e9f0f5;
  --ink: #142430;
  --muted: #5a6c79;
  --line: #d6e1e9;
  --brand: #06b6f8;
  --brand-ink: #0270a3;
  --brand-wash: #e0f4fd;
  --on-brand: #ffffff;
  --ok: #1d7f55;
  --ok-wash: #e2f3ea;
  --warn: #9a6200;
  --warn-wash: #fdf1dc;
  --bad: #b8352d;
  --bad-wash: #fbe7e5;
  --shadow: 0 1px 2px rgba(20, 36, 48, .06), 0 8px 24px rgba(20, 36, 48, .06);
  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  /* Printed documents keep their own fixed paper palette in every theme */
  --doc-paper: #ffffff;
  --doc-ink: #1b2630;
  --doc-muted: #5d6b76;
  --doc-line: #cfdbe3;
  --doc-tint: #eaf7fd;
  --doc-brand: #06b6f8;
  --doc-brand-ink: #0270a3;
  --r: 10px;
  /* Always light, whatever the phone or computer is set to */
  color-scheme: light only;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
h1, h2, h3 { font-stretch: 87.5%; letter-spacing: -.01em; text-wrap: balance; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1280px; margin: 0 auto; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand svg { width: 38px; height: 38px; flex: none; }
.brand b { display: block; font-stretch: 87.5%; font-weight: 800; letter-spacing: .04em; font-size: 1rem; line-height: 1.1; }
.brand span { display: block; font-size: .72rem; color: var(--muted); line-height: 1.2; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav button { flex: none; }
@media (max-width: 1440px) { .nav { order: 3; flex-basis: 100%; } .who { margin-left: auto; } }
.nav button { border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 550; }
.nav button:hover { background: var(--sunken); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--brand-wash); color: var(--brand-ink); }
.nav .sep { width: 1px; background: var(--line); margin: 6px 6px; }
.who { display: flex; align-items: center; gap: 8px; font-size: .85rem; flex: none; }
.role { font-size: .72rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--sunken); color: var(--muted); }
.role.admin { background: var(--brand-wash); color: var(--brand-ink); }

.wrap { max-width: 1280px; margin: 0 auto; padding-block: 24px 96px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); max-width: 70ch; margin-top: 4px; }
.stack { display: grid; gap: 16px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: none; color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .76rem; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-wash); }
textarea { resize: vertical; min-height: 64px; }
input[type=number] { font-variant-numeric: tabular-nums; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: .9rem; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-ink); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.span-all { grid-column: 1 / -1; }
.seg { display: inline-flex; background: var(--sunken); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.panel > h2, .panel > .panel-head { margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head p { color: var(--muted); font-size: .88rem; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-wash); color: var(--ok); }
.chip.warn { background: var(--warn-wash); color: var(--warn); }
.chip.bad { background: var(--bad-wash); color: var(--bad); }
.chip.brand { background: var(--brand-wash); color: var(--brand-ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.notice { display: block; padding: 12px 14px; border-radius: 9px; background: var(--warn-wash); color: var(--warn); font-size: .9rem; }
.notice.info { background: var(--brand-wash); color: var(--brand-ink); }
.notice b { font-weight: 700; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .76rem; font-weight: 650; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--sunken); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.group td { background: var(--sunken); font-weight: 700; font-stretch: 87.5%; font-size: .85rem; padding: 7px 12px; color: var(--ink); }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: var(--brand-wash); }
.pname { font-weight: 600; }
.pmeta { font-size: .78rem; color: var(--muted); }
.rate { font-weight: 650; }
.rate-cell { min-width: 84px; }

/* rates page */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 320px; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; }
.cats button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: .82rem; cursor: pointer; color: var(--muted); font-weight: 550; }
.cats button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.add-cell { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.add-cell input { width: 104px; }
.draftbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--ink); color: var(--surface);
  padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.draftbar-in { max-width: 1280px; margin: 0 auto; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.draftbar .btn { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.summary { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 80px); }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.sum-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 750; font-size: 1.15rem; }
.sum-actions { display: grid; gap: 8px; margin-top: 16px; }
.lines td { vertical-align: middle; }
.lines select { min-width: 220px; }
.lines input.qty { width: 110px; }
.lines input.mrate { width: 90px; }
.slab-chip { font-size: .72rem; }
.parts { font-size: .75rem; color: var(--muted); }
@media (max-width: 960px) { .builder { grid-template-columns: 1fr; } .summary { position: static; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login-card .brand svg { width: 56px; height: 56px; }
.login-card .brand b { font-size: 1.3rem; }
.login-card form { display: grid; gap: 12px; }
.err { color: var(--bad); font-size: .88rem; }

/* admin */
.cost-grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cost-grid th, .cost-grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.cost-grid th:first-child, .cost-grid td:first-child { text-align: left; color: var(--muted); font-weight: 550; }
.cost-grid thead th { font-size: .78rem; color: var(--muted); }
.cost-grid input { width: 92px; text-align: right; padding: 6px 8px; }
.cost-grid tr.total td { font-weight: 750; color: var(--ink); border-top: 2px solid var(--line); }
.cost-grid tr.sub td { color: var(--muted); font-size: .84rem; }
.delta-up { color: var(--bad); }
.delta-down { color: var(--ok); }
.save-bar { position: sticky; bottom: 0; z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: var(--shadow); margin-bottom: env(safe-area-inset-bottom, 0px); }
.drawer-bg { position: fixed; inset: 0; background: rgba(8, 18, 26, .45); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 21; overflow-y: auto;
  padding-block: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)); padding-left: 20px; padding-right: max(20px, env(safe-area-inset-right, 0px));
  display: grid; gap: 16px; align-content: start; box-shadow: var(--shadow); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.calc { background: var(--sunken); border-radius: 9px; padding: 12px 14px; font-size: .88rem; display: grid; gap: 4px; }
.calc .sum-row { padding: 2px 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 9px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.preview-banner { background: var(--warn-wash); color: var(--warn); font-size: .82rem; text-align: center; padding-block: 6px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- document sheet (A4) ---------- */
.doc-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.doc-toolbar .grp { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sheet-scroll { overflow-x: auto; padding-bottom: 12px; }
.doc { width: 210mm; min-height: 297mm; margin: 0 auto; background: var(--doc-paper); color: var(--doc-ink); padding: 14mm 14mm 12mm;
  box-shadow: var(--shadow); font: 9.4pt/1.42 var(--font); display: flex; flex-direction: column; gap: 5mm; }
.doc * { border-color: var(--doc-line); }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; padding-bottom: 4mm; border-bottom: 2.2pt solid var(--doc-brand); }
.doc-brand { display: flex; gap: 4mm; align-items: center; }
.doc-brand svg { width: 20mm; height: 20mm; flex: none; color: var(--doc-ink); }
.doc-co { font-stretch: 87.5%; font-weight: 800; font-size: 17pt; letter-spacing: .05em; line-height: 1.05; }
.doc-tag { color: var(--doc-muted); font-size: 8.2pt; max-width: 80mm; }
.doc-addr { font-size: 8.2pt; color: var(--doc-muted); white-space: pre-line; margin-top: 1.5mm; }
.doc-title { text-align: right; }
.doc-title h1 { font-size: 15pt; font-stretch: 87.5%; letter-spacing: .02em; color: var(--doc-brand-ink); font-weight: 750; }
.doc-title dl { display: grid; grid-template-columns: auto auto; gap: .6mm 3mm; margin: 2mm 0 0; font-size: 8.8pt; justify-content: end; }
.doc-title dt { color: var(--doc-muted); }
.doc-title dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; border: .6pt solid; border-radius: 1.5mm; }
.doc-parties > div { padding: 3mm 3.5mm; }
.doc-parties > div + div { border-left: .6pt solid var(--doc-line); }
.doc-label { font-size: 7.4pt; font-weight: 700; color: var(--doc-brand-ink); letter-spacing: .04em; margin-bottom: 1mm; }
.doc-party-name { font-weight: 700; font-size: 10pt; }
.doc-pre { white-space: pre-line; }
.doc-shipping { display: grid; grid-template-columns: repeat(4, 1fr); border: .6pt solid; border-radius: 1.5mm; }
.doc-shipping > div { padding: 2mm 3mm; border-right: .6pt solid var(--doc-line); border-bottom: .6pt solid var(--doc-line); }
.doc-shipping > div:nth-child(4n) { border-right: 0; }
.doc-shipping > div:nth-last-child(-n+4) { border-bottom: 0; }
.doc-shipping span { display: block; font-size: 7.4pt; color: var(--doc-muted); }
.doc-shipping b { font-weight: 600; }
.doc-intro { font-size: 9.4pt; }
table.doc-items { width: 100%; border-collapse: collapse; font-size: 9pt; }
.doc-items th { background: var(--doc-tint); color: var(--doc-brand-ink); font-size: 7.6pt; font-weight: 700; letter-spacing: .03em; text-align: left; padding: 2mm 2mm; border-top: .6pt solid; border-bottom: .6pt solid; }
.doc-items td { padding: 2.2mm 2mm; border-bottom: .6pt solid; vertical-align: top; }
.doc-items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-items .code { font-size: 7.8pt; color: var(--doc-muted); }
.doc-items .bd { font-size: 8pt; color: var(--doc-muted); margin-top: .8mm; }
.doc-items .bd b { color: var(--doc-ink); font-weight: 600; }
.doc-items tr { break-inside: avoid; }
.doc-bottom { display: grid; grid-template-columns: 1fr 74mm; gap: 6mm; align-items: start; }
.doc-words { font-size: 8.8pt; }
.doc-words b { display: block; font-size: 7.4pt; color: var(--doc-brand-ink); letter-spacing: .04em; }
.doc-totals { display: grid; font-variant-numeric: tabular-nums; font-size: 9.2pt; }
.doc-totals div { display: flex; justify-content: space-between; padding: 1.1mm 0; }
.doc-totals .grand { border-top: 1.2pt solid var(--doc-ink); margin-top: 1mm; padding-top: 2mm; font-weight: 800; font-size: 11.5pt; }
.doc-foot { display: grid; grid-template-columns: 1fr 64mm; gap: 6mm; border-top: .6pt solid; padding-top: 4mm; break-inside: avoid; }
.doc-bank { font-size: 8.8pt; }
.doc-bank table { border-collapse: collapse; }
.doc-bank td { padding: .4mm 3mm .4mm 0; }
.doc-bank td:first-child { color: var(--doc-muted); }
.doc-sign { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 1mm; }
.doc-sign .space { height: 16mm; display: flex; align-items: flex-end; justify-content: flex-end; }
.doc-sign img { max-height: 18mm; max-width: 50mm; }
.doc-sign .line { border-top: .6pt solid var(--doc-ink); padding-top: 1mm; min-width: 46mm; font-size: 8.2pt; color: var(--doc-muted); }
.doc-terms { font-size: 8pt; color: var(--doc-muted); }
.doc-terms ol { margin: 1mm 0 0; padding-left: 4.5mm; display: grid; gap: .5mm; }
.doc-end { margin-top: auto; display: flex; justify-content: space-between; gap: 4mm; font-size: 7.4pt; color: var(--doc-muted); border-top: .6pt solid; padding-top: 2mm; }
.doc-draft { color: var(--bad); }

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  body::before { display: none; }
  .no-print, .topbar, .preview-banner, .draftbar, .toast, .doc-toolbar { display: none !important; }
  .wrap { padding: 0 !important; max-width: none; }
  .sheet-scroll { overflow: visible; padding: 0; }
  .doc { box-shadow: none; margin: 0; width: 210mm; min-height: 0; padding-top: 9mm; padding-bottom: 6mm; }
  .doc { display: block; }
  .doc > * + * { margin-top: 3.5mm; }
  .doc-end { margin-top: 4mm; }
  .doc-items td { padding-top: 1.6mm; padding-bottom: 1.6mm; }
  .doc-sign .space { height: 12mm; }
  .doc-foot { padding-top: 3mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .topbar-in { gap: 10px; }
  .nav button { padding: 7px 9px; font-size: .9rem; }
  .add-cell input { width: 84px; }
  .panel { padding: 14px; }
}
table.t th.num, table.t td.num { text-align: right; }

/* product photos */
.pcell { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; display: block; background: var(--sunken); }
.thumb.sm { width: 40px; height: 40px; border-radius: 6px; }
.thumb.lg { width: 120px; height: 120px; border-radius: 10px; }
.thumb.none { border: 1px dashed var(--line); background: none; }
.thumb-btn { border: 0; padding: 0; background: none; cursor: zoom-in; border-radius: 8px; flex: none; }
.thumb-btn:hover .thumb { box-shadow: 0 0 0 2px var(--brand); }
.photo-edit { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.zoom { position: fixed; z-index: 21; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px)); background: var(--surface);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.zoom img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.zoom-meta { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 14px 16px; }
.doc-items td.ph { padding: 1.4mm 1mm; }
.doc-items td.ph img { width: 14mm; height: 14mm; object-fit: cover; border-radius: 1.2mm; display: block; }

/* combinations & packing */
.combo { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.combo .chip { white-space: normal; font-weight: 550; }
.combo-edit { display: grid; gap: 6px; margin-top: 8px; padding: 8px 10px; background: var(--sunken); border-radius: 8px; }
.combo-edit select { min-width: 0; }
.qhint .btn { padding: 2px 0; margin-top: 4px; font-size: .78rem; white-space: normal; text-align: left; }
.pack-sum { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.doc-pack td, .doc-pack th { font-size: 8.2pt; }
.doc-pack tr.pack-total td { font-weight: 750; border-top: 1pt solid var(--doc-ink); }
.doc-pack .tbc { color: var(--doc-muted); font-style: italic; }
.doc-note { font-size: 7.6pt; color: var(--doc-muted); margin-top: 1.5mm; }

.lines td:first-child { min-width: 260px; }
.lines input.qty { width: 100px; }
.combo-edit .check { align-items: flex-start; line-height: 1.35; }
.combo-edit .check input { margin-top: 2px; flex: none; }
.lines .slab-chip { margin-top: 4px; }

/* separate cap / wad / add-on lines under their container */
.lines tr.subline td:first-child { padding-left: 34px; }
.lines tr.subline td { background: color-mix(in srgb, var(--sunken) 55%, transparent); }
.sublabel { font-size: .74rem; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.lines .rm { padding: 4px 8px; font-size: 1rem; }
.lines input.mrate { width: 76px; }

/* rates open one product at a time */
.reveal { white-space: nowrap; }
.reveal[aria-expanded="true"] { background: var(--brand-wash); border-color: var(--brand); color: var(--brand-ink); }
tr.rate-open td { background: var(--brand-wash); border-top: 0; }
.rate-panel { padding: 4px 0 2px 68px; }
.rate-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.rate-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; display: grid; gap: 2px; min-width: 150px; }
.rate-tile b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.print-block { display: none; }
@media print {
  .rates-table, .rate-open { display: none !important; }
  .print-block { display: block; padding: 40px; font-size: 14pt; }
}
@media (max-width: 640px) { .rate-panel { padding-left: 0; } }

/* full-shipper quantity chips */
.qchips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.qchip { border: 1px dashed var(--line); background: var(--surface); border-radius: 6px; padding: 1px 7px; font-size: .76rem; cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums; }
.qchip:hover { border-color: var(--brand); color: var(--brand-ink); }
/* builder extras */
.hsn-edit { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 0 50px; font-size: .74rem; color: var(--muted); }
.hsn-edit input { width: 96px; padding: 3px 6px; font-size: .8rem; }
input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-wash); }
.warn-text { color: var(--warn); }
.band { margin-top: 3px; white-space: nowrap; }
.cust-wrap { position: relative; }
.suggest { position: absolute; z-index: 8; left: 0; right: 0; top: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); overflow: hidden; }
.suggest button { display: grid; width: 100%; text-align: left; gap: 1px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.suggest button:hover, .suggest button:focus-visible { background: var(--brand-wash); }
.suggest button span { font-size: .78rem; color: var(--muted); }
/* sales performance */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; }
.kpi span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-variant-numeric: tabular-nums; }
.perf .bar { height: 6px; background: var(--sunken); border-radius: 3px; margin-top: 5px; min-width: 120px; }
.perf .bar span { display: block; height: 100%; border-radius: 3px; }
.perf .bar .q { background: var(--muted); }
.perf .bar .p { background: var(--brand); }
/* product requests */
.req .kv { margin-top: 8px; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.req-actions input { flex: 1 1 220px; }
.printstamp { color: var(--doc-muted); }

/* stage colours (CRM and orders) */
:root { --s1: #6b7f8e; --s2: #3b82c4; --s3: #8a63c9; --s4: #c27c0e; --s5: #d4572a; --s6: #1d8a5c; --s7: #a33b3b; }
.st-new, .st-po { --st: var(--s1); } .st-qualified, .st-planning { --st: var(--s2); } .st-sample, .st-procurement { --st: var(--s3); }
.st-quoted, .st-production { --st: var(--s4); } .st-negotiation, .st-ready { --st: var(--s5); } .st-won, .st-invoiced { --st: var(--s6); } .st-lost { --st: var(--s7); }
.wrap.wide { max-width: 1560px; }
/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: var(--sunken); border-radius: var(--r); border-top: 4px solid var(--st, var(--line)); min-height: 200px; display: flex; flex-direction: column; }
.kcol.over { outline: 2px dashed var(--st, var(--brand)); outline-offset: -2px; }
.kcol header { display: flex; justify-content: space-between; align-items: baseline; gap: 2px 8px; padding: 10px 12px; flex-wrap: wrap; }
.kcol header b { font-size: .9rem; }
.kcol header b { font-stretch: 87.5%; }
.kcol-body { display: grid; gap: 8px; padding: 0 8px 10px; }
.kempty { color: var(--muted); font-size: .8rem; text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 8px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; display: grid; gap: 4px; cursor: pointer; font-size: .88rem; }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard:hover { border-color: var(--muted); }
.kc-top { display: flex; justify-content: space-between; gap: 4px 8px; align-items: baseline; flex-wrap: wrap; }
.kc-top b { overflow-wrap: anywhere; }
.ocard .kc-top b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.kcard .pmeta { overflow-wrap: anywhere; }
.kc-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.kc-foot { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 2px; }
.kc-foot .chip { font-size: .7rem; padding: 2px 7px; }
.kc-next { justify-self: start; padding: 2px 0; font-size: .78rem; }
.kc-next.primary { padding: 4px 10px; }
.prio { color: var(--warn); font-size: .8rem; letter-spacing: 1px; }
.stagebar { display: flex; flex-wrap: wrap; gap: 4px; }
.stagebar button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 10px; font-size: .78rem; cursor: pointer; color: var(--muted); }
.stagebar button.on { background: var(--st); border-color: var(--st); color: var(--surface); font-weight: 650; }
.stagebar button[disabled] { opacity: .45; cursor: not-allowed; }
.stchip { display: inline-block; font-size: .75rem; font-weight: 650; padding: 2px 9px; border-radius: 99px; color: var(--surface); background: var(--st); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; font-size: .88rem; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
/* order severity colour coding */
.ocard { border-left: 5px solid var(--sev, var(--line)); }
.sev-overdue { --sev: var(--bad); } .sev-late-ready { --sev: var(--bad); } .sev-soon { --sev: var(--warn); } .sev-ok { --sev: var(--ok); } .sev-ready { --sev: var(--brand); } .sev-done { --sev: var(--muted); }
.chip.sev { background: color-mix(in srgb, var(--sev, var(--muted)) 16%, transparent); color: var(--sev, var(--muted)); }
.ocard.sev-overdue { background: color-mix(in srgb, var(--bad) 6%, var(--surface)); }
.orow td:first-child { box-shadow: inset 5px 0 0 var(--sev, var(--line)); }
.lt-bar { height: 5px; border-radius: 3px; background: var(--sunken); overflow: hidden; margin: 2px 0; }
.lt-bar span { display: block; height: 100%; background: var(--sev, var(--brand)); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 12px; font-size: .78rem; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--sev); }
.bad-text { color: var(--bad); font-weight: 650; }
/* production performance */
.prodperf { margin-bottom: 16px; }
.prodperf .kpis { margin-bottom: 10px; }
.kpi b.good { color: var(--ok); } .kpi b.meh { color: var(--warn); } .kpi b.poor { color: var(--bad); }
.stage-times { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 16px; }
.stage-times > div { display: grid; gap: 3px; }
.stage-times .bar { height: 6px; background: var(--sunken); border-radius: 3px; }
.stage-times .st-fill { display: block; height: 100%; border-radius: 3px; background: var(--st); }

/* stock: last-updated stamps */
.stockval { white-space: nowrap; }
.stockval b { font-variant-numeric: tabular-nums; }
.stamp { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--muted); font-weight: 500; }
.stamp::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.stamp.fresh::before { background: var(--ok); } .stamp.aging::before { background: var(--warn); }
.stamp.stale { color: var(--bad); } .stamp.stale::before { background: var(--bad); }
.stamp.never { font-style: italic; } .stamp.never::before { display: none; }
.seg .segopt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: .85rem; cursor: pointer; border-radius: 7px; }
.seg .segopt:has(input:checked) { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.drawer .seg { flex-wrap: wrap; }
/* daily output */
.plant-forms .panel { margin-bottom: 0; }
.plant-forms { margin-bottom: 16px; }
.finds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.finds li { padding: 8px 12px; border-radius: 8px; border-left: 4px solid var(--muted); background: var(--sunken); font-size: .9rem; }
.finds li.poor { border-left-color: var(--bad); } .finds li.meh { border-left-color: var(--warn); }
.chart { margin: 0 0 14px; }
.chart figcaption { font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--muted); font-family: inherit; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .bar.out path { fill: var(--brand); } .chart .bar.down path { fill: var(--bad); }
.chart .bar:hover .hit { fill: var(--sunken); }
.hbars { display: grid; gap: 8px; }
.hbars > div { display: grid; grid-template-columns: minmax(0, 1.4fr) 2fr auto; gap: 10px; align-items: center; }
.hbars .small:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .bar { height: 8px; background: var(--sunken); border-radius: 4px; }
.hbars .bar span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
/* whatsapp */
.checklist { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.checklist li.ok { color: var(--ok); } .checklist li.todo { color: var(--muted); }
.copyrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copyrow code { background: var(--sunken); padding: 6px 10px; border-radius: 6px; font-size: .82rem; overflow-wrap: anywhere; }
pre.help, pre.msg { white-space: pre-wrap; font-family: inherit; font-size: .85rem; margin: 0; }
pre.help { background: var(--sunken); padding: 12px; border-radius: 8px; }
pre.help.reply { margin-top: 10px; border-left: 4px solid var(--ok); }
pre.help.reply.bad { border-left-color: var(--bad); }
textarea#wa-test { width: 100%; font-family: inherit; }

/* CRM revenue dashboard */
.kpis.rev { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi.wide { grid-column: span 2; }
@media (max-width: 640px) { .kpi.wide { grid-column: auto; } }
.target { margin-top: 6px; }
.lt-bar.big { height: 10px; position: relative; overflow: visible; }
.lt-bar.big i { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink, #222); opacity: .55; }
h2.sec { margin: 20px 0 10px; font-size: 1.05rem; }
.actgrid { margin-bottom: 16px; }
.panel.act h3 { margin: 0 0 2px; }
.actlist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.actlist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.actlist li.clickable:hover { background: var(--sunken); cursor: pointer; }
.funnel { display: grid; gap: 7px; margin-top: 8px; }
.funnel > div { display: grid; grid-template-columns: 120px 1fr 70px; gap: 10px; align-items: center; }
.funnel .bar { height: 10px; background: var(--sunken); border-radius: 5px; }
.funnel .st-fill { display: block; height: 100%; border-radius: 5px; background: var(--st); }
.req-photo { width: 100%; max-height: 220px; object-fit: contain; background: var(--sunken); border-radius: 8px; margin-bottom: 10px; }
.setupkey { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; letter-spacing: .5px; background: var(--sunken); padding: 10px 12px; border-radius: 8px; word-break: break-all; }
.dl-grid { display: flex; flex-wrap: wrap; gap: 8px; }
/* carton labels */
#print-labels { position: fixed; inset: 0; z-index: 200; background: var(--bg, #eef1f4); overflow: auto; }
.lp-bar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lp-sheet { display: grid; gap: 8px; padding: 16px; justify-content: center; }
.labels-a4 .lp-sheet { grid-template-columns: repeat(2, 99mm); }
.labels-a4x4 .lp-sheet { grid-template-columns: repeat(2, 95mm); }
.labels-4x6 .lp-sheet { grid-template-columns: 100mm; }
.clabel { background: #fff; color: #000; border: 1px solid #000; padding: 3mm 3.5mm; font-size: 8.5pt; line-height: 1.25; display: flex; flex-direction: column; gap: 1.2mm; overflow: hidden; break-inside: avoid; }
.labels-a4 .clabel { width: 99mm; height: 67mm; box-sizing: border-box; font-size: 8pt; gap: .9mm; padding: 2.5mm 3mm; line-height: 1.2; }
.labels-a4 .cl-head span { display: none; }
.labels-a4 .cl-carton { font-size: 1.35em; padding: 0; }
.labels-a4 .cl-addr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.labels-a4x4 .clabel { width: 95mm; height: 135mm; box-sizing: border-box; font-size: 10pt; gap: 2mm; }
.labels-4x6 .clabel { width: 100mm; height: 150mm; box-sizing: border-box; font-size: 11pt; gap: 2.5mm; padding: 5mm; border: 0; }
.cl-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid #000; padding-bottom: 1mm; gap: 6px; }
.cl-head b { font-size: 1.15em; letter-spacing: .5px; } .cl-head span { font-size: .8em; }
.cl-carton { font-size: 1.5em; text-align: center; border: 1.5px solid #000; padding: .5mm 0; }
.cl-carton b { font-size: 1.25em; }
.cl-row span, .cl-grid span { display: block; font-size: .75em; text-transform: uppercase; letter-spacing: .4px; color: #333; }
.cl-addr { font-size: .9em; }
.cl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm; }
.cl-grid .big { font-size: 1.3em; }
.cl-serial { margin-top: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 1.05em; border-top: 1px dashed #000; padding-top: 1mm; }
@media print {
  body.printing-labels > *:not(#print-labels) { display: none !important; }
  body.printing-labels #print-labels { position: static; background: #fff; overflow: visible; }
  body.printing-labels .lp-bar { display: none; }
  body.printing-labels .lp-sheet { padding: 0; gap: 2mm; }
  body.printing-labels.labels-4x6 .lp-sheet, body.printing-labels .labels-4x6 .lp-sheet { gap: 0; }
  body.printing-labels .labels-4x6 .clabel { break-after: page; }
}
/* phones: one-row scrolling menu */
@media (max-width: 700px) {
  .nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { white-space: nowrap; flex: none; }
  .nav .sep { flex: none; }
}

@media (max-width: 700px) {
  .kpis, .kpis.rev { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi.wide { grid-column: span 2; }
  .kpi { padding: 10px 12px; }
  .kpi b { font-size: 1.25rem; }
  .who > span:first-of-type { display: none; }
}

/* ready stock with rates */
.ready { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.ready-h { font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 4px; }
.ready-row { display: grid; grid-template-columns: 250px 1fr auto; gap: 4px 12px; align-items: center; padding: 5px 0; border-top: 1px dashed var(--line); font-size: .88rem; }
.ready-row:first-of-type { border-top: 0; }
.ready-row.yes .ready-v b { color: var(--ok); }
.ready-v .stamp { margin-left: 4px; }
@media (max-width: 640px) { .ready-row { grid-template-columns: 1fr; } }
.stkhint { font-size: .74rem; margin-top: 3px; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
