/* ============================================================
   Namibian Marketspace — mobile-first design system
   Conversion strategy:
   - blue   = brand / trust / security (nav, submit, approve)
   - orange = commerce action CTA (add to cart, buy, register)
   - green  = checkout / money / verification (success)
   - red    = urgency / danger (sales, out of stock, delete)
   Research basis: Blue = #1 trust color (35% preference), signals
   reliability & security critical for anti-scam marketplace messaging.
   Orange CTAs lift click-through, green lifts checkout completion.
   High contrast + single accent per screen.
   Free visuals: Google Fonts (Inter + Plus Jakarta Sans), pure-CSS
   gradient art, emoji iconography — no external image hotlinking.
   ============================================================ */

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-soft: #dbeafe;

  --cta: #ea580c;
  --cta-dark: #c2410c;
  --cta-soft: #ffedd5;

  --checkout: #16a34a;
  --checkout-dark: #15803d;
  --checkout-soft: #dcfce7;

  --dark: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --light: #f4f6f8;
  --white: #ffffff;

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;

  --focus: #1e40af;
  --overlay: rgba(15, 23, 42, .68);

  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, .10), 0 16px 40px rgba(15, 23, 42, .12);
  --shadow-3: 0 24px 70px rgba(0, 0, 0, .28);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;

  /* Safe Area insets */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Fluid layout tokens */
  --container-pad: clamp(12px, 3.5vw, 24px);
  --max-content-width: min(1200px, 100vw);
  --max-wide-width: min(1400px, 100vw);

  /* Fluid typography */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
  --h1-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.35rem);
  --h2-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  --h3-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--light);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Fast tap response on all touch devices (eliminates 300ms delay) */
button, a, input, select, textarea, .chip, .product-card, .tab-btn {
  touch-action: manipulation;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--dark); line-height: 1.25; font-weight: 800; font-family: var(--font-display); }
h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); }
h3 { font-size: var(--h3-size); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-inline: auto;
  padding-inline: max(var(--container-pad), var(--safe-left)) max(var(--container-pad), var(--safe-right));
}

.container-wide {
  width: 100%;
  max-width: var(--max-wide-width);
  margin-inline: auto;
  padding-inline: max(var(--container-pad), var(--safe-left)) max(var(--container-pad), var(--safe-right));
}

/* ---------------- Navigation ---------------- */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-1);
  padding-top: env(safe-area-inset-top);
}

.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 10px 16px;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.nav-links {
  display: flex;
  gap: 4px;
  order: 3;
  width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link.active { background: var(--primary); color: var(--white); }

.nav-spacer { flex: 1; }

.nav-user { font-size: .85rem; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  min-height: 44px;              /* WCAG 2.5.5 touch target */
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
  background: var(--light);
  color: var(--text);
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--cta); color: #fff; }       /* commerce CTA */
.btn-success { background: var(--checkout); color: #fff; } /* checkout / verify */
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: .88rem; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; min-height: 52px; }
.btn-block { width: 100%; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }

.card-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
}
.form-group .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  min-height: 48px;              /* comfortable touch target */
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;               /* 16px — prevents iOS zoom */
  background: var(--white);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

.textarea { min-height: 96px; resize: vertical; }
.input[readonly] { background: var(--light); }

/* ---------------- Alerts / Badges ---------------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  margin-bottom: 14px;
  display: none;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--checkout-dark); border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: var(--info); border: 1px solid #bfdbfe; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-pending { background: #fffbeb; color: var(--warning); }
.badge-approved, .badge-active, .badge-paid { background: #f0fdf4; color: var(--checkout-dark); }
.badge-rejected, .badge-suspended, .badge-overdue { background: #fef2f2; color: var(--danger); }
.badge-unpaid { background: #fffbeb; color: var(--warning); }
.badge-info { background: #eff6ff; color: var(--info); }
.badge-sale { background: var(--danger); color: #fff; }

/* ---------------- Tables ---------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: .9rem;
}
.table th {
  text-align: left;
  padding: 11px 12px;
  background: var(--light);
  color: var(--dark);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* ---------------- Stats ---------------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.stat-card .stat-label { font-size: .76rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; color: var(--dark); margin-top: 4px; }
.stat-card .stat-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 12px 16px;
  min-height: 44px;
  border: none;
  background: none;
  font-size: .95rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- Modal (bottom sheet on phones) ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;         /* bottom sheet on small screens */
  justify-content: center;
  z-index: 100;
  padding: 0;
  overscroll-behavior: contain;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-width: 720px;
  width: 100%;
  max-height: 90dvh;
  max-height: 90svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow-3);
  animation: sheet-up .22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overscroll-behavior: contain;
}
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: -10px auto 14px;
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 960px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
  position: sticky;
  top: -20px;
  background: var(--white);
  padding: 6px 0;
  z-index: 12;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.15rem; font-weight: 800; line-height: 1.25; }
.modal-close {
  background: var(--light);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.modal-close:hover { color: var(--danger); }
.modal-text { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal-sticky-cta {
  position: sticky;
  bottom: calc(-20px - var(--safe-bottom));
  background: var(--white);
  padding: 12px 0 calc(12px + var(--safe-bottom));
  margin-top: 14px;
  border-top: 1px solid var(--border);
  z-index: 12;
  box-shadow: 0 -4px 14px rgba(15, 23, 42, .06);
}

.modal-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-main-img {
  aspect-ratio: 1 / 1;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-main-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.modal-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity .15s ease, border-color .15s ease;
  touch-action: manipulation;
  flex: 0 0 auto;
}
.modal-thumb.active, .modal-thumb:hover {
  opacity: 1;
  border-color: var(--primary);
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: .5; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------------- Toast ---------------- */
#toast-box {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 13px 20px;
  border-radius: 999px;
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  animation: toast-in .25s ease;
  max-width: 100%;
  text-align: center;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-out { opacity: 0; transform: translateY(8px); transition: all .3s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Hero & search ---------------- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0e8a7c 55%, #0ea5e9 130%);
  color: #fff;
  padding: clamp(20px, 4vw, 38px) 0 clamp(22px, 4vw, 42px);
  margin-bottom: clamp(14px, 3vw, 22px);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -12%;
  width: 55%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 65%);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -70%;
  left: -10%;
  width: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .10), transparent 65%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }
.hero h1 { color: #fff; margin-bottom: 6px; font-size: var(--h1-size); }
.hero p { opacity: .92; max-width: 640px; font-size: clamp(0.92rem, 0.88rem + 0.2vw, 1.05rem); }

.hero-trust { display: flex; flex-wrap: wrap; gap: clamp(6px, 1.5vw, 10px); margin-top: 14px; }
.hero-trust span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.search-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: clamp(12px, 2.5vw, 18px);
}
@media (min-width: 560px) {
  .search-bar {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .search-bar .input { flex: 1 1 220px; min-width: 0; max-width: none; }
  .search-bar .select { max-width: none; flex: 0 0 auto; }
}

/* ---------------- Category chips ---------------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: clamp(12px, 2.5vw, 18px);
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  scroll-snap-align: start;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 44px;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  color: var(--text);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.delivery-line {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .9rem;
  flex-wrap: wrap;
}

/* ---------------- Product grid / cards ---------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));   /* 2-up on phones */
  gap: clamp(8px, 2vw, 16px);
  container-type: inline-size;
  container-name: catalog-grid;
}
.product-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .18s ease, transform .1s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 0 320px;
  contain: layout style paint;
  touch-action: manipulation;
}
.product-card:active { transform: scale(.985); }

.product-card .img-box {
  aspect-ratio: 1 / 1;
  background: #f1f5f9;
  overflow: hidden;
  position: relative;
}
.product-card .img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

.stock-ribbon {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .72rem;
  font-weight: 700;
  box-shadow: var(--shadow-1);
}
.stock-ribbon.out { background: var(--danger); color: #fff; }
.sale-ribbon {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .72rem;
  font-weight: 800;
  box-shadow: var(--shadow-1);
}

.product-card .p-body { padding: clamp(8px, 2vw, 14px); display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .p-name {
  font-weight: 700;
  font-size: clamp(0.85rem, 0.8rem + 0.25vw, 0.96rem);
  color: var(--dark);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.product-card .p-store { font-size: .76rem; color: var(--muted); }
.product-card .p-price { margin-top: auto; padding-top: 8px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.product-card .p-price .now { font-weight: 800; font-size: clamp(0.96rem, 0.9rem + 0.25vw, 1.1rem); color: var(--dark); }
.product-card .p-price .was { font-size: .78rem; color: var(--muted); text-decoration: line-through; }

.quick-add {
  margin-top: 10px;
  width: 100%;
}

.empty-state { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty-state .icon { font-size: 2.6rem; margin-bottom: 10px; }

/* ---------------- Cart ---------------- */
.cart-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-row img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }
.cart-row .c-name { font-weight: 700; }
.cart-row .c-meta { font-size: .8rem; color: var(--muted); }
.cart-row .c-price { font-weight: 800; white-space: nowrap; }
.qty-stepper { display: flex; align-items: center; gap: 4px; }
.qty-stepper button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
}
.qty-stepper span { min-width: 32px; text-align: center; font-weight: 700; font-size: 1rem; }

/* ---------------- Docs ---------------- */
.doc-preview { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.doc-preview a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; background: var(--light); }
.doc-preview img { max-width: 260px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }

/* ---------------- KYC / status ---------------- */
.kyc-status-banner { padding: 14px 18px; border-radius: var(--radius-sm); font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.kyc-pending { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }
.kyc-approved { background: #f0fdf4; color: var(--checkout-dark); border: 1px solid #bbf7d0; }
.kyc-rejected, .kyc-suspended { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.status-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.status-step { padding: 6px 12px; min-height: 34px; border-radius: 999px; background: var(--light); color: var(--muted); font-size: .8rem; font-weight: 700; }
.status-step.done { background: var(--success); color: #fff; }
.status-step.current { background: var(--primary); color: #fff; }
.status-arrow { color: var(--muted); }

/* ---------------- Auth pages ---------------- */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary) 0%, #0e8a7c 60%, #0ea5e9 140%);
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-3);
}
.auth-card.wide { max-width: 680px; }
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo .store-name { font-size: 1.35rem; font-weight: 800; color: var(--primary); font-family: var(--font-display); }

/* ---------------- Footer ---------------- */
.site-footer {
  margin-top: auto;
  background: var(--dark);
  color: #cbd5e1;
  padding: 40px 0 calc(32px + env(safe-area-inset-bottom));
  font-size: .88rem;
}
.footer-inner { display: flex; flex-direction: column; gap: 14px; }
.footer-brand { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; color: #fff; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { color: #cbd5e1; font-weight: 600; min-height: 36px; display: inline-flex; align-items: center; }
.footer-links a:hover { color: #fff; }
.footer-note { opacity: .75; max-width: 640px; }
.footer-copy { opacity: .55; font-size: .8rem; }

/* ---------------- Spreadsheet (products grid) ---------------- */
.spreadsheet-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.grid-scroll { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--white); -webkit-overflow-scrolling: touch; }
.grid-table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: .84rem; }
.grid-table th {
  background: var(--dark);
  color: #fff;
  padding: 10px 10px;
  font-size: .74rem;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  text-align: left;
  border-right: 1px solid rgba(255, 255, 255, .12);
}
.grid-table th.col-required::after { content: ' *'; color: #fda4af; }
.grid-table td { border: 1px solid var(--border); padding: 0; position: relative; }
.grid-table td.cell-num { width: 44px; text-align: center; background: var(--light); color: var(--muted); font-weight: 700; font-size: .78rem; position: sticky; left: 0; z-index: 1; }
.grid-table .cell-input {
  width: 100%;
  min-width: 140px;
  border: none;
  padding: 10px 9px;
  font-size: .88rem;
  background: transparent;
  color: var(--text);
}
.grid-table .cell-input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #f0fdfa; }
.grid-table .cell-input.cell-num-input { min-width: 90px; }
.grid-table textarea.cell-input { resize: vertical; min-height: 40px; }
.grid-table .cell-select {
  width: 100%;
  border: none;
  padding: 10px 9px;
  font-size: .88rem;
  background: transparent;
  cursor: pointer;
}
.grid-table td.cell-actions { min-width: 120px; white-space: nowrap; padding: 4px 8px; text-align: center; }
.cell-imgs { display: flex; gap: 4px; padding: 4px 6px; flex-wrap: wrap; min-width: 160px; }
.cell-imgs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); }
.cell-imgs .img-add {
  width: 44px;
  height: 44px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  background: var(--light);
}
.grid-status-bar { margin-top: 10px; font-size: .82rem; color: var(--muted); }
.row-invalid td { background: #fff7ed !important; }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 8px 18px; font-size: .92rem; margin-bottom: 10px; }
.detail-grid .dg-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.detail-grid .dg-value { font-weight: 600; word-break: break-word; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar .input, .filter-bar .select { flex: 1 1 220px; min-width: 0; max-width: none; }

/* ---------------- Mobile Bottom Navigation (Portrait) ---------------- */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(58px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 90;
  box-shadow: 0 -3px 12px rgba(15, 23, 42, 0.05);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 2px;
  padding: 6px 0;
  touch-action: manipulation;
  min-height: 48px;
  user-select: none;
}
.bottom-nav-item:hover, .bottom-nav-item.active {
  color: var(--primary);
  text-decoration: none;
}
.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  position: relative;
}
.bottom-cart-badge {
  position: absolute;
  top: -4px;
  right: -9px;
  background: var(--cta);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 767px) and (orientation: portrait) {
  body {
    padding-bottom: calc(64px + var(--safe-bottom));
  }
}

@media (min-width: 768px), (orientation: landscape) and (max-height: 540px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* ============================================================
   Ultra-compact screens & Foldable cover screens (<340px)
   ============================================================ */
@media (max-width: 340px) {
  .product-grid { grid-template-columns: 1fr; }
  .brand { font-size: 0.98rem; }
  .btn { width: 100%; }
  .chips .chip { padding: 6px 12px; font-size: 0.82rem; }
  .hero-trust span { font-size: 0.72rem; padding: 4px 8px; }
}

/* ============================================================
   Tablet portrait & up (≥640px)
   ============================================================ */
@media (min-width: 640px) {
  .container, .container-wide { padding: 0 24px; }
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-overlay { padding: 20px; align-items: center; }
  .modal { border-radius: var(--radius-lg); padding: 26px; animation: none; }
  .modal-header { top: -26px; }
  .modal-sticky-cta { bottom: -26px; padding-bottom: 14px; }
  #toast-box { left: 20px; right: auto; align-items: flex-start; }
  .toast { max-width: 360px; text-align: left; }
  .hero { padding: 40px 0; margin-bottom: 26px; }
  h1 { font-size: 2rem; }
}

/* ============================================================
   Tablet landscape / laptop & up (≥900px)
   ============================================================ */
@media (min-width: 900px) {
  .navbar-inner { flex-wrap: nowrap; height: 64px; padding: 0 24px; gap: 16px; }
  .brand { min-height: auto; }
  .nav-links { order: 0; width: auto; overflow: visible; flex-wrap: wrap; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .product-grid { grid-template-columns: repeat(4, 1fr); }
  .search-bar { flex-direction: row; flex-wrap: nowrap; }
  .search-bar .select { max-width: 260px; }
  .filter-bar .input, .filter-bar .select { max-width: 260px; flex: 0 0 auto; }
}

@media (min-width: 1280px) {
  .product-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ============================================================
   Large desktop / TV (1080p+, 9–10 ft viewing)
   ============================================================ */
@media (min-width: 1600px) {
  body { font-size: 1.0625rem; }
  .container { max-width: 1400px; }
  h1 { font-size: 2.4rem; }
  h2 { font-size: 1.6rem; }
  .product-card .p-name { font-size: 1rem; }
  .product-card .p-price .now { font-size: 1.15rem; }
  .navbar-inner { height: 72px; }
  .btn { min-height: 48px; }
}

@media (min-width: 2200px) {
  body { font-size: 1.125rem; }
  .container { max-width: 1700px; }
}

/* ============================================================
   Phones & Tablets in landscape (short viewport, max-height: 540px)
   ============================================================ */
@media (orientation: landscape) and (max-height: 540px) {
  .navbar { padding-top: 0; }
  .navbar-inner { padding-top: 4px; padding-bottom: 4px; min-height: 44px; }
  .nav-user { display: none; }
  .hero { padding: 12px 0 14px; margin-bottom: 12px; }
  .hero h1 { font-size: 1.35rem; margin-bottom: 2px; }
  .hero p { display: none; } /* Hide long paragraph to bring products above the fold */
  .hero-trust { margin-top: 6px; }
  .hero-trust span { padding: 3px 8px; font-size: 0.74rem; }
  .search-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 12px; }
  .chips { margin-bottom: 12px; }
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .product-card .img-box { aspect-ratio: 16 / 10; }
  .modal-overlay { align-items: center; padding: 10px; }
  .modal {
    max-height: 94dvh;
    border-radius: var(--radius);
    padding: 14px 18px;
    animation: none;
  }
  .modal::before { display: none; }
  .modal-header {
    position: sticky;
    top: -14px;
    background: var(--white);
    z-index: 20;
    padding: 4px 0;
    margin-bottom: 8px;
  }
  .modal-sticky-cta {
    position: sticky;
    bottom: -14px;
    background: var(--white);
    z-index: 20;
    padding: 8px 0;
    margin-top: 10px;
  }
  .modal .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 14px;
  }
  .auth-page { align-items: flex-start; padding-top: 12px; min-height: auto; }
  .auth-card { padding: 18px 20px; }
  .auth-logo { margin-bottom: 10px; }
}

/* ============================================================
   Touch devices (coarse pointer) — guaranteed tap targets
   ============================================================ */
@media (any-pointer: coarse) {
  .nav-link { padding: 12px 14px; min-height: 44px; }
  .tab-btn { padding: 14px 16px; min-height: 44px; }
  .btn-sm { padding: 10px 14px; min-height: 44px; }
  .doc-preview a { padding: 12px 16px; min-height: 44px; }
}

/* ============================================================
   Hover effects only on fine-pointer devices with real hover
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; }
  .nav-link:hover { background: var(--light); text-decoration: none; }
  .btn:hover { box-shadow: var(--shadow-2); }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-accent:hover { background: var(--cta-dark); }
  .btn-success:hover { background: var(--checkout-dark); }
  .table tbody tr:hover { background: #f8fafc; }
  .product-card:hover { box-shadow: var(--shadow-2); }
  .product-card:hover .img-box img { transform: scale(1.04); }
  .tab-btn:hover { color: var(--primary); }
  .modal-close:hover { color: var(--danger); }
  .cell-imgs .img-add:hover { border-color: var(--primary); color: var(--primary); }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Dark mode (prefers-color-scheme: dark)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  body { background: #0b1220; color: #e2e8f0; }
  h1, h2, h3, h4 { color: #f1f5f9; }
  .navbar { background: #101a2e; border-color: #1e293b; }
  .nav-link { color: #cbd5e1; }
  .mobile-bottom-nav {
    background: rgba(16, 26, 46, 0.94);
    border-color: #1e293b;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.35);
  }
  .bottom-nav-item { color: #94a3b8; }
  .bottom-nav-item.active, .bottom-nav-item:hover { color: var(--primary-soft); }
  .card, .stat-card, .table, .modal, .auth-card, .grid-scroll,
  .qty-stepper button, .doc-preview a, .modal-close {
    background: #111b30;
    border-color: #1e293b;
    color: #e2e8f0;
  }
  .modal-header, .modal-sticky-cta {
    background: #111b30;
    border-color: #1e293b;
  }
  .modal::before { background: #263449; }
  .input, .select, .textarea {
    background: #0d1626;
    border-color: #263449;
    color: #e2e8f0;
  }
  .input[readonly] { background: #0d1626; }
  .table th { background: #16233c; color: #e2e8f0; border-color: #263449; }
  .table td { border-color: #1e293b; }
  .table-wrap { background: transparent; }
  .nav-user { color: #94a3b8; }
  .product-card { background: #111b30; border-color: #1e293b; }
  .product-card .p-name, .stat-card .stat-value, .form-group label { color: #f1f5f9; }
  .product-card .p-price .now { color: #f1f5f9; }
  .cell-num { background: #16233c !important; color: #94a3b8 !important; }
  .grid-table .cell-input { color: #e2e8f0; }
  .product-card .img-box, .product-card .img-box img { background: #101a2e; }
  .stock-ribbon { background: rgba(13, 22, 38, 0.9); color: #e2e8f0; }
  .doc-preview img { border-color: #1e293b; }
  .cell-imgs .img-add { background: #0d1626; border-color: #263449; color: #94a3b8; }
  .row-invalid td { background: #3a2412 !important; }
  .delivery-line { background: #12332f; }
  .chips .chip { background: #111b30; border-color: #263449; color: #e2e8f0; }
  .chips .chip.active { background: var(--primary); color: #fff; }
  .hero-trust span { background: rgba(15, 23, 42, .45); border-color: rgba(255, 255, 255, .18); }
}