:root {
  --bg: #05070d;
  --surface: #0b1220;
  --surface2: #0e1626;
  --stroke: #1b2c44;
  --neon: #22d3ee;
  --neon-dim: #0e7490;
  --magenta: #f43f5e;
  --lime: #a3e635;
  --text: #e6f1ff;
  --muted: #7c8da6;
  --danger: #fb7185;
  --ok: #34d399;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(900px 420px at 50% -160px, rgba(34, 211, 238, .20), transparent 70%),
    linear-gradient(rgba(34, 211, 238, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, .05) 1px, transparent 1px);
  background-size: auto, 56px 56px, 56px 56px;
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------------- hero ---------------- */
.hero { position: relative; padding: 22px 20px 6px; max-width: 560px; margin: 0 auto; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  padding: 6px 8px; border-radius: 9px;
  border: 1px solid rgba(34, 211, 238, .5);
  background: rgba(34, 211, 238, .10);
  color: var(--neon); font-family: ui-monospace, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-text strong { font-size: 10.5px; letter-spacing: .18em; color: var(--neon); font-family: ui-monospace, monospace; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

.ghost {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--stroke); background: rgba(11, 18, 32, .8);
  color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
}
.ghost:hover { color: var(--neon); border-color: var(--neon-dim); }

/* ---------------- layout ---------------- */
#app { max-width: 560px; margin: 0 auto; padding: 8px 20px 28px; }
.screen { animation: fade .22s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.steps { display: flex; align-items: center; gap: 6px; margin: 10px 0 18px; }
.step {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-size: 11px; font-weight: 700; font-family: ui-monospace, monospace;
  background: var(--surface); color: var(--muted); border: 1px solid var(--stroke);
}
.step.active { background: rgba(34, 211, 238, .14); color: var(--neon); border-color: var(--neon); box-shadow: 0 0 14px rgba(34,211,238,.35); }
.step.done { color: var(--neon); border-color: var(--neon-dim); }
.bar { flex: 1; height: 1px; background: var(--stroke); }
.bar.done { background: linear-gradient(90deg, var(--neon-dim), transparent); }

.title {
  margin: 0 0 4px; font-size: 34px; letter-spacing: -.02em;
  font-family: "Segoe UI Semibold", system-ui, sans-serif; font-weight: 800;
  text-shadow: 0 0 26px rgba(34, 211, 238, .45);
}
.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* ---------------- card ---------------- */
.card {
  background: linear-gradient(180deg, rgba(14, 22, 38, .95), rgba(11, 18, 32, .95));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 20px 40px -28px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255,255,255,.03);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; margin-bottom: 8px;
  font-size: 10px; letter-spacing: .18em; font-weight: 700;
  color: var(--neon); font-family: ui-monospace, monospace;
}

input {
  width: 100%; padding: 15px 14px;
  font-size: 18px; font-family: ui-monospace, monospace;
  color: var(--text); background: var(--surface2);
  border: 1px solid var(--stroke); border-radius: 12px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #41536b; }
input:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(34, 211, 238, .16); }
#inp-store { text-transform: uppercase; letter-spacing: .12em; }

.btn {
  width: 100%; padding: 16px; font: inherit; font-size: 15px; font-weight: 800;
  letter-spacing: .12em; border: 0; border-radius: 14px; cursor: pointer;
  transition: transform .06s, box-shadow .15s, filter .15s;
}
.btn:active { transform: scale(.985); }
.btn.primary {
  background: linear-gradient(180deg, #4fe3f5, #12b6cf);
  color: #001318;
  box-shadow: 0 10px 30px -12px rgba(34, 211, 238, .75);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: .55; cursor: progress; }

.hint { margin: -4px 0 14px; font-size: 12px; color: var(--muted); min-height: 1em; font-family: ui-monospace, monospace; }
.hint.error { color: var(--danger); }

/* ---------------- store chip ---------------- */
.store-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--neon-dim); border-radius: 16px;
  cursor: pointer; transition: background .15s;
}
.store-chip:active { background: var(--surface2); }

.chip-avatar {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--neon); color: var(--neon);
  font-family: ui-monospace, monospace; font-size: 14px; font-weight: 700;
  background: rgba(34, 211, 238, .07);
}
.chip-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chip-info strong { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-sub { margin-top: 3px; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); font-family: ui-monospace, monospace; }

.pill {
  flex: 0 0 auto; border: 1px solid var(--neon-dim); border-radius: 999px;
  background: transparent; color: var(--neon);
  font: inherit; font-size: 10.5px; font-weight: 800; letter-spacing: .1em;
  padding: 9px 14px; cursor: pointer; transition: background .15s, transform .06s;
}
.pill:active { transform: scale(.94); background: rgba(34, 211, 238, .12); }

/* ---------------- empty ---------------- */
.empty { text-align: center; padding: 30px 0 10px; }
.empty-icon { font-size: 42px; color: var(--stroke); line-height: 1; }
.empty p { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* ---------------- result ---------------- */
.result { margin-top: 18px; }
.result .card { animation: pop .28s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

.card-title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; text-shadow: 0 0 18px rgba(34,211,238,.25); }
.card-sub { margin: 5px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .1em; font-family: ui-monospace, monospace; }

.tag {
  display: inline-block; margin-top: 10px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--neon-dim); color: var(--neon);
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em; font-family: ui-monospace, monospace;
}

.stock {
  display: flex; align-items: baseline; gap: 8px;
  margin: 18px 0 6px; padding: 16px;
  border-radius: 14px; border: 1px solid var(--stroke); background: var(--surface2);
}
.stock .num {
  font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -.02em;
  font-family: ui-monospace, monospace;
  color: var(--lime);
  text-shadow: 0 0 24px rgba(163, 230, 53, .5);
}
.stock.low .num { color: var(--magenta); text-shadow: 0 0 24px rgba(244, 63, 94, .5); }
.stock.zero .num { color: var(--danger); text-shadow: 0 0 24px rgba(251, 113, 133, .5); }
.stock .unit { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .12em; }
.stock .label {
  margin-left: auto; font-size: 10px; font-weight: 700; color: var(--muted);
  letter-spacing: .16em; font-family: ui-monospace, monospace;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.cell { padding: 12px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--stroke); }
.cell .k { font-size: 9.5px; letter-spacing: .16em; color: var(--neon); font-weight: 800; font-family: ui-monospace, monospace; }
.cell .v { margin-top: 4px; font-size: 13.5px; font-weight: 700; word-break: break-word; }

.card-foot { margin-top: 14px; font-size: 11px; color: var(--muted); line-height: 1.6; }

.error-box {
  padding: 16px; border-radius: 14px;
  background: rgba(251, 113, 133, .07);
  border: 1px solid rgba(251, 113, 133, .4);
}
.error-box h3 {
  margin: 0 0 6px; font-size: 12px; letter-spacing: .14em; color: var(--danger);
  font-family: ui-monospace, monospace;
}
.error-box p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.55; }
.error-box code { font-size: 11px; word-break: break-all; color: var(--danger); }

.skeleton { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--stroke); }
.sk-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #0e1626, #16233a, #0e1626); background-size: 200% 100%; margin-bottom: 10px; animation: shine 1.2s infinite; }
.sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; } .sk-line.tall { height: 44px; }
@keyframes shine { to { background-position: -200% 0; } }

/* ---------------- footer ---------------- */
.app-footer {
  max-width: 560px; margin: 0 auto; padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  text-align: center; color: var(--stroke);
  font-size: 10px; letter-spacing: .18em; font-family: ui-monospace, monospace;
}

/* ---------------- debug sheet ---------------- */
.debug { position: fixed; inset: 0; z-index: 50; }
.debug-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.debug-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 48vh; max-height: 48dvh;
  display: flex; flex-direction: column;
  background: #070b14; color: #c9d6e5;
  border-top: 1px solid var(--stroke);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .7);
  padding-bottom: env(safe-area-inset-bottom);
}
.debug-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--stroke); }
.debug-head strong { font-size: 11px; letter-spacing: .16em; font-family: ui-monospace, monospace; color: var(--neon); }
.debug-actions { display: flex; align-items: center; gap: 8px; }
.debug .link { color: var(--neon); font-size: 12px; }
.btn-close { border: 1px solid var(--stroke); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; padding: 7px 12px; cursor: pointer; }
.debug-log { overflow: auto; padding: 10px 14px 16px; font-family: ui-monospace, monospace; font-size: 11px; line-height: 1.5; }
.debug-entry { padding: 9px 0; border-bottom: 1px dashed #16233a; }
.debug-entry .req { color: var(--neon); word-break: break-all; }
.debug-entry .meta { color: var(--muted); }
.debug-entry pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; color: #9fb3c8; }
.ok-code { color: var(--ok); } .bad-code { color: var(--danger); }

body.no-scroll { overflow: hidden; }
/* ---------------- tombol cek + scan ---------------- */
.btn-row { display: flex; gap: 10px; }
.btn-row .primary { flex: 1; }
.scan-btn {
  width: auto; flex: 0 0 auto; padding: 16px 18px;
  background: transparent; border: 1px solid var(--magenta); color: var(--magenta);
  box-shadow: none;
}
.scan-btn:active { background: rgba(244, 63, 94, .15); }

/* ---------------- scanner kamera ---------------- */
.scan {
  position: fixed; inset: 0; z-index: 60;
  background: #000; display: flex; flex-direction: column;
}
.scan video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.scan-frame {
  position: absolute; left: 8%; right: 8%; top: 30%; height: 24%;
  border: 2px solid rgba(34, 211, 238, .95);
  border-radius: 14px;
  box-shadow: 0 0 34px rgba(34, 211, 238, .35), inset 0 0 34px rgba(34, 211, 238, .12);
  pointer-events: none;
}
.scan-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, .68); color: var(--text); font-size: 13px;
}

/* pastikan overlay benar-benar hilang saat hidden (mengalahkan display:flex) */
.scan[hidden], .debug[hidden] { display: none !important; }

/* ---------------- footer order (link telegram) ---------------- */
.app-footer { padding-top: 26px; }
.app-footer .order {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, .45);
  background: rgba(34, 211, 238, .05);
  color: var(--neon); text-decoration: none;
  letter-spacing: .14em; font-size: 10.5px; font-weight: 700;
  font-family: ui-monospace, monospace;
  transition: background .15s, border-color .15s, transform .06s;
}
.app-footer .order strong { color: #fff; letter-spacing: .06em; }
.app-footer .order:hover { background: rgba(34, 211, 238, .12); border-color: var(--neon); }
.app-footer .order:active { transform: scale(.97); }

/* stok berupa teks (mis. "Sedang SO") */
.stock .num.teks {
  font-size: 26px; letter-spacing: .04em;
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(251, 191, 36, .45);
}
