:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  --ink: #152821;
  --muted: #52645e;
  --paper: #fff;
  --bg: #f3f6f4;
  --line: #e2ebe6;
  --brand: #12684e;
  --brand-dark: #0d543e;
  --sidebar: #142c25;
  --radius: 13px;
  --shadow: 0 1px 2px #14372a0b, 0 4px 12px #14372a04;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #479c7c; outline-offset: 2px; }
a { color: var(--brand); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.15rem); line-height: 1.28; letter-spacing: -.035em; font-weight: 720; }
h2 { font-size: 1.12rem; line-height: 1.45; }
p { line-height: 1.55; }
code { color: #3e5550; font-size: .78rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
small { font-size: .81rem; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.muted { color: var(--muted); }
.green { color: var(--brand); }
.red-text { color: #a92c3c; }
.loading { margin: 12vh auto; text-align: center; }
.layout { display:grid; grid-template-columns: 221px minmax(0,1fr); min-height:100vh; }
.sidebar { position:sticky; top:0; height:100dvh; overflow:auto; padding:24px 14px 15px; display:flex; flex-direction:column; color:#eef8f2; background:var(--sidebar); }
.brand { display:flex; align-items:center; gap:12px; margin:1px 9px 25px; }
.brandmark { display:grid; place-items:center; background:#dcf1e4; color:#1a5a43; min-width:39px; width:39px; height:39px; border-radius:11px; font-size:1.22rem; font-weight:760; }
.brand strong, .brand small { display:block; line-height:1.4; }
.brand strong { font-size:1.03rem; letter-spacing:.05em; }
.brand small { color:#b0c8bb; margin-top:3px; }
.nav-group { margin:0 0 18px; }
.nav-title { color:#a0b9ad; padding:0 12px 7px; font-size:.78rem; }
.nav-link { border:0; border-radius:8px; padding:9px 11px; min-height:42px; width:100%; text-align:left; display:flex; gap:12px; align-items:center; color:#d6e7de; background:transparent; margin:2px 0; font-size:.92rem; }
.nav-link:hover { background:#234537; color:white; }
.nav-link.active { background:#245140; color:#fff; box-shadow:inset 3px 0 #76d8ac; font-weight:650; }
.nav-icon { display:grid; place-items:center; color:#a8dfc6; width:20px; font-size:1.15rem; font-family: system-ui,sans-serif; }
.side-footer { margin-top:auto; padding:15px 11px 4px; border-top:1px solid #355245; display:flex; gap:9px; align-items:flex-start; }
.side-footer strong,.side-footer small { display:block; }
.side-footer strong { font-size:.84rem; }
.side-footer small { color:#a5bfb1; margin-top:4px; }
.local-dot { width:8px; height:8px; border-radius:100%; background:#7cddae; margin-top:5px; }
.main-layout { min-width:0; }
.topbar { min-height:68px; padding:12px clamp(18px,3.05vw,50px); background:white; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:12px; }
.crumb, .top-actions { display:flex; gap:12px; align-items:center; font-size:.88rem; }
.crumb>span, .head-date { color:var(--muted); }
.demo-chip { display:inline-flex; white-space:nowrap; color:#256448; border:1px solid #d5e9de; background:#f2f9f4; border-radius:20px; padding:5px 10px; font-size:.8rem; }
.account { display:flex; align-items:center; text-align:left; gap:8px; padding:3px 0 3px 8px; color:var(--ink); font-size:.86rem; background:none; border:none; }
.account small { display:block; color:var(--muted); font-size:.76rem; margin-top:2px; }
.avatar { display:grid; place-items:center; height:34px; min-width:34px; border-radius:10px; color:#12684e; background:#e7f3eb; font-weight:700; }
.content { width:min(100%, 1570px); margin:0 auto; padding:30px clamp(18px,3.05vw,50px) 50px; }
.page-heading { display:flex; justify-content:space-between; align-items:center; gap:18px; margin-bottom:24px; }
.page-heading p { color:var(--muted); margin-top:7px; }
.date-control { display:flex; align-items:center; gap:9px; font-size:.86rem; color:var(--muted); flex-shrink:0; }
.date-control input { width:auto; }
.panel, .metric { border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); background:var(--paper); min-width:0; }
.metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:15px; margin-bottom:20px; }
.metric { padding:16px 17px 17px; display:flex; flex-direction:column; min-height:122px; }
.metric-head { display:flex; min-height:28px; align-items:center; justify-content:space-between; gap:8px; color:#4e6259; font-size:.9rem; font-weight:535; }
.metric>strong { font-size:clamp(1.22rem,2.3vw,1.83rem); font-variant-numeric:tabular-nums; line-height:1.28; margin-top:7px; overflow-wrap:anywhere; }
.metric>small { color:var(--muted); margin-top:7px; }
.metric-icon { display:grid; place-items:center; width:29px; height:29px; flex-shrink:0; border-radius:8px; font-weight:750; }
.teal { color:#165f46; background:#e5f4eb; }
.blue { color:#27539b; background:#eaf1fc; }
.orange { color:#8a4e13; background:#fff0da; }
.violet { color:#634b92; background:#f1ebfc; }
.slate { color:#4e6360; background:#edf2f1; }
.red { color:#9b293a; background:#fcebef; }
.unit { font-size:.88rem; color:var(--muted); font-weight:570; }
.dashboard-grid { display:grid; grid-template-columns:minmax(0,1.7fr) minmax(238px,1fr); align-items:start; gap:17px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:16px 18px; }
.panel-head p { color:var(--muted); font-size:.85rem; margin-top:3px; }
.panel-body { padding:0 18px 18px; }
.quick-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(126px,1fr)); padding:1px 18px 18px; gap:11px; }
.quick { display:flex; text-align:left; align-items:flex-start; flex-direction:column; gap:7px; min-height:112px; padding:11px; border:1px solid var(--line); border-radius:9px; background:#fbfdfc; color:var(--ink); }
.quick:hover { background:#edf7f0; border-color:#b7d6c4; }
.quick strong { font-size:.96rem; }
.quick small { color:var(--muted); line-height:1.35; font-size:.8rem; }
.quick-icon { display:grid; place-items:center; font-size:1.2rem; width:32px; height:32px; border-radius:8px; font-weight:700; }
.stock-bar { display:flex; border-radius:7px; overflow:hidden; height:10px; margin:0 18px 13px; }
.stock-bar .teal,.legend-square.teal { background:#369576; }
.stock-bar .blue,.legend-square.blue { background:#5684b9; }
.stock-bar .orange,.legend-square.orange { background:#deaa66; }
.stock-legend { display:grid; gap:8px; margin:0 18px 17px; }
.stock-legend>div { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:8px; font-size:.87rem; }
.stock-legend strong { font-variant-numeric:tabular-nums; }
.stock-legend small { color:var(--muted); font-weight:450; }
.legend-square { width:10px; height:10px; border-radius:3px; }
.table-wrap { overflow-x:auto; }
table { border-collapse:collapse; width:100%; text-align:left; font-size:.87rem; }
th { padding:10px 14px; color:#4a6259; background:#f4f8f6; font-weight:600; white-space:nowrap; }
td { padding:10px 14px; border-bottom:1px solid #edf1ee; vertical-align:middle; overflow-wrap:anywhere; }
th:first-child, td:first-child { padding-left:18px; }
th:last-child, td:last-child { padding-right:18px; }
tbody tr:last-child td { border-bottom:0; }
tbody tr:hover td { background:#fcfdfc; }
.recent :is(th,td) { padding-left:8px; padding-right:8px; }
.recent :is(th,td):first-child { padding-left:15px; }
.recent :is(th,td):last-child { padding-right:13px; }
.recent td:nth-child(4) { white-space:nowrap; }
.cell-sub { display:block; margin-top:4px; color:var(--muted); white-space:nowrap; }
.order-ref { color:#195945; white-space:nowrap; }
.tag { display:inline-flex; align-items:center; border-radius:7px; white-space:nowrap; padding:3px 8px; font-size:.79rem; font-weight:530; }
.empty { text-align:center; padding:32px 15px; color:var(--muted); font-size:.92rem; }
.button { min-height:37px; display:inline-flex; justify-content:center; align-items:center; gap:6px; border:1px solid transparent; border-radius:8px; line-height:1.3; padding:8px 13px; font-size:.88rem; font-weight:620; text-decoration:none; color:var(--ink); white-space:nowrap; }
.button.primary { background:var(--brand); color:#fff; }
.button.primary:hover { background:var(--brand-dark); }
.button.secondary { background:#fff; border-color:#cfdfd5; }
.button.secondary:hover { background:#f0f7f2; }
.button.text { background:transparent; color:#156048; padding:5px 7px; min-height:30px; }
.button.text:hover { background:#eaf5ee; }
.button.danger { color:#a53240; }
.button.danger:hover { background:#fcebef; }
.button.full { width:100%; min-height:43px; }
.toolbar { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.fields .wide { grid-column:1/-1; }
.field { display:grid; align-content:start; gap:6px; min-width:0; }
.field>span { color:#3a5147; font-size:.88rem; font-weight:540; }
input:where(:not([type="checkbox"],[type="radio"])), select, textarea, .value-box { border:1px solid #cfdfd5; color:var(--ink); background:#fff; border-radius:8px; width:100%; min-height:38px; padding:8px 10px; font-size:.9rem; }
input::placeholder,textarea::placeholder { color:#687b73; }
input[type="date"] { padding:7px 9px; min-width:130px; }
textarea { display:block; resize:vertical; }
select { appearance:none; padding-right:27px; background-image:linear-gradient(45deg,transparent 50%,#557268 50%),linear-gradient(135deg,#557268 50%,transparent 50%); background-position:calc(100% - 14px) 50%,calc(100% - 9px) 50%; background-size:5px 5px; background-repeat:no-repeat; }
.order-grid { display:grid; grid-template-columns:minmax(0,1.85fr) minmax(260px,1fr); align-items:start; gap:16px; }
.scan-row { display:flex; gap:10px; align-items:end; margin:0 18px 11px; }
.scan-row .field { flex:1; }
.accessory-row { margin-bottom:16px; }
.cart-table td,.cart-table th { padding-right:8px; padding-left:8px; }
.cart-table :is(th,td):first-child { padding-left:18px; }
.cart-table :is(th,td):last-child { padding-right:18px; }
.order-main .panel-body { margin-top:12px; }
.receipt-list { display:grid; gap:10px; }
.receipt-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto; gap:6px; align-items:end; }
.receipt-actions { display:flex; gap:7px; flex-wrap:wrap; margin:8px 0 0; }
.checkout-credit { display:flex; align-items:center; gap:8px; margin:9px 0; font-size:.9rem; font-weight:600; }
.checkout-credit input, #order-refund-form input[type="checkbox"] { width:16px; height:16px; accent-color:var(--brand); }
.dialog-body #order-refund-form input[type="checkbox"] { min-width:16px; margin:0; }
#order-refund-form .fields { margin-top:12px; }
.totals { display:grid; gap:10px; padding:13px 12px; margin:12px 0; border-radius:8px; background:#eef6f1; font-size:.9rem; }
.totals>div { display:flex; align-items:center; justify-content:space-between; gap:9px; }
.totals dt { color:#446157; }
.totals dd { margin:0; color:#1b4939; font-variant-numeric:tabular-nums; font-weight:680; }
.totals.inline { grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); }
.totals.inline>div { display:grid; align-content:start; gap:5px; }
.purchase-lines { margin:12px 0 5px; display:grid; gap:12px; }
.purchase-line { min-width:0; padding:10px 12px; border:1px solid var(--line); border-radius:9px; margin:0; background:#fafcfb; }
.purchase-line legend { color:var(--muted); padding:0 5px; font-size:.84rem; }
.line-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.line-fields .span-two { grid-column:1/-1; }
.stack { display:grid; gap:10px; }
.stack .totals { margin:4px 0; }
.previous { margin-top:18px; }
.inventory-head,.filters { flex-wrap:wrap; justify-content:flex-start; }
.inventory-head .filter-search { margin-left:auto; width:min(340px,100%); }
.inventory-list th:first-child { width:7.5rem; }
.inventory-list th:nth-child(2) { width:6.5rem; }
.inventory-list th:nth-child(3) { width:clamp(9rem,16vw,12rem); }
.inventory-list td:nth-child(3) .cell-sub { white-space:normal; }
.received-time { white-space:nowrap; font-variant-numeric:tabular-nums; }
.inventory-sort { display:inline-flex; align-items:center; gap:5px; border:0; color:inherit; background:transparent; padding:0; text-align:left; }
.inventory-sort span { color:var(--muted); font-size:.76em; }
.inventory-sort:hover, .inventory-list th[aria-sort] .inventory-sort, .inventory-list th[aria-sort] .inventory-sort span { color:var(--brand-dark); }
.segmented { display:flex; flex-wrap:wrap; gap:6px; }
.stockin-modes { margin-bottom:14px; }
.button.seg { background:#f2f6f4; color:#426057; min-height:35px; padding:6px 11px; }
.button.seg.active { color:#0d583f; border-color:#bfdbcc; background:#e3f2e8; }
.filters { align-items:end; }
.filters>.field { min-width:155px; }
.range { display:flex; flex-wrap:wrap; align-items:end; gap:8px; }
.small-metrics { margin:14px 0; }
.small-metrics .metric { min-height:90px; }
.small-metrics .metric>strong { font-size:1.43rem; }
dialog { padding:0; border:1px solid var(--line); color:var(--ink); width:min(720px,calc(100% - 28px)); max-height:calc(100dvh - 32px); border-radius:14px; box-shadow:0 24px 65px #102d2580; overflow:auto; }
dialog::backdrop { background:#112a2480; }
.dialog-header { position:sticky; top:0; background:#fff; z-index:1; display:flex; justify-content:space-between; gap:12px; align-items:center; padding:13px 17px; border-bottom:1px solid var(--line); }
.close { border:0; border-radius:8px; min-width:34px; height:34px; font-size:1.23rem; background:#eff5f1; color:#36594a; }
.dialog-body { padding:16px 17px; }
.dialog-body .table-wrap { border:1px solid var(--line); border-radius:8px; }
.dialog-body td input { min-width:65px; max-width:155px; }
.dialog-note { color:var(--muted); font-size:.9rem; margin-bottom:10px; }
.dialog-feedback { background:#fcebef; color:#942f3e; border-radius:7px; padding:9px 11px; margin-bottom:10px; font-size:.9rem; }
.dialog-foot { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; padding-top:15px; }
.login { display:grid; place-items:center; background:#19372d; min-height:100dvh; padding:22px; }
.login-panel { width:min(480px,100%); background:#fbfdfb; border-radius:19px; padding:27px; box-shadow:0 18px 56px #091c1680; }
.login-brand { color:var(--ink); margin:0 0 22px; }
.login-brand small { color:var(--muted); }
.login-form { display:grid; gap:13px; margin-top:20px; }
.login-form .dialog-feedback { margin-bottom:0; }
.login-foot { display:block; margin-top:18px; color:var(--muted); }
.permission-box { min-width:0; border:1px solid var(--line); border-radius:8px; margin:15px 0 0; padding:9px 12px 12px; }
.permission-box legend { padding:0 5px; font-weight:600; }
.permission-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(250px,100%),1fr)); gap:9px 12px; }
.permission-grid label { display:grid; grid-template-columns:16px minmax(0,1fr); align-items:start; gap:8px; font-size:.88rem; line-height:1.45; cursor:pointer; }
.permission-grid input[type="checkbox"] { width:16px; height:16px; margin:2px 0 0; accent-color:#195c47; }
.account-permissions { display:flex; flex-wrap:wrap; gap:5px; }
.toast { position:fixed; right:22px; bottom:22px; z-index:3; max-width:min(470px,calc(100% - 44px)); border-radius:9px; padding:12px 15px; color:white; background:#195c47; box-shadow:0 8px 25px #1b4b3f38; font-size:.92rem; }
.toast.error { background:#942f3e; }
@media(max-width:1100px) {
  .layout { grid-template-columns:185px minmax(0,1fr); }
  .quick-grid { grid-template-columns:repeat(auto-fit,minmax(100px,1fr)); }
}
@media(max-width:890px) {
  .dashboard-grid,.order-grid { grid-template-columns:minmax(0,1fr); }
  .stock-overview { order:2; }
}
@media(max-width:680px) {
  .layout { display:block; }
  .sidebar { position:relative; width:100%; height:auto; padding:12px; }
  .sidebar .brand { margin:0 2px 8px; }
  .sidebar nav { display:flex; flex-wrap:wrap; gap:2px; }
  .nav-group { display:contents; }
  .nav-title,.side-footer { display:none; }
  .nav-link { width:auto; padding:5px 6px; min-height:34px; margin:0; gap:3px; font-size:.82rem; }
  .nav-icon { width:16px; }
  .topbar { min-height:52px; }
  .head-date { display:none; }
  .content { padding-top:19px; }
  .page-heading { align-items:flex-start; flex-wrap:wrap; margin-bottom:17px; }
  .metrics { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .metric { padding:10px; }
  .panel-head { padding:12px; }
  .scan-row,.quick-grid { margin-left:0; margin-right:0; padding-left:12px; padding-right:12px; }
  .quick-grid { gap:7px; }
  .quick { min-width:0; padding:8px; }
}

.unit-tools { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:0 18px 9px; color:var(--muted); font-size:.87rem; }
.unit-code { white-space:nowrap; color:#214f42; font-weight:650; }
.unit-actions { justify-content:flex-start; flex-wrap:nowrap; }
.purchase-codes { display:grid; gap:6px; margin:8px 0; }
summary { cursor:pointer; color:var(--brand); }
#pick-results { margin-top:12px; }
#pick-results .dialog-note { margin-top:10px; }
#stocktake-result details { margin-top:8px; }
.label-sheet { display:grid; grid-template-columns:repeat(auto-fit,minmax(61mm,1fr)); gap:3mm; }
.print-label { color:#000; background:#fff; min-width:60mm; padding:2mm; text-align:center; border:1px solid #d8e2dc; border-radius:2mm; break-inside:avoid; }
.print-label strong { font-size:3.5mm; }
.label-details { display:block; margin-top:.5mm; font-size:3mm; line-height:1.35; overflow-wrap:anywhere; }
.print-label code { color:#000; font-size:3.2mm; letter-spacing:.2mm; }
.barcode { height:12mm; width:56mm; position:relative; margin:1mm auto; }
.barcode i { position:absolute; top:0; bottom:0; display:block; background:#000; print-color-adjust:exact; -webkit-print-color-adjust:exact; }
@media print {
  @page { margin:8mm; }
  body:has(dialog[open] .label-sheet)>:not(dialog),dialog:has(.label-sheet) .dialog-header,
  dialog:has(.label-sheet) .dialog-body>:not(.label-sheet) { display:none !important; }
  dialog:has(.label-sheet) { position:static; margin:0; max-height:none; overflow:visible; width:100%; border:0; box-shadow:none; }
  dialog:has(.label-sheet)::backdrop { background:transparent; }
  dialog:has(.label-sheet) .dialog-body { padding:0; }
  .label-sheet { display:grid; grid-template-columns:repeat(auto-fit,61mm); }
}
@media(max-width:680px) {
  .scan-row { flex-wrap:wrap; }
  .scan-row .field { flex-basis:100%; }
  .unit-tools { flex-wrap:wrap; }
}
