:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --ink: #18201f;
  --muted: #5d6b69;
  --line: #dde3e1;
  --brand: #0f5f58;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ef;
  --ok: #157a3c;
  --ok-soft: #e2f4e8;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --info: #1f5fa8;
  --info-soft: #e3edf9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 23, .06), 0 2px 8px rgba(16, 24, 23, .05);
  --side: 230px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 8px 0 4px;
  background: var(--brand); color: var(--brand-ink);
}
.topbar .menu-btn { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.topbar .menu-btn:active { background: rgba(255,255,255,.15); }
.topbar .title { font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { margin-left: auto; font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.shell { display: flex; min-height: calc(100vh - 52px); }
.side {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(280px, 84vw);
  background: var(--card); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .18s ease;
  overflow-y: auto; padding: 8px 0 24px;
}
.side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
.side .brand { padding: 12px 16px 10px; font-weight: 700; color: var(--brand); font-size: 17px; }
.side .grp { padding: 14px 16px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side a.nav {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; color: var(--ink); text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent;
}
.side a.nav:hover { background: var(--bg); }
.side a.nav.active { background: var(--brand-soft); border-left-color: var(--brand); color: var(--brand); font-weight: 650; }
.side a.nav svg { flex: none; opacity: .85; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
.main { flex: 1 1 auto; min-width: 0; padding: 12px 12px 80px; max-width: 1180px; width: 100%; margin: 0 auto; }
@media (min-width: 960px) {
  .topbar .menu-btn { display: none; }
  .topbar { padding-left: 16px; }
  .side { position: sticky; top: 52px; height: calc(100vh - 52px); transform: none; width: var(--side); flex: none; }
  .side .brand { display: none; }
  .scrim { display: none; }
  .main { padding: 20px 24px 60px; }
}

/* ---------- komponen ---------- */
h1.page { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 10px 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.col { flex: 1 1 160px; }
.stack > * + * { margin-top: 10px; }
.grid-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (min-width: 720px) { .grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.ok .n { color: var(--ok); } .stat.bad .n { color: var(--bad); } .stat.warn .n { color: var(--warn); } .stat.info .n { color: var(--info); }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (min-width: 720px) { .quick { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.quick a { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; box-shadow: var(--shadow); min-height: 84px; }
.quick a svg { color: var(--brand); }
.quick a:active { background: var(--brand-soft); }

label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.in, select.in, textarea.in {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #c9d2cf; border-radius: 8px; background: #fff; outline: none;
}
textarea.in { min-height: 70px; resize: vertical; }
.in:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,95,88,.15); }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #b9c4c1; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.sm { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.STOK, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.TERJUAL, .badge.info { background: var(--info-soft); color: var(--info); }
.badge.RUSAK, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.HILANG, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.BUKA { background: var(--warn-soft); color: var(--warn); }
.badge.SELESAI { background: var(--ok-soft); color: var(--ok); }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: #f7f9f8; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f7faf9; }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 8px; font-size: 13px; color: var(--muted); }

/* list kartu ringkas (mobile) */
.items { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.item .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.bad { border-color: #f0b8b3; background: #fff8f7; }
.item.warn { border-color: #f1d39c; background: #fffcf5; }
.item.ok { border-color: #b6dfc4; }
.item .x { margin-left: auto; flex: none; border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; }
.item .x:hover { background: var(--bg); color: var(--bad); }

/* ---------- kotak scan ---------- */
.scan {
  position: sticky; top: 56px; z-index: 20;
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow);
}
.scan.ready { border-color: var(--ok); }
.scan .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #b8c2bf; align-self: center; margin-left: 4px; }
.scan.ready .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.scan textarea {
  flex: 1 1 auto; min-width: 0; min-height: 44px; height: 44px; resize: none; border: 0; outline: none; padding: 10px 6px;
  font: 600 17px/1.4 ui-monospace, Menlo, Consolas, monospace; text-transform: uppercase; background: transparent; overflow: hidden; white-space: nowrap;
}
.scan textarea::placeholder { text-transform: none; font-weight: 500; font-family: system-ui, sans-serif; color: var(--muted); }
.scan .kb { flex: none; width: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.scan .kb.on { color: var(--brand); border-color: var(--brand); }
.scan-hint { font-size: 12px; color: var(--muted); margin: -6px 0 10px 4px; }
.flash-ok { animation: fok .5s ease; } .flash-bad { animation: fbad .6s ease; }
@keyframes fok { 0% { background: var(--ok-soft); } 100% { background: var(--card); } }
@keyframes fbad { 0% { background: var(--bad-soft); } 100% { background: var(--card); } }

.big-msg { padding: 16px; border-radius: 12px; font-weight: 650; font-size: 17px; text-align: center; margin-bottom: 12px; border: 2px solid transparent; }
.big-msg.ok { background: var(--ok-soft); color: var(--ok); border-color: #b6dfc4; }
.big-msg.bad { background: var(--bad-soft); color: var(--bad); border-color: #f0b8b3; }
.big-msg.wait { background: var(--info-soft); color: var(--info); border-color: #b9cfee; }
.big-msg.idle { background: var(--card); color: var(--muted); border-color: var(--line); font-weight: 500; }
.big-msg .sub { display: block; font-size: 14px; font-weight: 500; margin-top: 4px; color: var(--ink); }

.counter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
@media (min-width: 720px) { .counter-row { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.counter { border-radius: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.counter .n { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.counter .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.counter.sel { outline: 3px solid var(--brand); outline-offset: -1px; }
.counter.ok .n { color: var(--ok); } .counter.bad .n { color: var(--bad); } .counter.warn .n { color: var(--warn); } .counter.info .n { color: var(--info); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(10,20,18,.45); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-bg { align-items: center; padding: 20px; } }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 14px 14px 0 0; padding: 16px; }
@media (min-width: 640px) { .modal { border-radius: 14px; } }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(94vw, 460px); pointer-events: none; }
.toast { background: #1d2726; color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 500; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.warn { background: #8a5200; }

/* ---------- login ---------- */
.auth { max-width: 400px; margin: 8vh auto 0; padding: 0 16px; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo b { display: block; font-size: 22px; color: var(--brand); }
.err { color: var(--bad); font-weight: 600; font-size: 14px; min-height: 20px; }

/* ---------- label preview ---------- */
.lbl-preview { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; background: #e9ecea; border-radius: 10px; overflow: auto; }
.lbl-row-prev { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); position: relative; flex: none; }
.lbl { position: absolute; overflow: hidden; background: #fff; color: #000; outline: 1px dashed #c7cecb; font-family: Arial, Helvetica, sans-serif; }
.lbl .tx { position: absolute; white-space: nowrap; overflow: hidden; line-height: 1.2; }
.lbl svg { position: absolute; display: block; }
.prev-scale { transform-origin: top left; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .when { font-size: 12px; color: var(--muted); }
.picker { position: relative; }
.picker .list { position: absolute; left: 0; right: 0; top: 100%; z-index: 25; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; margin-top: 4px; }
.picker .opt { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker .opt:last-child { border-bottom: 0; }
.picker .opt:hover, .picker .opt.hl { background: var(--brand-soft); }
.picker .sel-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--brand); border-radius: 8px; background: var(--brand-soft); min-height: 44px; }
.note { font-size: 13px; color: var(--muted); background: #f7f9f8; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.note.warn { background: var(--warn-soft); border-color: #f1d39c; color: #6e4300; }
.only-desktop { display: none; }
@media (min-width: 720px) { .only-desktop { display: initial; } .only-mobile { display: none; } }
