:root {
  --canvas: #F4F6FA;
  --surface: #FFFFFF;
  --surface-muted: #ECF0F7;
  --hairline: #E3E8F0;
  --control-border: #838A9B;
  --ink: #121620;
  --ink-muted: #545D6E;
  --inverse: #FFFFFF;
  --nav-active: #E9F2FF;

  --accent: #165BC9;
  --accent-2: #1976D2;
  --link: #174FAD;
  --sky: #0C5EA5;

  --ok-fg: #197347;
  --ok-bg: #DEF3E7;
  --warn-fg: #874512;
  --warn-bg: #FFF0DB;
  --danger-fg: #A62D42;
  --danger-bg: #FCE5E9;
  --info-fg: #1855AE;
  --info-bg: #E4EFFF;

  --grad-btn: linear-gradient(120deg, #1A62CB 0%, #165BC9 65%, #1A4EB6 100%);
  --grad-charcoal: linear-gradient(130deg, #292B34 0%, #222327 57%, #17181D 100%);
  --grad-teal: linear-gradient(130deg, #0E6975 0%, #207E83 44%, #0F626A 100%);
  --grad-sky: linear-gradient(165deg, #0C5EA5 0%, #166FC1 52%, #49A0E8 100%);

  --r-control: 14px;
  --r-tile: 18px;
  --r-card: 24px;
  --r-pill: 9999px;

  --shadow-control: 0 1px 2px rgba(17, 19, 21, 0.05);
  --shadow-card: 0 1px 2px rgba(17, 19, 21, 0.04), 0 4px 12px rgba(17, 19, 21, 0.03);
  --shadow-overlay: 0 12px 32px rgba(17, 19, 21, 0.10), 0 2px 6px rgba(17, 19, 21, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #E9EEF6; }
body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100dvh;
  font: 400 15px/1.4 "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(18, 22, 32, 0.04), 0 12px 40px rgba(12, 94, 165, 0.08);
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Topbar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--sky);
  color: var(--inverse);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-ico { width: 20px; height: 20px; opacity: 0.95; }

.net {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  backdrop-filter: blur(8px);
}
.net::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6EE7B7;
}
.net.off {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.net.off::before { background: #D97706; }

main { padding: 0 0 104px; }

/* ---------- Typography ---------- */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; margin: 0 0 10px; }
.muted { color: var(--ink-muted); font-size: 14px; }
.center { text-align: center; }
.sub { font-size: 13px; color: var(--ink-muted); overflow-wrap: anywhere; }
.err { color: var(--danger-fg); font-size: 13px; font-weight: 500; margin-top: 2px; }

/* ---------- Sky Hero (Awan signature) ---------- */
.sky-hero {
  position: relative;
  overflow: hidden;
  background: var(--grad-sky);
  color: #FFFFFF;
  padding: 12px 16px 42px;
}
.sky-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120px 68px at 86% 88%, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(96px 56px at 73% 94%, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 72%),
    radial-gradient(140px 72px at 14% 96%, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, rgba(12, 94, 165, 0.22) 0%, rgba(12, 94, 165, 0.06) 55%, rgba(12, 94, 165, 0.26) 100%);
  pointer-events: none;
}
.sky-hero > * { position: relative; z-index: 1; }

.hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #FFFFFF;
  flex: none;
}
.hero-meta { flex: 1; min-width: 0; }
.hero-kicker { font-size: 12px; opacity: 0.88; font-weight: 500; }
.hero-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-pill {
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  flex: none;
  box-shadow: var(--shadow-control);
}
.hero-pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.hero-pill.warn { background: var(--warn-bg); color: var(--warn-fg); }

.hero-metric-wrap { text-align: center; padding: 6px 0 14px; }
.hero-metric-lbl { font-size: 13px; font-weight: 500; opacity: 0.92; margin-bottom: 4px; }
.hero-metric {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(12, 52, 98, 0.25);
}
.hero-sub { font-size: 13px; opacity: 0.9; margin-top: 4px; }

.glass-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  background: rgba(14, 29, 54, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
}
.glass-banner .ico { width: 18px; height: 18px; flex: none; opacity: 0.92; }
.glass-banner .grow { flex: 1; min-width: 0; }

/* ---------- Subpage Sky-Wash Header (Detail Kartu / Scan QR style) ---------- */
.sub-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #D6E9FF 0%, #EAF2FF 65%, var(--canvas) 100%);
}
.icon-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  box-shadow: var(--shadow-control);
}
.icon-back:active { transform: scale(0.96); }
.sub-head .grow { flex: 1; min-width: 0; }

/* ---------- White Sheet & Cards ---------- */
.sheet {
  position: relative;
  z-index: 2;
  margin-top: -24px;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 12px 16px 20px;
  box-shadow: 0 -4px 20px rgba(17, 19, 21, 0.05);
}
.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--hairline);
  margin: 0 auto 14px;
}

.container { padding: 4px 16px 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow-card);
}
.card.flat {
  box-shadow: none;
  background: var(--canvas);
  border-color: var(--hairline);
}

/* ---------- Signature Awan Feature Cards (Charcoal & Teal) ---------- */
.feature-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-card);
  padding: 18px;
  margin: 12px 0;
  color: #FFFFFF;
  box-shadow: var(--shadow-card);
}
.feature-card.charcoal { background: var(--grad-charcoal); }
.feature-card.teal { background: var(--grad-teal); }
.feature-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -24px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 24px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.feature-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.feature-brand { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; opacity: 0.92; }
.feature-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
}
.feature-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.feature-sub { font-size: 13px; opacity: 0.85; line-height: 1.4; }
.feature-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  opacity: 0.9;
}

/* ---------- Layout helpers ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Inputs & Fields ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 12px 0 6px;
}
.field {
  position: relative;
  display: flex;
  align-items: center;
}
.field-ico {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
  pointer-events: none;
}
.field input, .field select { padding-left: 42px; }

input, select {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--r-control);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  min-height: 48px;
  box-shadow: var(--shadow-control);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--control-border); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 91, 201, 0.14);
}

.search-wrap input {
  border-radius: var(--r-pill);
  background: var(--canvas);
  border-color: var(--hairline);
}

.qty { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.qty label { font-size: 12px; color: var(--ink-muted); margin-top: 8px; }
.qty input {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--canvas);
}

/* ---------- Buttons (Pill Primary + Clean Secondary/Semantic) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-control);
  transition: transform .1s, opacity .15s, background-color .15s;
}
.btn:active { transform: scale(0.985); }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn.primary {
  background: var(--grad-btn);
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(22, 91, 201, 0.24);
}
.btn.secondary {
  background: var(--info-bg);
  border-color: transparent;
  color: var(--link);
  box-shadow: none;
}
.btn.warn {
  background: var(--warn-bg);
  border-color: transparent;
  color: var(--warn-fg);
  box-shadow: none;
}
.btn.danger {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger-fg);
  box-shadow: none;
}
.btn.small { min-height: 40px; padding: 7px 14px; font-size: 13px; }
.btn.icon-only { min-height: 36px; width: 36px; padding: 0; border-radius: 50%; }
.btn.block { width: 100%; }
.btn.big { min-height: 52px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-muted);
  color: var(--ink-muted);
  flex: none;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge.info { background: var(--info-bg); color: var(--info-fg); }

/* ---------- Progress Bar ---------- */
.bar {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-btn);
  transition: width .25s ease;
}

/* ---------- Lists (Aktivitas Terbaru / Kategori style) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--hairline);
}
.list li:first-child { border-top: 0; padding-top: 4px; }
.list li:last-child { padding-bottom: 2px; }
.list .grow { flex: 1; min-width: 0; }
.list button.item {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.list button.item:active { opacity: 0.72; }

.ico-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--info-bg);
  color: var(--info-fg);
  flex: none;
}
.ico-circle.ok { background: var(--ok-bg); color: var(--ok-fg); }
.ico-circle.warn { background: var(--warn-bg); color: var(--warn-fg); }
.ico-circle.danger { background: var(--danger-bg); color: var(--danger-fg); }
.ico-circle.muted { background: var(--surface-muted); color: var(--ink-muted); }
.ico-circle svg { width: 18px; height: 18px; }

.item-title { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.chev { width: 16px; height: 16px; color: var(--control-border); flex: none; }

/* ---------- Bin × Level Grid ---------- */
.grid { display: grid; gap: 6px; margin: 8px 0 10px; }
.grid .h {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-align: center;
  align-self: end;
  font-variant-numeric: tabular-nums;
}
.cell {
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--surface-muted);
  color: var(--ink-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s, border-color .15s;
}
.cell:active { transform: scale(0.95); }
.cell.fill { background: var(--ok-bg); color: var(--ok-fg); }
.cell.empty { background: var(--warn-bg); color: var(--warn-fg); }
.cell.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 91, 201, 0.16);
}

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-muted); margin: 4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 4px; display: inline-block; }
.dot.none { background: var(--surface-muted); }
.dot.fill { background: var(--ok-bg); border: 1px solid var(--ok-fg); }
.dot.empty { background: var(--warn-bg); border: 1px solid var(--warn-fg); }

/* ---------- SKU Search Results & Picked ---------- */
.res {
  max-height: 280px;
  overflow: auto;
  margin-top: 8px;
  border-radius: var(--r-tile);
  border: 1px solid var(--hairline);
  background: var(--surface);
}
.res:empty { display: none; }
.res button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid var(--hairline);
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.res button:first-child { border-top: 0; }
.res button:active { background: var(--nav-active); }
.res .muted { padding: 12px 14px; margin: 0; }

.picked {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--info-bg);
  border: 1px solid rgba(22, 91, 201, 0.22);
  color: var(--ink);
  border-radius: var(--r-tile);
  padding: 12px 14px;
  margin-top: 10px;
}
.picked-code { font-size: 14px; font-weight: 700; color: var(--link); }

/* ---------- QR Scanner Viewfinder ---------- */
.scanner-box {
  position: relative;
  border-radius: var(--r-card);
  overflow: hidden;
  background: #0E131D;
  aspect-ratio: 1;
}
video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.scan-frame {
  position: absolute;
  inset: 18%;
  pointer-events: none;
}
.scan-frame i {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid #60A5FA;
}
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }

/* ---------- Login Hero ---------- */
.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: grid;
  place-items: center;
  margin: 4px auto 12px;
}
.login-logo svg { width: 30px; height: 30px; color: #FFFFFF; }

/* ---------- Bottom Sync Bar ---------- */
.sync {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  bottom: 0;
  z-index: 15;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  box-shadow: 0 -4px 16px rgba(17, 19, 21, 0.05);
}
.sync.pending {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-top-color: rgba(135, 69, 18, 0.18);
}
.sync-status { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 80px;
  z-index: 30;
  margin: 0 auto;
  max-width: 448px;
  padding: 12px 16px;
  border-radius: var(--r-tile);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-overlay);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { background: var(--danger-fg); }

/* ---------- Section Heading Row ---------- */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.sec-head h2 { margin: 0; }

/* ---------- Tambahan untuk tampilan Apps Script (memakai token warna di atas) ---------- */
main { padding-bottom: 168px; }
.lok { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--link); line-height: 1.15; }
.lok.err { color: var(--danger-fg); }
.warn-card, .err-card { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r-tile); padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.warn-card { background: var(--warn-bg); color: var(--warn-fg); }
.err-card { background: var(--danger-bg); color: var(--danger-fg); }
.warn-card > svg, .err-card > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.warn-card .grow, .err-card .grow { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 10px; text-align: center; }
.stats > div { background: var(--surface-muted); border-radius: var(--r-tile); padding: 10px 6px; }
.stats b { display: block; font-size: 20px; font-weight: 700; }
.stats span { font-size: 12px; color: var(--ink-muted); }
.q { white-space: nowrap; font-size: 14px; }
.list li.beda { background: var(--danger-bg); border-radius: 12px; padding-left: 8px; padding-right: 8px; }
.no { display: inline-block; min-width: 26px; padding: 1px 6px; margin-right: 6px; border-radius: 6px; background: var(--info-bg); color: var(--info-fg); font-size: 12px; font-weight: 700; text-align: center; vertical-align: 1px; }
.sync { flex-wrap: wrap; }
.sync .sync-status { flex: 1; }
.sync .btn.block { flex-basis: 100%; }
.sheet > .btn.block { margin-top: 4px; }
