/* ══════════════════════════════════════════════════════════════
   DESIGN SYSTEM — Dispensa Premium
   ══════════════════════════════════════════════════════════════ */
:root {
  /* Telegram overrides (applied by SDK) */
  --tg-theme-bg-color:           #ffffff;
  --tg-theme-text-color:         #0f172a;
  --tg-theme-hint-color:         #94a3b8;
  --tg-theme-link-color:         #6366f1;
  --tg-theme-button-color:       #6366f1;
  --tg-theme-button-text-color:  #ffffff;
  --tg-theme-secondary-bg-color: #f1f5f9;

  /* Brand */
  --accent:     #6366f1;
  --accent-end: #8b5cf6;
  --grad:       linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-warm:  linear-gradient(135deg, #f97316 0%, #ef4444 100%);
  --grad-cool:  linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
  --grad-dark:  linear-gradient(160deg, #0f172a 0%, #1e293b 100%);

  /* Surface */
  --bg:       var(--tg-theme-bg-color);
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;
  --border:   rgba(0,0,0,.06);

  /* Text */
  --txt:    var(--tg-theme-text-color);
  --txt2:   #475569;
  --txt3:   #94a3b8;
  --txt-inv:#ffffff;

  /* Status */
  --ok:     #10b981;
  --warn:   #f59e0b;
  --danger: #ef4444;
  --frozen: #06b6d4;

  /* Geometry */
  --r-xs:  6px;
  --r-sm:  10px;
  --r:     16px;
  --r-lg:  22px;
  --r-xl:  28px;

  /* Layout */
  --header-h: 60px;
  --nav-h:    72px;

  /* Shadow */
  --sh-sm:  0 1px 4px rgba(0,0,0,.07), 0 2px 8px rgba(0,0,0,.05);
  --sh:     0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  --sh-lg:  0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
  --sh-accent: 0 8px 24px rgba(99,102,241,.35);

  /* Transition */
  --t: .18s cubic-bezier(.4,0,.2,1);
  --t-spring: .35s cubic-bezier(.34,1.56,.64,1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ══════════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════════ */
#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

#page-title {
  flex: 1;
  font-size: 17px; font-weight: 700;
  text-align: center; letter-spacing: -.3px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.btn-icon {
  width: 40px; height: 40px;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background var(--t);
  flex-shrink: 0;
}
.btn-icon:active { background: var(--surface3); }

/* ══════════════════════════════════════════════════════════════
   CONTENT AREA
   ══════════════════════════════════════════════════════════════ */
#app-content {
  position: fixed;
  top: var(--header-h); bottom: var(--nav-h);
  left: 0; right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface2);
}

/* ══════════════════════════════════════════════════════════════
   BOTTOM NAV — floating pill style
   ══════════════════════════════════════════════════════════════ */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px 6px;
  color: var(--txt3);
  transition: color var(--t);
  position: relative;
}
.nav-btn.active { color: var(--accent); }

.nav-btn::before {
  content: '';
  position: absolute; top: 6px;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent;
  transition: background var(--t), transform var(--t);
}
.nav-btn.active::before {
  background: rgba(99,102,241,.10);
  transform: scale(1);
}

.nav-icon { font-size: 22px; line-height: 1; position: relative; z-index: 1; }
.nav-label { font-size: 10px; font-weight: 500; position: relative; z-index: 1; }

.add-icon {
  width: 44px; height: 44px;
  background: var(--grad);
  color: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 300;
  box-shadow: var(--sh-accent);
  margin-top: -10px;
  transition: transform var(--t-spring);
}
.nav-btn:active .add-icon { transform: scale(.93); }

.badge {
  position: absolute; top: 4px; right: 14px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
  z-index: 2;
}

/* ══════════════════════════════════════════════════════════════
   STATS
   ══════════════════════════════════════════════════════════════ */
.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 14px 14px 0;
}

.stat-card {
  border-radius: var(--r);
  padding: 14px 10px 12px;
  text-align: center;
  position: relative; overflow: hidden;
  box-shadow: var(--sh-sm);
}

.stat-card::before {
  content: '';
  position: absolute; inset: 0;
  opacity: .08; border-radius: var(--r);
}
.stat-card.ok     { background: var(--surface); }
.stat-card.ok     .stat-num { color: #10b981; }
.stat-card.ok::before { background: #10b981; }
.stat-card.warn   { background: var(--surface); }
.stat-card.warn   .stat-num { color: var(--warn); }
.stat-card.warn::before { background: var(--warn); }
.stat-card.danger { background: var(--surface); }
.stat-card.danger .stat-num { color: var(--danger); }
.stat-card.danger::before { background: var(--danger); }

.stat-num {
  font-size: 30px; font-weight: 800;
  line-height: 1; letter-spacing: -1px;
}
.stat-label {
  font-size: 11px; color: var(--txt3);
  font-weight: 500; margin-top: 4px;
  text-transform: uppercase; letter-spacing: .3px;
}

/* ══════════════════════════════════════════════════════════════
   LOCATION TABS
   ══════════════════════════════════════════════════════════════ */
.location-tabs {
  display: flex; gap: 6px;
  padding: 12px 14px 8px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.location-tabs::-webkit-scrollbar { display: none; }

.tab-chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  color: var(--txt2);
  box-shadow: var(--sh-sm);
  transition: all var(--t);
}
.tab-chip.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--sh-accent);
}

/* ══════════════════════════════════════════════════════════════
   PRODUCT GRID — full-bleed photo cards
   ══════════════════════════════════════════════════════════════ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 14px 24px;
}

.product-card {
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh);
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t);
  background: var(--surface);
  aspect-ratio: .78;
  position: relative;
}
.product-card:active {
  transform: scale(.96);
  box-shadow: var(--sh-sm);
}

/* Media fill */
.card-media {
  position: absolute; inset: 0;
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.product-card:active .card-media img { transform: scale(1.03); }

.card-media-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
  background: var(--surface3);
}

/* Gradient overlay */
.card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 30%,
    rgba(0,0,0,.15) 55%,
    rgba(0,0,0,.72) 100%
  );
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 8px;
}

/* No-photo overlay is lighter */
.card-no-photo .card-overlay {
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.55) 100%);
}

.card-chips {
  display: flex; gap: 4px;
  justify-content: space-between; align-items: flex-start;
}

.card-title-area { }

.card-name {
  font-size: 13px; font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.3;
}
.card-brand {
  font-size: 11px; color: rgba(255,255,255,.75);
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-loc-chip {
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 14px;
  border: 1px solid rgba(255,255,255,.15);
}

.card-consumption-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,.2);
}
.card-consumption-fill {
  height: 100%;
  transition: width .4s ease;
}
.fill-ok     { background: var(--frozen); }
.fill-done   { background: var(--ok); }
.fill-overdue{ background: var(--warn); }

/* Expiry pill */
.expiry-pill {
  font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 20px;
  letter-spacing: .2px;
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(4px);
}
.expiry-ok     { background: rgba(16,185,129,.85); color: #fff; }
.expiry-warn   { background: rgba(245,158,11,.90); color: #fff; }
.expiry-danger { background: rgba(239,68,68,.90);  color: #fff; }
.expiry-none   { background: rgba(0,0,0,.35);      color: rgba(255,255,255,.8); }
.expiry-frozen { background: rgba(6,182,212,.85);  color: #fff; }

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 56px 32px;
  color: var(--txt3);
}
.empty-state .empty-icon {
  font-size: 56px; margin-bottom: 14px;
  display: block;
  filter: grayscale(.3);
}
.empty-state p {
  font-size: 14px; line-height: 1.6;
  color: var(--txt2);
}

/* ══════════════════════════════════════════════════════════════
   FORM — ADD / EDIT
   ══════════════════════════════════════════════════════════════ */
.form-wrap { padding: 14px 14px 32px; }

.form-section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--txt3); padding: 16px 4px 6px;
}

.form-section {
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  margin-bottom: 4px;
}

.form-row {
  display: flex; align-items: center;
  padding: 0 16px;
  min-height: 50px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.form-row:last-child { border-bottom: none; }

.form-label {
  font-size: 13px; color: var(--txt2);
  width: 96px; flex-shrink: 0; font-weight: 500;
}

.form-input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  font-size: 15px; color: var(--txt);
  font-family: inherit; padding: 14px 0;
}
.form-input::placeholder { color: var(--txt3); }

select.form-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 16px;
  -webkit-appearance: none;
}

.form-row-full {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.form-row-full:last-child { border-bottom: none; }

.form-textarea {
  width: 100%; background: none; border: none; outline: none;
  font-size: 15px; color: var(--txt);
  font-family: inherit; resize: none;
  min-height: 80px; line-height: 1.5;
}
.form-textarea::placeholder { color: var(--txt3); }

/* AI Scan button — premium */
.btn-ai-scan {
  width: 100%;
  background: var(--grad);
  color: #fff; border: none; cursor: pointer;
  border-radius: var(--r);
  padding: 16px 20px;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 8px;
  box-shadow: var(--sh-accent);
  transition: transform var(--t), box-shadow var(--t);
  letter-spacing: .1px;
}
.btn-ai-scan:active {
  transform: scale(.97);
  box-shadow: 0 4px 14px rgba(99,102,241,.25);
}
.ai-icon { font-size: 22px; }

#ai-photo-input { display: none; }

/* Photo area */
.photo-area {
  padding: 14px 16px;
  display: flex; gap: 10px; flex-wrap: wrap;
}

.photo-thumb-wrap {
  position: relative; width: 76px; height: 76px;
}
.photo-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: var(--r-sm);
  box-shadow: var(--sh-sm);
}
.photo-thumb-del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px;
  background: var(--danger); color: #fff;
  border: 2px solid var(--surface);
  border-radius: 50%; cursor: pointer;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(239,68,68,.4);
}

.photo-add-btn {
  width: 76px; height: 76px;
  border: 2px dashed var(--surface3);
  background: var(--surface2);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; color: var(--txt3);
  font-size: 11px; font-weight: 500;
  transition: border-color var(--t), background var(--t);
}
.photo-add-btn:active {
  border-color: var(--accent);
  background: rgba(99,102,241,.05);
}
.photo-add-btn .add-plus { font-size: 26px; font-weight: 200; color: var(--accent); }
#photo-file-input { display: none; }

/* Submit */
.btn-submit {
  width: 100%; margin-top: 10px;
  background: var(--grad);
  color: #fff; border: none; cursor: pointer;
  border-radius: var(--r);
  padding: 16px;
  font-size: 16px; font-weight: 700;
  box-shadow: var(--sh-accent);
  transition: transform var(--t), box-shadow var(--t);
  letter-spacing: .1px;
}
.btn-submit:active {
  transform: scale(.98);
  box-shadow: 0 4px 12px rgba(99,102,241,.2);
}
.btn-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════════════════════════════
   PRODUCT MODAL
   ══════════════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
}
.modal.visible { pointer-events: all; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background .28s ease, backdrop-filter .28s ease;
}
.modal.visible .modal-backdrop {
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 94vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,0,.67,0);
  -webkit-overflow-scrolling: touch;
}
.modal.visible .modal-sheet {
  transform: translateY(0);
  transition: transform .38s cubic-bezier(.16,1,.3,1);
}

.modal-handle {
  width: 40px; height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin: 12px auto 4px;
}

.modal-body { padding: 0 0 40px; }

/* Gallery */
.gallery {
  width: 100%; aspect-ratio: 1 / 1;
  overflow: hidden; position: relative;
  background: var(--surface3);
}
.gallery-track {
  display: flex; height: 100%;
  transition: transform .26s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.gallery-slide {
  flex-shrink: 0; width: 100%; height: 100%;
}
.gallery-slide img {
  width: 100%; height: 100%; object-fit: cover;
}
.gallery-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
  background: linear-gradient(135deg, var(--surface3) 0%, var(--surface2) 100%);
}
.gallery-dots {
  position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 5px;
}
.gallery-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,.5);
  transition: background var(--t), transform var(--t), width var(--t);
}
.gallery-dot.active {
  background: #fff;
  width: 14px; border-radius: 3px;
}
.gallery-badge {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0,0,0,.45); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.15);
}

/* Detail content */
.detail-content { padding: 0 16px; }

.detail-name {
  font-size: 22px; font-weight: 800;
  margin-top: 16px; line-height: 1.25;
  letter-spacing: -.4px;
}
.detail-brand {
  font-size: 14px; color: var(--txt3); margin-top: 3px;
}

.detail-loc-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}

/* Info sections */
.detail-section {
  margin-top: 14px;
  background: var(--surface2);
  border-radius: var(--r);
  overflow: hidden;
}
.detail-section-title {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--txt3); padding: 10px 14px 2px;
}
.detail-row {
  display: flex; align-items: center;
  padding: 10px 14px; gap: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label {
  color: var(--txt3); width: 110px; flex-shrink: 0;
  font-size: 13px; font-weight: 500;
}
.detail-row-value { flex: 1; font-weight: 600; }

/* Consumption timer — glassmorphism dark card */
.consumption-timer {
  margin-top: 16px;
  background: var(--grad-dark);
  border-radius: var(--r);
  padding: 16px;
  color: #fff;
  position: relative; overflow: hidden;
}
.consumption-timer::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: rgba(99,102,241,.3);
  border-radius: 50%;
  filter: blur(30px);
}
.consumption-timer.done {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
}
.consumption-timer.done::before { background: rgba(16,185,129,.3); }
.consumption-timer.overdue {
  background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
}
.consumption-timer.overdue::before { background: rgba(239,68,68,.3); }

.timer-title {
  font-size: 10px; opacity: .65;
  text-transform: uppercase; letter-spacing: .7px; font-weight: 700;
}
.timer-name {
  font-size: 15px; font-weight: 700; margin-top: 4px;
  line-height: 1.3;
}
.timer-value {
  font-size: 34px; font-weight: 900; margin: 8px 0 6px;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
  line-height: 1;
}
.timer-bar { height: 4px; background: rgba(255,255,255,.15); border-radius: 2px; overflow: hidden; }
.timer-fill { height: 100%; background: rgba(255,255,255,.8); border-radius: 2px; transition: width .5s ease; }
.timer-meta { font-size: 11px; opacity: .55; margin-top: 6px; line-height: 1.4; }

.timer-start-btn {
  margin-top: 12px; width: 100%;
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--r-sm); padding: 9px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  letter-spacing: .2px;
  transition: background var(--t);
  backdrop-filter: blur(4px);
}
.timer-start-btn:active { background: rgba(255,255,255,.22); }

/* Modal actions */
.modal-actions {
  display: flex; gap: 10px;
  padding: 16px 16px 0;
}
.btn-edit {
  flex: 1;
  background: var(--grad); color: #fff;
  border: none; cursor: pointer; border-radius: var(--r);
  padding: 14px; font-size: 15px; font-weight: 700;
  box-shadow: var(--sh-accent);
  transition: transform var(--t);
}
.btn-edit:active { transform: scale(.97); }
.btn-delete {
  background: rgba(239,68,68,.1); color: var(--danger);
  border: none; cursor: pointer; border-radius: var(--r);
  padding: 14px 20px; font-size: 15px; font-weight: 700;
  transition: background var(--t);
}
.btn-delete:active { background: rgba(239,68,68,.2); }

/* Allergens */
.allergen-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 14px 12px;
}
.allergen-chip {
  background: rgba(245,158,11,.12);
  color: #b45309;
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(245,158,11,.2);
}

/* ══════════════════════════════════════════════════════════════
   EXPIRING VIEW
   ══════════════════════════════════════════════════════════════ */
.expiry-list { padding: 8px 14px 24px; }

.expiry-group-title {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--txt3); padding: 16px 4px 8px;
}

.expiry-item {
  background: var(--surface);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform var(--t), box-shadow var(--t);
}
.expiry-item:active {
  transform: scale(.98);
  box-shadow: none;
}

.expiry-thumb {
  width: 52px; height: 52px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; overflow: hidden;
}
.expiry-thumb img { width: 100%; height: 100%; object-fit: cover; }

.expiry-info { flex: 1; min-width: 0; }
.expiry-item-name { font-size: 14px; font-weight: 700; }
.expiry-item-sub {
  font-size: 12px; color: var(--txt3);
  margin-top: 2px; font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   SEARCH VIEW
   ══════════════════════════════════════════════════════════════ */
.search-wrap { padding: 14px; }

.search-input-wrap {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh);
  display: flex; align-items: center;
  padding: 0 14px; gap: 8px;
}
.search-icon { font-size: 16px; color: var(--txt3); flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 16px; color: var(--txt);
  font-family: inherit; padding: 14px 0;
}
.search-input::placeholder { color: var(--txt3); }
.search-clear {
  background: var(--surface3); border: none; cursor: pointer;
  color: var(--txt3); font-size: 12px; font-weight: 700;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.search-results { margin-top: 12px; }

/* ══════════════════════════════════════════════════════════════
   LOADING
   ══════════════════════════════════════════════════════════════ */
#loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; color: #fff;
}

.spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text { font-size: 14px; font-weight: 500; opacity: .8; }

/* ══════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 14px; right: 14px; z-index: 400;
  pointer-events: none;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}

.toast {
  background: rgba(15,23,42,.88);
  color: #fff; font-size: 14px; font-weight: 500;
  padding: 11px 20px; border-radius: 20px;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.08);
  max-width: 320px; text-align: center;
  animation: toastIn .22s cubic-bezier(.34,1.56,.64,1),
             toastOut .2s ease 2.8s forwards;
}
.toast.success { background: rgba(16,185,129,.9); }
.toast.error   { background: rgba(239,68,68,.9); }

@keyframes toastIn  {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }

/* ══════════════════════════════════════════════════════════════
   UTILS
   ══════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* Section divider inside form */
.form-section + .form-section-title { margin-top: 0; }

/* Subtle scroll fade at bottom of content */
#app-content::after {
  content: ''; pointer-events: none;
  position: sticky; bottom: 0; left: 0; right: 0; height: 24px; display: block;
  background: linear-gradient(to bottom, transparent, var(--surface2));
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --tg-theme-bg-color:           #1c1c1e;
    --tg-theme-text-color:         #f2f2f7;
    --tg-theme-secondary-bg-color: #2c2c2e;
    --surface:  #1c1c1e;
    --surface2: #2c2c2e;
    --surface3: #3a3a3c;
    --border:   rgba(255,255,255,.07);
    --txt:      #f2f2f7;
    --txt2:     #ebebf5;
    --txt3:     #8e8e93;
    --sh-sm:    0 1px 4px rgba(0,0,0,.3);
    --sh:       0 4px 16px rgba(0,0,0,.4);
    --sh-lg:    0 8px 32px rgba(0,0,0,.5);
  }
  .allergen-chip { background: rgba(245,158,11,.18); color: #fbbf24; }
}
