/* Home Manager – modern UI, light & dark */

:root,
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-subtle: #eef0f3;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --text: #1a1d21;
  --text-secondary: #5c6370;
  --muted: #8b9199;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-muted: #eff6ff;
  --border: #e5e8ec;
  --border-strong: #d1d5db;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg: #0f1114;
  --bg-subtle: #181b1f;
  --surface: #1a1d21;
  --surface-hover: #22262b;
  --text: #eef0f2;
  --text-secondary: #b4b9c0;
  --muted: #7a818a;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-muted: rgba(59, 130, 246, 0.15);
  --border: #2d3238;
  --border-strong: #3d434b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.35);
  --flash-success-bg: #052e16;
  --flash-success-border: #14532d;
  --flash-success-text: #86efac;
  --flash-error-bg: #450a0a;
  --flash-error-border: #7f1d1d;
  --flash-error-text: #fca5a5;
}

/* Form controls: always use theme text (and placeholder) so dark mode stays readable */
input:not([type="hidden"]),
select,
textarea {
  color: var(--text);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: var(--muted);
}
input::-moz-placeholder,
textarea::-moz-placeholder {
  color: var(--muted);
}

/* Dark mode: force readable text when inputs are focused/autofilled (browsers often inject white bg + black text) */
[data-theme="dark"] input:not([type="hidden"]):focus,
[data-theme="dark"] input:not([type="hidden"]):-webkit-autofill,
[data-theme="dark"] input:not([type="hidden"]):-webkit-autofill:hover,
[data-theme="dark"] input:not([type="hidden"]):-webkit-autofill:focus,
[data-theme="dark"] input:not([type="hidden"]):-webkit-autofill:active,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] textarea:-webkit-autofill:hover,
[data-theme="dark"] textarea:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill:active {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] input:-webkit-autofill:active,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] textarea:-webkit-autofill:hover,
[data-theme="dark"] textarea:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 9999px var(--surface) inset !important;
  box-shadow: 0 0 0 9999px var(--surface) inset !important;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 0;
  box-shadow: var(--shadow-sm);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

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

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

.nav a {
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.nav a:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.nav-signup {
  margin-left: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding-inline: 0.95rem;
}

.nav-signup:hover {
  color: #fff;
  background: var(--accent);
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  margin-left: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--accent);
  background: var(--accent-muted);
  border-color: var(--border-strong);
}

.theme-icon {
  display: block;
  line-height: 1;
}

[data-theme="light"] .theme-icon-moon,
[data-theme="dark"] .theme-icon-sun {
  display: none;
}

[data-theme="light"] .theme-icon-sun,
[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.nav-more-wrap {
  position: relative;
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.nav-more-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}

.nav-more-btn:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.nav-more-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 11rem;
  padding: 0.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}

.nav-more-menu.open {
  display: block;
}

.nav-more-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-more-menu a:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

/* Main */
.main {
  flex: 1;
  padding: 2.25rem 0;
}

h1 {
  margin-top: 0;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.lead {
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  font-size: 1.05rem;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.cards-four {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.card {
  display: block;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow-sm);
}

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

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Kitchen dashboard */
.kitchen-dashboard {
  margin-top: 2rem;
}
.kitchen-dashboard h2 {
  margin-bottom: 0.25rem;
}
.kitchen-dashboard-subtitle {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.kitchen-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.kitchen-dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.kitchen-stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.kitchen-stat-card h3 {
  margin: 0 0 0.6rem 0;
  font-size: 1rem;
}
.kitchen-stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kitchen-stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.95rem;
}
.kitchen-stat-list span {
  color: var(--text-secondary);
}
.kitchen-stat-list strong {
  font-weight: 600;
}
.kitchen-ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kitchen-ranking-list li {
  padding: 0.3rem 0;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-size: 0.95rem;
}
.kitchen-ranking-list li:first-child {
  border-top: none;
}
.kitchen-ranking-list .k-name {
  display: block;
}
.kitchen-ranking-list .k-meta {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Kitchen dashboard: per-user customize */
.kitchen-dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.kitchen-dashboard-customize {
  flex-shrink: 0;
}
.kitchen-dashboard-customize-actions {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.kitchen-dashboard-customize-hint {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.kitchen-dashboard-add-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kitchen-dashboard-add-tile label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.kitchen-dashboard-add-tile select {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 12rem;
}
.kitchen-tile-hidden {
  display: none !important;
}
.kitchen-stat-card.kitchen-tile-edit-remove {
  position: relative;
  padding-top: 2rem;
}
.kitchen-tile-remove-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.kitchen-tile-remove-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.kitchen-tile-drag-handle {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  cursor: grab;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  padding: 0.15rem;
}
.kitchen-tile-drag-handle:hover {
  color: var(--text);
}
.kitchen-tile-drag-handle:active {
  cursor: grabbing;
}
.kitchen-stat-card.kitchen-tile-edit-remove {
  padding-left: 2.25rem;
}
.kitchen-stat-card.kitchen-tile-dragging {
  opacity: 0.6;
}
.kitchen-stat-card.kitchen-tile-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.placeholder {
  color: var(--muted);
  font-style: italic;
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-danger:hover {
  border-color: #dc2626;
  background: #fef2f2;
  color: #dc2626;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.page-header h1 {
  margin: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  padding: 0.5rem 0.65rem;
  font-size: 1.1rem;
  line-height: 1;
}

.kitchen-settings-link {
  opacity: 0.85;
}

.kitchen-settings-link:hover {
  opacity: 1;
}

/* Flash messages */
.flash-messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.flash {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.flash-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

[data-theme="dark"] .flash {
  background: var(--flash-success-bg);
  border-color: var(--flash-success-border);
  color: var(--flash-success-text);
}

[data-theme="dark"] .flash-error {
  background: var(--flash-error-bg);
  border-color: var(--flash-error-border);
  color: var(--flash-error-text);
}

/* Forms */
.form {
  max-width: 100%;
}

.form-narrow {
  max-width: 28rem;
}

.form-group {
  margin-bottom: 1.125rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

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

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

.member-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.member-row {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.required {
  color: #dc2626;
}

.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.new-location-wrap {
  margin-top: 0.75rem;
  margin-left: 0;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table th,
.table td {
  padding: 0.875rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-subtle);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background 0.15s;
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table .actions {
  white-space: nowrap;
}

.table .actions .btn,
.table .actions form {
  display: inline-block;
  margin-right: 0.5rem;
}

/* Inline quantity */
.quantity-cell {
  white-space: nowrap;
}

.quantity-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.quantity-control .qty-form {
  display: inline-flex;
  align-items: center;
}

.quantity-control .qty-input {
  width: 3.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-right: 0.25rem;
  background: var(--surface);
  color: var(--text);
}

.quantity-control .btn-qty {
  min-width: 1.75rem;
  padding: 0.25rem 0.4rem;
  font-weight: 600;
}

.qty-value {
  min-width: 2rem;
  text-align: center;
  font-weight: 500;
  display: inline-block;
}

.editable-reorder {
  min-width: 2rem;
  text-align: center;
  display: inline-block;
}

.qty-unit {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.low-badge {
  display: inline-block;
  margin-left: 0.15rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 4px;
}

.expired-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 4px;
}

[data-theme="dark"] .expired-badge {
  background: var(--flash-error-bg);
  color: var(--flash-error-text);
}

.table .row-expired {
  background: #fef2f2;
}

[data-theme="dark"] .table .row-expired {
  background: rgba(127, 29, 29, 0.25);
}

.expired-alert {
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .expired-alert {
  background: var(--flash-error-bg);
  border-color: var(--flash-error-border);
  color: var(--flash-error-text);
}

/* Inventory inline edit */
.table-inventory .cell-name { min-width: 10rem; }
.editable-name {
  cursor: text;
  padding: 0.15rem 0;
  border-radius: 3px;
}
.editable-name:hover { background: var(--accent-muted); }
.inline-edit-input {
  width: 100%;
  padding: 0.2rem 0.4rem;
  font-size: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.editable-reorder {
  cursor: text;
  padding: 0.15rem 0;
  border-radius: 3px;
}
.editable-reorder:hover { background: var(--accent-muted); }

.editable-location {
  cursor: pointer;
  padding: 0.15rem 0;
  border-radius: 3px;
}
.editable-location:hover { background: var(--accent-muted); }
.location-select {
  width: 100%;
  min-width: 6rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
.hidden { display: none !important; }

.th-notes, .th-menu { width: 2.5rem; }
.cell-notes, .cell-menu { vertical-align: middle; }
.btn-notes {
  background: none;
  border: none;
  padding: 0.2rem 0.35rem;
  font-size: 0.9rem;
  opacity: 0.5;
  cursor: pointer;
  border-radius: 4px;
}
.btn-notes:hover { opacity: 0.9; }
.btn-notes.has-notes { opacity: 0.85; }

.menu-wrap { position: relative; }
.btn-menu {
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}
.btn-menu:hover { color: var(--text); background: var(--surface-hover); }
.menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  z-index: 20;
  padding: 0.25rem 0;
}
.menu-form { margin: 0; display: block; }
.menu-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  text-align: left;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item-link {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  box-sizing: border-box;
}
.menu-item-link:hover { background: var(--surface-hover); }
.menu-item-danger { color: #dc2626; }

/* Add row */
.add-row td { padding: 0.6rem 1rem; background: var(--bg-subtle); border-top: 2px solid var(--border); }
.add-row-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.add-row-name { flex: 1; min-width: 10rem; padding: 0.4rem 0.6rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-qty { width: 3.5rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-unit { width: 5rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-location { min-width: 6rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-reorder { width: 4.5rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-price { width: 5rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.add-row-expiry { min-width: 8rem; padding: 0.4rem; font-size: 0.95rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.cell-expiry .expiry-input { width: 10rem; padding: 0.25rem 0.4rem; font-size: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

/* Notes modal */
.notes-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.notes-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.notes-modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 20rem;
  max-width: 28rem;
  box-shadow: var(--shadow-hover);
}
.notes-modal-box label { display: block; margin-bottom: 0.35rem; font-weight: 500; }
#notes-textarea { width: 100%; padding: 0.5rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; resize: vertical; background: var(--surface); color: var(--text); }
.notes-modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

.inline-form {
  display: inline;
}

.empty-state {
  color: var(--text-secondary);
  padding: 2.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state a {
  color: var(--accent);
  font-weight: 500;
}

/* Section placeholder */
.section-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-top: 1rem;
  color: var(--text-secondary);
}

.section-placeholder ul {
  margin: 0.75rem 0 1rem 1.5rem;
  padding: 0;
}

.section-placeholder li {
  margin-bottom: 0.4rem;
}

.section-placeholder .muted {
  margin-bottom: 0;
}

/* Household tiles */
.household-tiles {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}

.household-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}

.household-tile h2 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
}

.household-tile h3 {
  margin: 1.25rem 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}

.water-reminder {
  padding: 0.75rem 1rem;
  background: var(--accent-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}

.water-reminder p {
  margin: 0 0 0.35rem 0;
}

.water-reminder a {
  font-size: 0.9rem;
}

.link-muted {
  color: var(--muted);
  text-decoration: none;
}

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

.water-add-reading .form-block,
.water-reading-form {
  margin-top: 0.5rem;
}

.water-history {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.water-reading-list {
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
}

.water-reading-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.water-reading-list li:last-child {
  border-bottom: none;
}

.water-reading-value {
  font-weight: 600;
}

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

.water-reading-notes {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Admin */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-section h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}
.admin-section .muted {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.form-inline label { margin: 0; }
.form-inline select,
.form-inline input[type="text"] {
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 12rem;
  background: var(--surface);
  color: var(--text);
}
.admin-list {
  list-style: none;
  margin: 1rem 0 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.admin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  gap: 1rem;
}
.admin-list-form { margin: 0; }

/* Kitchen settings */
.kitchen-settings-section {
  margin-bottom: 2rem;
}

.kitchen-settings-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--text);
}

.kitchen-settings-desc {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.kitchen-settings-add-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.kitchen-settings-add-form label {
  margin: 0;
}

.kitchen-settings-add-form input[type="text"] {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 12rem;
}

.kitchen-settings-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.kitchen-settings-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.kitchen-settings-list-item:last-child {
  border-bottom: none;
}

.kitchen-settings-item-order {
  display: flex;
  gap: 0.2rem;
}

.kitchen-settings-item-order .btn-icon {
  padding: 0.2rem 0.4rem;
  font-size: 0.9rem;
  min-width: auto;
}

.kitchen-settings-item-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
}

.kitchen-settings-item-edit {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.kitchen-settings-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* Meals / What's for supper */
.meals-section { margin-bottom: 1.5rem; }
.meals-section .admin-list { margin-top: 0.5rem; }
.meals-help { margin-bottom: 0.75rem; }
.meals-quick-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.meals-quick-tips span {
  padding: 0.25rem 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.meals-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  color: var(--text-secondary);
}
.meals-loading-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: meals-spin 0.7s linear infinite;
}
@keyframes meals-spin {
  to { transform: rotate(360deg); }
}

.meals-message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.meals-error {
  background: var(--flash-error-bg, #fef2f2);
  border: 1px solid var(--flash-error-border, #fecaca);
  color: var(--flash-error-text, #b91c1c);
}
.meals-stub {
  background: var(--accent-muted);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.meals-saved {
  background: var(--flash-success-bg, #dcfce7);
  border: 1px solid var(--flash-success-border, #86efac);
  color: var(--flash-success-text, #166534);
}
.meals-saved a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.meals-result {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.meals-result-title {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}
.meals-days {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.meals-day-card {
  padding: 0.875rem 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.meals-day-date {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.meals-day-meal {
  margin: 0;
  font-weight: 500;
}
.meals-day-notes,
.meals-day-missing {
  margin: 0.35rem 0 0 0;
  font-size: 0.9rem;
}
.meals-day-recipe {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.meals-recipe-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0.25rem 0;
}
.meals-recipe-ingredients {
  margin: 0 0 0.5rem 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.meals-recipe-instructions {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.meals-shopping-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}
.meals-shopping-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-secondary);
}

/* Recipe Book */
.recipe-book-plans {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.recipe-book-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.recipe-book-new-folder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}
.recipe-book-new-folder input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 12rem;
}
.recipe-book-folder {
  margin-bottom: 1.5rem;
}
.recipe-book-folder-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--text-secondary);
}
.recipe-book-plan-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 1rem 1.25rem;
}

/* Admin family */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.family-members {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.family-member-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.family-member-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.recipe-book-plan-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.recipe-move-select {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  min-width: 8rem;
}
.recipe-book-plan-title {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
}
.recipe-book-plan-date {
  font-size: 0.9rem;
  color: var(--muted);
}
.recipe-book-plan-content {
  padding: 0 1.25rem 1.25rem;
}
.recipe-book-loading {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}
.recipe-book-days {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.recipe-book-day .recipe-add-grocery-btn,
.recipe-book-day .recipe-cook-today-btn {
  margin-top: 0.5rem;
  margin-right: 0.5rem;
}

.meals-day-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.meals-rate-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 0.5rem;
}
.meals-day-rating {
  margin: 0;
  font-size: 1rem;
  color: #eab308;
  letter-spacing: 0.05em;
}
.recipe-rate-btn {
  padding: 0.15rem 0.25rem;
  min-width: 1.5rem;
  font-size: 1rem;
  color: #eab308;
}

/* Recipe add form */
.recipe-add-form .form-group {
  margin-bottom: 1.25rem;
}
.recipe-add-form .form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.recipe-add-form input[type="text"],
.recipe-add-form textarea {
  width: 100%;
  max-width: 32rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.recipe-add-form .form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.ingredients-selector {
  margin-bottom: 0.5rem;
}
.ingredients-selector-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.ingredients-selector-search-wrap {
  max-width: 32rem;
}
.ingredients-selector-search-wrap .ingredients-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.ingredients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  min-height: 2rem;
}
.ingredient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.ingredient-chip-text {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ingredient-chip-remove {
  padding: 0 0.15rem;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.ingredient-chip-remove:hover {
  color: var(--text);
}

/* Footer */
.site-footer {
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Grocery list */
.grocery-section {
  margin-bottom: 2rem;
}

.grocery-categories-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.25rem 0 1rem;
}

.grocery-categories-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.grocery-category-link,
.grocery-categories-manage {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}

.grocery-category-link:hover,
.grocery-categories-manage:hover {
  color: var(--accent);
}

.grocery-category-link.is-active {
  color: var(--accent);
  text-decoration: underline;
}

.grocery-group.is-hidden {
  display: none;
}

.grocery-reorder-toggle-row {
  margin: 0.5rem 0 1rem;
}

.grocery-section-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.grocery-section-title-row .grocery-section-title {
  margin: 0;
}

.grocery-reorder-content.is-hidden {
  display: none;
}

.grocery-section-title-edit {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  margin: 0;
  width: 12rem;
  max-width: 100%;
}

.grocery-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.grocery-group {
  margin-bottom: 1.5rem;
}

.grocery-group:last-child {
  margin-bottom: 0;
}

.grocery-group-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.grocery-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.grocery-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.grocery-list-item:last-child {
  border-bottom: none;
}

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

.grocery-check-form {
  flex-shrink: 0;
}

.grocery-check-btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.grocery-check-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

.grocery-list-item.checked .grocery-check-btn {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.grocery-item-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
}

.grocery-item-meta {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 3rem;
}
.grocery-item-name .grocery-item-qty {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}
.grocery-item-name .grocery-item-price {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.grocery-list-low .grocery-item-meta {
  margin-right: auto;
}

.grocery-add-form {
  margin-bottom: 1rem;
}

.grocery-add-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.grocery-list-select,
.grocery-list-dropdown {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  min-width: 8rem;
}

.search-add-wrap {
  position: relative;
  flex: 1;
  min-width: 12rem;
}

.grocery-add-name {
  width: 100%;
  min-width: 12rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  max-height: 14rem;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.search-results.open {
  display: block;
}

.search-result-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.search-result-item:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

.grocery-add-qty {
  width: 4rem;
  padding: 0.5rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.grocery-add-unit {
  width: 6rem;
  padding: 0.5rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.grocery-categorize-hint {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.grocery-add-category-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.grocery-add-category-label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.grocery-add-category {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  min-width: 8rem;
}

.grocery-add-category-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.grocery-add-category-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.grocery-add-category-inline label {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.grocery-add-category-inline input[type="text"] {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 10rem;
}

.grocery-add-category-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.grocery-add-category-hint a {
  color: var(--accent);
}

.grocery-item-category-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.grocery-item-category-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.grocery-item-category {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  max-width: 10rem;
}

.grocery-empty {
  color: var(--muted);
  font-style: italic;
  padding: 1rem;
  margin: 0;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.grocery-lists-bar {
  margin-bottom: 1.5rem;
}

.grocery-list-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.grocery-list-btn {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.grocery-list-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.grocery-list-btn-active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.grocery-list-add-btn {
  color: var(--text-muted, var(--text-secondary));
  border-style: dashed;
}

.grocery-list-add-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.grocery-add-list-form {
  display: inline;
}

.grocery-list-chooser-wrap {
  margin-bottom: 0.75rem;
}

.grocery-list-combobox {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.grocery-list-input-wrap {
  position: relative;
  min-width: 14rem;
  flex: 1;
}

.grocery-list-combobox .grocery-list-input-wrap input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
}

.grocery-list-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  max-height: 14rem;
  overflow-y: auto;
  z-index: 20;
  display: none;
}

.grocery-list-dropdown.open {
  display: block;
}

.grocery-list-dropdown-empty {
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted, var(--text-secondary));
}

.grocery-list-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.grocery-list-dropdown-item:hover {
  background: var(--surface-hover);
}

.grocery-list-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.grocery-list-tab-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.grocery-list-tab-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted, var(--text-secondary));
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-ghost.btn-danger:hover {
  color: var(--danger, #c00);
  border-color: var(--danger, #c00);
}

.grocery-list-tab {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

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

.grocery-list-tab.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.grocery-list-tab-menu-wrap {
  position: relative;
}

.grocery-list-tab-menu-btn {
  padding: 0.25rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
  min-width: auto;
}

.grocery-list-tab-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  z-index: 25;
  display: none;
  padding: 0.25rem 0;
}

.grocery-list-tab-menu.open {
  display: block;
}

.grocery-list-tab-menu a,
.grocery-list-tab-menu .inline-form {
  display: block;
}

.grocery-list-tab-menu a {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}

.grocery-list-tab-menu a:hover {
  background: var(--surface-hover);
}

.grocery-list-tab-menu .inline-form {
  margin: 0;
  padding: 0;
}

.grocery-menu-item-btn {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  text-align: left;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.grocery-menu-item-btn:hover {
  background: var(--surface-hover);
}

.grocery-menu-item-danger {
  color: var(--danger, #c00);
}

.grocery-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grocery-list-low .grocery-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.grocery-list-item .grocery-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}

/* Responsive helpers */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-compact th,
.table-compact td {
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
}

@media (max-width: 1024px) {
  .container {
    padding: 0 1.25rem;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .kitchen-dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (max-width: 900px) {
  .main {
    padding: 1.75rem 0;
  }

  h1 {
    font-size: 1.6rem;
  }

  .lead {
    font-size: 1rem;
    margin-bottom: 1.25rem;
  }

  .page-header-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14.5px;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .container {
    padding: 0 1rem;
  }

  .site-header .container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
  }

  /* Touch-friendly nav (min ~44px) */
  .nav a,
  .nav-signup {
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-more-wrap {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .nav-more-btn {
    min-height: 2.75rem;
    padding: 0.6rem 1rem;
  }

  .nav-more-menu {
    left: 0;
    right: 0;
    min-width: 0;
    margin-top: 0.35rem;
  }

  .nav-more-menu a {
    padding: 0.75rem 1rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  .theme-toggle {
    margin-left: 0;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
  }

  .logo {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
  }

  .nav a,
  .nav-signup,
  .nav-more-btn,
  .theme-toggle,
  .card {
    -webkit-tap-highlight-color: transparent;
  }

  .main {
    padding: 1.25rem 0;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  }

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

  .page-header-actions .btn {
    min-height: 2.75rem;
  }

  .page-header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
  }

  .cards,
  .cards-four {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .card {
    padding: 1.25rem;
    min-height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .card h2 {
    margin-top: 0;
  }

  .kitchen-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .kitchen-dashboard-customize-actions {
    padding: 0.75rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }

  .grocery-list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .grocery-item-meta {
    white-space: normal;
  }

  .grocery-item-actions {
    width: 100%;
  }

  .grocery-add-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .grocery-add-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .grocery-add-fields > * {
    width: 100%;
  }

  .grocery-add-category-wrap {
    width: 100%;
    justify-content: space-between;
  }

  .grocery-add-category-label {
    flex: 0 0 auto;
  }

  .grocery-add-category {
    flex: 1;
    min-width: 0;
  }

  .grocery-list-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .grocery-section-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .grocery-list-combobox {
    flex-direction: column;
    align-items: stretch;
  }

  .grocery-list-input-wrap {
    min-width: 0;
  }

  .grocery-list-tab {
    font-size: 0.85rem;
  }

  .admin-section {
    padding: 1rem;
  }

  .meals-day-actions {
    flex-wrap: wrap;
  }

  .meals-day-actions .recipe-cook-today-btn {
    width: 100%;
  }

  .meals-rate-label {
    margin-left: 0;
  }

  .notes-modal-box {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .grocery-category-link,
  .grocery-categories-manage {
    padding: 0.5rem 0.6rem;
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
  }

  /* Reduce iOS input zoom */
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="date"],
  input[type="search"],
  select {
    font-size: 16px;
  }

  .table.table-inventory thead {
    display: none;
  }

  .table.table-inventory,
  .table.table-inventory tbody,
  .table.table-inventory tr,
  .table.table-inventory td {
    display: block;
    width: 100%;
  }

  .table.table-inventory {
    border: none;
    box-shadow: none;
    background: none;
  }

  .table.table-inventory tr.inventory-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.9rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .table.table-inventory .cell-name {
    padding-top: 0.2rem;
  }

  .table.table-inventory .cell-name .editable-name {
    font-weight: 600;
  }

  .table.table-inventory tr.inventory-row.row-expired {
    background: rgba(239, 68, 68, 0.08);
  }

  [data-theme="dark"] .table.table-inventory tr.inventory-row.row-expired {
    background: rgba(127, 29, 29, 0.35);
  }

  .table.table-inventory td {
    border-bottom: none;
    padding: 0.45rem 0;
    display: grid;
    grid-template-columns: minmax(7.5rem, 38%) 1fr;
    align-items: center;
    gap: 0.6rem;
  }

  .table.table-inventory td::before {
    content: attr(data-label);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .table.table-inventory .quantity-control {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table.table-inventory .cell-notes,
  .table.table-inventory .cell-menu {
    align-items: center;
  }

  .table.table-inventory .cell-notes button,
  .table.table-inventory .cell-menu button {
    justify-self: start;
  }

  .table.table-inventory .cell-menu {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    padding: 0;
  }

  .table.table-inventory .cell-menu::before {
    content: "";
  }

  .table.table-inventory tr.inventory-row {
    position: relative;
    padding-top: 1.6rem;
  }

  .table.table-inventory .add-row td {
    padding: 0.75rem 0;
    background: var(--bg-subtle);
  }

  .table.table-inventory .add-row td::before {
    content: "";
  }

  .add-row-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .add-row-form input,
  .add-row-form select,
  .add-row-form button {
    width: 100%;
    min-height: 2.75rem;
  }

  .flash-messages {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .flash {
    word-break: break-word;
  }
}

@media (max-width: 540px) {
  .container {
    padding: 0 0.75rem;
  }

  .site-footer {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .site-footer p {
    font-size: 0.8rem;
  }

  .btn {
    padding: 0.55rem 0.9rem;
    min-height: 2.75rem;
  }

  .btn-sm {
    min-height: 2.25rem;
    padding: 0.4rem 0.65rem;
  }

  .grocery-check-btn {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
  }

  .meals-day-card {
    padding: 0.85rem 1rem;
  }

  .kitchen-dashboard-toggle {
    min-height: 2.75rem;
    padding: 0.6rem 1rem;
  }

  h1 {
    font-size: 1.45rem;
  }

  .lead {
    font-size: 0.95rem;
  }
}
