:root {
  --bg: #f8faf7;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e9e3;
  --primary: #102d23;
  --primary-2: #1c4a3a;
  --accent: #16a34a;
  --accent-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,45,35,.06), 0 4px 14px rgba(16,45,35,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 90px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--primary); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: #22c55e; color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none;
}
.brand-name { font-weight: 800; font-size: 17px; }
.brand-name span { color: #86efac; margin-left: 2px; }
.brand-sub { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.today { font-size: 12px; background: rgba(255,255,255,.12); padding: 6px 10px; border-radius: 99px; white-space: nowrap; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 60px; z-index: 19; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 99px;
  font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.tabs button.active { background: var(--accent-soft); color: var(--primary); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* Generic */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line); background: var(--card); padding: 10px 14px; border-radius: 10px;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 16px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

label.f { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.input:focus { outline: 2px solid #86efac; border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); padding: 6px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--muted);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--primary); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* Kasir layout */
.pos { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .pos { grid-template-columns: 1fr 360px; align-items: start; }
  .pos .cartpanel { position: sticky; top: 130px; }
  .cartbar { display: none !important; }
}
@media (max-width: 899px) { .pos .cartpanel { display: none; } }

.search { position: relative; }
.search input { padding-left: 38px; }
.search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pitem {
  text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); position: relative; min-height: 118px;
  display: flex; flex-direction: column; gap: 4px;
}
.pitem:active { transform: scale(.97); }
.pitem .emo { font-size: 28px; line-height: 1; }
.pitem .nm { font-weight: 600; font-size: 14px; line-height: 1.25; }
.pitem .pr { font-weight: 800; color: var(--primary); margin-top: auto; }
.pitem .qty {
  position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-weight: 800;
  font-size: 12px; min-width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; padding: 0 6px;
}
.pitem.out { opacity: .5; }
.pitem .st { font-size: 11px; color: var(--muted); }

.cartlist { max-height: 46vh; overflow-y: auto; }
.citem { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.citem:last-child { border-bottom: 0; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.stepper button { border: 0; background: #f3f5f2; width: 32px; height: 32px; font-weight: 800; font-size: 16px; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }
.totals .row { padding: 3px 0; }
.totals .grand { font-size: 20px; font-weight: 800; color: var(--primary); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .big { font-size: 36px; }

.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 30;
  background: var(--primary); color: #fff; border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 10px 30px rgba(16,45,35,.35); border: 0; width: auto; text-align: left;
}
.cartbar b { font-size: 17px; }
.cartbar .go { background: #22c55e; color: var(--primary); font-weight: 800; padding: 8px 14px; border-radius: 10px; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,20,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.x { border: 0; background: #f3f5f2; width: 34px; height: 34px; border-radius: 99px; font-size: 18px; }

.paybox { background: var(--accent-soft); border-radius: var(--radius); padding: 14px; text-align: center; }
.paybox .amt { font-size: 30px; font-weight: 800; color: var(--primary); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 6px; font-weight: 700; font-size: 14px; }
.seg button.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 4px; font-weight: 600; font-size: 13px; }
.change { font-size: 18px; font-weight: 800; }
.change.ok { color: var(--accent); }
.change.bad { color: var(--danger); }
.qris-img { max-width: 260px; width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; margin: 0 auto; }

/* Receipt */
.receipt {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5;
  background: #fffef8; border: 1px dashed #d6d3c4; border-radius: 10px; padding: 14px; color: #111;
}
.receipt .c { text-align: center; }
.receipt .b { font-weight: 700; }
.receipt hr { border: 0; border-top: 1px dashed #999; margin: 6px 0; }
.receipt .r { display: flex; justify-content: space-between; gap: 8px; }
.success { text-align: center; margin-bottom: 12px; }
.success .ic { font-size: 40px; }

/* Lists */
.list > .li { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list > .li:last-child { border-bottom: 0; }
.li .emo { font-size: 24px; width: 36px; text-align: center; flex: none; }
.li.void { opacity: .55; }
.li.void .amt { text-decoration: line-through; }
.lihead { padding: 10px 16px; background: #f3f5f2; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px; }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .val { font-size: 22px; font-weight: 800; color: var(--primary); margin-top: 2px; }
.bar { height: 8px; background: #eef2ec; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .col i { width: 100%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.chart .col span { font-size: 10px; color: var(--muted); }

.twocol { display: grid; gap: 16px; }
@media (min-width: 860px) { .twocol { grid-template-columns: 1fr 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600; z-index: 80; max-width: 90vw; text-align: center;
}
.note { background: var(--warn-soft); color: #78350f; padding: 10px 12px; border-radius: 10px; font-size: 13px; }

#printArea { display: none; }
@media print {
  @page { size: 58mm auto; margin: 2mm; }
  body { padding: 0; background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  #printArea .receipt { border: 0; padding: 0; font-size: 10.5px; background: #fff; }
}
