:root {
  --navy: #0f2f57; --navy-2: #173f70; --blue: #1d5fa8; --blue-l: #e8f0fa;
  --saffron: #e8772e; --green: #138808; --ok: #1e7b3c; --ok-l: #e6f4ea;
  --warn: #9a5b00; --warn-l: #fff4dc; --bad: #b3261e; --bad-l: #fdecea;
  --ink: #1c2733; --ink-2: #4a5868; --ink-3: #7b8796; --line: #d9dfe7; --line-2: #e9edf2;
  --bg: #f2f4f7; --card: #fff; --r: 8px;
  --font: "Noto Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
.tricolour { position: fixed; top: 0; left: 0; right: 0; height: 3px; display: flex; z-index: 50; }
.tricolour i { flex: 1; } .tricolour i:nth-child(1) { background: var(--saffron); } .tricolour i:nth-child(2) { background: #fff; } .tricolour i:nth-child(3) { background: var(--green); }
.boot { padding: 80px; text-align: center; color: var(--ink-3); }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .1px; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; padding-top: 3px; }
.side { background: var(--navy); color: #c9d6e6; display: flex; flex-direction: column; position: sticky; top: 3px; height: calc(100vh - 3px); }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { width: 34px; height: 34px; }
.brand b { display: block; color: #fff; font-size: 16px; letter-spacing: .3px; }
.brand span { font-size: 11px; color: #9fb3cc; }
.nav { padding: 8px 0; flex: 1; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: #c9d6e6; font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(255,255,255,.09); color: #fff; border-left-color: var(--saffron); }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; }
.nav .sec { padding: 14px 18px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: #7f97b5; }
.side .who { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side .who b { color: #fff; display: block; font-size: 13px; }
.side .who button { margin-top: 6px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 16px; position: sticky; top: 3px; z-index: 5; }
.topbar .store { margin-left: auto; text-align: right; font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.topbar .store b { color: var(--ink); font-size: 13px; }
.page { padding: 20px 24px 40px; max-width: 1400px; width: 100%; }
.mobnav { display: none; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.card > .hd { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.card > .hd .sp { flex: 1; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.actions .btn { white-space: normal; text-align: center; justify-content: center; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .sp { flex: 1; }
.stack > * + * { margin-top: 12px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.kpi .v { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--blue); }

/* forms */
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
label.f > span em { color: var(--bad); font-style: normal; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #c3ccd7; border-radius: 6px; padding: 8px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29,95,168,.25); border-color: var(--blue); }
input[type=checkbox] { width: auto; }
input.sm, select.sm { padding: 5px 7px; font-size: 13px; }
input.num { text-align: right; }
textarea { min-height: 70px; resize: vertical; }
.fgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.fgrid .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

/* buttons */
button, .btn { font: inherit; font-weight: 500; border: 1px solid #b9c4d2; background: #fff; color: var(--ink); border-radius: 6px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
button:hover, .btn:hover { background: #f4f7fb; text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; } .primary:hover { background: #18528f; }
.success { background: var(--ok); border-color: var(--ok); color: #fff; } .success:hover { background: #186531; }
.danger { color: var(--bad); border-color: #e3b3ae; } .danger:hover { background: var(--bad-l); }
.ghost { border-color: transparent; background: transparent; } .ghost:hover { background: rgba(0,0,0,.05); }
.side .ghost { color: #c9d6e6; border-color: rgba(255,255,255,.2); padding: 4px 10px; font-size: 12px; }
.big { padding: 11px 18px; font-size: 15px; }
.xs { padding: 3px 8px; font-size: 12px; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid #b9c4d2; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid #d5dce5; padding: 7px 12px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }

/* tables */
table { border-collapse: collapse; width: 100%; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); background: #f6f8fb; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafbfd; }
.tbl tr.click { cursor: pointer; }
.tbl.items td { padding: 6px 6px; } .tbl.items th { padding: 8px 6px; }
.tbl .name b { display: block; font-weight: 600; }
.tbl .name small { color: var(--ink-3); }
.empty { padding: 30px; text-align: center; color: var(--ink-3); }
.scroll-x { overflow-x: auto; }

/* badges & notes */
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--line-2); color: var(--ink-2); vertical-align: 1px; white-space: nowrap; }
.badge.h { background: #fde7d6; color: #8a3b07; } .badge.h1 { background: #fbd5d2; color: #8c1d18; } .badge.x { background: #3a0d0a; color: #fff; }
.badge.ok { background: var(--ok-l); color: var(--ok); } .badge.warn { background: var(--warn-l); color: var(--warn); } .badge.bad { background: var(--bad-l); color: var(--bad); }
.badge.blue { background: var(--blue-l); color: var(--blue); } .badge.count { background: var(--saffron); color: #fff; }
.note { padding: 10px 12px; border-radius: 6px; border: 1px solid; font-size: 13px; }
.note.warn { background: var(--warn-l); border-color: #efd29b; color: #5c3b00; }
.note.info { background: var(--blue-l); border-color: #c4d7ee; color: #123d6b; }
.note.bad { background: var(--bad-l); border-color: #f0c0bb; color: #7a1a14; }
.note.ok { background: var(--ok-l); border-color: #b8dcc3; color: #134d26; }

/* billing screen */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.pos .totals { position: sticky; top: 70px; }
.searchbox { position: relative; }
.searchbox input { font-size: 15px; padding: 11px 12px 11px 38px; }
.searchbox .mag { position: absolute; left: 12px; top: 11px; color: var(--ink-3); }
.dropdown { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(15,47,87,.15); z-index: 20; max-height: 380px; overflow: auto; }
.dropdown .it { padding: 8px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.dropdown .it:last-child { border-bottom: 0; }
.dropdown .it.on, .dropdown .it:hover { background: var(--blue-l); }
.dropdown .it .n { font-weight: 600; } .dropdown .it .m { font-size: 12px; color: var(--ink-3); }
.dropdown .it .p { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tline { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.tline.grand { border-top: 2px solid var(--navy); margin-top: 8px; padding-top: 10px; font-size: 22px; font-weight: 700; color: var(--navy); }
.words { font-size: 12px; color: var(--ink-2); font-style: italic; margin-top: 4px; }
.items input.sm { width: 62px; } .items input.bt { width: 92px; } .items input.ex { width: 82px; }
tr.unverified td { background: #fffaf0; }
tr.expired td { background: var(--bad-l); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(12,26,45,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 980px; }
.modal > .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; background: #f8fafc; border-radius: 10px 10px 0 0; }
.modal > .hd h2 { flex: 1; }
.modal > .bd { padding: 18px; }
.modal > .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: #fafbfc; border-radius: 0 0 10px 10px; }
.x { border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 2px 8px; color: var(--ink-3); }

/* scanner */
.cam { position: relative; background: #0b1520; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.cam video, .cam img { width: 100%; height: 100%; object-fit: contain; }
.cam .frame { position: absolute; inset: 12% 8%; border: 2px solid rgba(255,255,255,.7); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.cam .msg { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 3px #000; }
.progress { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .2s; }
.cand { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.cand + .cand { margin-top: 8px; }
.cand.on { border-color: var(--blue); background: var(--blue-l); box-shadow: inset 3px 0 0 var(--blue); }
.cand .sc { margin-left: auto; text-align: right; }
.diff { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 8px 12px; align-items: center; }
.diff .h { font-size: 11px; text-transform: uppercase; color: var(--ink-3); letter-spacing: .5px; }
.diff .was { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.diff input.changed { border-color: var(--saffron); background: #fff7f0; }
.question { font-size: 16px; font-weight: 600; color: var(--navy); }
.ocrtext { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; background: #f6f8fb; border: 1px solid var(--line-2); border-radius: 6px; padding: 10px; max-height: 160px; overflow: auto; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #0f2f57 0%, #1d4f8a 55%, #f2f4f7 55.2%); }
.login { width: 100%; max-width: 440px; }
.login .seal { text-align: center; color: #fff; margin-bottom: 18px; }
.login .seal img { width: 60px; height: 60px; }
.login .seal h1 { font-size: 24px; margin-top: 6px; letter-spacing: .5px; }
.login .seal p { margin: 2px 0 0; color: #bcd0e8; font-size: 13px; }
.namechips { display: flex; flex-wrap: wrap; gap: 8px; }
.namechips button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.pinpad button { justify-content: center; font-size: 18px; padding: 12px; }
.pindots { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.pindots i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--navy); }
.pindots i.f { background: var(--navy); }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #17293d; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; max-width: 90vw; }
#toast div.bad { background: var(--bad); } #toast div.ok { background: var(--ok); }

.bars { display: grid; gap: 6px; }
.bars .b { display: grid; grid-template-columns: 90px 1fr 90px; gap: 10px; align-items: center; font-size: 12.5px; }
.bars .b i { display: block; height: 14px; background: var(--blue); border-radius: 0 3px 3px 0; min-width: 2px; }

/* responsive */
@media (max-width: 1100px) { .pos { grid-template-columns: 1fr; } .pos .totals { position: static; } .g4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 10px 14px; }
  .page { padding: 14px 12px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .mobnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .mobnav a { flex: 1; text-align: center; color: #c9d6e6; padding: 8px 2px 7px; font-size: 11px; border-top: 3px solid transparent; }
  .mobnav a .ico { display: block; font-size: 18px; line-height: 1.2; }
  .mobnav a.on { color: #fff; border-top-color: var(--saffron); }
  .mobnav a:hover { text-decoration: none; }
  .diff { grid-template-columns: 90px 1fr 1fr; }
  #toast { bottom: 84px; }
  .seg.full { display: flex; } .seg.full button { flex: 1 1 auto; justify-content: center; }
  .pcard .fgrid { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .hide-m { display: none !important; }
}

/* ---------------- print ---------------- */
#print-root { display: none; }
@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
}
.inv { color: #000; font: 11px/1.35 var(--font); }
.inv table { width: 100%; border-collapse: collapse; }
.inv .head { display: grid; grid-template-columns: 1fr auto; gap: 10px; border-bottom: 2px solid #000; padding-bottom: 6px; }
.inv .head h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.inv .head .addr { font-size: 10.5px; }
.inv .title { text-align: center; font-weight: 700; font-size: 12px; letter-spacing: 2px; border-bottom: 1px solid #000; padding: 4px 0; }
.inv .meta { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #000; }
.inv .meta > div { padding: 5px 6px; } .inv .meta > div + div { border-left: 1px solid #000; }
.inv .meta td { padding: 1px 4px 1px 0; vertical-align: top; } .inv .meta td:first-child { color: #333; width: 78px; }
.inv .lines th { border-bottom: 1px solid #000; border-top: 0; font-size: 10px; text-align: left; padding: 4px 3px; }
.inv .lines td { padding: 3px; border-bottom: 1px dotted #999; vertical-align: top; }
.inv .lines .r { text-align: right; font-variant-numeric: tabular-nums; }
.inv .foot { display: grid; grid-template-columns: 1fr 240px; border-top: 1px solid #000; margin-top: 2px; }
.inv .foot > div { padding: 6px; } .inv .foot > div + div { border-left: 1px solid #000; }
.inv .slabs th, .inv .slabs td { border: 1px solid #777; padding: 2px 4px; font-size: 10px; }
.inv .tot td { padding: 1px 0; } .inv .tot td + td { text-align: right; font-variant-numeric: tabular-nums; }
.inv .tot tr.g td { border-top: 1px solid #000; font-size: 14px; font-weight: 700; padding-top: 4px; }
.inv .sign { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #000; padding-top: 6px; margin-top: 4px; font-size: 10px; }
.inv .sign .r { text-align: right; padding-top: 26px; }
.inv .cancelled { color: #b3261e; font-weight: 700; text-align: center; font-size: 16px; border: 2px solid #b3261e; padding: 4px; margin: 4px 0; }
.inv.a4 { width: 194mm; } .inv.a5 { width: 132mm; font-size: 10px; }
.inv.a5 .head h1 { font-size: 15px; }
.inv.t80 { width: 72mm; font: 11px/1.3 ui-monospace, Menlo, Consolas, "Courier New", monospace; }
.inv.t80 .c { text-align: center; } .inv.t80 hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
.inv.t80 td { padding: 1px 0; vertical-align: top; } .inv.t80 .r { text-align: right; }
.inv.t80 h1 { font-size: 14px; margin: 0; }
.preview { background: #e9edf2; padding: 20px; border-radius: 8px; overflow: auto; }
.preview .sheet { background: #fff; margin: 0 auto; padding: 8mm; box-shadow: 0 2px 12px rgba(0,0,0,.15); width: max-content; }
