/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DESIGN TOKENS ───────────────────────────────────── */
:root {
  --bg:        #ffffff;
  --bg2:       #f7f8fa;
  --bg3:       #eef0f4;
  --ink:       #0f1117;
  --ink2:      #3d4152;
  --ink3:      #7a7f94;
  --ink4:      #b0b4c4;
  --border:    #e4e5ec;
  --border2:   #d0d2de;
  --accent:    #1a6b4a;
  --accent2:   #2d9467;
  --accent3:   #3db87f;
  --accent-lt: #e6f2ed;
  --accent-bd: #9fe1cb;
  --accent-tx: #0f6e56;
  --amber-bg:  #faeeda;
  --amber-bd:  #fac775;
  --amber-tx:  #633806;
  --red-bg:    #fcebeb;
  --red-bd:    #f5a0a0;
  --red-tx:    #a32d2d;
  --green-bg:  #e6f7ef;
  --green-tx:  #1a6b4a;
  --sans:      'DM Sans', system-ui, sans-serif;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.14);
  --header-h:  64px;
}

/* ── DARK MODE ───────────────────────────────────────── */
html.dark {
  --bg:        #0f1117;
  --bg2:       #181b23;
  --bg3:       #22263a;
  --ink:       #f0f1f5;
  --ink2:      #c8cad6;
  --ink3:      #7a7f94;
  --ink4:      #444860;
  --border:    #252938;
  --border2:   #2e3248;
  --accent-lt: #0f2e22;
  --accent-bd: #1a6b4a;
  --accent-tx: #3db87f;
  --amber-bg:  #2e2010;
  --amber-bd:  #7a4e10;
  --amber-tx:  #f5c07a;
  --red-bg:    #2e1010;
  --red-bd:    #7a2020;
  --red-tx:    #f57a7a;
  --green-bg:  #0f2e22;
  --green-tx:  #3db87f;
}

/* ── BASE ────────────────────────────────────────────── */
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
  overflow: hidden;
}

/* ── APP SHELL ───────────────────────────────────────── */
/* position:fixed + inset:0 fills the true physical screen on iOS PWA
   regardless of viewport unit bugs. viewport-fit=cover in the meta tag
   ensures this reaches the home indicator zone. */
#app {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  touch-action: pan-x pan-y;
  background: var(--bg);
  overflow: hidden;
}

/* ── PAGE SYSTEM ─────────────────────────────────────── */
.page { display: none; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.page.active { display: flex; }

/* ── TOP BAR ─────────────────────────────────────────── */
.top-bar {
  height: var(--header-h);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
}
.top-bar-logomark {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.18);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.top-bar-logomark svg { width: 20px; height: 20px; }
.top-bar-appname { display: flex; flex-direction: column; flex: 1; }
.top-bar-appname-title   { font-size: 17px; font-weight: 700; color: #fff; line-height: 1.1; }
.top-bar-appname-version { font-size: 11px; color: rgba(255,255,255,.65); }
.top-bar-user-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 99px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
}
.top-bar-user-pill:active { background: rgba(255,255,255,.25); }
.top-bar-avatar {
  width: 28px; height: 28px;
  background: rgba(255,255,255,.9);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.top-bar-username { font-size: 13px; font-weight: 500; color: #fff; }
.top-bar-chevron  { color: rgba(255,255,255,.7); font-size: 14px; }

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-header { padding: 20px 16px 8px; flex-shrink: 0; }
.page-header-title { font-size: 22px; font-weight: 700; color: var(--ink); }
.page-header-sub   { font-size: 14px; color: var(--ink3); margin-top: 3px; }

/* ── SCROLL AREA ─────────────────────────────────────── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  /* Clear the fixed bottom-nav + home indicator */
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 16px);
  -webkit-overflow-scrolling: touch;
}
.scroll-area.no-nav { padding-bottom: 24px; }

/* ── BOTTOM NAV ──────────────────────────────────────── */
/* position:fixed bottom:0 always anchors to the true physical screen
   bottom on iOS, bypassing all viewport height calculation issues. */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  z-index: 200;
  /* Extend nav background into home indicator zone */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-tab {
  flex: 1;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  cursor: pointer;
  color: var(--ink4);
  transition: color 0.15s, border-color 0.15s;
  padding: 0 2px;
  min-width: 0;
}
.nav-tab .nav-icon  { font-size: 22px; line-height: 1; flex-shrink: 0; display: block; }
.nav-tab .nav-label { font-size: 10px; font-weight: 500; white-space: nowrap; line-height: 1.2; display: block; }
.nav-tab.active { color: var(--accent); border-top-color: var(--accent); }
.nav-indicator  { display: none !important; }
.nav-tab:active { opacity: 0.7; }

/* ── FABs ────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
  right: 20px;
  width: 52px; height: 52px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50%;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(26,107,74,.4);
  cursor: pointer; z-index: 50;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }
.fab.hidden { display: none; }
.fab-label {
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-xl);
  padding: 14px 28px;
  font-family: var(--sans); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 20px rgba(26,107,74,.4);
  cursor: pointer; z-index: 50;
  white-space: nowrap;
}
.fab-label:active { transform: translateX(-50%) scale(0.96); }
.fab-label.hidden { display: none; }

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 12px; font-weight: 600; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }

/* ── STAT GRID ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: var(--ink3); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1; }
.stat-card.accent { background: var(--accent-lt); border-color: var(--accent-bd); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.amber  { background: var(--amber-bg); border-color: var(--amber-bd); }
.stat-card.amber .stat-value  { color: var(--amber-tx); }
.stat-card.red    { background: var(--red-bg); border-color: var(--red-bd); }
.stat-card.red .stat-value    { color: var(--red-tx); }
.stat-card.blue   { background: #e8f0fe; border-color: #a8c4f8; }
.stat-card.blue .stat-value   { color: #1a56b0; }
html.dark .stat-card.blue     { background: #0f1e3a; border-color: #1a3a6b; }
html.dark .stat-card.blue .stat-value { color: #6fa3ef; }
.stat-card.purple { background: #f3effe; border-color: #c4a8f8; }
.stat-card.purple .stat-value { color: #6b21a8; }
html.dark .stat-card.purple   { background: #1e0f3a; border-color: #4a1a8b; }
html.dark .stat-card.purple .stat-value { color: #c084fc; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px;
  border-radius: var(--radius); border: none;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--ink2); border: 1px solid var(--border2); }
.btn-danger    { background: var(--red-bg); color: var(--red-tx); border: 1px solid var(--red-bd); }
.btn-outline   { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-lg        { padding: 15px 24px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-sm        { padding: 7px 13px; font-size: 12px; }
.btn-block     { width: 100%; }
.btn:disabled  { opacity: 0.45; cursor: not-allowed; }
.btn-import    { background: var(--amber-bg); color: var(--amber-tx); border: 1.5px solid var(--amber-bd); }
.btn-import:hover { background: var(--amber-bd); }
.btn-icon { background: none; border: none; padding: 8px; border-radius: var(--radius); cursor: pointer; color: var(--ink3); font-size: 20px; display: inline-flex; transition: background 0.15s; }
.btn-icon:hover { background: var(--bg3); }

/* ── FORM FIELDS ─────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--ink2); margin-bottom: 6px; }
.field-input {
  width: 100%; padding: 12px 14px;
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: var(--radius); font-family: var(--sans);
  font-size: 15px; color: var(--ink); outline: none;
  transition: border-color 0.15s; -webkit-appearance: none;
}
.field-input:focus  { border-color: var(--accent); background: var(--bg); }
.field-input.invalid { border-color: var(--red-tx) !important; background: var(--red-bg) !important; }
.field-input.invalid:focus { border-color: var(--red-tx) !important; }
.field-error {
  font-size: 12px;
  color: var(--red-tx);
  margin-top: 5px;
  min-height: 0;
  display: none;
  font-weight: 500;
}
.field-error.visible { display: block; }
/* Native HTML5 validation bubble override — use our inline style instead */
input:user-invalid { border-color: var(--red-tx) !important; }
.field-input::placeholder { color: var(--ink4); }
.field-input[type="file"] { padding: 9px 14px; }
select.field-input { cursor: pointer; }
.field-note { font-size: 11px; color: var(--ink3); margin-top: 4px; }

/* ── BADGES ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green  { background: var(--green-bg); color: var(--green-tx); }
.badge-amber  { background: var(--amber-bg); color: var(--amber-tx); }
.badge-red    { background: var(--red-bg);   color: var(--red-tx);   }
.badge-ink    { background: var(--bg3);      color: var(--ink3);     }
.badge-accent      { background: var(--accent-lt); color: var(--accent-tx); }
.badge-not-scanned { background: #f8f8f8; color: #888; border: 1px solid #e8e8e8; font-size: 10px; }
html.dark .badge-not-scanned { background: var(--bg2); color: var(--ink4); border-color: var(--border); }

/* ── LIST ITEMS ──────────────────────────────────────── */
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; background: var(--bg); }
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--bg2); }
.list-item-icon { width: 38px; height: 38px; background: var(--bg2); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--ink3); flex-shrink: 0; }
.list-item-icon.accent { background: var(--accent-lt); color: var(--accent); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub   { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.list-item-end   { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* ── MODALS ──────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900; display: flex; align-items: flex-end; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal-sheet {
  background: var(--bg); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-height: 92dvh; overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-handle { width: 36px; height: 4px; background: var(--border2); border-radius: 99px; margin: 0 auto 18px; }
.modal-title  { font-size: 17px; font-weight: 600; margin-bottom: 16px; }

/* ── TOAST ───────────────────────────────────────────── */
.toast-container { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: 90%; max-width: 400px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn 0.2s ease, toastOut 0.3s ease 2.5s both; text-align: center; }
.toast.success { background: #2d2d2d; color: var(--accent3); }
html.dark .toast.success { background: #2a2a2a; color: var(--accent3); }
/* Ensure base dark toast (non-success) also stays readable */
html.dark .toast { background: #2a2a2a; color: var(--ink2); }
.toast.error   { background: #d63031; color: #fff; }
.toast.warning { background: #d96a2a; color: #fff; }
@keyframes toastIn  { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── SCANNER ─────────────────────────────────────────── */
.scanner-wrapper { background: #000; border-radius: var(--radius-lg); overflow: hidden; position: relative; }
#reader { width: 100%; }
#reader video { width: 100% !important; }
#reader img   { display: none !important; }
.scanner-close-btn { position: absolute; top: 10px; right: 10px; z-index: 20; width: 36px; height: 36px; background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.scanner-corners { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.scanner-frame { width: 220px; height: 160px; position: relative; }
.scanner-frame::before, .scanner-frame::after, .scanner-frame .c3, .scanner-frame .c4 { content: ''; position: absolute; width: 28px; height: 28px; border-color: rgba(255,255,255,.85); border-style: solid; }
.scanner-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 8px 0 0 0; }
.scanner-frame::after  { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 8px 0 0; }
.scanner-frame .c3     { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 8px; }
.scanner-frame .c4     { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 8px 0; }
.scanner-frame.active::before,.scanner-frame.active::after,.scanner-frame.active .c3,.scanner-frame.active .c4 { border-color: var(--accent3); }
.manual-entry-row { display: flex; gap: 10px; align-items: stretch; }
.manual-entry-input { flex: 1; padding: 13px 14px; background: var(--bg2); border: 1.5px solid var(--border2); border-radius: var(--radius-lg); font-family: var(--sans); font-size: 15px; color: var(--ink); outline: none; transition: border-color 0.15s; -webkit-appearance: none; }
.manual-entry-input:focus { border-color: var(--accent); background: var(--bg); }
.manual-entry-input::placeholder { color: var(--ink4); }
.manual-entry-btn { width: 52px; height: 52px; flex-shrink: 0; background: var(--bg2); border: 1.5px solid var(--border2); border-radius: var(--radius-lg); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--ink3); transition: background 0.15s; }
.manual-entry-btn:active { background: var(--accent-lt); border-color: var(--accent); color: var(--accent); }

/* ── EXPIRY DOTS ─────────────────────────────────────── */
.expiry-dot    { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.expiry-ok     { background: var(--accent3); }
.expiry-warn   { background: #f5a623; }
.expiry-danger { background: #e74c3c; }

/* ── SECTION HEADER ──────────────────────────────────── */
.section-header { font-size: 11px; font-weight: 700; color: var(--ink3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; margin-top: 20px; }
.section-header:first-child { margin-top: 0; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; text-align: center; color: var(--ink3); }
.empty-state-icon  { font-size: 48px; opacity: .35; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--ink2); }
.empty-state-text  { font-size: 13px; line-height: 1.6; }

/* ── OFFLINE BANNER ──────────────────────────────────── */
#offline-banner { background: var(--amber-bg); border-bottom: 1px solid var(--amber-bd); color: var(--amber-tx); padding: 7px 16px; font-size: 12px; font-weight: 500; text-align: center; display: none; flex-shrink: 0; }
#offline-banner.visible { display: block; }

/* ── UPDATE SCREEN ───────────────────────────────────── */
#update-screen { position: fixed; inset: 0; z-index: 9990; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; gap: 16px; }
#update-screen.hidden { display: none; }
.update-icon  { font-size: 56px; color: var(--accent); }
.update-title { font-size: 20px; font-weight: 700; }
.update-sub   { font-size: 14px; color: var(--ink3); line-height: 1.6; }
.version-chips { display: flex; gap: 12px; justify-content: center; }
.version-chip  { padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.version-old   { background: var(--red-bg); color: var(--red-tx); }
.version-new   { background: var(--green-bg); color: var(--green-tx); }

/* ── LOGIN SCREEN ────────────────────────────────────── */
#login-screen { position: fixed; inset: 0; z-index: 9980; background: var(--bg); display: flex; flex-direction: column; overflow-y: auto; }
#login-screen.hidden { display: none; }
.login-header { background: var(--accent); padding: 56px 28px 36px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.login-logomark { width: 72px; height: 72px; background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.3); border-radius: 20px; display: flex; align-items: center; justify-content: center; animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.login-title { font-size: 24px; font-weight: 700; color: #fff; }
.login-sub   { font-size: 14px; color: rgba(255,255,255,.7); }
.login-body  { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.user-picker { display: flex; flex-direction: column; border: 1.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.user-pick-item { display: flex; align-items: center; gap: 12px; padding: 15px 16px; background: var(--bg); border: none; border-bottom: 1px solid var(--border); cursor: pointer; font-family: var(--sans); text-align: left; transition: background 0.1s; }
.user-pick-item:last-child { border-bottom: none; }
.user-pick-item:active { background: var(--accent-lt); }
.user-pick-avatar { width: 38px; height: 38px; background: var(--accent-lt); color: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-pick-name { font-size: 15px; font-weight: 500; color: var(--ink); }
.user-pick-role { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.pin-native-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.pin-label-row { text-align: center; }
.pin-label-row strong { font-size: 16px; font-weight: 600; display: block; }
.pin-label-row span   { font-size: 13px; color: var(--ink3); }
.pin-input-field { width: 180px; height: 56px; background: var(--bg2); border: 2px solid var(--border2); border-radius: var(--radius-lg); text-align: center; font-size: 28px; font-family: var(--sans); font-weight: 700; letter-spacing: 8px; color: var(--ink); outline: none; -webkit-appearance: none; transition: border-color 0.15s; }
.pin-input-field:focus { border-color: var(--accent); }
.pin-input-field.error { border-color: var(--red-tx); animation: shake 0.3s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* ── INSTALL SCREEN ──────────────────────────────────── */
#install-screen { position: fixed; inset: 0; z-index: 9970; background: var(--bg); display: flex; flex-direction: column; overflow-y: auto; }
#install-screen.hidden { display: none; }
.install-header { background: var(--accent); padding: 56px 28px 36px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.install-step { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.install-step:last-child { border-bottom: none; }
.install-step-num { width: 28px; height: 28px; background: var(--accent-lt); color: var(--accent); border-radius: 50%; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.install-step-text { font-size: 14px; color: var(--ink2); line-height: 1.5; }
.install-step-title { font-weight: 600; color: var(--ink); margin-bottom: 3px; }

/* ── QR & IMAGES ─────────────────────────────────────── */
.qr-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.detail-product-img { width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--radius-lg); background: var(--bg2); border: 1px solid var(--border); display: block; }
#detail-img-wrap { margin-bottom: 14px; border-radius: var(--radius-lg); overflow: hidden; background: var(--bg2); }
.product-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); flex-shrink: 0; }
#count-product-img-wrap { display: flex; align-items: center; margin-bottom: 10px; }
#np-img-preview { width: 100%; max-height: 200px; object-fit: contain; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg2); margin-top: 8px; }
#np-img-preview.hidden { display: none; }

/* ── REPORT TABLE ────────────────────────────────────── */
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { background: var(--bg2); text-align: left; padding: 8px 12px; font-weight: 600; color: var(--ink3); font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.report-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--ink2); }
.report-table tr:last-child td { border-bottom: none; }

/* ── STORAGE BAR ─────────────────────────────────────── */
.storage-bar { height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.storage-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.5s ease; }
.storage-bar-fill.warn   { background: #f5a623; }
.storage-bar-fill.danger { background: #e74c3c; }

/* ── TOGGLE ──────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.toggle-sub   { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.toggle { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg3); border-radius: 99px; transition: background 0.2s; cursor: pointer; }
.toggle-slider::before { content: ''; position: absolute; width: 22px; height: 22px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── SEARCH BAR ──────────────────────────────────────── */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1.5px solid var(--border2); border-radius: var(--radius-lg); padding: 11px 14px; margin-bottom: 14px; }
.search-bar i { color: var(--ink4); font-size: 18px; }
.search-bar input { flex: 1; border: none; background: transparent; font-family: var(--sans); font-size: 15px; color: var(--ink); outline: none; }
.search-bar input::placeholder { color: var(--ink4); }

/* ── LOADER ──────────────────────────────────────────── */
.loader { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 40px; }

/* ── SCAN PAGE ───────────────────────────────────────── */
.scan-camera-label { font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.scan-camera-sub   { font-size: 14px; color: var(--ink3); margin-bottom: 14px; line-height: 1.5; }
.scan-start-btn-area { display: flex; align-items: center; justify-content: center; min-height: 180px; background: var(--bg3); border-radius: var(--radius-lg); cursor: pointer; flex-direction: column; gap: 10px; color: var(--ink3); }
.scan-start-btn-area i    { font-size: 42px; color: var(--accent); opacity: .7; }
.scan-start-btn-area span { font-size: 14px; font-weight: 500; }
.result-banner { border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.result-banner.found { background: var(--accent-lt); border: 1px solid var(--accent-bd); }
.result-banner.new   { background: var(--amber-bg);  border: 1px solid var(--amber-bd); }
.result-banner.dup   { background: var(--red-bg);    border: 1px solid var(--red-bd); }
.result-banner-icon  { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.result-banner.found .result-banner-icon { color: var(--accent); }
.result-banner.new   .result-banner-icon { color: var(--amber-tx); }
.result-banner.dup   .result-banner-icon { color: var(--red-tx); }
.result-banner-body  { flex: 1; }
.result-banner-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.result-banner-sub   { font-size: 12px; color: var(--ink3); margin-top: 2px; }

/* ── ANDROID INSTALL BANNER ──────────────────────────── */
#android-install-banner { position: fixed; bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px); left: 12px; right: 12px; background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 14px 16px; display: flex; align-items: center; gap: 12px; z-index: 800; box-shadow: var(--shadow-lg); }
#android-install-banner.hidden { display: none; }
.install-banner-text  { flex: 1; font-size: 13px; line-height: 1.4; }
.install-banner-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }

/* ── USER DROPDOWN ───────────────────────────────────── */
.user-dropdown-overlay { position: fixed; inset: 0; z-index: 500; background: transparent; }
.user-dropdown-overlay.hidden { display: none; }
.user-dropdown-menu { position: fixed; top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 6px); right: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 501; min-width: 180px; overflow: hidden; animation: dropIn 0.15s ease; }
.user-dropdown-menu.hidden { display: none; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px) scale(0.97); } to { opacity: 1; transform: none; } }
.user-dropdown-header { padding: 12px 16px 10px; border-bottom: 1px solid var(--border); }
.user-dropdown-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.user-dropdown-role { font-size: 11px; color: var(--ink3); margin-top: 1px; }
.user-dropdown-item { display: flex; align-items: center; gap: 10px; padding: 13px 16px; background: none; border: none; border-bottom: 1px solid var(--border); width: 100%; text-align: left; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink2); cursor: pointer; transition: background 0.1s; }
.user-dropdown-item:last-child { border-bottom: none; }
.user-dropdown-item:active { background: var(--bg2); }
.user-dropdown-item i { font-size: 17px; color: var(--ink3); }
.user-dropdown-item.danger { color: var(--red-tx); }
.user-dropdown-item.danger i { color: var(--red-tx); }

/* ── MISC ────────────────────────────────────────────── */
#detail-qr-section { margin-bottom: 14px; }
#manual-entry-section.hidden { display: none; }
#recent-scans-section.hidden { display: none; }
#np-barcode-row.hidden { display: none; }
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-1   { flex: 1; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.text-center { text-align: center; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--ink3); }
.fw-600      { font-weight: 600; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
@media print { body { background:#fff; } .no-print { display:none!important; } }

/* ── ONBOARDING WIZARD ───────────────────────────────── */
#onboarding-screen {
  position: fixed; inset: 0; z-index: 9975;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#onboarding-screen.hidden { display: none; }
.onboarding-header {
  background: var(--accent);
  padding: 48px 28px 28px;
  flex-shrink: 0;
  text-align: center;
}
.onboarding-header-title { font-size: 22px; font-weight: 700; color: #fff; margin-top: 12px; }
.onboarding-header-sub   { font-size: 14px; color: rgba(255,255,255,.75); margin-top: 4px; }
.onboarding-progress {
  display: flex; gap: 6px; justify-content: center; margin-top: 16px;
}
.onboarding-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: background 0.2s;
}
.onboarding-dot.active { background: #fff; }
.onboarding-dot.done   { background: rgba(255,255,255,.7); }
.onboarding-body {
  flex: 1; overflow-y: auto;
  padding: 24px;
}
.onboarding-step { display: none; }
.onboarding-step.active { display: block; }
.onboarding-step-title { font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.onboarding-step-desc  { font-size: 14px; color: var(--ink3); margin-bottom: 20px; line-height: 1.6; }
.onboarding-footer {
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  flex-shrink: 0;
  background: var(--bg);
}
.notif-explainer {
  background: var(--accent-lt);
  border: 1px solid var(--accent-bd);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.notif-explainer-title { font-size: 15px; font-weight: 600; color: var(--accent-tx); margin-bottom: 8px; }
.notif-explainer-text  { font-size: 13px; color: var(--accent-tx); line-height: 1.6; }

