:root {
  --bg: #f4f6f8; --panel: #fff; --ink: #17212b; --muted: #5d6b7a; --line: #dfe4ea;
  --brand: #0f766e; --brand-dark: #0b5d57; --brand-soft: #e3f4f1;
  --danger: #b42318; --danger-soft: #fdecea; --warn: #b54708; --warn-soft: #fef3e2; --ok: #067647; --ok-soft: #e6f6ec;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 20px; } h3 { font-size: 16px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; background: #fff;
  border: 1px solid #b9c2cc; border-radius: 8px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; font-size: 15px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 15px; }
label.check input { width: 20px; min-height: 20px; margin: 0; }
button { min-height: 42px; padding: 8px 14px; border: 1px solid #b9c2cc; border-radius: 8px; background: #fff; cursor: pointer; font-weight: 600; }
button:hover { background: #f1f3f5; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--danger); border-color: #e8b4ae; }
button.danger:hover { background: var(--danger-soft); }
button.link { border: 0; background: none; color: var(--brand); padding: 4px 6px; min-height: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.user-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.user-grid button { min-height: 64px; display: block; text-align: center; }
.user-grid .role { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.pin-input { text-align: center; font-size: 26px; letter-spacing: 8px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.pinpad button { min-height: 56px; font-size: 20px; }

/* Rangka aplikasi */
.shell { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--brand-dark); margin-right: 4px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.nav button { border: 0; background: none; min-height: 36px; padding: 6px 12px; }
.nav button.active { background: var(--brand-soft); color: var(--brand-dark); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
main { flex: 1 1 auto; min-height: 0; overflow: auto; }
.page { max-width: 1180px; margin: 0 auto; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.cols .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
th.num { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7f9fa; }
tr.is-void td { color: var(--muted); text-decoration: line-through; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Layar kasir */
.pos { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 420px; }
.pos-left { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.pos-right { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
#scan { min-height: 52px; font-size: 18px; border-width: 2px; border-color: var(--brand); }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 0 0 auto; padding-bottom: 2px; }
.chips button { min-height: 34px; padding: 4px 12px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.chips button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.grid { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; }
.tile { display: block; width: 100%; text-align: left; min-height: 92px; padding: 10px; font-weight: 500; }
.tile .name { display: block; line-height: 1.25; min-height: 36px; }
.tile .price { display: block; margin-top: 6px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.tile .stock { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tile .stock.low { color: var(--danger); font-weight: 600; }
.cart { flex: 1 1 auto; min-height: 0; overflow: auto; }
.cart-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cart-item .name { font-weight: 600; line-height: 1.25; }
.cart-item .line { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { min-height: 36px; width: 36px; padding: 0; font-size: 18px; }
.qty input { width: 64px; min-height: 36px; text-align: center; padding: 4px; }
.cart-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.totals { padding: 10px 12px; border-top: 1px solid var(--line); }
.totals div { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 24px; font-weight: 700; padding-top: 6px; }
.cart-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 12px 8px; }
.cart-actions button { padding: 6px 4px; font-size: 13px; }
.pay { margin: 0 12px 12px; min-height: 60px; font-size: 20px; background: var(--brand); border-color: var(--brand); color: #fff; }
.pay:hover { background: var(--brand-dark); }
.notice { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 32, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border-radius: 14px; padding: 20px; }
.modal.wide { max-width: 760px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.pay-total { text-align: center; margin-bottom: 14px; }
.pay-total .value { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; margin-bottom: 12px; }
.change { font-size: 20px; font-weight: 700; display: flex; justify-content: space-between; padding: 10px 12px; background: var(--brand-soft); border-radius: 8px; font-variant-numeric: tabular-nums; }
.change.short { background: var(--danger-soft); color: var(--danger); }
.qris-img { display: block; max-width: 240px; width: 100%; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 8px; }
.big-change { text-align: center; padding: 16px; background: var(--brand-soft); border-radius: 12px; margin: 12px 0; }
.big-change .value { font-size: 40px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
#toast-root { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); }
.toast { padding: 10px 14px; border-radius: 8px; background: #17212b; color: #fff; font-weight: 500; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

/* Laporan */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: #e6eaee; border-radius: 10px; margin-bottom: 16px; flex-wrap: wrap; max-width: 100%; }
.seg button { border: 0; background: none; min-height: 38px; }
.seg button:hover { background: rgba(255, 255, 255, .6); }
.seg button.active { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 2px rgba(15, 23, 32, .15); }
.seg-sub { margin-bottom: 12px; }
.rep-head { margin-bottom: 12px; align-items: flex-end; }
button.chip { min-height: 42px; font-weight: 500; }
button.chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.delta { font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value { overflow-wrap: anywhere; }
tr.sum td { font-weight: 700; border-top: 1px solid #b9c2cc; }
td.alert { color: var(--danger); font-weight: 700; }
.flags { margin: 0; padding-left: 20px; } .flags li { padding: 2px 0; }
.card.spaced { margin-top: 16px; }
.cols + .cols { margin-top: 16px; }
.compare-note { margin: -8px 0 12px; }
.cols + .card { margin-top: 16px; }
.card + .cols { margin-bottom: 16px; }
svg.chart { display: block; width: 100%; height: auto; }
.chart-tip { position: fixed; z-index: 70; padding: 6px 10px; border-radius: 6px; background: #17212b; color: #fff; font-size: 13px; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-sort { border: 0; background: none; padding: 0; min-height: 0; font: inherit; font-weight: 600; color: inherit; white-space: nowrap; }
.th-sort:hover { background: none; color: var(--ink); }

@media (max-width: 900px) {
  main { overflow: auto !important; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .pos-left .grid { max-height: 40vh; }
  .pos-right { border-left: 0; border-top: 1px solid var(--line); }
  .cart { max-height: 40vh; }
}
