:root {
  --bg: #f6f4f1; --panel: #ffffff; --ink: #1f1b18; --muted: #6f665f; --line: #e7e1da;
  --brand: #b91c1c; --brand-ink: #ffffff; --brand-soft: #fdecec; --ok: #15803d; --ok-soft: #e8f6ed;
  --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#print-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.hide { display: none !important; }

/* tombol & input */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 14px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.btn:hover { border-color: #cfc6bd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 14px; }
.btn.lg { min-height: 54px; font-size: 17px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 42px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; font-weight: 500; }
.check input { width: 20px; height: 20px; min-height: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > .auto { flex: 0 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* kerangka */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 800; color: var(--brand); white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.topbar nav a.active { background: var(--brand-soft); color: var(--brand); }
.topbar .who { font-size: 13px; color: var(--muted); white-space: nowrap; }
.net { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.net.off { background: var(--warn-soft); color: var(--warn); }
.page { flex: 1; overflow: auto; padding: 16px; }
.page.narrow { max-width: 1100px; margin: 0 auto; width: 100%; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 160px; }

/* kasir */
.pos { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.catalog { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.cats button { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 8px 14px; white-space: nowrap; font-weight: 600; }
.cats button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.products { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; padding-bottom: 90px; }
.prod { position: relative; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; box-shadow: var(--shadow); }
.prod:active { transform: scale(.98); }
.prod .nm { font-weight: 650; line-height: 1.25; }
.prod .pr { color: var(--brand); font-weight: 700; }
.prod .badge { position: absolute; top: 6px; right: 6px; background: var(--brand); color: #fff; border-radius: 99px; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; }
.prod .stk { font-size: 12px; color: var(--muted); }
.prod .stk.low { color: var(--warn); font-weight: 700; }
.prod.out { opacity: .55; }
.cart { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cart-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.cart-items { flex: 1; overflow: auto; }
.ci { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ci .nm { font-weight: 600; }
.ci .sub { font-weight: 700; text-align: right; }
.ci .ctl { display: flex; align-items: center; gap: 6px; }
.qbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; line-height: 1; }
.qty { min-width: 34px; text-align: center; font-weight: 700; }
.ci .note { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.cart-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.cart-foot { border-top: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 8px; }
.sumrow { display: flex; justify-content: space-between; }
.sumrow.total { font-size: 22px; font-weight: 800; }
.cart-fab { display: none; }
@media (min-width: 861px) { .only-m { display: none !important; } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,16,12,.45); display: grid; place-items: center; z-index: 50; padding: 12px; }
.modal { background: var(--panel); border-radius: 16px; width: min(560px, 100%); max-height: calc(100dvh - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-h h2 { margin: 0; }
.modal-b { padding: 16px; }
.modal-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--panel); }
.pay-total { text-align: center; font-size: 34px; font-weight: 800; margin: 4px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .btn { flex: 1 1 110px; }
.chips .btn.sel { background: var(--ink); color: #fff; border-color: var(--ink); }
.payline { display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.change { font-size: 20px; font-weight: 800; color: var(--ok); text-align: center; margin-top: 12px; }
.qris { display: block; max-width: 260px; margin: 10px auto; border-radius: 10px; border: 1px solid var(--line); }

/* tabel */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: #faf8f6; position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf8f6; }
tr.void td { color: var(--muted); text-decoration: line-through; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #f0ece8; color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--brand-soft); color: var(--bad); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 22px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 110px 1fr 110px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { background: #f0ece8; border-radius: 6px; height: 14px; overflow: hidden; }
.bar .fill { background: var(--brand); height: 100%; border-radius: 6px; }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; font-size: 14px; }
.alert.info { background: #eef4fb; color: #1d4f86; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); }
.auth h1 { color: var(--brand); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
#toast div.err { background: var(--bad); }

@media (max-width: 860px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: fixed; inset: 0; z-index: 40; border-left: 0; transform: translateY(100%); transition: transform .2s; }
  .cart.open { transform: none; }
  .cart-fab { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30; justify-content: space-between; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
  .products { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .topbar .who { display: none; }
  .page { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 80px 1fr 90px; }
}
