/*
 * style.css — ShopSmart v2
 * ══════════════════════════════════════════════════════════
 * Pure CSS, zero frameworks.
 * Three-page SPA: Splash → Auth → Dashboard
 * Layout: body locked at 100vh, only .app-main scrolls.
 */

/* ────────────────────────────────────────────────────────
   DESIGN TOKENS
──────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --green:        #28a745;
  --green-d:      #218838;
  --green-dd:     #1e7e34;
  --green-lt:     #d4edda;
  --green-bg:     #f0fff4;
  /* Navy */
  --navy:         #2c3e50;
  --navy-d:       #1f2a36;
  /* Greys */
  --g0:  #f8f9fa;
  --g1:  #f0f2f5;
  --g2:  #e9ecef;
  --g3:  #dee2e6;
  --g4:  #ced4da;
  --g5:  #adb5bd;
  --g6:  #6c757d;
  --g7:  #495057;
  --g8:  #343a40;
  --g9:  #212529;
  --white: #ffffff;
  /* Semantic */
  --danger:   #dc3545;
  --danger-d: #c82333;
  --warn:     #e67e22;
  --info:     #3498db;
  --info-d:   #2980b9;
  /* Shadows */
  --sh-sm: 0 2px 6px rgba(0,0,0,.08);
  --sh-md: 0 4px 16px rgba(0,0,0,.12);
  --sh-lg: 0 8px 28px rgba(0,0,0,.18);
  --sh-xl: 0 16px 48px rgba(0,0,0,.22);
  /* Radius */
  --r1: 6px;  --r2: 10px;  --r3: 16px;  --r4: 22px;
  /* Animation */
  --spd: .24s;
  --ease: cubic-bezier(.4,0,.2,1);
  /* Typography */
  --ff: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ff-brand: 'Pacifico', cursive;
  /* Layout */
  --header-h:    56px;
  --bottom-nav-h: 62px;
}

/* ────────────────────────────────────────────────────────
   RESET
──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  /* ★ KEY: lock the viewport — no body-level scroll ever */
  height: 100%;
  overflow: hidden;
  font-family: var(--ff);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--g8);
  background: var(--g1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img  { max-width:100%; display:block; }
a    { color:var(--green-d); text-decoration:none; }
a:hover { text-decoration:underline; }
h1,h2,h3,h4 { font-family:var(--ff); font-weight:700; color:var(--navy); line-height:1.3; }
p { margin-bottom:.6rem; }
p:last-child { margin-bottom:0; }
ul { list-style:none; }
button { font-family:var(--ff); }

/* ────────────────────────────────────────────────────────
   PAGE SYSTEM  (single-page, show/hide by .active)
──────────────────────────────────────────────────────── */
.page {
  /* hidden by default */
  display: none;
  /* must fill entire viewport */
  position: fixed;
  inset: 0;           /* top:0 right:0 bottom:0 left:0 */
  width: 100%;
  height: 100%;
  overflow: hidden;   /* each page manages its own scroll */
}

/* SPLASH — centred content */
#page-splash.active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e8449, #28a745, #27ae60);
  overflow: hidden;
}

/* AUTH — allow scroll on tiny screens */
#page-auth.active {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e8449, #28a745, #27ae60);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

/* DASHBOARD — flex column, only .app-main scrolls */
#page-dashboard.active {
  display: flex;
  flex-direction: column;
  background: var(--g1);
  overflow: hidden;
}

/* ────────────────────────────────────────────────────────
   UTILITIES
──────────────────────────────────────────────────────── */
.hidden   { display:none !important; }
.sr-only  { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.muted    { color:var(--g6); font-size:.86rem; }
.btn-full { width:100%; }

/* ────────────────────────────────────────────────────────
   BUTTONS
──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: .93rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--r2);
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  min-width: 44px;
  transition: background var(--spd) var(--ease),
              transform  var(--spd) var(--ease),
              box-shadow var(--spd) var(--ease),
              opacity    var(--spd);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
}
.btn:focus-visible  { outline: 3px solid var(--green); outline-offset: 2px; }
.btn:disabled       { opacity:.55; cursor:not-allowed; transform:none !important; }
.btn-primary    { background:var(--green);   color:#fff; }
.btn-primary:hover:not(:disabled)   { background:var(--green-d);  transform:translateY(-1px); box-shadow:var(--sh-sm); }
.btn-secondary  { background:var(--navy);    color:#fff; }
.btn-secondary:hover:not(:disabled) { background:var(--navy-d);   transform:translateY(-1px); }
.btn-danger     { background:var(--danger);  color:#fff; }
.btn-danger:hover:not(:disabled)    { background:var(--danger-d); transform:translateY(-1px); }
.btn-info       { background:var(--info);    color:#fff; }
.btn-info:hover:not(:disabled)      { background:var(--info-d);   transform:translateY(-1px); }
.btn-sm   { padding:7px 12px; font-size:.82rem; min-height:34px; }
.btn-logout {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  padding: 6px 12px;
  font-size: .83rem;
  min-height: 36px;
}
.btn-logout:hover { background:rgba(255,255,255,.26); transform:none; }

/* Loading spinner inside button */
.btn.loading { pointer-events:none; opacity:.72; }
.btn.loading::after {
  content:'';
  display:inline-block;
  width:14px; height:14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color:#fff;
  border-radius:50%;
  animation: spin .7s linear infinite;
  margin-left:8px;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* Header icon buttons */
.hbtn {
  background: rgba(255,255,255,.12);
  border: none;
  border-radius: var(--r1);
  color: rgba(255,255,255,.92);
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background var(--spd);
  -webkit-tap-highlight-color: transparent;
}
.hbtn:hover  { background:rgba(255,255,255,.26); }
.hbtn:focus-visible { outline:2px solid #fff; }

/* ────────────────────────────────────────────────────────
   FORM ELEMENTS
──────────────────────────────────────────────────────── */
.fg  { margin-bottom: 1rem; }       /* field-group */
.fl  { display:block; font-size:.88rem; font-weight:600; color:var(--g7); margin-bottom:5px; }
.fi  {                              /* field-input */
  display:block; width:100%;
  padding:11px 14px;
  font-family:var(--ff);
  font-size:16px;               /* 16px prevents iOS auto-zoom */
  color:var(--g9);
  background:var(--white);
  border:2px solid var(--g3);
  border-radius:var(--r2);
  outline:none;
  min-height:44px;
  transition:border-color var(--spd), box-shadow var(--spd);
}
.fi::placeholder { color:var(--g5); }
.fi:focus { border-color:var(--green); box-shadow:0 0 0 3px rgba(40,167,69,.15); }
.fi.err   { border-color:var(--danger); box-shadow:0 0 0 3px rgba(220,53,69,.1); }
.fe { display:block; font-size:.76rem; color:var(--danger); min-height:16px; margin-top:3px; }

/* Input with icon inside */
.fi-wrap { position:relative; }
.fi-wrap .fi  { padding-right:46px; }
.fi-eye {
  position:absolute; right:12px; top:50%; transform:translateY(-50%);
  background:none; border:none; color:var(--g5); cursor:pointer;
  font-size:.93rem; padding:4px; transition:color var(--spd); z-index:2;
}
.fi-eye:hover { color:var(--g7); }

/* Password strength */
.str-bar  { height:5px; background:var(--g2); border-radius:10px; margin-top:7px; overflow:hidden; }
.str-fill { height:100%; border-radius:10px; width:0; transition:width .32s var(--ease), background .32s; }
.str-fill.s1 { width:25%;  background:var(--danger); }
.str-fill.s2 { width:50%;  background:var(--warn); }
.str-fill.s3 { width:75%;  background:var(--info); }
.str-fill.s4 { width:100%; background:var(--green); }
.str-label { font-size:.74rem; color:var(--g6); margin-top:4px; display:block; }

/* ────────────────────────────────────────────────────────
   ALERT BANNERS
──────────────────────────────────────────────────────── */
.auth-alert {
  padding:11px 14px; border-radius:var(--r2); font-size:.86rem; font-weight:500;
  margin-bottom:12px; border-left:4px solid transparent;
}
.auth-alert.err  { background:#fdf2f2; color:#9b2c2c; border-color:var(--danger); }
.auth-alert.ok   { background:#f0fff4; color:#276749; border-color:var(--green); }
.auth-alert.info { background:#ebf8ff; color:#2b6cb0; border-color:var(--info); }

/* ────────────────────────────────────────────────────────
   TOASTS
──────────────────────────────────────────────────────── */
#toastBox {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(90vw, 360px);
}
.toast {
  padding: 11px 20px;
  border-radius: 50px;
  font-size: .86rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--sh-lg);
  animation: tIn .28s var(--ease) forwards;
  text-align: center;
  pointer-events: auto;
  max-width: 100%;
  word-break: break-word;
}
.toast.out { animation: tOut .28s var(--ease) forwards; }
.toast-success { background:var(--green); }
.toast-error   { background:var(--danger); }
.toast-info    { background:var(--navy); }
.toast-warning { background:var(--warn); }
@keyframes tIn  { from{opacity:0;transform:translateY(10px);}  to{opacity:1;transform:translateY(0);} }
@keyframes tOut { from{opacity:1;transform:translateY(0);}     to{opacity:0;transform:translateY(-8px);} }

/* ────────────────────────────────────────────────────────
   ★  SPLASH PAGE
──────────────────────────────────────────────────────── */
/* Decorative bg blobs */
#page-splash::before, #page-splash::after {
  content:'';
  position:fixed;
  border-radius:50%;
  background:rgba(255,255,255,.06);
  animation: blob 7s ease-in-out infinite;
}
#page-splash::before { width:420px; height:420px; top:-160px; right:-100px; }
#page-splash::after  { width:320px; height:320px; bottom:-110px; left:-80px; animation-delay:3.5s; }
@keyframes blob { 0%,100%{transform:translateY(0) scale(1);}  50%{transform:translateY(-20px) scale(1.04);} }

.splash-inner {
  position:relative; z-index:10;
  display:flex; flex-direction:column; align-items:center; gap:14px;
  max-width:420px; width:calc(100% - 40px);
  opacity:0; transform:translateY(26px);
  animation: splashIn .65s ease .1s forwards;
}
@keyframes splashIn { to{opacity:1;transform:translateY(0);} }
#page-splash.fade-out .splash-inner { animation:splashOut .4s ease forwards !important; }
@keyframes splashOut { to{opacity:0;transform:translateY(-22px);} }

.splash-logo    { font-family:var(--ff-brand); font-size:clamp(2.8rem,10vw,4.8rem); color:#fff; text-shadow:0 4px 18px rgba(0,0,0,.22); letter-spacing:2px; }
.splash-divider { width:56px; height:2px; background:rgba(255,255,255,.3); border-radius:2px; }
.splash-tagline { font-size:clamp(.86rem,3vw,1.05rem); color:rgba(255,255,255,.85); text-align:center; }
.splash-spinner-wrap { display:flex; flex-direction:column; align-items:center; gap:10px; margin-top:4px; }
.splash-spinner { width:40px; height:40px; border:4px solid rgba(255,255,255,.25); border-top-color:#fff; border-radius:50%; animation:spin .85s linear infinite; }
.splash-status  { font-size:.8rem; color:rgba(255,255,255,.7); min-height:16px; text-align:center; }
.splash-pills   { display:flex; flex-wrap:wrap; justify-content:center; gap:7px; margin-top:8px; }
.splash-pill    { background:rgba(255,255,255,.13); color:rgba(255,255,255,.9); font-size:.73rem; padding:5px 12px; border-radius:50px; border:1px solid rgba(255,255,255,.2); }

/* ────────────────────────────────────────────────────────
   ★  AUTH PAGE
──────────────────────────────────────────────────────── */
/* Decorative blobs */
#page-auth::before, #page-auth::after {
  content:''; position:fixed; border-radius:50%; background:rgba(255,255,255,.06); animation:blob 8s ease-in-out infinite;
}
#page-auth::before { width:380px;height:380px;top:-140px;right:-90px; }
#page-auth::after  { width:300px;height:300px;bottom:-100px;left:-70px;animation-delay:4s; }

.auth-card {
  position:relative; z-index:10;
  display:flex;
  width:100%; max-width:880px;
  background:var(--white);
  border-radius:var(--r4);
  box-shadow:var(--sh-xl);
  overflow:hidden;
  animation: cardIn .5s var(--ease) forwards;
  min-height:min(560px, 90vh);
}
@keyframes cardIn { from{opacity:0;transform:scale(.96) translateY(18px);}  to{opacity:1;transform:scale(1) translateY(0);} }

/* Brand left panel */
.auth-brand {
  display:none;
  flex:1;
  background:linear-gradient(160deg,#218838,#28a745);
  padding:48px 40px;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  flex-shrink:0;
}
@media(min-width:768px){ .auth-brand{display:flex;} }
.auth-brand-logo  { font-family:var(--ff-brand); font-size:3rem; color:#fff; text-shadow:0 3px 10px rgba(0,0,0,.18); margin-bottom:8px; }
.auth-brand-sub   { color:rgba(255,255,255,.82); font-size:.96rem; margin-bottom:32px; }
.auth-brand-list  { text-align:left; display:flex; flex-direction:column; gap:10px; }
.auth-brand-list li { color:rgba(255,255,255,.9); font-size:.88rem; display:flex; align-items:center; gap:10px; }
.auth-brand-list li::before { content:'✓'; width:22px; height:22px; background:rgba(255,255,255,.2); border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:.72rem; font-weight:700; flex-shrink:0; }

/* Form right panel */
.auth-form-col {
  flex:1;
  padding:40px 36px;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  min-width:0;
}
@media(max-width:767px){ .auth-form-col{padding:28px 20px;} }

/* Tabs */
.auth-tabs  { display:flex; background:var(--g1); border-radius:var(--r2); padding:4px; margin-bottom:20px; gap:4px; }
.auth-tab   { flex:1; padding:9px; font-size:.9rem; font-weight:600; border:none; border-radius:var(--r1); cursor:pointer; color:var(--g6); background:transparent; transition:background var(--spd),color var(--spd),box-shadow var(--spd); }
.auth-tab.active { background:var(--white); color:var(--green-d); box-shadow:var(--sh-sm); }

.auth-title     { font-size:1.7rem; margin-bottom:4px; }
.auth-subtitle  { color:var(--g6); font-size:.9rem; margin-bottom:18px; }
.a-link { background:none; border:none; color:var(--green-d); font-weight:600; font-size:.86rem; cursor:pointer; padding:0; }
.a-link:hover   { text-decoration:underline; }
.auth-switch    { text-align:center; font-size:.84rem; color:var(--g6); margin-top:14px; }

/* Show/hide panels */
.auth-panel         { display:none; }
.auth-panel.active  { display:block; }

/* Auth overlays (forgot pw / signup success) */
.ovl {
  position:fixed; inset:0;
  background:rgba(0,0,0,.54);
  display:flex; align-items:center; justify-content:center;
  z-index:1000; padding:20px;
  animation:fadeIn .2s ease;
}
.ovl.hidden { display:none !important; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }
.ovl-box { background:var(--white); border-radius:var(--r3); padding:32px 28px; max-width:420px; width:100%; box-shadow:var(--sh-xl); animation:cardIn .3s var(--ease); }
.ovl-title { font-size:1.35rem; margin-bottom:6px; }
.ovl-sub   { color:var(--g6); font-size:.9rem; margin-bottom:16px; }
.ovl-btns  { display:flex; gap:10px; margin-top:8px; }
.success-circle { width:64px; height:64px; background:var(--green-lt); border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 18px; font-size:1.75rem; color:var(--green-d); }

/* ────────────────────────────────────────────────────────
   ★  DASHBOARD  — fixed-height column layout
──────────────────────────────────────────────────────── */

/* Header */
.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--green), var(--green-d));
  color: #fff;
  padding: 0 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sh-md);
  z-index: 200;
  gap: 8px;
}
.app-logo       { font-family:var(--ff-brand); font-size:1.75rem; color:#fff; text-shadow:0 2px 6px rgba(0,0,0,.18); letter-spacing:1px; white-space:nowrap; }
.app-hdr-right  { display:flex; align-items:center; gap:6px; flex-shrink:0; }
.logout-label   { display:none; }
@media(min-width:500px){ .logout-label{display:inline;} }

/* ★ Main — THE ONLY SCROLLING AREA in dashboard */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 1rem 1rem calc(var(--bottom-nav-h) + 16px); /* bottom pad for fixed nav */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* App sections */
.app-sec {
  display: none;
  width: 100%;
  max-width: 600px;
  background: var(--white);
  border-radius: var(--r3);
  box-shadow: var(--sh-md);
  padding: 22px;
  margin: 0 auto;
}
.app-sec.active {
  display: block;
  animation: secIn .3s var(--ease);
}
@keyframes secIn { from{opacity:0;transform:translateY(10px);}  to{opacity:1;transform:translateY(0);} }

.sec-title  { font-size:1.12rem; margin-bottom:14px; }
.sec-hdr    { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.sec-hdr .sec-title { margin-bottom:0; }
.sec-acts   { display:flex; gap:7px; flex-wrap:wrap; }

/* Footer inside scrollable area */
.app-footer {
  width:100%; max-width:600px; text-align:center;
  font-size:.74rem; color:var(--g5);
  padding:16px 0 4px;
  margin-top:auto;
}
.app-footer a { color:var(--green-d); }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--white);
  border-top: 1px solid var(--g2);
  display: flex;
  box-shadow: 0 -3px 14px rgba(0,0,0,.07);
  z-index: 300;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--g5);
  font-size: .65rem;
  font-family: var(--ff);
  font-weight: 600;
  padding: 6px 4px;
  transition: color var(--spd);
  -webkit-tap-highlight-color: transparent;
}
.nav-btn i    { font-size:1.3rem; transition:transform var(--spd) var(--ease); }
.nav-btn:hover, .nav-btn.active { color:var(--green); }
.nav-btn.active i { transform:translateY(-2px); }
.nav-btn:focus-visible { outline:2px solid var(--green); outline-offset:-2px; }

/* ────────────────────────────────────────────────────────
   SCANNER SECTION
──────────────────────────────────────────────────────── */
.camera-wrap {
  width:100%; aspect-ratio:4/3; border-radius:var(--r2);
  overflow:hidden; background:#111; position:relative;
  border:2px solid var(--g3); margin-bottom:14px;
  max-height:280px;
}
.camera-wrap video { width:100%; height:100%; object-fit:cover; display:block; }
.cam-overlay { position:absolute; inset:0; pointer-events:none; z-index:10; }
.cam-corner { position:absolute; width:24px; height:24px; border-color:var(--green); border-style:solid; }
.cam-corner.tl { top:10px;    left:10px;    border-width:3px 0 0 3px; }
.cam-corner.tr { top:10px;    right:10px;   border-width:3px 3px 0 0; }
.cam-corner.bl { bottom:10px; left:10px;    border-width:0 0 3px 3px; }
.cam-corner.br { bottom:10px; right:10px;   border-width:0 3px 3px 0; }
.cam-scanline {
  position:absolute; left:8%; right:8%; height:2px;
  background:linear-gradient(90deg,transparent,var(--green),transparent);
  animation:scanY 2s ease-in-out infinite;
}
@keyframes scanY { 0%{top:8%;opacity:.6;} 50%{top:88%;opacity:1;} 100%{top:8%;opacity:.6;} }
.scan-hint  { text-align:center; color:var(--g6); font-size:.86rem; margin-bottom:14px; }
.manual-row { display:flex; gap:10px; flex-wrap:wrap; }
.manual-row .fi { flex:1; min-width:150px; }

/* Camera start / error overlays */
.cam-start-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; background: var(--g0);
  z-index: 5;
}
.cam-error-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--g0);
  z-index: 6;
}
.camera-wrap.active .cam-start-overlay,
.camera-wrap.active .cam-error-overlay,
.camera-wrap.starting .cam-start-overlay,
.camera-wrap.starting .cam-error-overlay {
  display: none;
}
.camera-wrap.starting {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--g0);
}
.camera-wrap.starting::after {
  content: 'Starting camera…';
  color: var(--g5);
  font-size: 0.9rem;
}
.camera-wrap.scan-success {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 4px rgba(40,167,69,.35);
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Quagga canvas overlay */
.camera-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ────────────────────────────────────────────────────────
   RECEIPT SECTION
──────────────────────────────────────────────────────── */
.rec-meta {
  display:flex; justify-content:space-between; font-size:.8rem; color:var(--g6);
  padding-bottom:10px; border-bottom:1px dashed var(--g3); margin-bottom:12px; flex-wrap:wrap; gap:4px;
}
.rec-list {
  max-height:280px; overflow-y:auto; overflow-x:hidden;
  border:1px solid var(--g2); border-radius:var(--r2);
  background:var(--g0); padding:8px; margin-bottom:12px;
  scroll-behavior:smooth;
}
.rec-list::-webkit-scrollbar { width:4px; }
.rec-list::-webkit-scrollbar-thumb { background:var(--g4); border-radius:4px; }
.rec-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 6px; border-radius:var(--r1);
  transition:background var(--spd); gap:6px;
  border-bottom:1px solid var(--g2);
}
.rec-item:last-child { border-bottom:none; }
.rec-item:hover { background:var(--g1); }
.rec-item-name  { flex:1; font-size:.87rem; font-weight:600; color:var(--g8); }
.rec-item-tag   { font-size:.7rem; color:var(--g6); font-weight:400; margin-left:4px; }
.rec-item-right { display:flex; align-items:center; gap:5px; white-space:nowrap; }
.rec-item-price { font-size:.88rem; font-weight:700; color:var(--navy); }
.rec-item-del   {
  background:none; border:none; color:var(--g4); cursor:pointer;
  font-size:.88rem; padding:2px 5px; border-radius:4px;
  transition:color var(--spd),background var(--spd); line-height:1;
}
.rec-item-del:hover { color:var(--danger); background:rgba(220,53,69,.08); }
.rec-empty { text-align:center; padding:26px 0; color:var(--g5); font-size:.87rem; }
.rec-total-row {
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px; background:var(--green-bg); border:1px solid var(--green-lt);
  border-radius:var(--r2); margin-bottom:12px;
}
.rec-total-lbl { font-size:1rem; font-weight:700; color:var(--navy); }
.rec-total-amt { font-size:1.3rem; font-weight:700; color:var(--green-d); }
.pay-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:8px; }

/* ────────────────────────────────────────────────────────
   INVENTORY SECTION
──────────────────────────────────────────────────────── */
.inv-hint { font-size:.84rem; color:var(--g6); margin-bottom:12px; }
.inv-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:11px 12px; background:var(--g0); border-radius:var(--r2);
  border-left:4px solid var(--green); margin-bottom:9px; gap:8px;
  transition:box-shadow var(--spd);
}
.inv-item:hover { box-shadow:var(--sh-sm); }
.inv-item.low { border-left-color:var(--warn); background:#fffaf0; }
.inv-item-info { flex:1; min-width:0; }
.inv-item-name { font-weight:700; font-size:.88rem; color:var(--g9); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.inv-item-sub  { font-size:.76rem; color:var(--g6); margin-top:2px; }
.inv-item-acts { display:flex; gap:4px; }
.inv-act {
  background:none; border:none; color:var(--g5); cursor:pointer;
  font-size:.93rem; padding:5px 6px; border-radius:4px;
  transition:color var(--spd),background var(--spd);
}
.inv-act:hover      { color:var(--danger);  background:rgba(220,53,69,.07); }
.inv-act.bell:hover { color:var(--warn);    background:rgba(230,126,34,.07); }

/* ────────────────────────────────────────────────────────
   MODALS
──────────────────────────────────────────────────────── */
.modal-ovl {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.52);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 800;
  animation: fadeIn .2s ease;
  padding: 0;
}
@media(min-width:600px){ .modal-ovl{align-items:center; padding:20px;} }
.modal-ovl.hidden { display:none !important; }

.modal-panel {
  background: var(--white);
  border-radius: var(--r4) var(--r4) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--sh-xl);
  animation: slideUp .3s var(--ease);
}
@media(min-width:600px){
  .modal-panel { border-radius: var(--r4); animation: cardIn .3s var(--ease); }
}
@keyframes slideUp { from{transform:translateY(100%);} to{transform:translateY(0);} }
.modal-panel.modal-wide { max-width:680px; }

.modal-hdr {
  display:flex; align-items:center; justify-content:space-between;
  padding:15px 20px; border-bottom:1px solid var(--g2); flex-shrink:0;
}
.modal-hdr h3 { font-size:1.03rem; margin:0; }
.modal-x {
  background:none; border:none; font-size:1.2rem; cursor:pointer;
  color:var(--g6); padding:4px 6px; border-radius:var(--r1);
  transition:background var(--spd),color var(--spd); line-height:1;
}
.modal-x:hover { background:var(--g1); color:var(--g9); }
.modal-body {
  flex:1; overflow-y:auto; overflow-x:hidden; padding:18px 20px;
  -webkit-overflow-scrolling:touch;
}
.modal-body::-webkit-scrollbar { width:4px; }
.modal-body::-webkit-scrollbar-thumb { background:var(--g3); border-radius:4px; }
.modal-ftr {
  padding:12px 20px; border-top:1px solid var(--g2);
  display:flex; gap:10px; justify-content:space-between; align-items:center;
  flex-shrink:0; flex-wrap:wrap;
}

/* Confirm / Prompt boxes */
.dlg-box {
  background:var(--white); border-radius:var(--r3); padding:26px;
  max-width:400px; width:calc(100% - 32px);
  box-shadow:var(--sh-xl); animation:cardIn .3s var(--ease);
}
.dlg-title { font-size:1.05rem; margin-bottom:8px; }
.dlg-msg   { font-size:.88rem; color:var(--g6); margin-bottom:0; }
.dlg-btns  { display:flex; gap:10px; justify-content:flex-end; margin-top:16px; }

/* ────────────────────────────────────────────────────────
   WANTS & NEEDS
──────────────────────────────────────────────────────── */
.wn-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0; border-bottom:1px solid var(--g2); gap:12px;
}
.wn-item:last-child { border-bottom:none; }
.wn-item-name { font-weight:600; font-size:.88rem; }
.wn-item-sub  { font-size:.76rem; color:var(--g6); }
.wn-item select {
  padding:6px 10px; border:2px solid var(--g3); border-radius:var(--r1);
  font-family:var(--ff); font-size:.84rem; background:var(--white);
  cursor:pointer; transition:border-color var(--spd);
}
.wn-item select:focus { outline:none; border-color:var(--green); }
.wn-totals { display:flex; gap:16px; font-size:.87rem; font-weight:600; flex-wrap:wrap; }
.wn-need   { color:var(--green-d); }
.wn-want   { color:var(--warn); }

/* ────────────────────────────────────────────────────────
   SAVINGS CARDS
──────────────────────────────────────────────────────── */
.sc-form { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.sc-form .fi { flex:1; min-width:130px; }
.sc-card {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; background:var(--g0); border-radius:var(--r2);
  border-left:4px solid var(--navy); margin-bottom:9px; gap:8px;
}
.sc-card-store  { font-weight:700; font-size:.9rem; color:var(--navy); }
.sc-card-num    { font-size:.8rem; color:var(--g6); }
.sc-card-acts   { display:flex; gap:4px; }
.sc-btn { background:none; border:none; color:var(--g5); cursor:pointer; font-size:.93rem; padding:5px 6px; border-radius:4px; transition:color var(--spd); }
.sc-btn:hover { color:var(--navy); }
.sc-qr-zone {
  margin-top:14px; padding:16px;
  border:2px dashed var(--g3); border-radius:var(--r2);
  text-align:center; min-height:80px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px;
}
.sc-qr-zone canvas, .sc-qr-zone img { border-radius:6px; max-width:100%; }

/* ────────────────────────────────────────────────────────
   RECIPES
──────────────────────────────────────────────────────── */
.recipe-card {
  background:var(--white); border:1px solid var(--g2);
  border-left:4px solid var(--green); border-radius:var(--r2);
  padding:14px; margin-bottom:12px;
}
.recipe-title { font-size:.97rem; font-weight:700; color:var(--navy); margin-bottom:5px; }
.recipe-meta  { font-size:.78rem; color:var(--g6); margin-bottom:7px; display:flex; gap:14px; flex-wrap:wrap; }
.recipe-steps { font-size:.86rem; color:var(--g7); line-height:1.5; }

/* ────────────────────────────────────────────────────────
   SHOPPING LIST
──────────────────────────────────────────────────────── */
.sl-form  { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.sl-form .fi { flex:1; min-width:130px; }
.sl-qty   { width:68px !important; flex:none !important; min-width:unset !important; }
.sl-list  { padding:0; }
.sl-item  { display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--g2); }
.sl-item:last-child { border-bottom:none; }
.sl-check { width:19px; height:19px; cursor:pointer; accent-color:var(--green); flex-shrink:0; }
.sl-name  { flex:1; font-size:.88rem; font-weight:600; color:var(--g8); }
.sl-name.done { text-decoration:line-through; color:var(--g4); }
.sl-qty-badge { font-size:.74rem; color:var(--g5); background:var(--g2); padding:2px 7px; border-radius:50px; white-space:nowrap; }
.sl-del   { background:none; border:none; color:var(--g4); cursor:pointer; font-size:.9rem; padding:3px 5px; border-radius:4px; transition:color var(--spd); line-height:1; }
.sl-del:hover { color:var(--danger); }

/* ────────────────────────────────────────────────────────
   SPENDING TRACKER
──────────────────────────────────────────────────────── */
.sp-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); gap:10px; margin-bottom:16px; }
.sp-stat  { background:var(--g0); border-radius:var(--r2); padding:12px; text-align:center; border:1px solid var(--g2); }
.sp-val   { font-size:1.25rem; font-weight:700; color:var(--green-d); display:block; }
.sp-label { font-size:.72rem; color:var(--g6); margin-top:2px; }
.sp-entry { padding:11px 13px; background:var(--g0); border-radius:var(--r2); border-left:3px solid var(--green); margin-bottom:9px; }
.sp-entry-hdr { display:flex; justify-content:space-between; font-size:.84rem; font-weight:700; color:var(--navy); margin-bottom:3px; }
.sp-entry-sub { font-size:.76rem; color:var(--g6); }

/* ────────────────────────────────────────────────────────
   PAYFAST
──────────────────────────────────────────────────────── */
.pf-summary  { background:var(--g0); border-radius:var(--r2); padding:13px; margin-bottom:14px; border:1px solid var(--g2); line-height:1.6; font-size:.92rem; }
.pf-total    { font-size:1.45rem; font-weight:700; color:var(--green-d); display:block; margin-top:5px; }
.pf-btns     { display:flex; gap:10px; }
.pf-badge    { font-size:.72rem; color:var(--g5); text-align:center; margin-top:12px; display:block; }
.info-list   { margin:12px 0 0 4px; line-height:2.1; font-size:.9rem; }
.info-list li { display:flex; align-items:center; gap:8px; }
.info-list li i { color:var(--green); font-size:.8rem; }

/* ────────────────────────────────────────────────────────
   CHATBOT
──────────────────────────────────────────────────────── */
.chat-wrap {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 14px;
  z-index: 500;
}
.chat-toggle {
  width:52px; height:52px; border-radius:50%;
  background:var(--navy); color:#fff; border:none; cursor:pointer;
  font-size:1.3rem; display:flex; align-items:center; justify-content:center;
  box-shadow:var(--sh-lg); transition:transform var(--spd),background var(--spd);
  -webkit-tap-highlight-color:transparent;
}
.chat-toggle:hover { transform:scale(1.1); background:var(--green); }
.chat-window {
  position:absolute; bottom:62px; left:0;
  width:300px; max-width:calc(100vw - 28px);
  background:var(--white); border-radius:var(--r3);
  box-shadow:var(--sh-xl); display:flex; flex-direction:column;
  overflow:hidden; animation:slideUp .3s var(--ease);
}
.chat-window.hidden { display:none; }
.chat-hdr {
  background:var(--navy); color:#fff; padding:11px 14px;
  display:flex; justify-content:space-between; align-items:center;
  font-size:.88rem; font-weight:600;
}
.chat-msgs {
  min-height:180px; max-height:250px; overflow-y:auto;
  padding:10px; display:flex; flex-direction:column; gap:7px;
}
.chat-msgs::-webkit-scrollbar { width:3px; }
.chat-msgs::-webkit-scrollbar-thumb { background:var(--g3); border-radius:3px; }
.chat-msg { max-width:82%; padding:7px 11px; border-radius:13px; font-size:.84rem; line-height:1.4; }
.chat-msg.user { background:var(--green); color:#fff; align-self:flex-end; border-bottom-right-radius:3px; }
.chat-msg.bot  { background:var(--g1);   color:var(--g9); align-self:flex-start; border-bottom-left-radius:3px; }
.chat-input-row { display:flex; border-top:1px solid var(--g2); background:var(--white); }
.chat-input-row input { flex:1; border:none; padding:9px 11px; font-family:var(--ff); font-size:.86rem; outline:none; color:var(--g9); }
.chat-input-row button { background:none; border:none; padding:9px 11px; cursor:pointer; color:var(--navy); font-size:1.05rem; transition:color var(--spd); min-width:38px; }
.chat-input-row button:hover { color:var(--green); }
.chat-input-row button.listening { color:var(--danger); }

/* ────────────────────────────────────────────────────────
   DARK MODE  (body.dark)
──────────────────────────────────────────────────────── */
body.dark {
  --g0:  #1a1a2e; --g1:  #16213e; --g2:  #233150;
  --g3:  #2d3561; --g4:  #334155; --g5:  #64748b;
  --g6:  #94a3b8; --g7:  #cbd5e1; --g8:  #e2e8f0; --g9:  #f1f5f9;
  --white:   #1e1e2e;
  --navy:    #334155;
  --navy-d:  #1e293b;
  --green-bg: #0a2516;
  --green-lt: #14532d;
  color: #e2e8f0;
  background: #0f0f1e;
}
body.dark .app-header       { background:linear-gradient(135deg,#145a32,#1e8449); }
body.dark .bottom-nav       { background:#1e1e2e; border-top-color:#2d3561; }
body.dark .app-sec          { background:#1e1e2e; }
body.dark .rec-list         { background:#252535; }
body.dark .rec-item:hover   { background:#2a2a3e; }
body.dark .inv-item         { background:#252535; }
body.dark .inv-item.low     { background:#1e160a; }
body.dark .modal-panel,
body.dark .dlg-box,
body.dark .ovl-box          { background:#1e1e2e; }
body.dark .modal-hdr,
body.dark .modal-ftr        { border-color:#2d3561; }
body.dark .wn-item          { border-color:#2d3561; }
body.dark .sc-card          { background:#252535; }
body.dark .sc-qr-zone       { border-color:#2d3561; background:#252535; }
body.dark .recipe-card      { background:#252535; border-color:#2d3561; }
body.dark .sl-item          { border-color:#2d3561; }
body.dark .sp-stat,
body.dark .sp-entry         { background:#252535; border-color:#2d3561; }
body.dark .pf-summary       { background:#252535; border-color:#2d3561; }
body.dark .auth-card        { background:#1e1e2e; }
body.dark .auth-tabs        { background:#252535; }
body.dark .auth-tab.active  { background:#1e1e2e; }
body.dark .chat-window      { background:#1e1e2e; }
body.dark .chat-input-row   { background:#1e1e2e; border-top-color:#2d3561; }
body.dark .chat-input-row input { background:#1e1e2e; color:#e2e8f0; }
body.dark .chat-msg.bot     { background:#252535; color:#e2e8f0; }
body.dark .fi               { background:#2a2a3e; color:#e2e8f0; border-color:#334155; }
body.dark .wn-item select   { background:#2a2a3e; color:#e2e8f0; border-color:#334155; }
body.dark h1, body.dark h2,
body.dark h3, body.dark h4  { color:#e2e8f0; }
body.dark .app-footer       { color:#4a5568; }
body.dark .auth-subtitle,
body.dark .auth-switch      { color:#94a3b8; }
/* dark icon swap */
body.dark #darkIcon::before { content:'\f185'; } /* fa-sun unicode */

/* ────────────────────────────────────────────────────────
   RESPONSIVE FINE-TUNING
──────────────────────────────────────────────────────── */
@media(max-width:480px){
  .app-logo      { font-size:1.45rem; }
  .sec-hdr       { flex-direction:column; align-items:flex-start; }
  .pay-row       { flex-direction:column; }
  .pay-row .btn  { width:100%; }
  .manual-row    { flex-direction:column; }
  .pf-btns       { flex-direction:column; }
  .auth-form-col { padding:22px 16px; }
  .camera-wrap   { max-height:220px; }
}

@media(min-width:768px){
  .camera-wrap { max-height:360px; }
}

/* ────────────────────────────────────────────────────────
   ACCESSIBILITY & REDUCED MOTION
──────────────────────────────────────────────────────── */
:focus-visible { outline:3px solid var(--green); outline-offset:2px; }
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms !important;
    transition-duration:.01ms !important;
  }
}
@media(prefers-contrast:high){
  :root{ --green:#006400; --navy:#000080; }
  .fi { border-width:2px; }
}
@media print{
  .bottom-nav,.chat-wrap,.app-header { display:none !important; }
  body { background:#fff; overflow:visible; height:auto; }
  .page { position:static; height:auto; overflow:visible; }
}