/* ---- APP SHELL ---- */
.app-body {
  min-height: 100vh;
  background: var(--bg);
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 244, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(44, 36, 24, 0.08);
}

.app-nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.app-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.app-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.app-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.app-tab:hover {
  background: var(--bg-warm);
  color: var(--fg);
}

.app-tab.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.tab-icon { font-size: 1rem; }

.app-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
  transition: background 0.3s;
}
.sync-dot.connected { background: var(--green); }
.sync-dot.disconnected { background: var(--red); }

/* ---- HOUSEHOLD PANEL ---- */
.household-panel {
  background: white;
  border-bottom: 1px solid rgba(44, 36, 24, 0.1);
  box-shadow: 0 4px 20px rgba(44, 36, 24, 0.08);
}

.household-panel-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#household-info {
  font-size: 0.95rem;
  color: var(--fg-muted);
}

.household-actions {
  display: flex;
  gap: 40px;
}

.household-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}

.household-col h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- MAIN CONTENT ---- */
.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-size: 1.8rem;
  color: var(--fg);
  margin-bottom: 4px;
}

.page-sub {
  font-size: 0.95rem;
  color: var(--fg-muted);
}

/* ---- LOCATION FILTER TABS ---- */
.location-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.loc-tab {
  padding: 6px 18px;
  border: 1px solid rgba(44, 36, 24, 0.15);
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  background: white;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.loc-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.loc-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---- ITEMS GRID ---- */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.item-card {
  background: white;
  border: 1px solid rgba(44, 36, 24, 0.08);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.item-card:hover {
  box-shadow: 0 4px 16px rgba(44, 36, 24, 0.1);
  transform: translateY(-2px);
}

.item-card.low-stock {
  border-color: var(--red);
  border-left-width: 3px;
}

.item-card-emoji {
  font-size: 2rem;
  line-height: 1;
}

.item-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--fg);
}

.item-card-meta {
  font-size: 0.82rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.location-badge.pantry  { background: #FFF4E6; color: #B45309; }
.location-badge.fridge  { background: #EEF6FF; color: #1D4ED8; }
.location-badge.freezer { background: #EFF6FF; color: #1E40AF; }

.low-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #FEE2E2;
  color: var(--red);
  font-weight: 600;
}

.item-qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(44, 36, 24, 0.15);
  background: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.qty-btn:hover { background: var(--bg-warm); }

.qty-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  min-width: 32px;
  text-align: center;
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

/* ---- GROCERY LIST ---- */
.grocery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.grocery-count {
  font-size: 0.88rem;
  color: var(--fg-muted);
  font-weight: 500;
}

.grocery-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: white;
  border: 1px solid rgba(44, 36, 24, 0.08);
  border-radius: var(--radius);
  transition: opacity 0.2s;
}

.grocery-item.checked {
  opacity: 0.5;
}

.grocery-item.checked .grocery-item-name {
  text-decoration: line-through;
  color: var(--fg-muted);
}

.grocery-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid rgba(44, 36, 24, 0.2);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.grocery-checkbox.checked {
  background: var(--green);
  border-color: var(--green);
  color: white;
  font-size: 0.85rem;
}

.grocery-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--fg);
}

.grocery-item-qty {
  font-size: 0.88rem;
  color: var(--fg-muted);
  white-space: nowrap;
}

.auto-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.grocery-del {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.grocery-del:hover { color: var(--red); }

/* ---- STATES ---- */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--fg);
}

.empty-state p {
  color: var(--fg-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.loading-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--fg-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(224, 122, 58, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

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

/* ---- MODAL ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 24, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(44, 36, 24, 0.2);
}

.modal h3 {
  font-size: 1.3rem;
  margin-bottom: 24px;
  color: var(--fg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---- FORMS ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.form-row .form-group { flex: 1; margin-bottom: 0; }

.emoji-group { flex: 0 0 72px; }
.emoji-input { text-align: center; font-size: 1.5rem; padding: 8px 6px; }

.input {
  padding: 10px 14px;
  border: 1px solid rgba(44, 36, 24, 0.18);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--fg);
  background: white;
  transition: border-color 0.15s;
  width: 100%;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-sm {
  padding: 8px 12px;
  border: 1px solid rgba(44, 36, 24, 0.18);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--fg);
  background: white;
  width: 100%;
}

.input-sm:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---- BUTTONS ---- */
.btn-primary {
  padding: 10px 22px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--accent-light); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  padding: 10px 22px;
  background: white;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-outline:hover { background: var(--accent-glow); }

.btn-ghost {
  padding: 8px 16px;
  background: none;
  color: var(--fg-muted);
  border: 1px solid rgba(44, 36, 24, 0.15);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover { background: var(--bg-warm); color: var(--fg); }
.btn-ghost.danger:hover { background: #FEE2E2; color: var(--red); border-color: var(--red); }

.btn-sm { padding: 6px 14px; font-size: 0.84rem; }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(44, 36, 24, 0.12);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover { background: var(--bg-warm); }
.btn-icon.del:hover { background: #FEE2E2; border-color: var(--red); }

.hidden { display: none !important; }

/* ---- TOAST ---- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--fg);
  color: #f3efe8;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(44, 36, 24, 0.25);
  animation: slide-in 0.25s ease;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

@keyframes slide-in {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---- EXPIRY INDICATORS ---- */
.expiring-section {
  margin-bottom: 28px;
}

.expiring-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #92400E;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.expiring-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.expiring-soon-card {
  border-color: #FCD34D;
  border-left-width: 3px;
  background: #FFFBEB;
}

.expiry-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.expiry-badge.fresh {
  background: #D1FAE5;
  color: #065F46;
}

.expiry-badge.warning {
  background: #FEF3C7;
  color: #92400E;
}

.expiry-badge.urgent {
  background: #FEE2E2;
  color: #991B1B;
}

/* ---- EXPIRY QUICK-SET BUTTONS ---- */
.expiry-quick-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn-expiry {
  padding: 5px 12px;
  background: var(--bg-warm);
  color: var(--fg-muted);
  border: 1px solid rgba(44, 36, 24, 0.15);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}

.btn-expiry:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-expiry-clear {
  color: var(--fg-muted);
}

.btn-expiry-clear:hover {
  background: #FEE2E2;
  color: var(--red);
  border-color: var(--red);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .app-nav-inner { padding: 0 16px; gap: 12px; }
  .app-tab span.tab-icon { display: none; }
  .app-main { padding: 20px 16px 60px; }
  .page-header { flex-direction: column; }
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .household-actions { flex-direction: column; gap: 20px; }
  .form-row { flex-direction: column; gap: 0; }
  .modal { padding: 24px 20px; }
  .expiry-quick-btns { flex-wrap: wrap; }
}

/* ---- PAGE HEADER ACTIONS ---- */
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- SCAN BUTTON ---- */
.btn-scan {
  padding: 10px 22px;
  background: #1a1a2e;
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
}

.btn-scan:hover { background: #2d2d4a; }
.btn-scan:active { transform: scale(0.97); }

/* ---- FIELD HINT ---- */
.field-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--fg-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* ---- BARCODE SCANNER ---- */
.scanner-wrap {
  max-width: 500px;
  margin: 0 auto;
}

.scanner-header {
  margin-bottom: 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 16px;
  font-weight: 500;
}

.back-link:hover { color: var(--accent); }

.scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #111;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-placeholder {
  text-align: center;
  color: #888;
}

.scanner-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.scanner-placeholder p {
  font-size: 0.9rem;
}

.scanner-region {
  position: absolute;
  inset: 0;
}

#scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-corner {
  position: absolute;
  width: 28px;
  height: 28px;
}

.scanner-corner.tl { top: 20%; left: 12%; border-top: 3px solid var(--accent); border-left: 3px solid var(--accent); border-radius: 4px 0 0 0; }
.scanner-corner.tr { top: 20%; right: 12%; border-top: 3px solid var(--accent); border-right: 3px solid var(--accent); border-radius: 0 4px 0 0; }
.scanner-corner.bl { bottom: 20%; left: 12%; border-bottom: 3px solid var(--accent); border-left: 3px solid var(--accent); border-radius: 0 0 0 4px; }
.scanner-corner.br { bottom: 20%; right: 12%; border-bottom: 3px solid var(--accent); border-right: 3px solid var(--accent); border-radius: 0 0 4px 0; }

.scanner-guide-line {
  position: absolute;
  top: 20%;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: scan-line 2s ease-in-out infinite;
}

@keyframes scan-line {
  0%   { top: 20%; }
  50%  { top: 75%; }
  100% { top: 20%; }
}

/* ---- SCAN RESULT ---- */
.scan-result {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  z-index: 300;
  pointer-events: none;
}

.scan-result.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.scan-result-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1px solid rgba(44, 36, 24, 0.1);
  border-radius: 14px;
  padding: 16px 24px;
  box-shadow: 0 8px 32px rgba(44, 36, 24, 0.15);
  min-width: 260px;
}

.scan-success-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.scan-success-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scan-success-text strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  color: var(--fg);
}

.scan-success-action {
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 500;
}

/* ---- MODAL ICON ---- */
.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  text-align: center;
}

.modal-sub {
  color: var(--fg-muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
  text-align: center;
}

.modal-hint {
  color: var(--fg-muted);
  font-size: 0.88rem;
  text-align: center;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ---- MULTI MATCH LIST ---- */
.multi-match-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.match-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg);
  border: 1px solid rgba(44, 36, 24, 0.12);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  width: 100%;
}

.match-item-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.match-item-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--fg);
}

.match-item-meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* ---- CAMERA DENIED ---- */
.scanner-fallback {
  text-align: center;
  padding: 40px 24px;
}

.fallback-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.scanner-fallback h3 {
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: var(--fg);
}

.scanner-fallback p {
  color: var(--fg-muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ---- MANUAL SEARCH ---- */
.manual-search {
  background: white;
  border: 1px solid rgba(44, 36, 24, 0.1);
  border-radius: 14px;
  padding: 24px;
  margin-top: 24px;
}

.manual-search h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.manual-search .form-group {
  margin-bottom: 12px;
}

.manual-search .btn-primary {
  width: 100%;
}
