#auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,0.5);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s;
}

#auth-modal[style*="display: flex"] {
  display: flex !important;
  opacity: 1;
}

#auth-modal .modal-content {
  background: #fff;
  border-radius: 16px;
  max-width: 340px;
  width: 100%;
  padding: 24px 20px 20px 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), var(--shadow-lg);
  max-height: 90vh;
  overflow: auto;
  position: relative;
  animation: popupIn 0.18s cubic-bezier(.4,1.4,.6,1) both;
}

@keyframes popupIn {
  0% { transform: scale(0.95) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

#auth-modal:focus {
  outline: none;
}

#auth-modal .modal-content:focus {
  outline: 2px solid var(--primary);
}

#auth-modal input, #auth-modal button {
  font-size: 1rem;
}

#auth-modal #close-auth-modal {
  background: var(--gray-400);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 10px 0;
  margin-top: 12px;
  width: 100%;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#auth-modal #close-auth-modal:hover {
  background: var(--gray-500);
}
#product-details-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,0.5);
  padding: 16px;
}

#product-details-modal .modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  overflow: auto;
}
:root { --primary: #6366f1; --primary-light: #8b5cf6; --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db; --gray-400: #9ca3af; --gray-500: #6b7280; --gray-700: #374151; --gray-800: #1f2937; --gray-900: #111827; --space-xs: 0.25rem; --space-sm: 0.5rem; --space-md: 1rem; --space-lg: 1.5rem; --space-xl: 2rem; --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem; --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05); --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1); --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1); }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%); color: var(--gray-800); line-height: 1.6; min-height: 100vh; }
#app { max-width: 428px; margin: 0 auto; background: #fff; min-height: 100vh; box-shadow: var(--shadow-lg); }
.app-header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: #fff; padding: var(--space-lg) var(--space-md); text-align: center; }
.app-title { font-size: 1.5rem; font-weight: 700; margin-bottom: var(--space-xs); }
.app-subtitle { opacity: 0.9; font-size: 0.875rem; }
.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-sm);
}
.header-control {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.2;
  backdrop-filter: blur(6px);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.3);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.header-control-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  color: #fff;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.8) 50%), linear-gradient(135deg, rgba(255,255,255,0.8) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.header-control-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.header-control-btn:hover,
.header-control-btn:focus-visible,
.header-control-select:hover,
.header-control-select:focus {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.9);
  transform: translateY(-1px);
}
.header-control-btn:focus-visible,
.header-control-select:focus {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}
.sync-status {
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  text-align: center;
  color: rgba(255,255,255,0.85);
  min-height: 1.2em;
}
.sync-status[data-state="offline"] {
  color: #fde68a;
}
.sync-status[data-state="syncing"] {
  color: #bbf7d0;
}
.sync-status[data-state="idle"] {
  color: rgba(255,255,255,0.85);
}
.auth-hidden {
  display: none !important;
}
body:not(.is-authenticated) [data-auth-locked="true"] {
  display: none !important;
}
body:not(.is-authenticated) #pre-login-marketing {
  display: block;
}
body.is-authenticated #pre-login-marketing {
  display: none;
}
#language-selector[data-active-language] {
  font-weight: 600;
}
#language-selector[data-active-language="el"] {
  direction: ltr;
}
#language-selector option {
  font-weight: 400;
}
#language-selector[data-active-language="en"] option[value="en"],
#language-selector[data-active-language="el"] option[value="el"] {
  font-weight: 600;
}
button[data-loading="true"] {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}
button[data-loading="true"] > * {
  visibility: hidden;
}
button[data-loading="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-left: -8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: button-spin 0.75s linear infinite;
}
@keyframes button-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.prelogin-section {
  padding: var(--space-lg) var(--space-md) var(--space-md);
  background: linear-gradient(150deg, rgba(99,102,241,0.08) 0%, rgba(16,185,129,0.08) 100%);
}
.prelogin-card {
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(99,102,241,0.12);
  display: grid;
  gap: var(--space-sm);
}
.prelogin-card h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--primary);
}
.prelogin-line {
  color: var(--gray-700);
  font-size: 0.95rem;
}
.prelogin-line--emphasis {
  font-weight: 600;
  color: var(--gray-800);
}
.prelogin-benefits {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.prelogin-benefit {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: var(--space-sm);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.benefit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(16,185,129,0.22));
  font-size: 1.25rem;
  color: #fff;
  font-weight: 600;
}
.prelogin-benefit p {
  margin: 0;
  color: var(--gray-700);
  font-size: 0.9rem;
  line-height: 1.4;
}
@media (min-width: 480px) {
  .prelogin-benefits {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
main { padding: var(--space-md); }
#scanner-section {
  padding: var(--space-xl) var(--space-md) var(--space-md) var(--space-md);
  text-align: center;
  position: relative;
  z-index: 1;
  min-height: unset;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
#reader {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: 0 auto var(--space-md);
  position: relative;
  z-index: 1;
  min-height: 0 !important;
  height: auto !important;
  max-width: 95vw;
  max-height: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
}
#start-scan { background: var(--primary); color: #fff; border: none; padding: var(--space-md) var(--space-xl); border-radius: var(--radius-lg); font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; box-shadow: var(--shadow-sm); }
#start-scan:hover:not(:disabled) { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }
#start-scan:disabled { opacity: 0.6; cursor: not-allowed; }

.camera-help-btn {
  background: var(--warning);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: var(--space-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.camera-help-btn:hover {
  background: #d97706;
  transform: translateY(-1px);
}
#product-info { background: #fff; margin: var(--space-md) 0; padding: var(--space-lg); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-100); }
#duplicate-note { display: none; margin: var(--space-md) 0; padding: var(--space-md); border-radius: var(--radius-lg); background: rgba(245, 158, 11, 0.14); border: 1px solid rgba(245, 158, 11, 0.38); color: var(--gray-700); font-size: 0.9rem; line-height: 1.5; }
#duplicate-note strong { display: inline-block; margin-right: 6px; color: var(--warning); }
#product-image-container { margin: 8px 0; }
#product-image { max-width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--space-lg); }
#product-name-edit { margin: 8px 0 12px; }
label { display: block; margin: 8px 0 4px; }
input[type="date"], input[type="text"] { padding: 12px; font-size: 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); width: 100%; }
#ingredients-section, #score-section { margin: 8px 0 12px; }
.score-container { display: flex; align-items: center; gap: 10px; }
.score-track { width: 180px; height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; border: 1px solid #e2e8f0; }
.score-bar { height: 100%; width: 0%; transition: width 0.3s ease; }
.score-bar.low { background: #ef4444; }
.score-bar.medium { background: #f59e0b; }
.score-bar.high { background: #16a34a; }
.score-value { font-weight: 700; min-width: 28px; text-align: right; }
#expiry-estimation { margin-top: var(--space-md); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; margin-right: 8px; }
.badge.high { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge.medium { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.badge.low { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
#reasoning-text { font-size: 13px; color: #475569; margin-left: 4px; }
#why-this-date { background: #0ea5e9; margin-left: 8px; color: #fff; border: none; padding: 8px 12px; border-radius: var(--radius-sm); }
#list-section { padding: 0 var(--space-sm) var(--space-xl); }
.section-title { font-size: 1.375rem; font-weight: 700; color: var(--gray-900); margin: 0; padding-left: 0; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--space-md); padding: 0 var(--space-xs); }
.list-toolbar__heading { flex: 1 1 auto; min-width: 160px; }
.list-count { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; display: inline-block; }
.list-toolbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.list-search { position: relative; display: flex; align-items: center; }
.list-search input { padding: 6px 28px 6px 12px; border: 1px solid var(--gray-300); border-radius: 999px; font-size: 0.85rem; background: #fff; min-width: 180px; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.list-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.list-search__clear { position: absolute; right: 8px; background: none; border: none; font-size: 1rem; color: var(--gray-400); cursor: pointer; padding: 0; line-height: 1; }
.list-search__clear:hover { color: var(--gray-600); }
.list-sort { position: relative; }
.list-sort select { padding: 6px 32px 6px 12px; border: 1px solid var(--gray-300); border-radius: 999px; font-size: 0.85rem; background: #fff; min-width: 160px; appearance: none; -webkit-appearance: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.list-sort select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.list-sort__icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--gray-500); font-size: 0.75rem; }
#list-items { list-style: none; margin: 0; padding: 0; position: relative; }
.list-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--radius-md); padding: 10px 14px; border: 1px solid transparent; transition: background 0.2s ease, border-color 0.2s ease; position: relative; margin-bottom: 8px; }
.list-item::before { content: ''; position: absolute; left: 0; top: 12%; width: 3px; height: 76%; border-radius: 2px; transition: background-color 0.2s ease; }
.list-item.red::before { background: var(--danger); }
.list-item.yellow::before { background: var(--warning); }
.list-item.green::before { background: var(--success); }
.list-item:last-child { margin-bottom: 0; }
.list-empty { list-style: none; padding: 24px 16px; text-align: center; color: var(--gray-500); font-size: 0.9rem; }
.list-empty__content { max-width: 280px; margin: 0 auto; }
.list-item:hover { background: #f8fafc; border-color: var(--gray-200); }
.list-item--highlight { box-shadow: 0 0 0 2px rgba(99,102,241,0.35); }
.item-main { display: flex; align-items: center; gap: 12px; width: 100%; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 1rem; font-weight: 600; color: var(--gray-900); margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expiry-text { font-size: 0.75rem; color: var(--gray-500); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.expiry-text:hover { color: var(--gray-600); }
.item-meta { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.score-badge { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: #fff; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; min-width: 36px; text-align: center; }
.delete-btn { background: transparent; border: none; padding: 4px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.2s ease, transform 0.2s ease; }
.delete-btn:hover { background: var(--gray-100); transform: scale(1.05); }
.virtual-spacer { height: 0; margin: 0; padding: 0; }
#modal-root { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(2,6,23,0.5); padding: 16px; z-index: 1000; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal { background: #fff; border-radius: 12px; max-width: 520px; width: 100%; padding: 16px; border: 1px solid #e2e8f0; max-height: calc(100vh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal h4 { margin-top: 0; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.fab { position: fixed; bottom: var(--space-xl); right: var(--space-xl); width: 56px; height: 56px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); border: none; border-radius: 50%; color: #fff; font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg); transition: all 0.2s ease; z-index: 100; }
.fab:hover { transform: scale(1.1); box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1); }
.btn-primary { background: var(--primary); color: #fff; border: none; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-lg); font-weight: 600; display: inline-flex; align-items: center; gap: var(--space-xs); box-shadow: var(--shadow-sm); transition: background 0.2s, transform 0.2s; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }
.modal-content { background: #fff; border-radius: var(--radius-xl); padding: var(--space-xl); max-width: 420px; width: 100%; max-height: 80vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--gray-100); padding-bottom: var(--space-md); margin-bottom: var(--space-lg); }
.score-badge { color: #fff; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-md); font-weight: 700; min-width: 2.5rem; text-align: center; }
@media (max-width: 480px) {
  .list-toolbar { flex-direction: column; align-items: stretch; padding: 0; }
  .list-toolbar__heading { width: 100%; }
  .list-toolbar__actions { width: 100%; justify-content: flex-start; gap: 6px; }
  .list-toolbar__actions .list-search,
  .list-toolbar__actions .list-sort { flex: 1 1 100%; }
  .list-search { width: 100%; }
  .list-sort { width: 100%; }
  .list-search input, .list-sort select { width: 100%; }
}

@media (max-width: 600px) {
  #modal-root { align-items: flex-start; }
  .modal { margin: 32px auto; }
}

@keyframes itemHighlight {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Mobile-optimized scanner styles */
#reader {
  width: 100%;
  max-width: 100vw;
  position: relative;
  overflow: hidden;
}

#reader video {
  width: 100% !important;
  max-width: 100vw;
  max-height: 320px;
  height: auto !important;
  object-fit: cover;
  border-radius: var(--radius-lg);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: block;
  margin: 0 auto;
}
#reader canvas {
  display: block;
  margin: 0 auto;
  max-width: 100vw;
  max-height: 320px;
  height: auto !important;
  background: transparent !important;
}

/* Mobile scanner controls */
#scanner-controls {
  margin-top: var(--space-md);
}

/* Custom overlay for better visual guidance - positioned relative to reader */
#reader .scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
}

.scanner-frame {
  width: min(360px, 80%);
  height: min(200px, 42vw);
  position: relative;
  border: 3px solid rgba(34, 197, 94, 0.9);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  background: rgba(34, 197, 94, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}

.scanner-blur {
  position: absolute;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Optimized barcode scanning frame - wider for horizontal barcodes */
.barcode-frame {
  width: min(340px, 75%);
  height: min(180px, 36vw);
  border-radius: 18px;
}

.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 4px solid rgba(34, 197, 94, 0.95);
  border-radius: 6px;
}

.corner.top-left { top: -4px; left: -4px; border-right: none; border-bottom: none; }
.corner.top-right { top: -4px; right: -4px; border-left: none; border-bottom: none; }
.corner.bottom-left { bottom: -4px; left: -4px; border-right: none; border-top: none; }
.corner.bottom-right { bottom: -4px; right: -4px; border-left: none; border-top: none; }

.scan-instruction {
  text-align: center;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.65);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-top: var(--space-md);
  backdrop-filter: blur(2px);
}

.scan-tip {
  text-align: center;
  color: rgba(226, 232, 240, 0.85);
  font-size: 0.75rem;
  margin-top: var(--space-xs);
  font-style: italic;
}

/* Animated scan line for barcode scanning */
.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.9), transparent);
  animation: scanLine 2s linear infinite;
  opacity: 0.9;
}

@keyframes scanLine {
  0% {
    top: 0;
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
  100% {
    top: calc(100% - 3px);
    opacity: 0.85;
  }
}

.scanner-frame--active {
  border-color: rgba(45, 212, 191, 0.95);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.5), 0 0 14px rgba(45, 212, 191, 0.45);
}

.scanner-frame--success {
  border-color: rgba(34, 197, 94, 1);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45), 0 0 18px rgba(34, 197, 94, 0.55);
}

.scanner-frame--success::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid rgba(34, 197, 94, 0.5);
  animation: scannerSuccessFlash 0.4s ease;
}

@keyframes scannerSuccessFlash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

.scanner-instructions {
  background: rgba(15, 23, 42, 0.6);
  color: rgba(248, 250, 252, 0.95);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  text-align: center;
}

.scanner-instructions p {
  margin: var(--space-xs) 0;
  font-size: 0.875rem;
}

.scanner-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.control-btn {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  padding: var(--space-md);
  border-radius: 50%;
  font-size: 1.2rem;
  width: 50px;
  height: 50px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Hide default html5-qrcode UI elements for cleaner mobile experience */
#reader__scan_region img[alt="Camera based scan"] {
  display: none !important;
}

#reader__dashboard_section {
  display: none !important;
}

#reader__dashboard_section_csr {
  display: none !important;
}

/* Hide the default scanning box overlay by making it transparent */
#reader__scan_region {
  opacity: 0 !important;
  pointer-events: none !important;
}

#reader__scan_region canvas {
  opacity: 0 !important;
}

/* Hide the scanning box border */
#reader__scan_region svg {
  display: none !important;
}

/* Hide any default QR/barcode scanning overlays */
#reader__camera_selection {
  display: none !important;
}

/* Hide default scanner UI elements */
#reader__dashboard {
  display: none !important;
}

/* Ensure our custom overlay is the only one visible */
#reader .scanner-overlay {
  display: flex !important;
}

/* Mobile-specific responsive adjustments */
@media (max-width: 768px) {
  .scanner-frame {
    width: min(300px, 88%);
    height: min(160px, 46vw);
  }
  
  .barcode-frame {
    width: min(280px, 82%);
    height: min(140px, 40vw);
  }
  
  .scanner-instructions {
    padding: var(--space-xs) var(--space-sm);
  }
  
  .scanner-instructions p {
    font-size: 0.8rem;
  }
  
  .control-btn {
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }
  
  #reader {
    margin: 0 auto;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .scanner-frame {
    width: min(240px, 94%);
    height: min(140px, 54vw);
  }
  
  .barcode-frame {
    width: min(220px, 88%);
    height: min(110px, 42vw);
  }
  
  .corner {
    width: 20px;
    height: 20px;
    border-width: 3px;
  }
  
  .scanner-buttons {
    gap: var(--space-sm);
  }
  
  .control-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }
  
  .scan-instruction {
    font-size: 0.75rem;
    padding: var(--space-xs) var(--space-sm);
  }
  
  .scan-tip {
    font-size: 0.7rem;
  }
}

/* Loading spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: 90%;
  width: 400px;
}

.toast {
  background: var(--gray-800);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  animation: slideUp 0.3s ease-out;
}

.toast.hiding {
  animation: slideDown 0.3s ease-out forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100px);
    opacity: 0;
  }
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
}

.toast-action {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.toast-action:hover {
  background: var(--primary-light);
}

/* Expired items section */
#expired-items-section {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: #fff3f3;
  border-radius: var(--radius-lg);
  border: 1px solid #ffcccc;
}

#expired-items-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.expired-item {
  background: white;
  border: 1px solid #ffcccc;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.expired-item-info h4 {
  margin: 0 0 4px 0;
  color: var(--gray-800);
  font-size: 1rem;
}

.expired-item-info p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.expired-item-actions {
  display: flex;
  gap: 8px;
}

.restore-btn {
  background: var(--success);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.restore-btn:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* Product image in list */
.item-image {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
  margin-right: 12px;
  border: 1px solid var(--gray-200);
}

.item-main {
  display: flex;
  align-items: center;
  width: 100%;
}

.recipe-modal {
  padding: var(--space-md);
  width: 100%;
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
}

.recipe-modal__header {
  margin-bottom: var(--space-sm);
}

.recipe-modal__summary {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
}

.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.recipe-card {
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.recipe-card__image {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.recipe-card__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.recipe-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.recipe-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--gray-700);
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 500;
}

.recipe-card__badge--urgent {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.recipe-card__badge--soon {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.recipe-card__footnote {
  font-size: 0.75rem;
  color: var(--gray-500);
}

@media (max-width: 640px) {
  .recipe-modal {
    padding: var(--space-sm);
    max-height: 75vh;
  }

  .recipe-list {
    grid-template-columns: 1fr;
  }

  .recipe-card__image {
    height: 150px;
  }
}
/ *   A c c o r d i o n   S t y l e s   * /  
 d e t a i l s > s u m m a r y   {  
         l i s t - s t y l e :   n o n e ;  
         c u r s o r :   p o i n t e r ;  
         p o s i t i o n :   r e l a t i v e ;  
         p a d d i n g :   v a r ( - - s p a c e - s m )   0 ;  
 }  
  
 d e t a i l s > s u m m a r y : : - w e b k i t - d e t a i l s - m a r k e r   {  
         d i s p l a y :   n o n e ;  
 }  
  
 d e t a i l s > s u m m a r y : : a f t e r   {  
         c o n t e n t :   ' ' ;  
         p o s i t i o n :   a b s o l u t e ;  
         r i g h t :   0 ;  
         t o p :   5 0 % ;  
         t r a n s f o r m :   t r a n s l a t e Y ( - 5 0 % )   r o t a t e ( 0 d e g ) ;  
         w i d t h :   1 2 p x ;  
         h e i g h t :   1 2 p x ;  
         b a c k g r o u n d - i m a g e :   u r l ( " d a t a : i m a g e / s v g + x m l , % 3 C s v g   x m l n s = ' h t t p : / / w w w . w 3 . o r g / 2 0 0 0 / s v g '   f i l l = ' n o n e '   v i e w B o x = ' 0   0   2 4   2 4 '   s t r o k e = ' % 2 3 6 b 7 2 8 0 '   s t r o k e - w i d t h = ' 2 ' % 3 E % 3 C p a t h   s t r o k e - l i n e c a p = ' r o u n d '   s t r o k e - l i n e j o i n = ' r o u n d '   d = ' M 1 9   9 l - 7   7 - 7 - 7 '   / % 3 E % 3 C / s v g % 3 E " ) ;  
         b a c k g r o u n d - s i z e :   c o n t a i n ;  
         b a c k g r o u n d - r e p e a t :   n o - r e p e a t ;  
         t r a n s i t i o n :   t r a n s f o r m   0 . 2 s   e a s e ;  
 }  
  
 d e t a i l s [ o p e n ] > s u m m a r y : : a f t e r   {  
         t r a n s f o r m :   t r a n s l a t e Y ( - 5 0 % )   r o t a t e ( 1 8 0 d e g ) ;  
 }  
  
 . l i s t - t o o l b a r   {  
         m a r g i n - t o p :   1 r e m ;  
 }  
  
 / *   F r e s h   I t e m   S e c t i o n   i n   S c a n n e r   * /  
 # f r e s h - i t e m - s e c t i o n   {  
         w i d t h :   1 0 0 % ;  
         m a x - w i d t h :   4 0 0 p x ;  
         m a r g i n - b o t t o m :   v a r ( - - s p a c e - l g ) ;  
         t e x t - a l i g n :   l e f t ;  
 }  
  
 # f r e s h - i t e m - s e c t i o n   h 3   {  
         f o n t - s i z e :   1 . 1 r e m ;  
         c o l o r :   v a r ( - - g r a y - 7 0 0 ) ;  
         m a r g i n - b o t t o m :   v a r ( - - s p a c e - x s ) ;  
 }  
  
 / *   M o d a l   C l o s e   B u t t o n   U p d a t e s   * /  
 . m o d a l - c o n t e n t   {  
         p o s i t i o n :   r e l a t i v e ;  
 }  
  
 # c l o s e - a u t h - m o d a l ,  
 # d e t a i l s - c l o s e ,  
 # m o d a l - c l o s e   {  
         p o s i t i o n :   a b s o l u t e ;  
         t o p :   1 2 p x ;  
         r i g h t :   1 2 p x ;  
         w i d t h :   3 2 p x ;  
         h e i g h t :   3 2 p x ;  
         p a d d i n g :   0 ;  
         m a r g i n :   0   ! i m p o r t a n t ;  
         b o r d e r - r a d i u s :   5 0 % ;  
         b a c k g r o u n d :   v a r ( - - g r a y - 1 0 0 )   ! i m p o r t a n t ;  
         c o l o r :   v a r ( - - g r a y - 5 0 0 )   ! i m p o r t a n t ;  
         d i s p l a y :   f l e x ;  
         a l i g n - i t e m s :   c e n t e r ;  
         j u s t i f y - c o n t e n t :   c e n t e r ;  
         m i n - w i d t h :   u n s e t ;  
         f o n t - s i z e :   0 ;  
         / *   H i d e   t e x t   i f   a n y   * /  
         b o r d e r :   1 p x   s o l i d   v a r ( - - g r a y - 2 0 0 )   ! i m p o r t a n t ;  
         b o x - s h a d o w :   n o n e   ! i m p o r t a n t ;  
 }  
  
 # c l o s e - a u t h - m o d a l : : b e f o r e ,  
 # d e t a i l s - c l o s e : : b e f o r e ,  
 # m o d a l - c l o s e : : b e f o r e   {  
         c o n t e n t :   ' Ã  ' ;  
         f o n t - s i z e :   2 4 p x ;  
         l i n e - h e i g h t :   1 ;  
         f o n t - w e i g h t :   4 0 0 ;  
 }  
  
 # c l o s e - a u t h - m o d a l : h o v e r ,  
 # d e t a i l s - c l o s e : h o v e r ,  
 # m o d a l - c l o s e : h o v e r   {  
         b a c k g r o u n d :   v a r ( - - g r a y - 2 0 0 )   ! i m p o r t a n t ;  
         c o l o r :   v a r ( - - g r a y - 7 0 0 )   ! i m p o r t a n t ;  
 }  
  
 / *   A d j u s t   M o d a l   H e a d e r   t o   n o t   o v e r l a p   c l o s e   b u t t o n   * /  
 . m o d a l - h e a d e r   {  
         p a d d i n g - r i g h t :   4 0 p x ;  
 }  
  
 # a u t h - m o d a l   . m o d a l - c o n t e n t   {  
         p a d d i n g - t o p :   4 8 p x ;  
         / *   G i v e   s p a c e   f o r   c l o s e   b u t t o n   * /  
 }  
  
 / *   H i d e   o r i g i n a l   b u t t o n s   t h a t   w e   a r e   r e p u r p o s i n g   o r   i f   t h e y   w e r e   a t   b o t t o m   * /  
 / *   A c t u a l l y   w e   r e p u r p o s e d   t h e m   b y   I D ,   b u t   s t r u c t u r e   m i g h t   n e e d   a d j u s t m e n t .    
       F o r   a u t h   m o d a l ,   c l o s e   b u t t o n   w a s   a t   b o t t o m .   * /  
  
 / *   F i x   f o o t e r   i n   g e n e r i c   m o d a l   * /  
 . m o d a l   f o o t e r   {  
         d i s p l a y :   n o n e ;  
         / *   H i d e   d e f a u l t   f o o t e r   i f   w e   m o v e   c l o s e   b t n   t o   t o p   * /  
 }  
  
 / *   B u t   w a i t ,   g e n e r i c   m o d a l   m i g h t   h a v e   o t h e r   b u t t o n s ?    
       N o ,   g e n e r i c   m o d a l   u s u a l l y   j u s t   h a s   " G o t   i t "   w h i c h   i s   t h e   c l o s e   b u t t o n .    
       I f   I   m o v e   i t   t o   t o p   r i g h t ,   I   c a n   h i d e   t h e   f o o t e r .   * /  
 
/* History & Restock Feature Styles */

.check-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
  color: var(--gray-400);
  transition: color 0.2s;
  display: flex;
  align-items: center;
}
.check-btn:hover {
  color: var(--success, #10b981);
}
.check-btn svg {
  width: 24px;
  height: 24px;
}

.expiry-text {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.expiry-text:hover {
  text-decoration: underline;
}
.pencil-icon {
  width: 14px;
  height: 14px;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.expiry-text:hover .pencil-icon {
  opacity: 1;
}

.history-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 8px;
}
.history-badge.consumed {
  background-color: var(--green-100, #dcfce7);
  color: var(--green-800, #166534);
}
.history-badge.deleted {
  background-color: var(--red-100, #fee2e2);
  color: var(--red-800, #991b1b);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    background: white;
    margin-bottom: 8px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.history-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.history-info h4 {
  margin: 0 0 4px 0;
  color: var(--gray-900);
}
.history-meta {
  font-size: 0.85rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

