/* ── Variables ────────────────────────────────────────────────────── */
:root {
  --green:       #2d6a4f;
  --green-mid:   #40916c;
  --green-light: #52b788;
  --green-pale:  #d8f3dc;
  --amber:       #e07b39;
  --amber-pale:  #fff3e6;
  --red:         #e53e3e;
  --bg:          #f4f7f5;
  --card:        #ffffff;
  --text:        #1b2d2a;
  --muted:       #6b7b74;
  --border:      #d8e4de;
  --sidebar-w:   220px;
  --nav-h:       58px;
  --radius:      8px;
  --shadow:      0 2px 10px rgba(0,0,0,0.07);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

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

/* ── Top nav ──────────────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 200;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

.site-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.site-name:hover { text-decoration: none; opacity: 0.9; }

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-links a {
  color: rgba(255,255,255,0.88);
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.nav-links a:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

.nav-email {
  color: rgba(255,255,255,0.65);
  font-size: 0.85rem;
  padding: 0 0.5rem;
}

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.88);
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-family: inherit;
  transition: background 0.15s;
}
.btn-link:hover { background: rgba(255,255,255,0.15); }

.btn-outline-white {
  border: 1.5px solid rgba(255,255,255,0.55);
}

/* ── App layout ───────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--nav-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
}

.sidebar h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.pantry-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.pantry-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.3rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  gap: 0.25rem;
}

.pantry-list .qty {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-empty {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.sidebar-footer {
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.pitch {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Main content ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.75rem 2rem;
  min-width: 0;
}

.page-container { max-width: 860px; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.alert-success { background: var(--green-pale); color: var(--green); }
.alert-error   { background: #fce8e8; color: #b91c1c; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  font-family: inherit;
  transition: filter 0.15s, opacity 0.15s;
  text-align: center;
  line-height: 1.4;
}
.btn:hover { filter: brightness(0.92); text-decoration: none; }

.btn-primary   { background: var(--green); color: #fff; }
.btn-secondary { background: #e8efeb; color: var(--text); }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-sm        { padding: 0.3rem 0.8rem; font-size: 0.82rem; }
.btn-block     { display: block; width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.875rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(82,183,136,0.18);
}

/* ── Search section ───────────────────────────────────────────────── */
.search-form {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 2rem;
}
.search-form h2 { font-size: 1.25rem; margin-bottom: 0.3rem; }
.search-hint { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }

.ingredients-group { position: relative; margin-bottom: 1rem; }
.ingredients-group input {
  font-size: 1.1rem;
  padding: 0.85rem 1rem;
}

/* ── Ingredient autocomplete dropdown ────────────────────────────── */
.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
}
.ac-dropdown.ac-open { display: block; }
.ac-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}
.ac-item:hover,
.ac-item.ac-active {
  background: var(--green-pale);
  color: var(--green);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.search-row .form-group { flex: 1; margin: 0; }
.search-row .form-group-sm { flex: 0 0 170px; margin: 0; }
.search-row .form-group-sm input,
.search-row .form-group-sm select { width: 100%; }

.missing-hint { margin: 0.75rem 0 0; }

/* ── Section headers ──────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.section-header h2 { font-size: 1.1rem; font-weight: 600; }
.section-hint { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-pale); color: var(--green); }
.badge-amber { background: var(--amber-pale); color: #9a4f1a; }
.badge-gray  { background: #eee; color: #555; }

/* ── Recipe grid ──────────────────────────────────────────────────── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s, box-shadow 0.18s;
}
.recipe-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.11);
}

.recipe-card img {
  width: 100%;
  height: 175px;
  object-fit: cover;
}

.card-img-placeholder {
  height: 175px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--green-pale);
}

.card-body {
  padding: 1rem 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-body h3 {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-actions {
  margin-top: auto;
  padding-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Recipe detail ────────────────────────────────────────────────── */
.recipe-detail { max-width: 820px; }

.recipe-detail-header { margin-bottom: 1rem; }
.recipe-detail-header h1 { font-size: 1.6rem; margin: 0.4rem 0; line-height: 1.25; }

.recipe-detail-image {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.recipe-meta {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.meta-chip {
  background: var(--green-pale);
  color: var(--green);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}
.meta-chip-link {
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.meta-chip-link:hover {
  filter: brightness(0.95);
  text-decoration: none;
}

/* ── Nutrition facts ──────────────────────────────────────────────── */
.nutrition-label {
  border: 2px solid var(--text);
  border-radius: var(--radius);
  max-width: 380px;
  padding: 0.25rem 1rem;
  margin-bottom: 1.5rem;
}
.nutrition-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.nutrition-row:last-child { border-bottom: none; }
.nutrition-row-indent .nutrition-name { padding-left: 1.25rem; color: var(--muted); }
.nutrition-row-calories {
  font-size: 1.3rem;
  font-weight: 700;
  border-bottom: 4px solid var(--text);
}
.nutrition-name { font-weight: 500; }
.nutrition-amount { font-weight: 600; white-space: nowrap; }
.nutrition-dv { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

.caloric-breakdown { max-width: 480px; margin-bottom: 1.75rem; }
.caloric-breakdown h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.6rem; }
.breakdown-bars {
  display: flex;
  border-radius: 20px;
  overflow: hidden;
  height: 2.2rem;
}
.breakdown-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 0.4rem;
}
.breakdown-carbs   { background: var(--green); }
.breakdown-fat     { background: #e0a13e; }
.breakdown-protein { background: #5b8ad6; }

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem 1.5rem;
  max-width: 700px;
  margin-bottom: 1rem;
}
.nutrition-grid-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.nutrition-footnote { font-size: 0.8rem; margin-top: 1rem; }

.popup-page { padding: 1.25rem 1.5rem; }

@media (max-width: 600px) {
  .nutrition-grid { grid-template-columns: 1fr; }
}

.recipe-columns {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}

.recipe-ingredients h2,
.recipe-instructions h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.recipe-instructions h2 {
  border-bottom: 2px solid var(--green-pale);
  padding-bottom: 0.4rem;
}

.ingredients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 2px solid var(--green-pale);
  padding-bottom: 0.4rem;
  margin-bottom: 0.75rem;
}
.ingredients-header h2 { margin-bottom: 0; }

.unit-toggle {
  display: flex;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.unit-toggle-btn {
  border: none;
  background: var(--card);
  color: var(--text);
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.unit-toggle-btn + .unit-toggle-btn { border-left: 1.5px solid var(--border); }
.unit-toggle-btn.active { background: var(--green); color: #fff; }
.unit-hidden { display: none; }

.recipe-ingredients ul {
  list-style: none;
  padding: 0;
}
.recipe-ingredients ul li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.recipe-instructions ol {
  padding-left: 1.25rem;
}
.recipe-instructions ol li {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
}

.instructions-raw {
  font-size: 0.9rem;
  line-height: 1.7;
}

.upgrade-nudge {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* ── Cook confirmation ────────────────────────────────────────────── */
.confirm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.confirm-table th {
  background: var(--green-pale);
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
}
.confirm-table td {
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.confirm-table .row-unmatched td { opacity: 0.55; }

.deduct-input {
  width: 80px !important;
  padding: 0.3rem 0.5rem !important;
  font-size: 0.85rem !important;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-card {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--card);
  padding: 2.25rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.auth-switch { margin-top: 1.25rem; font-size: 0.875rem; color: var(--muted); text-align: center; }

/* ── Pantry page ──────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; margin-bottom: 0.2rem; }

.add-item-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}
.add-item-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

.add-form .form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.add-form .form-group { flex: 2; margin: 0; }
.add-form .form-group-sm { flex: 1; }
.add-form .form-group-btn { flex: 0 0 auto; }

/* ── Tables ───────────────────────────────────────────────────────── */
.pantry-table, .admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.pantry-table th, .admin-table th {
  background: var(--green-pale);
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
}
.pantry-table td, .admin-table td {
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
.pantry-table tr:hover td, .admin-table tr:hover td { background: #f9fbfa; }

.table-input {
  width: 100% !important;
  padding: 0.3rem 0.5rem !important;
  font-size: 0.875rem !important;
  border-radius: 5px !important;
}
.table-input-sm { max-width: 90px !important; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

/* ── Upgrade page ─────────────────────────────────────────────────── */
.upgrade-card {
  max-width: 500px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  text-align: center;
}
.upgrade-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.upgrade-card h2 { color: var(--green); margin-bottom: 0.75rem; font-size: 1.5rem; }
.upgrade-card p { color: var(--muted); margin-bottom: 1rem; }
.upgrade-card ul {
  text-align: left;
  margin: 0.5rem 0 1.5rem 1.25rem;
  line-height: 2;
  font-size: 0.95rem;
}
.upgrade-contact { margin-top: 0; }
.upgrade-contact p { margin-bottom: 0.75rem; font-weight: 500; color: var(--text); }
.upgrade-pricing {
  margin: 1.25rem 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
}
.upgrade-pricing .upgrade-period { font-size: 1rem; font-weight: 400; color: var(--muted); }
.upgrade-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1rem 0;
  position: relative;
}
.upgrade-divider::before, .upgrade-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.upgrade-divider::before { left: 0; }
.upgrade-divider::after  { right: 0; }
.btn-disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Checkbox grid (preferences) ─────────────────────────────────────── */
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ── Pantry tabs ──────────────────────────────────────────────────── */
.pantry-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.pantry-tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.pantry-tab:hover { color: var(--text); text-decoration: none; }
.pantry-tab.active { color: var(--green); border-bottom-color: var(--green); }
.tab-count {
  background: var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
}
.tab-count-warning { background: #fde8d8; color: #9a4f1a; }

/* ── Expiry indicators ────────────────────────────────────────────── */
.expiry-label {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.4rem;
}
.label-expired { background: #fce8e8; color: #b91c1c; }
.label-soon    { background: #fde8d8; color: #9a4f1a; }

.row-expired td { background: #fff8f8; }
.row-expiring td { background: #fffaf5; }

.table-input-date { max-width: 140px !important; }

/* ── Expiring sidebar banner ──────────────────────────────────────── */
.expiring-banner {
  display: block;
  background: #fde8d8;
  color: #9a4f1a;
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-decoration: none;
}
.expiring-banner:hover { background: #fbd5b8; text-decoration: none; }

/* ── Barcode scanner modal ────────────────────────────────────────── */
.barcode-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.barcode-modal.open { display: flex; }

.barcode-modal-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
}

.barcode-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.barcode-modal-header h3 { font-size: 1.05rem; font-weight: 600; }

.barcode-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
}
.barcode-close:hover { color: var(--text); }

#barcode-reader {
  width: 100%;
  min-height: 200px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.barcode-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.barcode-status-error { color: var(--red); }

/* ── Scan to Pantry modal ─────────────────────────────────────────── */
.scan-modal-content {
  max-width: 560px;
}

.scan-step .section-hint { margin-bottom: 1rem; }

.scan-coming-soon {
  margin-top: 0.5rem;
  opacity: 0.6;
  cursor: not-allowed;
}
.scan-coming-soon:hover { filter: none; }

.scan-spinner {
  width: 36px;
  height: 36px;
  margin: 1.5rem auto 1rem;
  border: 4px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: scan-spin 0.8s linear infinite;
}
@keyframes scan-spin {
  to { transform: rotate(360deg); }
}

.scan-results-table { margin-bottom: 1rem; max-height: 320px; }
.scan-results-table tbody { display: block; max-height: 280px; overflow-y: auto; }
.scan-results-table thead, .scan-results-table tbody tr { display: table; width: 100%; table-layout: fixed; }

.scan-modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── How it works ─────────────────────────────────────────────────── */
.how-it-works {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 600px;
}
.how-it-works h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.how-it-works ol {
  padding-left: 1.25rem;
  line-height: 2;
  font-size: 0.9rem;
}

/* ── Misc ─────────────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.4rem; color: var(--text); }

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    position: relative;
    top: auto;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 2px solid var(--border);
    max-height: 220px;
    overflow-y: auto;
  }

  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
  }

  .recipe-grid { grid-template-columns: 1fr; }

  .search-row { flex-direction: column; }
  .search-row .form-group,
  .search-row .form-group-sm { width: 100%; flex: none; }

  .recipe-columns { grid-template-columns: 1fr; }

  .add-form .form-row { flex-direction: column; }
  .add-form .form-group,
  .add-form .form-group-sm { width: 100%; flex: none; }

  .nav-email { display: none; }

  /* Receipt review — stack each item as a card instead of a squished table row */
  .receipt-table {
    display: block;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }
  .receipt-table thead { display: none; }
  .receipt-table tbody { display: block; }
  .receipt-table tr {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.4rem 0.6rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    padding: 0.65rem 0.75rem;
    box-shadow: var(--shadow);
  }
  .receipt-table td {
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
  }
  .receipt-table td:nth-child(1) { grid-row: 1; grid-column: 1; }
  .receipt-table td:nth-child(2) { grid-row: 1; grid-column: 2 / 4; }
  .receipt-table td:nth-child(3) { grid-row: 2; grid-column: 2; }
  .receipt-table td:nth-child(4) { grid-row: 2; grid-column: 3; }
  .receipt-table .table-input,
  .receipt-table .table-input-sm { max-width: none !important; width: 100% !important; }

  /* Pantry "All Items" table — mobile card layout */
  .pantry-item-table {
    display: block;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }
  .pantry-item-table thead { display: none; }
  .pantry-item-table tbody { display: block; }
  .pantry-item-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    padding: 0.75rem;
    box-shadow: var(--shadow);
  }
  .pantry-item-table td { padding: 0; border: none; display: flex; align-items: center; }
  /* Ingredient: full width, row 1 */
  .pantry-item-table td:nth-child(1) { grid-row: 1; grid-column: 1 / 3; }
  /* Quantity: row 2 left; Unit: row 2 right */
  .pantry-item-table td:nth-child(2) { grid-row: 2; grid-column: 1; }
  .pantry-item-table td:nth-child(3) { grid-row: 2; grid-column: 2; }
  /* Expires: full width, row 3 — gives date picker room */
  .pantry-item-table td:nth-child(4) { grid-row: 3; grid-column: 1 / 3; flex-wrap: wrap; gap: 0.25rem; }
  /* Actions: full width, row 4 */
  .pantry-item-table td:nth-child(5) { grid-row: 4; grid-column: 1 / 3; gap: 0.5rem; }
  .pantry-item-table .table-input,
  .pantry-item-table .table-input-sm,
  .pantry-item-table .table-input-date {
    max-width: none !important;
    width: 100% !important;
    min-height: 44px !important;
    font-size: 0.875rem !important;
    box-sizing: border-box !important;
  }
  /* Ingredient name input: slightly larger to read at a glance */
  .pantry-item-table td:nth-child(1) .table-input {
    font-size: 1rem !important;
    font-weight: 500 !important;
  }
  /* Tap-friendly buttons */
  .pantry-item-table .btn { min-height: 44px; }

  /* Pantry "Expiring" table — mobile card layout */
  .pantry-expiring-table {
    display: block;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }
  .pantry-expiring-table thead { display: none; }
  .pantry-expiring-table tbody { display: block; }
  .pantry-expiring-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    padding: 0.75rem;
    box-shadow: var(--shadow);
  }
  .pantry-expiring-table td { padding: 0; border: none; font-size: 0.875rem; display: flex; align-items: center; }
  /* Name: full width, row 1 */
  .pantry-expiring-table td:nth-child(1) { grid-row: 1; grid-column: 1 / 3; font-size: 1rem; font-weight: 600; }
  /* Qty: row 2 left; Unit: row 2 right */
  .pantry-expiring-table td:nth-child(2) { grid-row: 2; grid-column: 1; }
  .pantry-expiring-table td:nth-child(3) { grid-row: 2; grid-column: 2; }
  /* Expires date: full width, row 3 */
  .pantry-expiring-table td:nth-child(4) { grid-row: 3; grid-column: 1 / 3; }
  /* Status badge: full width, row 4 */
  .pantry-expiring-table td:nth-child(5) { grid-row: 4; grid-column: 1 / 3; }
  /* Delete: full width, row 5 */
  .pantry-expiring-table td:nth-child(6) { grid-row: 5; grid-column: 1 / 3; }
  .pantry-expiring-table .btn { min-height: 44px; width: 100%; justify-content: center; }
}
