/* BuildOS design system
   Soft, low-glare colours (warm off-white, muted teal, amber accent), a matching dark theme,
   big touch targets and tabular numbers. Theme: auto (follows the phone) or forced with <html data-theme>. */
:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --card-2: #f9f8f5;
  --ink: #23292d;
  --ink-2: #3c454b;
  --muted: #6c757c;
  --line: #e7e4dd;
  --primary: #255f52;
  --primary-ink: #ffffff;
  --primary-soft: #e3efeb;
  --accent: #f0a83c;
  --accent-ink: #3a2706;
  --accent-soft: #fdf1dc;
  --good: #2c7a53;
  --good-soft: #e2f2e9;
  --bad: #c2462f;
  --bad-soft: #fbe7e2;
  --warn: #a96d12;
  --warn-soft: #fbf0db;
  --shadow: 0 1px 2px rgba(30, 35, 40, .05), 0 4px 14px rgba(30, 35, 40, .05);
  --radius: 16px;
  --tabbar: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141819; --card: #1c2123; --card-2: #22282a; --ink: #e6e9ea; --ink-2: #c9cfd2; --muted: #98a2a7; --line: #2b3235;
    --primary: #5fb59f; --primary-ink: #0e1a17; --primary-soft: #1f3530; --accent: #eaa649; --accent-ink: #2b1c03; --accent-soft: #3a2d17;
    --good: #67c393; --good-soft: #1c3227; --bad: #ef7d66; --bad-soft: #3a211c; --warn: #e2b25c; --warn-soft: #382c16;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141819; --card: #1c2123; --card-2: #22282a; --ink: #e6e9ea; --ink-2: #c9cfd2; --muted: #98a2a7; --line: #2b3235;
  --primary: #5fb59f; --primary-ink: #0e1a17; --primary-soft: #1f3530; --accent: #eaa649; --accent-ink: #2b1c03; --accent-soft: #3a2d17;
  --good: #67c393; --good-soft: #1c3227; --bad: #ef7d66; --bad-soft: #3a211c; --warn: #e2b25c; --warn-soft: #382c16;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--card-2); color: var(--ink); border-color: var(--line); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.price, .stat .n, .total, .up b, input[type=number] { font-variant-numeric: tabular-nums; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

/* ---------- header ---------- */
.top { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 12px 16px 10px; padding-top: calc(12px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); }
.top .row { gap: 8px; }
.brandmark { width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; flex: none; }
.brandmark svg.ic { width: 20px; height: 20px; vertical-align: 0; }
.brand { font-weight: 700; font-size: 16px; line-height: 1.2; }
.sub { font-size: 12.5px; color: var(--muted); }
.hbtn { border: 0; background: transparent; color: var(--ink-2); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.hbtn:active { background: var(--line); }
.hbtn svg.ic { width: 22px; height: 22px; vertical-align: 0; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink-2); border-radius: 99px; padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.chip svg.ic { width: 15px; height: 15px; vertical-align: 0; }
.chip.on { background: var(--accent-soft); color: var(--warn); border-color: transparent; }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; }

/* ---------- tab bar ---------- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.tabs a { flex: 1; text-align: center; padding: 6px 0 4px; font-size: 11.5px; color: var(--muted); text-decoration: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs a svg.ic { width: 22px; height: 22px; vertical-align: 0; }
.tabs a.on { color: var(--primary); font-weight: 700; }
.tabs a.on .pillbg { background: var(--primary-soft); }
.tabs .pillbg { border-radius: 99px; padding: 3px 16px; display: grid; place-items: center; transition: background .15s; }

/* ---------- type ---------- */
h1 { font-size: 22px; margin: 2px 0 4px; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 22px 0 8px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pagehead { margin: 2px 0 12px; }
.pagehead p { margin: 0; color: var(--muted); font-size: 14px; }
.hello h1 { font-size: 24px; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card.demo { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.card.danger-card { background: var(--bad-soft); border-color: transparent; box-shadow: none; }
.card.info { background: var(--primary-soft); border-color: transparent; box-shadow: none; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; box-shadow: var(--shadow); }
.stat .n { font-size: 21px; font-weight: 750; letter-spacing: -.01em; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.bad .n { color: var(--bad); }
.stat.warn .n { color: var(--warn); }
a.stat:active, .tile:active, .li:active { transform: scale(.99); }

/* big action tiles on Home */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.tile .tic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.tile .tic svg.ic { width: 22px; height: 22px; vertical-align: 0; }
.tile b { font-size: 16px; }
.tile span { font-size: 13px; color: var(--muted); line-height: 1.3; }
.tile.main { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.tile.main .tic { background: rgba(255, 255, 255, .16); color: var(--primary-ink); }
.tile.main span { color: inherit; opacity: .82; }

/* "needs attention" rows */
.alert { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.alert:last-child { border-bottom: 0; }
.alert .aic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.alert .aic svg.ic { vertical-align: 0; }
.alert .aic.bad { background: var(--bad-soft); color: var(--bad); }
.alert .aic.warn { background: var(--warn-soft); color: var(--warn); }
.alert .aic.ok { background: var(--primary-soft); color: var(--primary); }
.alert .chev { color: var(--muted); }

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.right { text-align: right; }
.bold { font-weight: 700; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
code { background: var(--card-2); border-radius: 6px; padding: 1px 5px; font-size: 12.5px; }

/* ---------- search ---------- */
.search { position: sticky; top: 64px; z-index: 4; background: var(--bg); padding: 4px 0 10px; }
.search.row { gap: 8px; }
.search input { width: 100%; padding: 13px 14px 13px 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a9296' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center; font-size: 17px; box-shadow: var(--shadow); }
.scanbtn { padding: 0 14px; height: 50px; border-radius: 14px; }
.scanbtn svg.ic { width: 22px; height: 22px; }

/* ---------- lists ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.li { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li .t { font-weight: 650; }
.li .s { font-size: 13px; color: var(--muted); }
.li.voided .t, .li.voided .price { text-decoration: line-through; color: var(--muted); }
.ledger .li { cursor: default; }
.price { font-weight: 750; white-space: nowrap; }
.pill { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 99px; background: var(--card-2); color: var(--ink-2); font-weight: 650; border: 1px solid var(--line); text-decoration: none; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 30px 14px; }
.empty .eic { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .eic svg.ic { width: 26px; height: 26px; vertical-align: 0; }
.empty b { color: var(--ink); display: block; margin-bottom: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--card); border-radius: 13px; padding: 11px 15px; font-weight: 650; cursor: pointer; text-decoration: none; color: var(--ink); min-height: 44px; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 14px; border-radius: 11px; min-height: 36px; }
.btn.big { padding: 15px 16px; font-size: 18px; min-height: 54px; border-radius: 16px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { flex: 1 1 auto; }
.fab { position: fixed; right: 16px; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); z-index: 5; border-radius: 99px; padding: 14px 20px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.iconbtn { border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 10px; }
.iconbtn:active { background: var(--line); }

/* ---------- forms ---------- */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.f input, .f select, .f textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.f textarea { min-height: 70px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
input[type=number] { -moz-appearance: textfield; }

.unitrow, .unithead { display: grid; grid-template-columns: 1.2fr .9fr 1fr 1fr 34px; gap: 6px; }
.unitrow { margin-bottom: 6px; align-items: center; }
.unitrow input { width: 100%; padding: 9px 8px; border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.unithead { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.unitblock { border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.bcrow { display: flex; gap: 6px; align-items: center; }
.bcrow .ub { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }

/* quotation / cart lines */
.qline { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.qline:last-child { border-bottom: 0; }
.qline .ctrl { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.qline .ctrl input, .qline .ctrl select { padding: 9px 8px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.qline .ctrl .qty { width: 60px; text-align: center; }
.qline .ctrl .pr { width: 92px; }
.qline .ctrl select { min-width: 74px; flex: 1; }
.qline .ctrl .qbtn { width: 38px; min-height: 38px; padding: 0; font-size: 20px; box-shadow: none; }
.total { display: flex; justify-content: space-between; font-size: 21px; font-weight: 800; padding-top: 10px; }
.paybar { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px 0; background: var(--bg); z-index: 3; }
.paybar .btn { flex: 1; }
.paybar .btn.accent { flex: 2; }

.unitprices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.unitprices .up { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; color: var(--muted); }
.unitprices .up b { font-size: 19px; color: var(--ink); }

/* ---------- sheets ---------- */
.modal { position: fixed; inset: 0; background: rgba(12, 16, 18, .5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); padding: 10px 0 10px; z-index: 1; gap: 10px; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.x { border: 0; background: var(--card-2); color: var(--ink-2); width: 36px; height: 36px; border-radius: 99px; font-size: 16px; cursor: pointer; flex: none; }
.scan-ov { z-index: 25; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; z-index: 30; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }

/* scanner, PIN */
.scanbox { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanline { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff5a45; box-shadow: 0 0 8px #ff5a45; }
.scanmsg { text-align: center; margin: 8px 0; }
.ean { display: block; width: 100%; height: auto; }
.pin-sheet .pin { width: 100%; font-size: 28px; letter-spacing: .3em; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; }
.pinmsg { text-align: center; margin-bottom: 10px; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* demo banner + guided tour */
.demobar { position: sticky; top: 0; z-index: 7; background: var(--accent); color: var(--accent-ink); text-align: center; font-size: 13px; font-weight: 700; padding: 6px 12px; }
.demobar a { color: inherit; }
.tour { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); z-index: 40; max-width: 560px; margin: 0 auto; background: var(--ink); color: var(--bg); border-radius: 18px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.tour b { display: block; font-size: 16px; margin-bottom: 3px; }
.tour p { margin: 0 0 10px; font-size: 14px; opacity: .9; }
.tour .row { gap: 8px; }
.tour .btn { box-shadow: none; }
.tour .dots { font-size: 12px; opacity: .7; }
.tour-hl { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 14px; position: relative; z-index: 2; transition: outline-color .2s; }

/* ---------- print ---------- */
.print-area { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; color: #000; font-size: 12pt; padding: 0; }
  .print-area table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  .print-area th, .print-area td { border-bottom: 1px solid #bbb; padding: 6px 4px; text-align: left; }
  .print-area .r { text-align: right; }
  .print-area h1 { font-size: 18pt; margin: 0; }
  .print-area .doc-title { font-size: 14pt; font-weight: 700; margin-top: 14px; letter-spacing: .05em; }
  .print-area .tot { font-size: 14pt; font-weight: 700; }
  .print-area .note { font-size: 9pt; color: #555; margin-top: 18px; }
  .print-area .labels { page: labels; display: grid; grid-template-columns: repeat(3, 63.5mm); grid-auto-rows: 38.1mm; column-gap: 2.5mm; }
  .print-area .label { padding: 2mm 3mm; overflow: hidden; display: flex; flex-direction: column; break-inside: avoid; }
  .print-area .lstore { font-size: 6pt; color: #555; white-space: nowrap; overflow: hidden; }
  .print-area .lname { font-size: 8.5pt; font-weight: 700; line-height: 1.1; max-height: 2.2em; overflow: hidden; }
  .print-area .lprice { font-size: 12pt; font-weight: 800; margin: .5mm 0; }
  .print-area .lprice span { font-size: 7pt; font-weight: 400; }
  .print-area .lcode { font: 10pt monospace; margin-top: auto; }
  .print-area .label .ean { margin-top: auto; height: 15mm; width: auto; max-width: 100%; }
  @page { margin: 14mm; }
  @page labels { margin: 15.1mm 7.2mm; }
}
.card.info .aic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--card); color: var(--primary); }
.card.info .aic svg.ic { vertical-align: 0; }
