/* ---------- design tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe2e7;
  --text: #15171a;
  --text-2: #4d535c;
  --muted: #6b7280;
  --primary: #1d5fd1;
  --primary-h: #174fb0;
  --primary-soft: #e7effc;
  --ok: #0f7b3e;
  --ok-soft: #e4f5ea;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --danger: #c22a2a;
  --danger-soft: #fdeaea;
  --series-1: #2a78d6;
  --grid: #e7e9ed;
  --side: #10213f;
  --side-text: #c9d4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .22);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111317; --surface: #1a1d22; --surface-2: #20242a; --border: #30353d;
    --text: #eef0f3; --text-2: #c3c8d0; --muted: #9aa1ac;
    --primary: #4a8ef0; --primary-h: #6aa3f5; --primary-soft: #1d2b44;
    --ok: #4cc27e; --ok-soft: #173123; --warn: #e3a63b; --warn-soft: #33290f; --danger: #f07070; --danger-soft: #3a1b1b;
    --series-1: #3987e5; --grid: #2a2f36; --side: #0b1424; --side-text: #b5c2db;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111317; --surface: #1a1d22; --surface-2: #20242a; --border: #30353d;
  --text: #eef0f3; --text-2: #c3c8d0; --muted: #9aa1ac;
  --primary: #4a8ef0; --primary-h: #6aa3f5; --primary-soft: #1d2b44;
  --ok: #4cc27e; --ok-soft: #173123; --warn: #e3a63b; --warn-soft: #33290f; --danger: #f07070; --danger-soft: #3a1b1b;
  --series-1: #3987e5; --grid: #2a2f36; --side: #0b1424; --side-text: #b5c2db;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.4; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 8px 0 0; }
a { color: var(--primary); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
kbd { font-family: ui-monospace, Consolas, monospace; font-size: 11px; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); font-weight: 600; }
.pos { color: var(--ok); }
.center { text-align: center; margin: 12px; }
.mt { margin-top: 18px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 24px !important; }
.ok-msg { color: var(--ok); }
.error-box, .alert-error { background: var(--danger-soft); color: var(--danger); padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.err { color: var(--danger); min-height: 1em; margin: 0; font-weight: 500; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; }

/* ---------- controls ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 30%, transparent); outline-offset: 0; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); margin: 0; flex: none; }
input[type=file] { padding: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); border-color: var(--primary-h); }
.btn-primary kbd { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn-lg { padding: 12px 20px; min-height: 48px; font-size: 16px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 16px; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.del:hover { color: var(--danger); background: var(--danger-soft); }
.badge { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; min-width: 18px; }
.badge:empty { display: none; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; }
.tag-void { background: var(--danger-soft); color: var(--danger); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--text); border-radius: 6px; padding: 2px 4px 2px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; margin: 4px 4px 0 0; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; }
.chips:empty { display: none; }

/* forms */
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.form label small { font-weight: 400; }
.form label.check-label, .check-label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { flex-direction: row !important; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--text) !important; }
.seg label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.margin { font-weight: 700; padding: 9px 0; color: var(--ok); }
.margin.neg { color: var(--danger); }

/* ---------- login / setup ---------- */
.center-card { max-width: 420px; margin: 8vh auto; background: var(--surface); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); }
.center-card.wide { max-width: 640px; }
.center-card h1 { font-size: 26px; margin-bottom: 4px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 210px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 6px 10px 18px; min-width: 0; }
.brand img { flex: none; border-radius: 8px; }
.brand .lbl { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand .store-name { color: var(--side-text); font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordmark { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.wordmark i { font-style: normal; color: #ffc21a; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .wordmark { font-size: 30px; color: #0f1d3a; }
.login-brand .wordmark i { color: #2453e0; }
.side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--side-text); text-decoration: none; border-radius: 8px; font-weight: 600; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.active { background: var(--primary); color: #fff; }
.side a kbd { margin-left: auto; background: transparent; color: inherit; border-color: rgba(255,255,255,.25); }
.side .ic { width: 22px; text-align: center; }
.side-foot { margin-top: auto; }
.user-btn { width: 100%; display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.06); color: #fff; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; font: inherit; text-align: left; }
.user-btn small { display: block; color: var(--side-text); font-size: 11px; text-transform: capitalize; }
main.page { overflow-y: auto; padding: 18px 22px 40px; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { max-width: 380px; }
.filters select, .filters input[type=date] { width: auto; }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.sum-line { margin: 0 0 10px; color: var(--text-2); }
.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.tab.active { background: var(--primary); color: #fff; }
.offline-banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: var(--danger); color: #fff; text-align: center; padding: 8px; font-weight: 600; }
body.offline .offline-banner { display: block; }

/* ---------- cards & tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.card .table-wrap { border: 0; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 10px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tfoot td { font-weight: 600; border-bottom: 0; }
.tbl.compact td { padding: 6px 8px; }
.tbl.compact th { padding: 6px 8px; position: static; }
.tbl th.num { text-align: right; }
.tbl .chk { width: 36px; }
tr.inactive td { opacity: .55; }
tr.void-row td { text-decoration: line-through; color: var(--muted); }
tr.void-row td:first-child { text-decoration: none; }
.grand-row td { font-size: 18px; font-weight: 800; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: 4px; }
.stock { font-weight: 700; }
.stock.low { color: var(--warn); }
.stock.neg { color: var(--danger); }
.link { display: inline-block; margin-top: 8px; font-weight: 600; }

/* ---------- scanner ---------- */
.scanbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.scan-field { flex: 1; min-width: 260px; position: relative; }
.scan-input { font-size: 18px; padding: 12px 14px 12px 46px; min-height: 52px; border: 2px solid var(--primary); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7280'%3E%3Cpath d='M2 5h2v14H2zm3 0h1v14H5zm2 0h3v14H7zm4 0h1v14h-1zm3 0h2v14h-2zm3 0h1v14h-1zm2 0h3v14h-3z'/%3E%3C/svg%3E") no-repeat 14px center / 22px; }
.scan-results { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; }
.scan-results.open { display: block; }
.scan-item { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.scan-item:last-child { border-bottom: 0; }
.scan-item.active, .scan-item:hover { background: var(--primary-soft); }
.scan-item.inactive { opacity: .6; }
.si-main { display: flex; flex-direction: column; min-width: 0; }
.si-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-main span { font-size: 12.5px; }
.si-stock { font-size: 13px; color: var(--muted); }
.si-stock.low { color: var(--warn); font-weight: 700; }
.si-stock.neg { color: var(--danger); font-weight: 700; }
.si-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.scan-empty { padding: 14px; color: var(--muted); }

/* ---------- billing ---------- */
.page-billing { padding: 14px 16px 14px; overflow: hidden; }
.page-billing > .view { height: 100%; }
.bill-layout { display: grid; grid-template-columns: 1fr 330px; gap: 14px; height: 100%; }
.bill-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.cart-wrap { flex: 1; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-height: 0; }
.cart td { padding: 7px 8px; }
.cart .idx { width: 34px; color: var(--muted); text-align: center; }
.cart tr.last { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.item-name { font-weight: 700; }
.cart .qty-col { width: 150px; text-align: center; }
.cart .amt { font-weight: 700; font-size: 16px; white-space: nowrap; }
.qty-ctl { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.qbtn { width: 32px; height: 36px; border: 0; background: var(--surface-2); font-size: 18px; font-weight: 700; color: var(--text); cursor: pointer; }
.qbtn:hover { background: var(--primary-soft); }
.qty-in { width: 64px; text-align: center; border: 0; border-radius: 0; font-weight: 700; font-size: 16px; min-height: 36px; padding: 4px; }
.qty-ctl .qty-in:focus { outline: 2px solid var(--primary); }
.unit { margin-top: 2px; }
.price-in { width: 92px; text-align: right; min-height: 34px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.cart-empty { text-align: center; color: var(--text-2); padding: 70px 20px !important; font-size: 17px; }
.big-icon { font-size: 46px; margin-bottom: 8px; }
.hint-bar { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 2px 0; font-size: 12.5px; color: var(--muted); }
.bill-side { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow-y: auto; }
.cust { display: grid; gap: 8px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 0; padding: 10px 0; border-top: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.totals dt { color: var(--text-2); }
.totals dd { margin: 0; text-align: right; font-weight: 600; }
.grand { display: flex; justify-content: space-between; align-items: baseline; background: var(--primary-soft); border-radius: 10px; padding: 12px 14px; }
.grand span { font-weight: 800; color: var(--text-2); }
.grand b { font-size: 32px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.btn-pay { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 20px; min-height: 60px; border-radius: 12px; }
.btn-pay:hover:not(:disabled) { background: color-mix(in srgb, var(--ok) 85%, #000); border-color: transparent; }
.btn-pay kbd { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.4); }
.side-actions { display: flex; gap: 8px; }
.side-actions .btn { flex: 1; }
.last-card { background: var(--ok-soft); border-radius: 10px; padding: 12px; display: grid; gap: 4px; }
.last-card .big { font-size: 22px; font-weight: 800; }
.change { font-weight: 700; font-size: 18px; min-height: 1.3em; }
.change.ok { color: var(--ok); }
.change.bad { color: var(--danger); }
.list-btn { justify-content: flex-start; text-align: left; white-space: normal; }

/* payment modal */
.pay-total { font-size: 40px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-mode { position: relative; }
.pay-mode input { position: absolute; opacity: 0; }
.pay-mode span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border: 2px solid var(--border); border-radius: 10px; font-weight: 700; color: var(--text); cursor: pointer; }
.pay-mode input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.pay-mode input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); }
.pay-form [name=paid] { font-size: 24px; text-align: center; min-height: 52px; font-weight: 700; }
.notes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.pay-form .change { text-align: center; margin-top: 8px; }
.upi-box { text-align: center; }
.qr { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; padding: 10px; border-radius: 10px; color: #000; }
.qr svg { width: 220px; height: 220px; }
.qr-amt { font-weight: 700; }

/* ---------- stock entry ---------- */
.grn-head { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.grn td { padding: 6px 6px; }
.grn .qty-in { width: 70px; border: 1px solid var(--border); border-radius: 8px; }
.grn .price-in { width: 90px; }
.batch-in { width: 100px; min-height: 34px; padding: 4px 8px; }
.exp-in { width: 150px; min-height: 34px; padding: 4px 8px; }
.grn-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.grn-total { display: flex; gap: 16px; align-items: baseline; font-size: 15px; }
.grn-total b { font-size: 24px; }

/* ---------- invoices ---------- */
.inv-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.inv-meta div { display: flex; flex-direction: column; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }
.inv-meta .muted { font-size: 12px; }
.modal .actions { margin-top: 14px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-l { color: var(--text-2); font-size: 13px; font-weight: 600; }
.kpi-v { font-size: 26px; font-weight: 800; margin: 4px 0; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi-s { font-size: 12.5px; }
.up { color: var(--ok); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 14px; }
.dash-grid .card { margin: 0; }
.meters { display: grid; gap: 8px; }
.meter-row { display: grid; grid-template-columns: minmax(80px, 1.2fr) 2fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.meter-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.meter { height: 10px; background: var(--grid); border-radius: 5px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.meter-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.status-ic { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; font-size: 12px; font-weight: 800; margin-right: 4px; vertical-align: 1px; }
.status-ic.warn { background: var(--warn-soft); color: var(--warn); }
.status-ic.crit { background: var(--danger-soft); color: var(--danger); }

/* chart */
.chart { position: relative; }
.chart-plot { width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--series-1); transition: opacity .1s; }
.chart svg:hover .bar { opacity: .55; }
.chart svg:hover .bar.on, .chart .bar.on { opacity: 1; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:focus-visible { fill: color-mix(in srgb, var(--series-1) 10%, transparent); }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; font-size: 12.5px; white-space: nowrap; z-index: 5; }
.chart-tip[hidden] { display: none; }
.chart-tip b { font-size: 15px; color: var(--text); }
.chart-tip span { color: var(--muted); }
.chart-table { margin-top: 6px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table table { margin-top: 6px; }

/* settings */
.settings { gap: 0; }
.sticky-save { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); margin-bottom: 14px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; animation: pop .14s; }
.modal-wide { max-width: 880px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; }
.confirm-msg { font-size: 16px; margin: 0 0 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #1d2430; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; border-left: 5px solid var(--ok); transition: opacity .3s, transform .3s; }
.toast-error { border-left-color: #ff6b6b; }
.toast-warn { border-left-color: #f0b429; }
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .bill-layout { grid-template-columns: 1fr 290px; }
  .grand b { font-size: 26px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 64px 1fr; }
  .side .lbl, .side a kbd { display: none; }
  .brand { justify-content: center; padding: 6px 0 14px; }
  .side a { justify-content: center; padding: 12px 0; }
  .side .ic { font-size: 20px; }
  .user-btn { justify-content: center; }
  .page-billing { overflow-y: auto; }
  .bill-layout { grid-template-columns: 1fr; height: auto; }
  .cart-wrap { min-height: 260px; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inv-meta { grid-template-columns: repeat(2, 1fr); }
  .hint-bar { display: none; }
}
@media (max-width: 560px) {
  main.page { padding: 12px 12px 30px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { flex-direction: row; order: 2; padding: 4px; overflow-x: auto; }
  .side-foot { margin: 0 0 0 auto; }
  .side a { padding: 10px 12px; }
  .grid4, .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .cart .qty-col { width: 120px; }
}

@media print {
  .side, .offline-banner, #toasts { display: none !important; }
}

/* ---------- quick add ---------- */
.quick-card { padding: 16px 18px; }
.quick-help { margin: 0 0 12px; color: var(--text-2); }
.quick-help b { color: var(--primary); }
.quick-form { display: grid; grid-template-columns: 1.3fr 2.6fr 1fr .9fr auto; gap: 10px; align-items: end; }
.quick-form.with-gst { grid-template-columns: 1.3fr 2.6fr 1fr .9fr .7fr auto; }
.quick-form > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.quick-form input { min-height: 46px; font-size: 16px; }
.quick-form input[name=name] { font-weight: 600; }
.quick-form .qf-add { min-height: 46px; }
.quick-form .scan-field { min-width: 0; }
.qf-more, .qf-status { grid-column: 1 / -1; }
.qf-more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 0; }
.qf-more .grid4 { margin-top: 10px; }
.qf-more label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.qf-status { min-height: 22px; font-size: 14px; }
.qf-status.ok { color: var(--ok); }
.qf-status.new { color: var(--primary); }
.qf-status.bad { color: var(--danger); font-weight: 600; }
.tag-new { background: var(--primary-soft); color: var(--primary); }
.tag-old { background: var(--surface-2); color: var(--muted); }
.supplier-in { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 240px; }

/* ---------- settings: GST + bill design ---------- */
textarea { resize: vertical; min-height: 0; line-height: 1.35; }
.big-switch { align-items: flex-start !important; font-weight: 700 !important; font-size: 15px !important; flex-wrap: wrap; }
.big-switch small { flex-basis: 100%; padding-left: 26px; font-weight: 400; }
.disabled { opacity: .5; }
.bill-design { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.bd-fields { display: grid; gap: 12px; min-width: 0; }
.bd-fields > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.logo-row { display: flex; gap: 14px; align-items: center; }
.logo-box { width: 160px; height: 72px; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; background: #fff; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-btn { cursor: pointer; }
.toggles { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 14px; margin: 0; }
.toggles legend { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 0 6px; }
.bd-preview { position: sticky; top: 10px; }
.preview-paper { margin-top: 6px; background: #e9ebef; border-radius: 10px; padding: 12px 0; display: flex; justify-content: center; overflow: hidden; }
.preview-paper iframe { border: 0; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); transform-origin: top center; flex: none; }
@media (max-width: 1100px) {
  .bill-design { grid-template-columns: 1fr; }
  .bd-preview { position: static; }
}
@media (max-width: 900px) {
  .quick-form, .quick-form.with-gst { grid-template-columns: 1fr 1fr; }
  .quick-form > label:nth-child(2) { grid-column: 1 / -1; }
}

/* input with a fixed suffix (staff login IDs) */
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--text-2); font-weight: 600; white-space: nowrap; }

/* ---------- BraneBill console ---------- */
.console { min-height: 100vh; display: flex; flex-direction: column; }
.console-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 22px; background: var(--side); color: #fff; flex-wrap: wrap; }
.console-top .muted { color: var(--side-text); }
.console-brand { display: flex; align-items: center; gap: 10px; }
.console-brand .wordmark { font-size: 21px; }
.console-tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; background: rgba(255,255,255,.12); color: #fff; padding: 3px 8px; border-radius: 999px; }
.console-main { padding: 20px 22px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }
.console-main .page-head input[type=search] { width: 300px; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.cred-card { display: grid; gap: 8px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.cred-card div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.cred-card b { font-size: 15px; word-break: break-all; }
.input-suffix .btn { border-radius: 0 8px 8px 0; border-left: 0; min-height: 0; }
@media (max-width: 560px) {
  .console-main { padding: 14px 12px 30px; }
  .console-main .page-head input[type=search] { width: 100%; }
}
.console td code { white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-brand .wordmark { color: #fff; }
  :root:not([data-theme="light"]) .login-brand .wordmark i { color: #ffc21a; }
}
