:root {
  --bg: #f4f5f2;
  --panel: #ffffff;
  --panel-2: #f9faf8;
  --ink: #1b2422;
  --ink-2: #4d5a57;
  --ink-3: #7c8885;
  --line: #e1e5e0;
  --line-2: #eef0ec;
  --brand: #0f5257;
  --brand-2: #13696f;
  --brand-soft: #e3f0ef;
  --accent: #d9822b;
  --ok: #217a45;
  --ok-soft: #e2f3e8;
  --warn: #a8620b;
  --warn-soft: #fbefdc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 4px 16px rgba(20, 30, 28, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615; --panel: #1a201f; --panel-2: #1f2625; --ink: #e8ecea; --ink-2: #b4bdba; --ink-3: #87918e;
    --line: #2c3533; --line-2: #252d2b; --brand: #4fb3b0; --brand-2: #6ac6c3; --brand-soft: #1d3332;
    --ok: #5ccb8a; --ok-soft: #1b3326; --warn: #e6a44f; --warn-soft: #3a2c18; --bad: #f2867e; --bad-soft: #3d1f1d;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121615; --panel: #1a201f; --panel-2: #1f2625; --ink: #e8ecea; --ink-2: #b4bdba; --ink-3: #87918e;
  --line: #2c3533; --line-2: #252d2b; --brand: #4fb3b0; --brand-2: #6ac6c3; --brand-soft: #1d3332;
  --ok: #5ccb8a; --ok-soft: #1b3326; --warn: #e6a44f; --warn-soft: #3a2c18; --bad: #f2867e; --bad-soft: #3d1f1d;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; flex: none; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-store { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 14px 10px 4px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topbar { display: none; }
.pw-warn { background: var(--warn-soft); color: var(--warn); padding: 10px 28px; font-weight: 550; border-bottom: 1px solid var(--line); }
.pw-warn a { font-weight: 700; margin-left: 6px; }

/* ---------- komponen ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 16px; }
.btn.icon { width: 32px; padding: 0; }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
label.f.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 14px; }
.input, select.input, textarea.input { height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; width: 100%; min-width: 0; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 64px; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 0; border-color: var(--brand); }
.input.num { text-align: right; }
.input.big { height: 46px; font-size: 18px; font-weight: 600; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 32px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.tbl tr.click { cursor: pointer; }
.tbl td.mono { white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; background: var(--panel-2); }
.tbl .num { text-align: right; }
.tbl tr.bold td { font-weight: 700; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 22, 21, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .14s ease-out; }
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; font-weight: 500; animation: pop .15s; }
.toast.err { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h1 { margin: 14px 0 4px; }

/* ---------- kasir ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos-scan { display: flex; gap: 8px; }
.pos-scan .search { flex: 1; }
.pos-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); z-index: 20; max-height: 360px; overflow-y: auto; }
.pos-results .opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.pos-results .opt:hover, .pos-results .opt.sel { background: var(--brand-soft); }
.pos-results .opt .meta { font-size: 12px; color: var(--ink-3); }
.cart td { padding: 8px 10px; }
.cart .qty { width: 72px; }
.cart .price { width: 110px; }
.cart .disc { width: 70px; }
.pos-side { position: sticky; top: 16px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; gap: 10px; }
.sum-row .input { width: 120px; height: 32px; }
.grand { font-size: 30px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--brand); }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-methods button { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; font-size: 13px; }
.pay-methods button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { flex: 1; min-width: 70px; height: 32px; border-radius: 8px; border: 1px dashed var(--line); background: var(--panel-2); color: var(--ink-2); cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; }
.change { padding: 10px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 700; display: flex; justify-content: space-between; }
.change.minus { background: var(--warn-soft); color: var(--warn); }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-3); background: var(--panel-2); }

.chart-box { position: relative; height: 260px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 18px; border-bottom: 1px solid var(--line-2); }
.list-plain li:last-child { border-bottom: 0; }

.report-sum { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.report-sum .card { padding: 10px 14px; min-width: 160px; }
.report-sum .v { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.report-list a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
.report-list a:hover { border-color: var(--brand); text-decoration: none; }
.report-list a b { display: block; margin-bottom: 3px; }
.report-list a span { color: var(--ink-3); font-size: 12.5px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 550; }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos-side { position: static; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .grand { font-size: 26px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } .stat .value { font-size: 18px; } }

/* ---------- cetak ---------- */
.print-page { background: #fff; color: #000; min-height: 100vh; }
.print-bar { position: sticky; top: 0; background: #222; color: #fff; padding: 10px 16px; display: flex; gap: 8px; align-items: center; z-index: 5; flex-wrap: wrap; }
.print-bar .btn { height: 32px; }
.print-bar select { height: 32px; border-radius: 6px; padding: 0 8px; }
.doc { color: #000; background: #fff; font-family: Arial, Helvetica, sans-serif; margin: 0 auto; }
.doc.a4 { width: 210mm; min-height: 297mm; padding: 14mm 14mm; font-size: 12px; }
.doc.a4.landscape { width: 297mm; min-height: 210mm; }
.doc.a5 { width: 148mm; padding: 8mm; font-size: 11px; }
.doc.struk { padding: 3mm 2mm; font-family: "Courier New", ui-monospace, monospace; font-size: 11.5px; line-height: 1.3; }
.doc.struk.w58 { width: 58mm; }
.doc.struk.w80 { width: 80mm; }
.doc .center { text-align: center; }
.doc .right { text-align: right; }
.doc hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; }
.doc table { width: 100%; border-collapse: collapse; }
.doc .inv-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
.doc .inv-title { font-size: 26px; font-weight: 800; letter-spacing: .04em; text-align: right; }
.doc .store-name { font-size: 18px; font-weight: 800; }
.doc .inv-items th { background: #eee; border: 1px solid #999; padding: 6px; font-size: 11px; text-align: left; }
.doc .inv-items td { border: 1px solid #bbb; padding: 5px 6px; }
.doc .inv-tot td { padding: 3px 6px; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 30px; text-align: center; }
.doc .sign > div { width: 40%; }
.doc .sign .line { margin-top: 56px; border-top: 1px solid #000; padding-top: 3px; }
.doc .stamp { display: inline-block; border: 3px solid; padding: 4px 14px; font-weight: 800; font-size: 18px; transform: rotate(-8deg); letter-spacing: .1em; }
.doc .stamp.lunas { color: #217a45; }
.doc .stamp.belum { color: #b3261e; }
.doc.rep h2 { font-size: 15px; text-align: center; margin: 10px 0 2px; }
.doc.rep table.r th { border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 4px 5px; font-size: 10.5px; text-align: left; }
.doc.rep table.r td { padding: 3px 5px; font-size: 10.5px; border-bottom: 1px dotted #ccc; vertical-align: top; }
.doc.rep table.r tfoot td { border-top: 1px solid #000; border-bottom: 2px double #000; font-weight: 700; }
.doc.rep .num { text-align: right; white-space: nowrap; }
.doc.rep .meta { display: flex; justify-content: space-between; font-size: 11px; }
.doc.rep .foot { margin-top: 10px; font-size: 10px; color: #555; }
@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  .print-bar, #toasts { display: none !important; }
  .doc.a4, .doc.a5 { padding: 0; min-height: 0; width: auto; }
  .doc.struk { padding: 0; }
  .doc.rep table.r thead { display: table-header-group; }
  .doc.rep tr { break-inside: avoid; }
}
