/* Blood Sugar Guide — Diabetes-friendly grocery app */

:root {
  --bg: #0f1412;
  --surface: #1a221e;
  --surface-hover: #232d28;
  --text: #e8edea;
  --text-muted: #8a9a92;
  --accent: #3d9d7a;
  --accent-soft: rgba(61, 157, 122, 0.2);
  --border: #2d3a34;
  --low: #5cb88a;
  --medium: #e8b84a;
  --high: #d96b5b;
  --na: #6b7a85;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.header {
  background: linear-gradient(135deg, var(--surface) 0%, #1e2b24 100%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  transform: translateY(3px);
}

.header-logo {
  display: block;
  max-width: 260px;
  height: auto;
  margin: 0;
}

.logo {
  margin: 0 0 0.25rem 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.auth-btn {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.auth-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
  color: white;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
  margin-bottom: -2px;
  text-align: left;
}

.tab-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.tab-icon svg {
  display: block;
}

.tab-label-wrap {
  display: flex;
  gap: 0.1rem;
}

.tab-label-wrap:has(.tab-subtext) {
  flex-direction: column;
}

.tab-label-wrap:has(.tab-badge) {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
}

.tab-label {
  display: block;
  white-space: nowrap;
}

.tab-subtext {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tab-button.active .tab-subtext {
  color: var(--text-muted);
}

.tab-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  background: var(--border);
  color: var(--text);
  border-radius: 999px;
}

.tab-badge.has-count {
  display: inline-flex;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 3px solid var(--accent);
  margin-bottom: -3px;
  background: var(--accent-soft);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.scroll-to-top-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
  z-index: 10;
}

.scroll-to-top-btn.scroll-to-top-btn--visible {
  opacity: 1;
  pointer-events: auto;
}

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

.add-to-list-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 0.2s, border-color 0.2s;
  z-index: 10;
}

.add-to-list-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
  color: white;
}

.add-more-items-btn {
  padding: 0.6rem 1.25rem;
  min-width: 12rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.add-more-items-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
  color: white;
}

.under-table-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: max-content;
  max-width: 100%;
  margin: 1.5rem auto;
}

.under-table-actions .add-more-items-btn,
.under-table-actions .toggle-custom-btn {
  width: 100%;
  min-width: 12rem;
}

.under-table-actions .toggle-custom-btn {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
}

.under-table-actions .add-custom-item-toggle {
  margin: 0;
  width: 100%;
}

.intro-text {
  margin-bottom: 1.5rem;
  color: var(--text);
  line-height: 1.6;
}

.intro-text p {
  margin: 0 0 0.75rem 0;
}

.intro-text p:last-child {
  margin-bottom: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0;
}

.filter-label {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.category-select {
  font: inherit;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  min-width: 200px;
  line-height: 1.5;
  vertical-align: middle;
  touch-action: manipulation;
  contain: paint;
}

.category-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.search {
  flex: 1;
  min-width: 180px;
  font: inherit;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.search::placeholder {
  color: var(--text-muted);
}

.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.clear-selections-btn {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

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

.view-my-list-btn {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.view-my-list-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
  color: white;
}

.view-my-list-btn .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-my-list-btn .btn-icon svg {
  display: block;
}

/* Hide print-blocked messages on screen; they are shown only when printing (and left empty) */
.print-blocked-message {
  display: none;
}

@media print {
  body.grocery-cart-active *,
  body.food-guide-print-blocked * {
    display: none !important;
  }

  body.grocery-cart-active .print-blocked-message--cart,
  body.food-guide-print-blocked .print-blocked-message--food {
    display: block !important;
    padding: 2rem;
    font-size: 1.1rem;
    line-height: 1.5;
    color: #fff;
    background: #000;
  }
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend-main-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.legend-clear-wrap {
  margin-top: 0.25rem;
}

.legend-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.clear-filter-btn {
  padding: 0.25rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

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

.legend-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.legend-group-gi {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.legend-group-gl {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.legend-group-rec {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  max-width: calc((100% - 1.5rem) / 2);
}

.legend-group-rec .rec-filter-buttons.filter-button-group {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.legend-group-label {
  font-weight: 600;
  color: var(--text);
}

.legend-row-gi-gl {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-start;
}

.legend-row-gi-gl .legend-group-gi,
.legend-row-gi-gl .legend-group-gl {
  flex: 1 1 280px;
  min-width: 0;
}

.legend-row-gi-gl .filter-button-group {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.legend-group-gi .legend-group-label,
.legend-group-gl .legend-group-label,
.legend-group-label-rec {
  color: #fff;
}

.legend-group-gi .segment,
.legend-group-gl .segment {
  color: #fff;
  font-weight: 500;
}

.gi-segmented-bar {
  display: flex;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.gl-segmented-bar {
  display: flex;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.gi-filter-buttons,
.gl-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-button-group {
  gap: 0.5rem;
  max-width: 540px;
  border: none;
  border-radius: 0;
  overflow: visible;
  padding: 0;
}

.filter-button-group .segment {
  flex: 1;
  border: none;
  border-radius: var(--radius);
  border-right: none;
  white-space: nowrap;
}

.filter-button-group .segment:last-child {
  border-right: none;
}

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

.rec-filter-buttons .rec-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  min-height: 1.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  transition: filter 0.2s, box-shadow 0.2s, background-color 0.2s;
  white-space: nowrap;
}

.rec-filter-buttons .rec-segment:hover {
  filter: none;
}

.rec-filter-buttons .rec-segment.rec-allowable {
  background: transparent;
  border-color: var(--low);
  color: var(--low);
}

.rec-filter-buttons .rec-segment.rec-allowable:hover {
  background: rgba(92, 184, 138, 0.15);
}

.rec-filter-buttons .rec-segment.rec-moderation {
  background: transparent;
  border-color: var(--medium);
  color: var(--medium);
}

.rec-filter-buttons .rec-segment.rec-moderation:hover {
  background: rgba(232, 184, 74, 0.15);
}

.rec-filter-buttons .rec-segment.rec-limit {
  background: transparent;
  border-color: var(--high);
  color: var(--high);
}

.rec-filter-buttons .rec-segment.rec-limit:hover {
  background: rgba(217, 107, 91, 0.15);
}

.rec-filter-buttons .rec-segment.active {
  filter: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.rec-filter-buttons .rec-segment.rec-allowable.active {
  background: rgba(92, 184, 138, 0.25);
}

.rec-filter-buttons .rec-segment.rec-moderation.active {
  background: rgba(232, 184, 74, 0.25);
}

.rec-filter-buttons .rec-segment.rec-limit.active {
  background: rgba(217, 107, 91, 0.25);
}

.rec-filter-buttons .rec-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rec-filter-buttons .rec-icon svg {
  display: block;
}

.rec-filter-buttons .rec-text {
  font-weight: 700;
  font-size: 0.9rem;
}

.rec-filter-buttons .rec-segment.rec-allowable .rec-icon,
.rec-filter-buttons .rec-segment.rec-allowable .rec-text {
  color: var(--low);
}

.rec-filter-buttons .rec-segment.rec-moderation .rec-icon,
.rec-filter-buttons .rec-segment.rec-moderation .rec-text {
  color: var(--medium);
}

.rec-filter-buttons .rec-segment.rec-limit .rec-icon,
.rec-filter-buttons .rec-segment.rec-limit .rec-text {
  color: var(--high);
}

.gi-segment-inner,
.gl-segment-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
}

.gi-segment-icon,
.gl-segment-icon {
  display: none;
}

.gi-segment-icon svg,
.gl-segment-icon svg {
  display: block;
}

.gi-segmented-bar .segment,
.gl-segmented-bar .segment,
.gi-filter-buttons .segment,
.gl-filter-buttons .segment {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  user-select: none;
  color: #000;
  transition: opacity 0.2s, filter 0.2s;
  border: none;
  min-height: 1.75rem;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.9), 0 1px 2px rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  border: 2px solid transparent;
}

.gi-segmented-bar .segment:hover,
.gl-segmented-bar .segment:hover,
.gi-filter-buttons .segment:hover,
.gl-filter-buttons .segment:hover {
  filter: brightness(1.1);
  color: #fff;
}

.gi-segmented-bar .segment:hover .segment-label,
.gl-segmented-bar .segment:hover .segment-label,
.gi-filter-buttons .segment:hover .segment-label,
.gl-filter-buttons .segment:hover .segment-label,
.gi-segmented-bar .segment:hover .segment-range,
.gl-segmented-bar .segment:hover .segment-range,
.gi-filter-buttons .segment:hover .segment-range,
.gl-filter-buttons .segment:hover .segment-range {
  color: #fff;
}

.gi-segmented-bar .segment-low,
.gl-segmented-bar .segment-low,
.gi-filter-buttons .segment-low,
.gl-filter-buttons .segment-low {
  /* GI/GL Low: match Recommendation low color, filled */
  background: var(--low);
}

.gi-segmented-bar .segment-medium,
.gl-segmented-bar .segment-medium,
.gi-filter-buttons .segment-medium,
.gl-filter-buttons .segment-medium {
  /* GI/GL Medium: match Recommendation medium color, filled */
  background: var(--medium);
}

.gi-segmented-bar .segment-high,
.gl-segmented-bar .segment-high,
.gi-filter-buttons .segment-high,
.gl-filter-buttons .segment-high {
  /* GI/GL High: match Recommendation high color, filled */
  background: var(--high);
}

.gi-segmented-bar .segment.active,
.gl-segmented-bar .segment.active,
.gi-filter-buttons .segment.active,
.gl-filter-buttons .segment.active {
  filter: brightness(1.15);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Selected state: keep colored background + white outline, text turns white for contrast */
.gi-segmented-bar .segment.active .segment-label,
.gl-segmented-bar .segment.active .segment-label,
.gi-filter-buttons .segment.active .segment-label,
.gl-filter-buttons .segment.active .segment-label,
.gi-segmented-bar .segment.active .segment-range,
.gl-segmented-bar .segment.active .segment-range,
.gi-filter-buttons .segment.active .segment-range,
.gl-filter-buttons .segment.active .segment-range {
  color: #fff;
}

.gi-segmented-bar .segment-label,
.gl-segmented-bar .segment-label,
.gi-filter-buttons .segment-label,
.gl-filter-buttons .segment-label {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: #000;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.95), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.gi-segmented-bar .segment-range,
.gl-segmented-bar .segment-range,
.gi-filter-buttons .segment-range,
.gl-filter-buttons .segment-range {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.95;
  letter-spacing: 0.01em;
  color: #000;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.9), 0 1px 1px rgba(0, 0, 0, 0.12);
}

.gi-filter-buttons .segment,
.gl-filter-buttons .segment {
  flex: 0 0 auto;
}

.filter-button-group .segment {
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-filter {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s, opacity 0.2s;
  user-select: none;
}

.legend-filter:hover {
  background-color: var(--surface-hover);
}

.legend-filter.active {
  background-color: var(--surface-hover);
  opacity: 1;
  font-weight: 500;
}

.legend-filter:not(.active) {
  opacity: 0.7;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-filter.active .legend-dot {
  width: 16px;
  height: 16px;
  box-shadow: 0 0 0 2px var(--border);
}

.legend-dot.low { background: var(--low); }
.legend-dot.medium { background: var(--medium); }
.legend-dot.high { background: var(--high); }
.legend-dot.na { background: var(--na); }

.legend-sep {
  color: var(--border);
  margin: 0 0.25rem;
}

.category-cards {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.category-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.category-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
}

.category-heading-row h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.remove-category-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.remove-category-btn:hover {
  color: var(--high);
  background: rgba(217, 107, 91, 0.15);
  border-color: var(--high);
}

.remove-category-btn .trash-icon {
  display: block;
}

.items-table-wrap {
  overflow-x: auto;
}

.items-table {
  width: 100%;
  min-width: 720px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.items-table .col-item { width: 20%; }
.items-table .col-serving { width: 22%; }
.items-table .col-gi { width: 11%; }
.items-table .col-gl { width: 11%; }
.items-table .col-sodium { width: 11%; }
.items-table .col-rec { width: 14%; }
.items-table .col-add { width: 11%; }
.items-table .col-quantity { width: 25%; }
.items-table .col-remove { width: 15%; }

/* Grocery list specific column widths */
#grocery-list-items .items-table .col-indicator { width: 4%; }
#grocery-list-items .items-table .col-item { width: 40%; }
#grocery-list-items .items-table .col-quantity { width: 20%; }
#grocery-list-items .items-table .col-type { width: 20%; }
#grocery-list-items .items-table .col-remove { width: 16%; }

.rec-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rec-indicator.rec-allowable {
  background-color: var(--low);
}

.rec-indicator.rec-moderation {
  background-color: var(--medium);
}

.rec-indicator.rec-limit {
  background-color: var(--high);
}

.rec-indicator.rec-custom {
  background-color: var(--border);
}

.items-table .indicator {
  text-align: center;
  padding-left: 1rem;
  padding-right: 0.5rem;
}

.items-table th,
.items-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-break: break-word;
}

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

.items-table th.sortable-th {
  cursor: pointer;
  padding-right: 1.25rem;
  user-select: none;
}

.items-table th.sortable-th:hover {
  color: var(--text);
}

.items-table th.sortable-th .sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.9;
}

.items-table th.sortable-th.sort-active {
  color: var(--accent);
}

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

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

.items-table .serving {
  color: var(--text-muted);
  white-space: nowrap;
}

.items-table .gi,
.items-table .gl {
  font-family: var(--font-mono);
  font-weight: 500;
  min-width: 3.5rem;
}

.gi-low, .gl-low { color: var(--low); }
.gi-medium, .gl-medium { color: var(--medium); }
.gi-high, .gl-high { color: var(--high); }
.gi-na, .gl-na { color: var(--na); }

.items-table .rec {
  white-space: nowrap;
}

.items-table .rec .rec-cell-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.items-table .rec .rec-cell-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.items-table .rec .rec-cell-icon svg {
  display: block;
}

.rec-allowable { color: var(--low); font-weight: 500; }
.rec-moderation { color: var(--medium); font-weight: 500; }
.rec-limit { color: var(--high); font-weight: 500; }

.legend-filter-rec {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s, opacity 0.2s;
  user-select: none;
}

.legend-filter-rec:hover {
  background-color: var(--surface-hover);
}

.legend-filter-rec.active {
  background-color: var(--surface-hover);
  opacity: 1;
  font-weight: 600;
}

.legend-filter-rec:not(.active) {
  opacity: 0.7;
}

.items-table .sodium {
  white-space: nowrap;
  font-weight: 500;
}
.sodium-low { color: var(--low); }
.sodium-moderate { color: var(--medium); }
.sodium-high { color: var(--high); }

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  display: none;
}

.empty-state p {
  margin-bottom: 1rem;
}

.add-from-food-guide-btn {
  padding: 0.6rem 1.25rem;
  min-width: 12rem;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.add-from-food-guide-btn:hover {
  background: var(--accent-soft, rgba(61, 157, 122, 0.2));
  border-color: var(--accent-hover, #2d7a4f);
  color: var(--text);
}

.grocery-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.grocery-list-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

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

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

.list-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

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

.list-menu-btn[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.list-menu-icon {
  display: flex;
  line-height: 0;
}

.list-menu-icon svg {
  display: block;
}

.list-menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  min-width: 14rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-menu-dropdown[hidden] {
  display: none;
}

.list-menu-item {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.list-menu-item:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.list-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.list-menu-item.save-list-btn {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(45, 122, 79, 0.25);
}

.list-menu-item.save-list-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(45, 122, 79, 0.35);
}

.export-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.export-btn:hover:not(:disabled) {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.clear-btn {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

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

.clear-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.save-list-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.save-list-btn:hover:not(:disabled) {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.save-list-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.start-shopping-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.start-shopping-btn:hover:not(:disabled) {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.start-shopping-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* Shopping mode tab */
.shopping-header {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.shopping-header-main h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.shopping-header-main .shopping-subtitle {
  margin: 0 0 0.35rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
}

.shopping-header-main .shopping-intro {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.shopping-header-main {
  flex: 1;
}

.shopping-header-actions {
  display: flex;
  align-items: flex-start;
}

.shopping-list-container {
  margin-top: 1rem;
}

.shopping-list-container .category-section {
  margin-bottom: 1.5rem;
}

/* Purchased section heading uses same row as Current List; match other category headers */
#shopping-list-container .category-heading-row .purchased-heading {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

#shopping-list-container .items-table-shopping .col-checkbox { width: 4%; }
#shopping-list-container .items-table-shopping .col-item { width: 34%; }
#shopping-list-container .items-table-shopping .col-status { width: 8%; }
#shopping-list-container .items-table-shopping .col-quantity { width: 18%; }
#shopping-list-container .items-table-shopping .col-type { width: 20%; }
#shopping-list-container .items-table-shopping .col-remove { width: 16%; }

#shopping-list-container .items-table-shopping .indicator {
  text-align: center;
  vertical-align: middle;
}

#shopping-list-container .items-table-shopping .status-dot {
  text-align: center;
  vertical-align: middle;
}

/* To buy: theme-matched checkbox, green checkmark when checked, transparent background */
#shopping-list-container .category-section .shopping-purchased-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  vertical-align: middle;
  transition: border-color 0.2s, background 0.2s;
}

#shopping-list-container .category-section .shopping-purchased-cb:hover {
  border-color: var(--text-muted);
}

#shopping-list-container .category-section .shopping-purchased-cb:checked {
  border-color: var(--accent);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d9d7a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 1rem 1rem;
  background-position: center;
  background-repeat: no-repeat;
}

/* Purchased section: same as To buy — green border and checkmark, transparent when checked */
#shopping-list-container .purchased-section .shopping-purchased-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  vertical-align: middle;
  transition: border-color 0.2s, background 0.2s;
}

#shopping-list-container .purchased-section .shopping-purchased-cb:hover {
  border-color: var(--text-muted);
}

#shopping-list-container .purchased-section .shopping-purchased-cb:checked {
  border-color: var(--accent);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d9d7a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 1rem 1rem;
  background-position: center;
  background-repeat: no-repeat;
}

.purchased-section {
  margin-top: 1.5rem;
  padding: 1rem 0;
  padding-top: 0.4rem;
  border-top: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

#shopping-list-container .purchased-section .category-heading-row {
  margin-bottom: 0.75rem;
  padding: 0.5rem 1rem 0.25rem;
  background: transparent;
  border-bottom: none;
}

#shopping-list-container .purchased-section .purchased-heading {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
}

/* Tighter spacing within the Purchased table to match To buy tables (keep horizontal padding consistent) */
#shopping-list-container .purchased-section .items-table-shopping th,
#shopping-list-container .purchased-section .items-table-shopping td {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

#shopping-list-container .purchased-section .items-table-shopping thead th {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

/* Standalone purchased heading (e.g. outside shopping row); overridden in shopping by rule above */
.purchased-heading {
  margin: 0 0 0.75rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
}

.purchased-row {
  color: var(--text-muted);
}

.purchased-row td {
  text-decoration: line-through;
}

.saved-lists-header {
  margin-bottom: 1rem;
}

.saved-lists-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem 0;
}

.saved-lists-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.saved-lists-continue-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.saved-lists-continue-banner.hidden {
  display: none;
}

.saved-lists-continue-text {
  color: var(--text);
  font-size: 0.95rem;
}

.saved-lists-continue-btn {
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.saved-lists-continue-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.saved-lists-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.saved-lists-empty {
  margin-top: 1rem;
}

.saved-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.saved-list-card.saved-list-card--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow);
}

@keyframes savedListNewIn {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes savedListDuplicateFlash {
  0% {
    box-shadow: 0 0 0 3px var(--accent), var(--shadow);
    background: var(--accent-soft);
  }
  60% {
    box-shadow: 0 0 0 2px var(--accent), var(--shadow);
    background: var(--accent-soft);
  }
  100% {
    box-shadow: var(--shadow);
    background: var(--surface);
  }
}

.saved-list-card.saved-list-card--new {
  animation: savedListNewIn 0.4s ease-out;
}

.saved-list-card.saved-list-card--highlight {
  animation: savedListDuplicateFlash 1.5s ease-out forwards;
}

.saved-list-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.saved-list-date {
  font-weight: 500;
  color: var(--text);
}

.saved-list-name-input {
  flex: 1;
  min-width: 120px;
  max-width: 280px;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.saved-list-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.saved-list-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.saved-list-last-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 0.25rem;
}

.saved-list-active-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  margin-left: 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.saved-list-name-saved-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  pointer-events: none;
}

.saved-list-name-saved-check.show {
  opacity: 1;
  transform: scale(1);
}

.saved-list-name-saved-check svg {
  display: block;
}

.saved-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.saved-list-btn {
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.saved-list-btn.save-name-btn {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.saved-list-btn.save-name-btn:hover {
  background: rgba(61, 157, 122, 0.3);
  border-color: var(--accent-hover, #2d7a4f);
  color: white;
}

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

.saved-list-btn.use-saved {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.saved-list-btn.use-saved:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.saved-list-btn.export-saved-pdf {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.saved-list-btn.export-saved-pdf:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.saved-list-btn.remove-saved-icon {
  margin-left: auto;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.saved-list-btn.remove-saved-icon:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--accent);
}

.add-custom-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.add-custom-item h3 {
  margin: 0;
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

.custom-item-form {
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.add-custom-item-toggle {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.toggle-custom-btn {
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.toggle-custom-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-hover, #2d7a4f);
  color: var(--accent-hover, #2d7a4f);
}

.custom-item-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.custom-item-input.quantity-input {
  flex: 0 0 auto;
  min-width: 150px;
  max-width: 200px;
}

.quantity-stepper-form {
  flex: 0 0 auto;
}

.custom-item-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.custom-item-select {
  min-width: 180px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.custom-item-select.type-select {
  min-width: 150px;
  max-width: 200px;
}

.custom-item-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.add-custom-btn {
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.add-custom-btn:hover {
  background: var(--accent-hover, #2d7a4f);
}

.grocery-list-items {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.add-btn, .remove-btn {
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  min-width: 2rem;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

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

.add-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.add-btn-icon svg {
  display: block;
}

.add-btn.added {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  cursor: default;
}

.add-btn.added .add-btn-icon {
  color: white;
}

.add-btn .add-btn-icon-check {
  display: none;
}

.add-btn.added .add-btn-icon-plus {
  display: none;
}

.add-btn.added .add-btn-icon-check {
  display: inline-flex;
}

.add-btn.added:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  min-width: 2rem;
  padding: 0.4rem 0.8rem;
  background: #dc3545;
  border: 1px solid #dc3545;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.remove-btn:hover {
  background: #c82333;
  border-color: #c82333;
}

.remove-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.remove-btn-icon svg {
  display: block;
}

.items-table .rec {
  padding-right: 0.15rem;
}

.items-table .add {
  padding-left: 0.15rem;
}

.items-table .add,
.items-table .remove {
  text-align: center;
}

.items-table .quantity {
  text-align: center;
}

.quantity-input {
  width: 100%;
  max-width: 120px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: center;
  transition: border-color 0.2s, background-color 0.2s;
}

.quantity-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-hover);
}

.quantity-input::placeholder {
  color: var(--text-muted);
}

/* Quantity stepper: minus, value, plus in a single rounded bar */
.quantity-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  max-width: 120px;
}

.stepper-btn {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 400;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.stepper-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.stepper-btn:active {
  background: var(--border);
}

.stepper-btn:focus {
  outline: none;
}

.stepper-btn:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.stepper-value {
  min-width: 2rem;
  padding: 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  color: var(--text);
}

.stepper-value-input {
  width: 2.5rem;
  min-width: 2.5rem;
  padding: 0.4rem 0.25rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper-value-input::-webkit-outer-spin-button,
.stepper-value-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.type-select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.type-select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-hover);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.items-table .type {
  text-align: center;
}

.footer {
  max-width: 1100px;
  margin: 2rem auto 0;
  padding: 1rem 0 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.footer p {
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.footer-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.legal-page {
  max-width: 720px;
  margin: 0;
  padding: 1rem 0;
}

.legal-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.legal-page h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.legal-page h3 {
  font-size: 1.05rem;
  margin: 1rem 0 0.35rem;
  color: var(--text);
}

.legal-page p {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 0.95rem;
}

.legal-page ul {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
  color: var(--text);
  font-size: 0.95rem;
}

.legal-page li {
  margin-bottom: 0.25rem;
}

.legal-page a {
  color: var(--accent);
  text-decoration: none;
}

.legal-page a:hover {
  text-decoration: underline;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.logo-link:hover {
  text-decoration: none;
}

.login-page {
  max-width: 400px;
  margin: 0;
  padding: 1rem 0;
}

.login-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.login-page h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.login-intro {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.login-form label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: var(--text);
}

.login-form input {
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

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

.login-submit-btn {
  margin-top: 1rem;
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
}

.login-submit-btn:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.login-message {
  display: none;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--surface-hover);
  color: var(--text);
}

.login-message-error {
  background: rgba(200, 80, 80, 0.15);
  color: var(--high, #c55);
}

.login-back {
  margin-top: 2rem;
  font-size: 0.95rem;
}

.login-back a {
  color: var(--accent);
  text-decoration: none;
}

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

/* Login layout: two-column + Welcome Back card (login.html only) */
.login-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
}

.login-layout .login-branding {
  grid-column: 1;
  grid-row: 1;
  background: linear-gradient(135deg, var(--surface) 0%, #1e2b24 100%);
  padding: 2rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 0;
}

.login-branding-logo-link {
  color: inherit;
  text-decoration: none;
}

.login-branding-logo-link:hover {
  text-decoration: none;
}

.login-branding-logo {
  display: block;
  max-width: 280px;
  height: auto;
  margin: 0;
}

.login-hero {
  margin-top: 1.5rem;
  max-width: 420px;
  text-align: left;
}

.login-hero-heading {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.login-hero-heading span {
  color: var(--low);
}

.login-hero-subtitle {
  margin: 0 0 1.5rem;
  font-size: 0.98rem;
  color: var(--text-muted);
}

.login-hero-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem;
}

.login-hero-list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.login-hero-check {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--low);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #0f1412;
  flex-shrink: 0;
}

.login-hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.login-hero-metric {
  flex: 1 1 120px;
  min-width: 0;
}

.login-hero-metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.login-hero-metric-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.login-hero-trust {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-layout .login-right {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 0;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #f5f6f5;
  color: #1a221e;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.login-card-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  text-align: center;
  color: #1a221e;
}

.login-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.login-tab {
  flex: 1;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  color: #6b7a72;
  cursor: pointer;
  border-radius: 0;
}

.login-tab:hover {
  color: #1a221e;
}

.login-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.login-card-message {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.06);
  color: #1a221e;
}

.login-card-message.login-message-error {
  background: rgba(200, 80, 80, 0.15);
  color: #b54a4a;
}

.login-panel {
  margin-bottom: 1rem;
}

.login-panel-hidden {
  display: none !important;
}

.login-form .login-label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: #1a221e;
}

.login-form .login-label:first-child {
  margin-top: 0;
}

.input-wrap {
  position: relative;
  margin-bottom: 0.25rem;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7a72;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-icon svg {
  display: block;
}

.login-card .login-input {
  width: 100%;
  max-width: none;
  padding: 0.6rem 0.75rem 0.6rem 40px;
  font: inherit;
  font-size: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  background: #fff;
  color: #1a221e;
  box-sizing: border-box;
}

.login-card .login-input::placeholder {
  color: #8a9a92;
}

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

.login-hint {
  font-size: 0.8rem;
  color: #6b7a72;
  margin: 0 0 0.75rem;
}

.login-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.login-remember span {
  color: var(--accent);
}

.login-remember input {
  width: auto;
  margin: 0;
}

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

.login-forgot-link:hover {
  text-decoration: underline;
}

.login-btn {
  width: 100%;
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  box-sizing: border-box;
}

.login-btn-primary {
  margin-top: 0.25rem;
  margin-bottom: 1rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.login-btn-primary:hover {
  background: var(--accent-hover, #2d7a4f);
  border-color: var(--accent-hover, #2d7a4f);
}

.login-btn-google {
  background: #fff;
  color: #1a221e;
  border: 1px solid rgba(0, 0, 0, 0.15);
  margin-bottom: 1rem;
}

.login-btn-google:hover {
  background: #f0f2f0;
  border-color: rgba(0, 0, 0, 0.2);
}

.login-btn-google-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.login-divider-line {
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.12);
}

.login-divider-text {
  font-size: 0.8rem;
  color: #6b7a72;
  font-weight: 500;
}

.login-magic-link-wrap {
  margin-bottom: 1rem;
}

.login-magic-link-toggle {
  font: inherit;
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.login-magic-link-toggle:hover {
  text-decoration: underline;
}

.login-magic-link-block {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.login-magic-link-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #6b7a72;
  min-height: 1.25em;
}

.login-magic-link-message-success {
  color: var(--accent);
  font-weight: 500;
}

.login-back {
  margin-top: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.login-back a {
  color: var(--accent);
  text-decoration: none;
}

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

.login-card-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.8rem;
  text-align: center;
  color: #6b7a72;
}

.login-card-footer-text {
  margin: 0;
}

.login-card-footer a {
  color: var(--accent);
  text-decoration: none;
}

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

.login-card-footer-sep {
  margin: 0 0.35rem;
  color: #8a9a92;
}

.login-layout-footer {
  grid-column: 1 / -1;
  grid-row: 2;
}

@media (max-width: 768px) {
  .login-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .login-layout .login-branding {
    grid-column: 1;
    grid-row: 1;
    padding: 1.5rem 1.5rem;
    min-height: auto;
  }

  .login-branding-logo {
    max-width: 220px;
  }

  .login-branding-tagline,
  .login-branding-copy {
    font-size: 0.9rem;
  }

  .login-layout .login-right {
    grid-column: 1;
    grid-row: 2;
    padding: 1.5rem;
    align-items: flex-start;
  }

  .login-card {
    padding: 1.5rem;
  }

  .login-layout-footer {
    grid-column: 1;
    grid-row: 3;
  }

  .header-inner {
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
  }

  .header-logo {
    max-width: 160px;
  }

  /* Tabs: wrap so all appear on screen without horizontal scroll */
  .tabs {
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
  }

  .tab-button {
    flex: 1 1 calc(50% - 0.2rem);
    min-width: 0;
    padding: 0.5rem 0.5rem;
    font-size: 0.85rem;
    text-align: left;
  }

  .tab-icon svg {
    width: 18px;
    height: 18px;
  }

  .tab-subtext {
    font-size: 0.7rem;
  }

  .main {
    padding-top: 0.75rem;
  }

  #food-guide-panel .items-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #food-guide-panel .items-table {
    min-width: 0;
  }

  #food-guide-panel .items-table .col-item {
    width: 40%;
  }

  #food-guide-panel .items-table col.col-serving,
  #food-guide-panel .items-table col.col-sodium {
    display: none;
  }

  #food-guide-panel .items-table th:nth-child(2),
  #food-guide-panel .items-table td:nth-child(2),
  #food-guide-panel .items-table th:nth-child(5),
  #food-guide-panel .items-table td:nth-child(5) {
    display: none;
  }

  #food-guide-panel .items-table .col-gi { width: 14%; }
  #food-guide-panel .items-table .col-gl { width: 14%; }
  #food-guide-panel .items-table .col-rec { width: 22%; min-width: 4.5rem; }
  #food-guide-panel .items-table .col-add { width: 14%; min-width: 3rem; }

  #food-guide-panel .items-table th {
    white-space: nowrap;
    font-size: 0.7rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    text-align: left;
  }

  #food-guide-panel .items-table th:nth-child(1),
  #food-guide-panel .items-table th:nth-child(3),
  #food-guide-panel .items-table th:nth-child(4),
  #food-guide-panel .items-table th:nth-child(6) {
    text-align: left;
  }

  #food-guide-panel .items-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    text-align: left;
  }

  #food-guide-panel .items-table td:nth-child(1),
  #food-guide-panel .items-table td:nth-child(3),
  #food-guide-panel .items-table td:nth-child(4),
  #food-guide-panel .items-table td:nth-child(6) {
    text-align: left;
  }

  #food-guide-panel .items-table .add-btn {
    padding: 0.4rem;
    min-width: 2.25rem;
  }

  #food-guide-panel .items-table td:first-child {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
  }

  #food-guide-panel .items-table td:nth-child(6) {
    white-space: nowrap;
    word-break: keep-all;
    padding-right: 1.25rem;
  }

  #food-guide-panel .items-table td:nth-child(7) {
    padding-left: 0.5rem;
    min-width: 3rem;
    text-align: center;
  }

  #food-guide-panel .items-table td:nth-child(3),
  #food-guide-panel .items-table td:nth-child(4),
  #food-guide-panel .items-table td:nth-child(7) {
    white-space: nowrap;
  }

  .filters {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filters .category-select,
  .filters .search {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  .filters .search {
    flex: none;
  }

  .filters .clear-selections-btn,
  .filters .view-my-list-btn {
    align-self: flex-start;
  }

  /* Mobile: force View Grocery Cart + Clear cart onto same row, equal width & height */
  .filters .view-my-list-btn,
  .filters .clear-selections-btn {
    flex: 0 0 auto;
    max-width: none;
    white-space: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .filters .view-my-list-btn {
    flex-basis: 68%;
    max-width: 68%;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
  }

  .filters .clear-selections-btn {
    flex-basis: 30%;
    max-width: 30%;
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
  }

  .legend {
    margin-top: 1rem;
    margin-bottom: 1rem;
    gap: 1rem;
    font-size: 0.9rem;
  }

  .legend-group-rec {
    max-width: 100%;
  }

  .legend-group {
    align-items: center;
    gap: 0.5rem 0.75rem;
  }

  .legend-group strong {
    flex-basis: 100%;
    width: 100%;
    margin-bottom: 0.15rem;
    color: var(--text);
    font-size: 0.9rem;
  }

  .legend-filter,
  .legend-filter-rec {
    padding: 0.5rem 0.75rem;
    min-height: 2.5rem;
  }

  .gi-filter-buttons,
  .gl-filter-buttons {
    flex-wrap: nowrap;
  }

  .gi-filter-buttons .legend-filter,
  .gl-filter-buttons .legend-filter {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.4rem 0.35rem;
    font-size: 0.85rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* On mobile, show text-only GI/GL chips with wrapped labels */
  .gi-segment-inner,
  .gl-segment-inner {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
  }

  .gi-segment-icon,
  .gl-segment-icon {
    display: none;
  }

  .gi-filter-buttons .segment-label,
  .gl-filter-buttons .segment-label {
    display: block;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    max-width: 100%;
  }

  .gi-filter-buttons .segment-range,
  .gl-filter-buttons .segment-range {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 1;
  }

  /* Current List header buttons - fit on mobile without horizontal scroll */
  .grocery-list-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .grocery-list-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .grocery-list-actions > .start-shopping-btn {
    flex: 1 1 calc(100% - 2.75rem - 0.75rem);
    min-width: 0;
  }

  /* Grocery List: fit table to viewport width (no horizontal scroll) */
  #grocery-list-items .items-table-wrap {
    overflow-x: visible;
  }

  #grocery-list-items .items-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    font-size: 0.85rem;
  }

  #grocery-list-items .items-table .col-indicator { width: 5%; }
  #grocery-list-items .items-table .col-item { width: 32%; }
  #grocery-list-items .items-table .col-quantity { width: 14%; }
  #grocery-list-items .items-table .col-type { width: 29%; }
  #grocery-list-items .items-table .col-remove { width: 20%; }

  #grocery-list-items .items-table th,
  #grocery-list-items .items-table td {
    padding: 0.45rem 0.35rem;
    word-break: break-word;
  }

  #grocery-list-items .items-table th {
    white-space: nowrap;
    font-size: 0.7rem;
  }

  #grocery-list-items .quantity-input {
    max-width: none;
    min-width: 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.85rem;
  }

  #grocery-list-items .quantity-stepper {
    max-width: none;
    width: 100%;
  }

  #grocery-list-items .stepper-btn {
    width: 1.6rem;
    height: 1.65rem;
    font-size: 0.95rem;
  }

  #grocery-list-items .stepper-value {
    min-width: 1.25rem;
    padding: 0 0.2rem;
    font-size: 0.8rem;
  }

  #grocery-list-items .type-select {
    min-width: 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.85rem;
  }

  #grocery-list-items .items-table .remove-btn {
    padding: 0.35rem;
    min-width: 1.75rem;
    min-height: 1.75rem;
  }

  #grocery-list-items .items-table .remove-btn-icon svg {
    width: 12px;
    height: 12px;
  }

  /* Shopping tab: fit table to viewport width (no horizontal scroll) */
  #shopping-list-container .items-table-wrap {
    overflow-x: visible;
  }

  #shopping-list-container .items-table-shopping {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    font-size: 0.85rem;
  }

  #shopping-list-container .items-table-shopping .col-checkbox { width: 5%; }
  #shopping-list-container .items-table-shopping .col-item { width: 32%; }
  #shopping-list-container .items-table-shopping .col-status { width: 0; }
  #shopping-list-container .items-table-shopping .col-quantity { width: 14%; }
  #shopping-list-container .items-table-shopping .col-type { width: 29%; }
  #shopping-list-container .items-table-shopping .col-remove { width: 20%; }

  /* Hide Type column on mobile; give more space to Qty */
  #shopping-list-container .items-table-shopping .col-type,
  #shopping-list-container .items-table-shopping th.type,
  #shopping-list-container .items-table-shopping td.type {
    display: none;
  }
  #shopping-list-container .items-table-shopping .col-item { width: 40%; }
  #shopping-list-container .items-table-shopping .col-quantity { width: 28%; }
  #shopping-list-container .items-table-shopping .col-remove { width: 22%; }

  #shopping-list-container .items-table-shopping th,
  #shopping-list-container .items-table-shopping td {
    padding: 0.45rem 0.35rem;
    word-break: break-word;
  }

  #shopping-list-container .items-table-shopping th {
    white-space: nowrap;
    font-size: 0.7rem;
  }

  #shopping-list-container .category-section .shopping-purchased-cb {
    width: 1.1rem;
    height: 1.1rem;
  }

  /* Align checkboxes with item text on mobile: vertical center + horizontal left */
  #shopping-list-container .items-table-shopping .indicator {
    vertical-align: middle;
    text-align: left;
    padding-right: 1rem;
  }

  #shopping-list-container .items-table-shopping .indicator .shopping-purchased-cb {
    margin: 0;
    vertical-align: middle;
    display: inline-block;
  }

  #shopping-list-container .items-table-shopping tbody td {
    vertical-align: middle;
  }

  #shopping-list-container .items-table-shopping td:nth-child(2) {
    padding-left: 1rem;
    line-height: 1.35;
  }

  #shopping-list-container .items-table-shopping th:nth-child(2) {
    padding-left: 1rem;
    vertical-align: middle;
  }

  #shopping-list-container .items-table-shopping .quantity-input {
    max-width: none;
    min-width: 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.85rem;
  }

  #shopping-list-container .items-table-shopping .type-select {
    min-width: 0;
    padding: 0.35rem 0.4rem;
    font-size: 0.85rem;
  }

  /* Hide Status dot column on mobile for Grocery Cart / Shopping */
  #shopping-list-container .items-table-shopping .col-status,
  #shopping-list-container .items-table-shopping th.status,
  #shopping-list-container .items-table-shopping td.status-dot {
    display: none;
  }

  #shopping-list-container .items-table-shopping .quantity-stepper {
    max-width: none;
    width: 100%;
  }

  #shopping-list-container .items-table-shopping .stepper-btn {
    width: 1.6rem;
    height: 1.65rem;
    font-size: 0.95rem;
  }

  #shopping-list-container .items-table-shopping .stepper-value {
    min-width: 1.25rem;
    padding: 0 0.2rem;
    font-size: 0.8rem;
  }

  #shopping-list-container .items-table-shopping .remove-btn {
    padding: 0.35rem;
    min-width: 1.75rem;
    min-height: 1.75rem;
  }

  #shopping-list-container .items-table-shopping .remove-btn-icon svg {
    width: 12px;
    height: 12px;
  }

  #shopping-list-container .purchased-section .items-table-shopping th,
  #shopping-list-container .purchased-section .items-table-shopping td {
    padding-top: 0.45rem;
    padding-bottom: 0.35rem;
  }

  #shopping-list-container .purchased-section {
    padding: 0.6rem 0 1rem;
    padding-top: 0.35rem;
    margin-top: 1.5rem;
  }

  /* Checkmark centering inside Purchased checkboxes on mobile */
  #shopping-list-container .purchased-section .shopping-purchased-cb:checked {
    background-position: 50% 50%;
    background-size: 0.95rem 0.95rem;
  }

  /* Grocery Cart: keep burger menu dropdown in view (align right so it opens left) */
  #shopping-panel .list-menu-dropdown {
    left: auto;
    right: 0;
  }

  /* Saved Grocery Lists: keep date on screen (no overflow) */
  #saved-lists-panel .saved-list-name-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #saved-lists-panel .saved-list-name-input {
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
  }

  #saved-lists-panel .saved-list-last-updated {
    flex-basis: 100%;
    margin-left: 0;
    margin-top: 0.15rem;
  }
}

@media (max-width: 600px) {
  .items-table .gi { min-width: 2.5rem; }
  .items-table .gl { min-width: 2.5rem; }
}
