:root {
  --bg: #f4f6f8; --panel: #fff; --ink: #17212b; --muted: #66727f; --line: #dde3e9;
  --accent: #0d6e6e; --accent-ink: #fff; --good: #1a7f4b; --bad: #b42318; --warn: #9a6700; --soft: #e8f3f3;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); display: grid; grid-template: "top top" auto "nav main" 1fr / 220px minmax(0, 1fr); min-height: 100vh; }
#top { grid-area: top; display: flex; gap: 18px; align-items: center; padding: 10px 18px; background: #102a33; color: #fff; flex-wrap: wrap; }
#top select { margin-left: 6px; }
.brand { font-size: 19px; margin-right: 12px; }
.brand b { color: #5fd0c5; }
.demo { margin-left: auto; font-size: 12px; opacity: .7; }
#nav { grid-area: nav; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 0 40px; }
#nav h3 { margin: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#nav a { display: block; padding: 5px 18px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
#nav a:hover { background: var(--bg); }
#nav a.on { border-left-color: var(--accent); background: var(--soft); font-weight: 600; }
#nav a.off { color: var(--muted); }
main { grid-area: main; padding: 18px 24px 120px; }
h1 { margin: 0 0 14px; font-size: 22px; }
h2 { margin: 0; font-size: 15px; }
h3 { font-size: 13px; margin: 16px 0 8px; }
h4 { margin: 12px 0 4px; font-size: 12px; }
a { color: var(--accent); }
.lead { max-width: 70ch; font-size: 15px; }
.muted, small.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.card > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tools, .toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolbar { margin-top: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.cols > .card { margin-bottom: 0; }
.cols { margin-bottom: 16px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.r { text-align: right; font-variant-numeric: tabular-nums; }
td .btn { margin-right: 4px; }
.btn { display: inline-block; font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 5px 11px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs .btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field span { font-size: 12px; color: var(--muted); }
.wide, .full, .note { grid-column: 1 / -1; }
.note { color: var(--muted); }
.check { display: flex; gap: 6px; align-items: center; padding-bottom: 6px; }
input, select, textarea { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); max-width: 100%; }
textarea, pre { font-family: Consolas, monospace; font-size: 13px; }
pre { background: #0f2027; color: #d7f5f0; padding: 12px; border-radius: 6px; overflow: auto; max-height: 420px; }
input.qty { width: 90px; }
.lines td.n input { width: 90px; }
.lines td:first-child { min-width: 240px; }
.lines td:first-child select, .lines td:first-child input { width: 100%; }
tr.why td { border: 0; padding-top: 0; font-size: 12px; color: var(--good); }
.row { display: flex; gap: 8px; margin-bottom: 6px; }
.totals { display: flex; justify-content: flex-end; gap: 20px; padding: 10px 0; align-items: center; flex-wrap: wrap; }
.totals .btn { margin-right: auto; }
.totals .big { font-size: 17px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: #eceff3; color: #475260; white-space: nowrap; }
.b-paid, .b-ok, .b-approved, .b-received, .b-delivered, .b-allocated, .b-complete, .b-done, .b-invoiced, .b-applied { background: #e3f4ea; color: var(--good); }
.b-unpaid, .b-awaiting-approval, .b-part-paid, .b-part-received, .b-not-invoiced, .b-sent, .b-out, .b-open, .b-open-quote, .b-follow-up, .b-low-stock, .b-late-delivery { background: #fdf1d7; color: var(--warn); }
.b-on-hold, .b-rejected, .b-declined, .b-returned, .b-credited, .b-overdue-invoice { background: #fde7e5; color: var(--bad); }
.how { background: var(--soft); border-radius: 8px; padding: 8px 14px; margin-bottom: 16px; }
.how summary { cursor: pointer; font-weight: 600; }
.how ul { margin: 6px 0 2px; padding-left: 18px; }
.locked { background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tour { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.step { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; text-decoration: none; color: var(--ink); }
.step:hover { border-color: var(--accent); }
.step.off { opacity: .55; }
.step .no { background: var(--accent); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; flex: none; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 19px; }
.stats.small b { font-size: 15px; }
.bars { display: flex; gap: 6px; height: 140px; align-items: stretch; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bars i { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars span { font-size: 11px; color: var(--muted); }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 16px; }
.pos form { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { font: inherit; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.tile:hover { border-color: var(--accent); }
.tile small { color: var(--muted); }
.tile span { font-weight: 600; color: var(--accent); }
.due { text-align: right; padding: 10px 0; }
.due b { display: block; font-size: 28px; }
.receipt { background: #e3f4ea; border-radius: 6px; padding: 10px 12px; margin-top: 12px; }
.meter { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: var(--good); }
.meter.over i { background: var(--bad); }
.pos .qty { width: 70px; }
.pos, .checkout { align-items: start; }
.checkout { text-align: center; }
.checkout .due { text-align: center; }
.checkout .toolbar { justify-content: center; }
.neg { color: var(--bad); }
.up { color: var(--good); }
#modal { position: fixed; inset: 0; background: rgba(10, 20, 30, .45); display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow: auto; z-index: 10; }
.sheet { background: var(--panel); border-radius: 10px; padding: 20px 24px; width: min(900px, 100%); }
.sheet .close { float: right; }
#effect { position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100% - 32px)); max-height: 55vh; overflow: auto; background: var(--panel); border: 2px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); z-index: 15; font-size: 12px; }
#effect header { display: flex; justify-content: space-between; align-items: center; }
#effect th, #effect td { padding: 3px 4px; }
#toasts { position: fixed; top: 60px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--good); color: #fff; padding: 9px 14px; border-radius: 6px; max-width: 360px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }
.toast.bad { background: var(--bad); }
@media (max-width: 800px) {
  body { grid-template: "top" auto "nav" auto "main" 1fr / minmax(0, 1fr); }
  #nav { display: flex; overflow-x: auto; padding: 4px; border-right: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
  #nav h3 { display: none; }
  main { padding: 14px 12px 140px; }
  .pos, .cols { grid-template-columns: minmax(0, 1fr); }
  .demo { display: none; }
}
@media print {
  #top, #nav, #effect, #toasts, .noprint, .tools, .how, .tabs, .sheet .close, form { display: none !important; }
  body { display: block; background: #fff; }
  #modal { position: static; background: none; padding: 0; }
  #modal:not([hidden]) ~ * { display: none; }
  body:has(#modal:not([hidden])) main { display: none; }
}
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center; margin-top: 8px; }
.drop p { margin-top: 0; }
.file { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.file.bad { border-color: var(--bad); }
.file .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.file .head b { flex: 1; min-width: 180px; overflow-wrap: anywhere; }
.file p { margin: 6px 0 0; }
summary { cursor: pointer; margin-top: 6px; }
.btn.big { font-size: 16px; padding: 10px 24px; }
#login { position: fixed; inset: 0; background: #102a33; display: grid; place-items: center; z-index: 30; padding: 16px; }
#login form { background: var(--panel); padding: 22px; border-radius: 10px; width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; }
.signout { font-size: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; margin-bottom: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.label { border: 1px dashed var(--line); padding: 8px; text-align: center; display: flex; flex-direction: column; gap: 3px; background: #fff; color: #000; break-inside: avoid; }
.label svg { width: 100%; height: 44px; fill: #000; }
.label span { font-weight: 700; font-size: 16px; }
@media print { .noprint, form .toolbar { display: none !important; } form[data-form="take"] { display: block !important; } .signout { display: none; } }
.preview { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-top: 12px; max-height: 320px; overflow: auto; }

#top .mods { color: #fff; }
.modules { border: 0; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.modules legend { font-weight: 600; margin-bottom: 6px; }
.module { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.module input { margin-top: 3px; }
.module.held { background: var(--soft); }
button.step { font: inherit; text-align: left; cursor: pointer; }
.b-in-use { background: var(--soft); }
.guide > li { margin-bottom: 12px; }
.b-missing { background: #fdecea; color: var(--bad); }
.guide table { margin: 8px 0; }
