/* ================================================================
   WMS PRO — Complete Design System
   Mobile-first, 390×844 viewport, native app aesthetic
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --slate-950: #020617;
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;

  --emerald-600: #059669;
  --emerald-500: #10B981;
  --emerald-400: #34D399;
  --emerald-100: #D1FAE5;
  --emerald-50:  #ECFDF5;

  --amber-600:  #D97706;
  --amber-500:  #F59E0B;
  --amber-400:  #FBBF24;
  --amber-100:  #FEF3C7;
  --amber-50:   #FFFBEB;

  --red-600:  #DC2626;
  --red-500:  #EF4444;
  --red-400:  #F87171;
  --red-100:  #FEE2E2;
  --red-50:   #FFF5F5;

  --blue-500: #3B82F6;
  --blue-400: #60A5FA;
  --blue-100: #DBEAFE;

  --purple-500: #8B5CF6;
  --purple-100: #EDE9FE;

  /* Semantic */
  --color-bg:        var(--slate-900);
  --color-surface:   var(--slate-800);
  --color-surface-2: var(--slate-700);
  --color-border:    rgba(255,255,255,0.08);
  --color-text:      var(--slate-100);
  --color-text-muted:var(--slate-400);
  --color-success:   var(--emerald-500);
  --color-warning:   var(--amber-500);
  --color-danger:    var(--red-500);
  --color-info:      var(--blue-500);

  /* Layout */
  --app-max-width: 430px;
  --topbar-h: 60px;
  --bottomnav-h: 68px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow-green: 0 0 20px rgba(16,185,129,0.25);
  --shadow-glow-amber: 0 0 20px rgba(245,158,11,0.25);
  --shadow-glow-red:   0 0 20px rgba(239,68,68,0.25);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4,0,0.2,1);
  --transition-base: 250ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 400ms cubic-bezier(0.4,0,0.2,1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--slate-950);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ─────────────────────────────────────────────────── */
#app {
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--color-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

/* ── Top Bar ───────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--topbar-h);
  background: rgba(15,23,42,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-glow-green);
}

.topbar-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--color-text);
}

.topbar-logo-text span { color: var(--emerald-500); }

/* Search Bar */
.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 12px;
  height: 38px;
  gap: 8px;
  transition: var(--transition-base);
}

.search-bar:focus-within {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 13px;
  font-family: inherit;
}

.search-bar input::placeholder { color: var(--color-text-muted); }

.search-icon { color: var(--color-text-muted); flex-shrink: 0; }

.btn-scan-topbar {
  width: 38px; height: 38px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald-500);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.btn-scan-topbar:active { transform: scale(0.92); background: var(--color-surface-2); }

/* ── Main Content ──────────────────────────────────────────────── */
#main-content {
  flex: 1;
  margin-top: var(--topbar-h);
  margin-bottom: var(--bottomnav-h);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ── Tab Views ─────────────────────────────────────────────────── */
.tab-view {
  display: none;
  min-height: calc(100dvh - var(--topbar-h) - var(--bottomnav-h));
  padding: 16px;
  animation: slideUp 280ms cubic-bezier(0.34,1.56,0.64,1);
}

.tab-view.active { display: block; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Bottom Navigation ─────────────────────────────────────────── */
#bottomnav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--bottomnav-h);
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  gap: 4px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  position: relative;
}

.nav-item .nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: var(--transition-fast);
}

.nav-item svg { transition: var(--transition-fast); }

.nav-item.active {
  color: var(--emerald-500);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--emerald-500);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
  box-shadow: var(--shadow-glow-green);
}

.nav-item:active { transform: scale(0.92); }

/* Scan button in nav (center) */
.nav-item.nav-scan {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  flex: 0 0 64px;
  height: 48px;
  box-shadow: var(--shadow-glow-green);
}
.nav-item.nav-scan::before { display: none; }
.nav-item.nav-scan:active { transform: scale(0.9); }

/* ── Section Headers ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.section-action {
  font-size: 12px;
  font-weight: 500;
  color: var(--emerald-500);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.section-action:hover { background: rgba(16,185,129,0.1); }

/* ── KPI Cards ─────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-base);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.emerald::before { background: var(--emerald-500); }
.kpi-card.amber::before   { background: var(--amber-500); }
.kpi-card.red::before     { background: var(--red-500); }
.kpi-card.blue::before    { background: var(--blue-500); }

.kpi-card:active { transform: scale(0.97); }

.kpi-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 18px;
}
.kpi-card.emerald .kpi-icon { background: rgba(16,185,129,0.15); color: var(--emerald-400); }
.kpi-card.amber .kpi-icon   { background: rgba(245,158,11,0.15); color: var(--amber-400); }
.kpi-card.red .kpi-icon     { background: rgba(239,68,68,0.15); color: var(--red-400); }
.kpi-card.blue .kpi-icon    { background: rgba(59,130,246,0.15); color: var(--blue-400); }

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-card.emerald .kpi-value { color: var(--emerald-400); }
.kpi-card.amber .kpi-value   { color: var(--amber-400); }
.kpi-card.red .kpi-value     { color: var(--red-400); }
.kpi-card.blue .kpi-value    { color: var(--blue-400); }

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ── Chart Cards ───────────────────────────────────────────────── */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  width: 100%;
}

/* Period Selector Tabs */
.period-tabs {
  display: flex;
  background: var(--slate-900);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  margin-bottom: 14px;
}

.period-tab {
  flex: 1;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--color-text-muted);
  border: none;
  background: transparent;
  font-family: inherit;
}

.period-tab.active {
  background: var(--emerald-500);
  color: #fff;
  box-shadow: var(--shadow-glow-green);
}

/* Fast Moving List */
.fast-moving-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.fast-moving-item:last-child { border-bottom: none; }

.fast-moving-rank {
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  background: var(--slate-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.fast-moving-rank.top { background: linear-gradient(135deg, var(--amber-500), var(--amber-600)); color: #fff; }

.fast-moving-info { flex: 1; min-width: 0; }
.fast-moving-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fast-moving-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

.fast-moving-bar-wrap {
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.fast-moving-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald-400);
}
.fast-moving-bar {
  width: 100%;
  height: 4px;
  background: var(--slate-700);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.fast-moving-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-500), var(--emerald-400));
  border-radius: var(--radius-full);
  transition: width 600ms cubic-bezier(0.4,0,0.2,1);
}

/* Warehouse Distribution */
.warehouse-dist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--slate-900);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}
.warehouse-dist-item:active { transform: scale(0.98); border-color: var(--emerald-500); }

.wh-dot {
  width: 10px; height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.wh-info { flex: 1; min-width: 0; }
.wh-name { font-size: 13px; font-weight: 600; color: var(--color-text); }
.wh-meta { font-size: 11px; color: var(--color-text-muted); }
.wh-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

/* ── Forms & Inputs ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  outline: none;
  transition: var(--transition-base);
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.form-control::placeholder { color: var(--color-text-muted); }

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.input-with-icon {
  position: relative;
}
.input-with-icon .form-control { padding-right: 44px; }
.input-with-icon .input-icon-btn {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: rgba(16,185,129,0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--emerald-500);
  transition: var(--transition-fast);
}
.input-with-icon .input-icon-btn:active { transform: translateY(-50%) scale(0.9); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  letter-spacing: 0.2px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-600));
  color: #fff;
  box-shadow: var(--shadow-glow-green);
}
.btn-primary:active { background: var(--emerald-600); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}

.btn-warning {
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  color: #fff;
  box-shadow: var(--shadow-glow-amber);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red-500), var(--red-600));
  color: #fff;
  box-shadow: var(--shadow-glow-red);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  width: auto;
}

.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  width: auto;
  flex: 0 0 40px;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}

/* Product Result Card */
.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
  transition: var(--transition-base);
}

.product-card:active { transform: scale(0.98); }

.product-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.product-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--slate-700);
  color: var(--slate-300);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.product-name { font-size: 14px; font-weight: 700; color: var(--color-text); }
.product-meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.stock-total {
  text-align: right;
  flex-shrink: 0;
}
.stock-total-value { font-size: 20px; font-weight: 800; color: var(--emerald-400); letter-spacing: -0.5px; }
.stock-total-label { font-size: 10px; color: var(--color-text-muted); }

/* Location Breakdown */
.location-list { display: flex; flex-direction: column; gap: 6px; }
.location-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--slate-900);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}
.loc-icon { color: var(--emerald-500); flex-shrink: 0; }
.loc-text { flex: 1; color: var(--slate-300); }
.loc-qty  { font-weight: 700; color: var(--emerald-400); }

/* ── Stock Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.badge-ok      { background: var(--emerald-100); color: var(--emerald-600); }
.badge-low     { background: var(--amber-100);   color: var(--amber-600); }
.badge-out     { background: var(--red-100);     color: var(--red-600); }
.badge-pending { background: var(--amber-100);   color: var(--amber-600); }
.badge-approved{ background: var(--emerald-100); color: var(--emerald-600); }
.badge-rejected{ background: var(--red-100);     color: var(--red-600); }
.badge-fulfilled{ background: var(--emerald-100); color: var(--emerald-600); }
.badge-partial { background: var(--amber-100);   color: var(--amber-600); }
.badge-expired { background: var(--red-100);     color: var(--red-600); }
.badge-critical{ background: var(--red-100);     color: var(--red-600); }
.badge-warning-exp { background: var(--amber-100); color: var(--amber-600); }
.badge-info    { background: var(--blue-100);    color: var(--blue-500); }
.badge-gray    { background: var(--slate-700);   color: var(--slate-300); }

/* ── Toast Notifications ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 76px;
  left: 50%; transform: translateX(-50%);
  width: calc(min(100vw, var(--app-max-width)) - 32px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  animation: toastIn 300ms cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: all;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

.toast.hiding { animation: toastOut 250ms ease forwards; }

.toast-success { background: rgba(5,150,105,0.95); color: #fff; border: 1px solid var(--emerald-500); }
.toast-error   { background: rgba(185,28,28,0.95);  color: #fff; border: 1px solid var(--red-500); box-shadow: var(--shadow-glow-red); }
.toast-warning { background: rgba(180,83,9,0.95);   color: #fff; border: 1px solid var(--amber-500); }
.toast-info    { background: rgba(30,41,59,0.97);   color: var(--slate-200); border: 1px solid var(--slate-600); }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-size: 13px; font-weight: 700; }
.toast-msg   { font-size: 12px; opacity: 0.9; margin-top: 2px; }

/* ── Scanner Modal ─────────────────────────────────────────────── */
#scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
}
#scanner-modal.open { display: flex; }

.scanner-sheet {
  background: var(--slate-900);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: var(--app-max-width);
  animation: slideSheet 320ms cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes slideSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--slate-600);
  border-radius: var(--radius-full);
  margin: 0 auto 16px;
}

.scanner-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}

#qr-reader {
  width: 100% !important;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--emerald-500) !important;
  box-shadow: var(--shadow-glow-green);
}

#qr-reader * { border-radius: 0 !important; }

.scanner-manual {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

/* ── Search Overlay ────────────────────────────────────────────── */
#search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--slate-950);
  display: none;
  flex-direction: column;
}
#search-overlay.open { display: flex; }

.search-overlay-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-border);
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(20px);
}

.search-overlay-header input {
  flex: 1;
  background: var(--color-surface);
  border: 1.5px solid var(--emerald-500);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  outline: none;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── FIFO Alert Banner ─────────────────────────────────────────── */
.fifo-alert {
  background: linear-gradient(135deg, rgba(185,28,28,0.2), rgba(239,68,68,0.1));
  border: 1.5px solid var(--red-500);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.fifo-alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--red-400);
  margin-bottom: 8px;
}

.fifo-alert-body { font-size: 12px; color: var(--slate-300); line-height: 1.6; }

/* FIFO Suggestion */
.fifo-suggestion {
  background: linear-gradient(135deg, rgba(5,150,105,0.15), rgba(16,185,129,0.08));
  border: 1.5px solid var(--emerald-500);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
}
.fifo-suggestion-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ── Scan Session Card ─────────────────────────────────────────── */
.scan-product-card {
  background: linear-gradient(135deg, var(--color-surface), var(--slate-700));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}

.scan-product-code {
  font-size: 10px;
  font-weight: 700;
  color: var(--emerald-500);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.scan-product-name { font-size: 17px; font-weight: 700; color: var(--color-text); margin-bottom: 4px; }
.scan-product-uom  { font-size: 12px; color: var(--color-text-muted); }
.scan-product-stock { font-size: 13px; color: var(--emerald-400); margin-top: 8px; font-weight: 600; }

/* ── Variance Display ──────────────────────────────────────────── */
.variance-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--slate-900);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 12px 0;
}
.variance-col { text-align: center; }
.variance-col-label { font-size: 10px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.variance-col-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.variance-divider { color: var(--slate-600); font-size: 20px; }
.variance-positive { color: var(--emerald-400); }
.variance-negative { color: var(--red-400); }
.variance-zero { color: var(--color-text-muted); }

/* ── Report Cards ──────────────────────────────────────────────── */
.report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition-base);
}
.report-card:active { transform: scale(0.98); border-color: var(--emerald-500); }

.report-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.report-card-body { flex: 1; }
.report-card-title { font-size: 14px; font-weight: 700; color: var(--color-text); margin-bottom: 3px; }
.report-card-desc  { font-size: 12px; color: var(--color-text-muted); line-height: 1.4; }
.report-card-arrow { color: var(--color-text-muted); flex-shrink: 0; }

/* ── Data Table (mobile optimized) ────────────────────────────── */
.data-list { display: flex; flex-direction: column; gap: 8px; }

.data-row {
  background: var(--slate-900);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--color-border);
}

.data-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.data-row-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
.data-row-meta  { font-size: 11px; color: var(--color-text-muted); }

.data-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.data-cell-label { font-size: 10px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.data-cell-value { font-size: 13px; font-weight: 600; color: var(--color-text); margin-top: 1px; }

/* ── Ledger Items ──────────────────────────────────────────────── */
.ledger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.ledger-item:last-child { border-bottom: none; }

.ledger-dot {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ledger-dot.in  { background: rgba(16,185,129,0.15); color: var(--emerald-400); }
.ledger-dot.out { background: rgba(239,68,68,0.15);  color: var(--red-400); }

.ledger-info { flex: 1; min-width: 0; }
.ledger-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
.ledger-meta  { font-size: 11px; color: var(--color-text-muted); margin-top: 1px; }

.ledger-qty { text-align: right; }
.ledger-qty-value { font-size: 14px; font-weight: 700; }
.ledger-qty-value.in  { color: var(--emerald-400); }
.ledger-qty-value.out { color: var(--red-400); }
.ledger-balance { font-size: 11px; color: var(--color-text-muted); }

/* ── Expiry Alert Rows ─────────────────────────────────────────── */
.expiry-row { position: relative; overflow: hidden; }
.expiry-row.expired::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--red-500);
  border-radius: 3px 0 0 3px;
}
.expiry-row.critical::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--amber-500);
}

/* ── Filters Row ───────────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-row .form-control { font-size: 12px; padding: 9px 10px; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 6px; }
.empty-desc  { font-size: 13px; color: var(--slate-600); }

/* ── Skeleton Loader ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-800) 25%, var(--slate-700) 50%, var(--slate-800) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Loading Spinner ───────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page Header ───────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.5px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* ── Step Indicator ────────────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}
.step {
  display: flex;
  align-items: center;
  gap: 6px;
}
.step-num {
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  background: var(--slate-700);
  color: var(--slate-400);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
}
.step-num.active { background: var(--emerald-500); color: #fff; box-shadow: var(--shadow-glow-green); }
.step-num.done   { background: var(--emerald-600); color: #fff; }
.step-label { font-size: 11px; color: var(--color-text-muted); }
.step-label.active { color: var(--emerald-400); font-weight: 600; }
.step-sep { flex: 1; height: 1px; background: var(--slate-700); }

/* ── Activity Feed ─────────────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot.in  { background: var(--emerald-500); box-shadow: 0 0 6px var(--emerald-500); }
.activity-dot.out { background: var(--red-500); box-shadow: 0 0 6px var(--red-500); }
.activity-text { flex: 1; font-size: 12px; color: var(--slate-300); line-height: 1.5; }
.activity-text strong { color: var(--color-text); }
.activity-time { font-size: 11px; color: var(--slate-600); white-space: nowrap; }

/* ── Divider ───────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 0;
}

/* ── Utility ───────────────────────────────────────────────────── */
.text-emerald { color: var(--emerald-400); }
.text-amber   { color: var(--amber-400); }
.text-red     { color: var(--red-400); }
.text-muted   { color: var(--color-text-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-700       { font-weight: 700; }
.fw-600       { font-weight: 600; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.gap-8        { gap: 8px; }
.flex         { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-700); border-radius: 3px; }

/* ── Safe areas ────────────────────────────────────────────────── */
@supports (padding: max(0px)) {
  #topbar { padding-top: max(0px, env(safe-area-inset-top)); }
}

/* ── Report Detail View ────────────────────────────────────────── */
#report-detail-view { display: none; }
#report-detail-view.open { display: block; }
#report-list-view.hidden { display: none; }

.report-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.btn-back {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.btn-back:active { transform: scale(0.92); }

/* ── Opname Approval List ──────────────────────────────────────── */
.opname-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}
.opname-card.pending-card { border-color: rgba(245,158,11,0.3); }

.opname-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Warehouse Select Pills ────────────────────────────────────── */
.wh-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.wh-pills::-webkit-scrollbar { display: none; }
.wh-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.wh-pill.active {
  background: rgba(16,185,129,0.15);
  border-color: var(--emerald-500);
  color: var(--emerald-400);
}
