/* ============================
   CSS Reset & Variables
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --primary-dark: #1b4332;
  --danger: #d32f2f;
  --danger-light: #ef5350;
  --warning: #ed6c02;
  --success: #2e7d32;
  --bg: #f5f5f0;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #757575;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --nav-height: 56px;
  --sidebar-width: 220px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --text: #e8e8e8;
  --text-muted: #a0a0a0;
  --border: #404040;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --primary: #40916c;
  --primary-light: #52b788;
  --primary-dark: #1b4332;
  --danger: #ef5350;
  --danger-light: #f44336;
  --warning: #ffa726;
  --success: #66bb6a;
}

[data-theme="dark"] .btn:hover { background: #3a3a3a; }
[data-theme="dark"] .btn-secondary:hover { background: rgba(64,145,108,0.15); }
[data-theme="dark"] .btn-danger:hover { background: rgba(239,83,80,0.15); }
[data-theme="dark"] .card-image { background: #3a3a3a; }
[data-theme="dark"] .no-image { background: #3a3a3a; }
[data-theme="dark"] .special-image { background: #3a3a3a; }
[data-theme="dark"] .photo-placeholder { background: #333; }
[data-theme="dark"] .no-thumb { background: #333; }
[data-theme="dark"] .menu-status.active { background: #1b3a2a; color: var(--success); }
[data-theme="dark"] .menu-status.inactive { background: #3a2020; color: var(--danger); }
[data-theme="dark"] .allergen-badge { color: #1a1a1a; }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .autocomplete-item:hover { background: rgba(64,145,108,0.15); }
[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(64,145,108,0.25); }
[data-theme="dark"] .special-dish-option:hover { background: rgba(64,145,108,0.1); }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ============================
   Top Navigation
   ============================ */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--nav-height);
  padding: 0 20px;
  background: var(--primary-dark);
  color: white;
  box-shadow: var(--shadow);
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

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

.theme-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* Sync status indicator */
.sync-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  transition: background 0.3s;
}

.sync-indicator.connected { background: #66bb6a; }
.sync-indicator.disconnected { background: #ef5350; }

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-sm);
  min-height: 44px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

/* ============================
   Main Content
   ============================ */
#app-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ============================
   Page Header
   ============================ */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 2px;
}

.menu-title-area { flex: 1; }

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { background: #f0f0f0; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-secondary:hover { background: rgba(45,106,79,0.08); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: rgba(211,47,47,0.08); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-icon {
  padding: 6px 10px;
  font-size: 1.2rem;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 36px;
  min-height: 36px;
}

.btn-back {
  border: none;
  padding: 8px 12px;
  font-size: 1rem;
}

/* ============================
   Inputs & Forms
   ============================ */
.input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 16px; /* Prevents iOS zoom */
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
  min-height: 44px;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.15);
}

select.input { appearance: auto; }
textarea.input { resize: vertical; min-height: 80px; }

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 20px;
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-bottom: 20px;
  z-index: 10;
}

/* ============================
   Filter Bar
   ============================ */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-bar .input { flex: 1; }
.filter-bar select.input { flex: 0 0 180px; }

/* ============================
   Card Grid
   ============================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-image {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #e8e8e0;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card-body { padding: 16px; }

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 4px 0 8px;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.category-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 20px;
}

/* ============================
   Allergen Badges
   ============================ */
.allergen-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.allergen-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #1a1a1a;
  border-radius: 20px;
  white-space: nowrap;
}

.allergen-badge.compact {
  padding: 2px 8px;
  font-size: 0.68rem;
}

/* ============================
   Ingredient Rows
   ============================ */
.ingredient-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ing-field { min-width: 0; }
.ing-name-field { flex: 2; min-width: 140px; }
.ing-qty-field { flex: 0 0 80px; }
.ing-unit-field { flex: 0 0 80px; }
.ing-prep-field { flex: 2; min-width: 140px; }

.remove-ingredient {
  color: var(--danger);
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 36px;
  min-height: 36px;
}

/* ============================
   Autocomplete
   ============================ */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.95rem;
}

.autocomplete-item:hover {
  background: rgba(45,106,79,0.08);
}

/* ============================
   Cost Breakdown
   ============================ */
.cost-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cost-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 8px 14px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.cost-row:last-child { border-bottom: none; }

.cost-total {
  font-weight: 700;
  background: var(--bg);
}

.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }

/* ============================
   Photo Upload
   ============================ */
.photo-upload {
  cursor: pointer;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.photo-upload:hover { border-color: var(--primary); }

.photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  background: var(--bg);
}

.photo-preview {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

/* ============================
   Menu Builder
   ============================ */
.menu-summary-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.menu-category-section {
  margin-bottom: 24px;
}

.category-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 12px;
}

.menu-dish-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.dish-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
}

.dish-thumb img { width: 100%; height: 100%; object-fit: cover; }
.no-thumb { width: 100%; height: 100%; background: var(--bg); }

.dish-info { flex: 1; min-width: 0; }
.dish-info strong { display: block; margin-bottom: 2px; }

.servings-control {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.servings-count {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.servings-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.menu-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.menu-status.active { background: #e8f5e9; color: var(--success); }
.menu-status.inactive { background: #fbe9e7; color: var(--danger); }

.menu-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ============================
   Menu Pricing Bar
   ============================ */
.menu-pricing-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
  border-left: 4px solid var(--primary);
}

.pricing-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pricing-input-group label {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.pricing-input-group .input {
  max-width: 180px;
}

.pricing-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.pricing-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.pricing-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.pricing-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Dish cost in menu builder rows */
.dish-cost-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  min-width: 80px;
}

.dish-cost-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.dish-cost-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================
   Weekly Specials
   ============================ */
.specials-week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.specials-week-display {
  flex: 1;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

.week-label-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 8px;
  vertical-align: middle;
}

.special-card {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}

.special-card:hover {
  box-shadow: var(--shadow-lg);
}

.special-card.special-inactive {
  opacity: 0.6;
}

.special-image {
  width: 140px;
  min-height: 120px;
  flex-shrink: 0;
  background: #e8e8e0;
}

.special-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.special-body {
  flex: 1;
  padding: 16px;
  min-width: 0;
}

.special-body h3 {
  font-size: 1.1rem;
  margin: 4px 0 6px;
}

.special-header {
  display: flex;
  gap: 8px;
  align-items: center;
}

.special-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.special-tag.inactive {
  background: #fbe9e7;
  color: var(--danger);
}

.special-notes {
  font-style: italic;
  color: var(--primary-dark);
  font-size: 0.9rem;
  margin: 6px 0;
}

.special-dates {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.special-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-left: 1px solid var(--border);
}

.special-dish-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.special-dish-option:hover {
  background: rgba(45,106,79,0.05);
}

.special-dish-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.special-dish-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.special-dish-label strong { flex: 1; }

/* ============================
   Dish Picker Modal
   ============================ */
.dish-picker-list {
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
}

.dish-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.dish-picker-info { flex: 1; }
.dish-picker-info strong { display: block; margin-bottom: 2px; }

/* ============================
   Todo / Task View
   ============================ */
.todo-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  min-height: 44px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.shopping-summary {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  font-size: 1.05rem;
}

.todo-group { margin-bottom: 24px; }

.todo-group-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  text-transform: capitalize;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}

.todo-item input[type="checkbox"] {
  margin-top: 4px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

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

.todo-item.checked .todo-text { text-decoration: line-through; }

.todo-text { flex: 1; }
.todo-text strong { display: block; }

.todo-qty {
  font-weight: 600;
  color: var(--primary);
  margin-left: 8px;
}

.todo-cost {
  color: var(--text-muted);
  margin-left: 8px;
  font-size: 0.9rem;
}

.todo-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ============================
   Modal
   ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 { font-size: 1.25rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================
   Toast Notifications
   ============================ */
#toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 12px);
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 320px;
}

.toast.show { transform: translateX(0); }
.toast-success { background: #2e7d32; color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: #1565c0; color: white; }

/* ============================
   Utilities
   ============================ */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.error {
  text-align: center;
  padding: 40px 20px;
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 16px; font-size: 1.1rem; }

/* Span all columns when inside a grid */
.card-grid .empty-state,
.card-grid .loading,
.card-grid .error {
  grid-column: 1 / -1;
}

/* ============================
   Lightbox
   ============================ */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: zoom-out;
}

.lightbox-overlay.show { opacity: 1; }

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.3); }

.lightbox-title {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  max-width: 80vw;
  text-align: center;
}

/* ============================
   Drag and Drop
   ============================ */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 4px 8px;
  user-select: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  min-width: 28px;
  min-height: 44px;
  touch-action: none;
}

.drag-handle:active { cursor: grabbing; }

.menu-dish-row.dragging {
  opacity: 0.4;
  transform: scale(0.98);
}

.menu-dish-row.drag-over {
  border-top: 3px solid var(--primary);
  margin-top: -3px;
}

/* ============================
   Favorites
   ============================ */
.favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.9);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.15s, background 0.15s;
  color: #ccc;
}

.favorite-btn:hover { transform: scale(1.15); }
.favorite-btn.favorited { color: #e53935; }

[data-theme="dark"] .favorite-btn { background: rgba(0,0,0,0.6); }

/* Tags */
.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(45,106,79,0.1);
  color: var(--primary);
  border-radius: 12px;
}

[data-theme="dark"] .tag-badge { background: rgba(64,145,108,0.2); }

.filter-favorites-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
  white-space: nowrap;
}

.filter-favorites-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================
   Toast Undo Action
   ============================ */
.toast-action {
  display: inline-block;
  margin-left: 12px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.toast-action:hover { background: rgba(255,255,255,0.35); }

/* ============================
   Guest Allergy Conflicts
   ============================ */
.menu-info-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.menu-info-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.allergen-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.allergen-toggle {
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 28px;
}

.allergen-toggle.active {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.menu-dish-row.allergy-conflict {
  border-left: 4px solid var(--danger);
}

.allergy-warning {
  font-size: 0.75rem;
  color: var(--danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================
   Allergen Substitutions
   ============================ */
.substitution-section {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.substitution-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--primary-dark);
}

.substitution-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.sub-field { min-width: 0; }
.sub-allergen-field { flex: 0 0 100px; }
.sub-original-field { flex: 1; min-width: 100px; }
.sub-substitute-field { flex: 1; min-width: 100px; }
.sub-qty-field { flex: 0 0 70px; }
.sub-unit-field { flex: 0 0 70px; }
.sub-notes-field { flex: 1; min-width: 100px; }

.sub-arrow {
  color: var(--text-muted);
  font-weight: 700;
  flex-shrink: 0;
}

.subs-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #fff3e0;
  color: #e65100;
  border-radius: 12px;
  cursor: pointer;
}

[data-theme="dark"] .subs-badge { background: #3a2a1a; color: #ffb74d; }

/* ============================
   Bottom Navigation (mobile)
   ============================ */
.bottom-nav {
  display: none; /* hidden on desktop */
}

/* ============================
   Responsive — Tablet (≤768px)
   ============================ */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar select.input { flex: 1; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header h1 { font-size: 1.4rem; }

  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; }

  .menu-dish-row { flex-wrap: wrap; }
  .servings-control { margin-left: auto; }

  .todo-detail { max-width: 140px; }

  .pricing-input-group {
    flex-direction: column;
    align-items: flex-start;
  }
  .pricing-input-group .input { max-width: 100%; }
  .pricing-stats { gap: 16px; }

  .special-card { flex-direction: column; }
  .special-image { width: 100%; height: 160px; }
  .special-actions {
    flex-direction: row;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px 16px;
  }

  .dish-cost-info { min-width: 60px; }

  .ingredient-row { flex-wrap: wrap; }
  .ing-name-field { flex: 1 1 100%; }
  .ing-qty-field { flex: 1; }
  .ing-unit-field { flex: 1; }
  .ing-prep-field { flex: 1 1 100%; }
}

/* ============================
   Responsive — Mobile (≤480px)
   ============================ */
@media (max-width: 480px) {
  /* Hide top nav links — replaced by bottom tab bar */
  .nav-links { display: none; }
  .btn-logout { display: none !important; }

  /* Compact top nav */
  .top-nav {
    padding: 0 16px;
    gap: 12px;
  }
  .nav-brand { font-size: 1.1rem; }

  /* Main content: add padding for bottom nav + safe area */
  #app-content {
    padding: 12px 12px calc(64px + env(safe-area-inset-bottom, 0px)) 12px;
  }

  /* Cards: single column */
  .card-grid { grid-template-columns: 1fr; }

  /* Modal: bottom sheet style */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 85vh;
    max-width: 100%;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Sticky form actions: safe area */
  .form-actions {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Toasts: full-width at bottom */
  #toast-container {
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    transform: translateY(120%);
    text-align: center;
  }
  .toast.show { transform: translateY(0); }

  /* Menu builder rows: cleaner on small screens */
  .menu-summary-bar { font-size: 0.8rem; gap: 8px; }
  .dish-cost-info { display: none; } /* hide cost column, shown in summary bar */

  /* Filter bar: tighter */
  .filter-bar { gap: 8px; }

  /* Page header */
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 1.25rem; }

  /* Bottom nav: show on mobile */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--primary-dark);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
  }

  .bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-family: var(--font);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
    min-height: 56px;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-link.active,
  .bottom-nav-link:active {
    color: white;
  }

  .bottom-nav-link.active .bottom-nav-icon {
    transform: scale(1.15);
  }

  .bottom-nav-icon {
    font-size: 1.4rem;
    line-height: 1;
    transition: transform 0.15s;
  }

  .bottom-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  /* Substitution rows: stack on mobile */
  .substitution-row { flex-direction: column; }
  .sub-allergen-field,
  .sub-original-field,
  .sub-substitute-field,
  .sub-qty-field,
  .sub-unit-field,
  .sub-notes-field { flex: 1 1 100%; }
  .sub-arrow { display: none; }

  /* Allergen toggles: smaller */
  .allergen-toggle { font-size: 0.65rem; padding: 3px 8px; }
}

/* ============================
   Responsive — Large (≥1024px)
   ============================ */
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .ingredient-row { flex-wrap: nowrap; }
}

/* ============================
   Sidebar Layout (≥481px desktop)
   ============================ */
@media (min-width: 481px) {
  /* Push page content right to make room for sidebar */
  body {
    padding-left: var(--sidebar-width);
  }

  /* Convert top nav into a vertical sidebar */
  .top-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
    overflow-y: auto;
  }

  .nav-brand {
    padding: 24px 20px 16px;
    font-size: 1.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 8px;
  }

  .nav-links {
    flex-direction: column;
    flex: 1;
    gap: 2px;
    padding: 8px;
    align-items: stretch;
  }

  .nav-link {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  /* Bottom of sidebar: theme toggle + logout */
  .nav-right {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.12);
    margin-left: 0;
  }

  .theme-toggle {
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    font-size: 1.1rem;
    padding: 8px 12px;
    color: rgba(255,255,255,0.75);
  }

  .sync-indicator {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    align-self: center;
  }

  .btn-logout {
    width: 100%;
    justify-content: flex-start;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    margin-left: 0;
  }

  .btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: rgba(255,255,255,0.4);
  }

  /* Toast: no top nav bar offset needed */
  #toast-container {
    top: 20px;
  }

  /* Give content breathing room at top */
  #app-content {
    padding: 24px 24px 24px;
  }
}

/* ============================
   Print Styles
   ============================ */
@media print {
  .top-nav,
  .page-header .btn,
  .todo-tabs,
  #print-btn,
  .form-actions,
  .card-actions { display: none !important; }

  body { background: white; }
  #app-content { max-width: none; padding: 0; }

  .tab-content { display: block !important; }

  .tab-content + .tab-content {
    page-break-before: always;
  }

  .todo-item {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .shopping-summary { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================
   Login Page
   ============================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-title {
  font-family: var(--font);
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle {
  font-family: var(--font);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 16px; /* 16px minimum prevents iOS auto-zoom */
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.15);
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 600;
}

.login-error {
  display: none;
  color: var(--danger);
  font-size: 13px;
  font-family: var(--font);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(211,47,47,0.08);
  border-radius: var(--radius-sm);
}

.login-success {
  color: var(--success);
  font-size: 14px;
  font-family: var(--font);
  text-align: center;
  padding: 16px;
  background: rgba(46,125,50,0.08);
  border-radius: var(--radius-sm);
}

.login-links {
  text-align: center;
  margin-top: 16px;
}

.login-links a {
  color: var(--primary);
  font-family: var(--font);
  font-size: 13px;
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

/* Logout button */
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  margin-left: 8px;
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ============================
   Nav link as button (unit converter)
   ============================ */
.nav-link-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

/* ============================
   Offline Banner
   ============================ */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--warning);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============================
   Allergen Cover Grid
   ============================ */
.allergen-cover-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.allergen-cover-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.allergen-cover-count {
  width: 72px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  min-height: 32px;
}

.allergen-cover-count:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(45,106,79,0.15);
}

.allergen-cover-num {
  font-size: 0.75em;
  opacity: 0.85;
  font-weight: 700;
}

/* ============================
   Purchase Order Table
   ============================ */
.po-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.po-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}

.po-header-row:last-child { margin-bottom: 0; }

.po-label {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.po-date {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.po-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.po-table th {
  background: var(--primary-dark);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.po-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.po-category-row td {
  background: rgba(45,106,79,0.08);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  padding: 6px 12px;
}

.po-total-row td {
  background: var(--bg);
  border-top: 2px solid var(--border);
  font-size: 1rem;
}

.po-used-in {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 200px;
}

.po-footer {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.po-footer-line {
  font-size: 0.9rem;
  border-bottom: 1px solid var(--text);
  padding-bottom: 2px;
  min-width: 260px;
  color: var(--text-muted);
}

[data-theme="dark"] .po-category-row td { background: rgba(64,145,108,0.12); }
[data-theme="dark"] .po-total-row td { background: #2a2a2a; }

/* ============================
   Service Notes Calendar
   ============================ */
.service-notes-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

.sn-calendar-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: sticky;
  top: 20px;
}

.sn-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sn-calendar-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sn-cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 1rem;
  color: var(--text);
}

.sn-cal-nav:hover { background: var(--bg); }

.sn-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.sn-day-header {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
  text-transform: uppercase;
}

.sn-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: background 0.1s;
  gap: 2px;
}

.sn-day:hover { background: var(--bg); }

.sn-day.today {
  font-weight: 700;
  border-color: var(--primary);
  color: var(--primary);
}

.sn-day.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.sn-day.has-notes::after {
  content: '';
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.sn-day.selected.has-notes::after { background: white; }
.sn-day.empty { cursor: default; opacity: 0; pointer-events: none; }

.sn-notes-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sn-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sn-notes-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.sn-note-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.sn-note-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sn-note-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.sn-shift-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 12px;
  background: rgba(45,106,79,0.12);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sn-note-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.sn-note-content {
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
}

.sn-note-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.sn-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .service-notes-layout {
    grid-template-columns: 1fr;
  }
  .sn-calendar-panel { position: static; }
}

/* ============================
   Flavor Pairings Page
   ============================ */
.fp-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

.fp-sidebar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.fp-search-bar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.fp-category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.fp-cat-btn {
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  transition: all 0.1s;
}

.fp-cat-btn:hover, .fp-cat-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.fp-ingredient-list {
  flex: 1;
  overflow-y: auto;
}

.fp-ingredient-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fp-ingredient-item:hover { background: var(--bg); }
.fp-ingredient-item.active { background: rgba(45,106,79,0.1); border-left: 3px solid var(--primary); }

.fp-ingredient-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.fp-ingredient-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fp-detail {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.fp-detail-header {
  margin-bottom: 20px;
}

.fp-detail-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.fp-detail-cat {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fp-section {
  margin-bottom: 20px;
}

.fp-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.fp-flavor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fp-flavor-tag {
  padding: 4px 12px;
  background: rgba(45,106,79,0.1);
  color: var(--primary);
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.fp-pairings-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fp-pairing-chip {
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font);
  color: var(--text);
}

.fp-pairing-chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.fp-pairing-chip.has-detail {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.fp-notes {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.fp-attribution {
  margin-top: 24px;
  padding: 12px 16px;
  background: rgba(237,108,2,0.08);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  border-left: 3px solid var(--warning);
}

.fp-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .fp-layout { grid-template-columns: 1fr; }
  .fp-sidebar { position: static; max-height: 350px; }
}

/* ============================
   Unit Converter Modal
   ============================ */
.unit-converter {
  padding: 4px 0;
}

.uc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.uc-tab-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  transition: all 0.15s;
}

.uc-tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.uc-panel { display: none; }
.uc-panel.active { display: block; }

.uc-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.uc-input-row input {
  flex: 1;
  padding: 10px 14px;
  font-size: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
  font-family: var(--font);
}

.uc-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.15);
}

.uc-input-row select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 44px;
  appearance: auto;
}

.uc-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.uc-result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.uc-result-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.uc-result-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.uc-quick-ref {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.uc-quick-ref h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.uc-quick-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.uc-quick-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.uc-quick-table td:first-child {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* ============================
   Service Notes — shift picker & legend
   ============================ */
.sn-cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  justify-content: center;
}

.sn-dot-legend {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.sn-shift-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sn-shift-opt {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font);
  border: 2px solid var(--sc, var(--border));
  border-radius: 20px;
  background: none;
  color: var(--sc, var(--text));
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.7;
}

.sn-shift-opt:hover {
  opacity: 1;
  background: rgba(0,0,0,0.06);
}

.sn-shift-opt.active {
  background: var(--sc, var(--primary));
  color: white;
  opacity: 1;
  border-color: var(--sc, var(--primary));
}

/* ============================
   Ingredient Row — inline unit converter
   ============================ */
.ing-main-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Mirror the old ingredient-row flex layout */
.ingredient-row { flex-wrap: wrap; }

.ing-convert-btn {
  flex-shrink: 0;
  font-size: 1rem;
  padding: 6px 8px;
  min-width: 34px;
  min-height: 34px;
  border-color: var(--primary);
  color: var(--primary);
}

.ing-convert-btn:hover:not(:disabled) {
  background: rgba(45,106,79,0.08);
}

.ing-converter {
  width: 100%;
  padding: 8px 12px;
  background: rgba(45,106,79,0.06);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 2px;
}

.ing-converter-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ing-converter-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.ing-converter-target {
  padding: 5px 8px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  min-height: 34px;
  appearance: auto;
}

.ing-converter-result {
  font-size: 0.9rem;
  color: var(--text);
  min-width: 80px;
}

[data-theme="dark"] .ing-converter {
  background: rgba(64,145,108,0.08);
}
