:root {
  --primary: #1976D2;
  --primary-dark: #1565C0;
  --primary-light: #BBDEFB;
  --bg: #F4F6F9;
  --bg2: #FFFFFF;
  --bg3: #EDF1F6;
  --card: #FFFFFF;
  --card2: #F8FAFC;
  --border: #E2E8F0;
  --text: #1E293B;
  --text2: #64748B;
  --text3: #94A3B8;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --nav-height: 86px;
  --header-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

#app { height: 100%; display: flex; flex-direction: column; }

.screen { height: 100%; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.screen.active { display: flex; }

/* Auth */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.auth-logo { text-align: center; margin-bottom: 36px; }
.logo-icon { font-size: 56px; margin-bottom: 8px; color: var(--primary); line-height: 1; }
.logo-icon i { font-size: inherit; }
.auth-logo h1 { font-size: 32px; font-weight: 700; color: var(--primary); }
.auth-logo p { color: var(--text2); margin-top: 4px; }
.auth-tabs {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form.hidden { display: none; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 14px; font-weight: 500; color: var(--text2); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 12px; color: var(--danger); margin-top: 6px; }
.catalog-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  box-shadow: var(--shadow);
}
.catalog-search i { color: var(--text3); font-size: 18px; }
.catalog-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  padding: 12px 0;
  font: inherit;
  color: var(--text);
}
.session-count,
.bulk-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.barcode-video-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #000;
  aspect-ratio: 4 / 3;
  border: 2px solid transparent;
}
.barcode-video-wrap.scanning { border-color: var(--warning); }
.barcode-video-wrap.found { border-color: var(--primary); }
.barcode-video-wrap.failed { border-color: var(--danger); }
.barcode-video-wrap::after {
  content: '';
  position: absolute;
  left: 5%;
  right: 5%;
  top: 32%;
  height: 34%;
  border: 2px solid rgba(255,255,255,0.82);
  border-radius: 8px;
  pointer-events: none;
  z-index: 2;
}
.barcode-video-wrap.scanning::after { border-color: var(--warning); }
.barcode-video-wrap.found::after { border-color: var(--primary); box-shadow: 0 0 0 999px rgba(34,197,94,0.08); }
.barcode-video-wrap.failed::after { border-color: var(--danger); }
.barcode-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.barcode-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.barcode-input-row .btn {
  padding-left: 12px;
  padding-right: 12px;
}
.barcode-lookup-status {
  min-height: 18px;
  color: var(--text3);
}
.barcode-lookup-status.info { color: var(--text2); }
.barcode-lookup-status.success { color: var(--primary); }
.barcode-lookup-status.error { color: var(--danger); }
.barcode-feedback {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  padding: 10px 12px;
}
.barcode-feedback-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.barcode-feedback-log {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text3);
  font-size: 12px;
}
.barcode-feedback-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
}
.barcode-feedback-row span {
  color: var(--text3);
  font-weight: 600;
}
.barcode-feedback-row.success { color: var(--primary); }
.barcode-feedback-row.warn { color: var(--warning); }
.barcode-feedback-row.error { color: var(--danger); }
.barcode-detail-prompt {
  border: 1.5px solid rgba(34, 197, 94, 0.32);
  background: rgba(34, 197, 94, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.barcode-detail-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}
.barcode-detail-head i {
  color: var(--primary);
  font-size: 22px;
}
.barcode-detail-head strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}
.barcode-detail-head span {
  display: block;
  color: var(--text2);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.35;
}
#barcode-reader,
#quagga-reader,
#barcode-reader video,
#quagga-reader video,
#quagga-reader canvas {
  width: 100% !important;
  height: 100% !important;
}
#barcode-reader,
#quagga-reader {
  min-height: 100%;
}
#quagga-reader canvas.drawingBuffer {
  position: absolute;
  inset: 0;
  z-index: 1;
}
#barcode-reader__scan_region {
  height: 100%;
}
#barcode-reader__dashboard,
#barcode-reader__header_message {
  display: none !important;
}
.barcode-scan-status {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  z-index: 3;
}
.barcode-video-wrap.found .barcode-scan-status { background: rgba(34,197,94,0.92); }
.barcode-video-wrap.failed .barcode-scan-status { background: rgba(239,68,68,0.92); }
.form-error { color: var(--danger); font-size: 14px; padding: 8px 12px; background: rgba(239,68,68,0.08); border-radius: var(--radius-sm); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-height: 44px;
  white-space: nowrap;
}
.btn i { font-size: 17px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-sm i { font-size: 15px; }
.btn-icon { padding: 10px; min-width: 44px; min-height: 44px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn i { font-size: 22px; }
.icon-btn:hover { background: var(--bg3); }

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 8px; }
#page-title { font-size: 18px; font-weight: 600; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img,
.profile-avatar img,
.member-dot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.notif-icon { font-size: 22px; }
.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: #fff;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
#notif-btn { position: relative; }

/* Main content */
#page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 80px);
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-2px) scale(1.08); }
  70%  { transform: translateY(0) scale(1); }
}

/* Bottom nav - full width */
.bottom-nav {
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 0;
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: 0;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
  flex: 1;
  height: var(--nav-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
  transition: color 0.35s ease;
  position: relative;
}
.nav-btn i.nav-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
/* Text: always reserves space, only opacity changes — no layout shift */
.nav-btn span {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  white-space: nowrap;
  height: 13px;
  line-height: 13px;
  opacity: 0;
  transition: opacity 0.35s ease;
}
/* Underline under the label */
.nav-btn span::after {
  content: '';
  display: block;
  height: 2px;
  width: var(--lineWidth, 0px);
  background: currentColor;
  border-radius: 99px;
  margin-top: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-btn.active {
  color: var(--primary);
}
.nav-btn.active span {
  opacity: 1;
}
.nav-btn.nav-bounce i.nav-icon {
  animation: iconBounce 0.55s ease forwards;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 16px; }

/* Dashboard */
.dashboard {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dashboard-kicker {
  font-size: 12px;
  color: var(--text3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dashboard-hero h3 {
  font-size: 22px;
  line-height: 1.15;
  margin-top: 3px;
}
.dashboard-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.summary-primary {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}
.summary-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.summary-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.summary-actions .btn {
  padding-left: 10px;
  padding-right: 10px;
}
.summary-label {
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
}
.summary-value {
  font-size: 34px;
  line-height: 1;
  margin-top: 8px;
  font-weight: 800;
  color: var(--text);
}
.summary-diff {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}
.summary-diff.up { color: var(--danger); }
.summary-diff.down { color: var(--primary); }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.mini-stat {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.mini-stat:nth-child(2n) { border-right: none; }
.mini-stat:nth-last-child(-n+2) { border-bottom: none; }
.mini-stat i {
  color: var(--primary);
  font-size: 18px;
}
.mini-stat strong {
  font-size: 18px;
  line-height: 1.1;
}
.mini-stat span {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}

.summary-label,
.mini-stat span,
.month-chart .section-title small,
.dashboard-list-row small,
.dashboard-history-row small,
.time-stat span,
.range-total-row small,
.range-trip-row small,
.list-card-meta,
.recipe-list-group-head small,
.settings-item-sub,
.product-row-meta,
.picker-row-meta,
.picker-empty-sub,
.household-member small,
.item-library-meta,
.history-date {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title a { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 500; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-actions.refined { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow);
}
.quick-btn:active { background: var(--bg3); }
.quick-btn i { font-size: 22px; color: var(--primary); }

.month-chart {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow);
}
.month-chart .section-title {
  margin-bottom: 14px;
}
.month-chart .section-title small {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}
.month-chart-frame {
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 12px 4px 0;
  border-bottom: 1px solid var(--border);
}
.month-bar {
  flex: 1;
  min-width: 3px;
  background: var(--bg3);
  border-radius: 4px 4px 0 0;
}
.month-bar.has-data {
  background: var(--primary);
}
.month-chart-axis {
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
}
.dashboard-list-stack,
.dashboard-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dashboard-list-row,
.dashboard-history-row {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.dashboard-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: start;
}
.dashboard-list-row .list-status-badge { align-self: center; }
.dashboard-list-row strong,
.dashboard-history-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}
.dashboard-list-row small,
.dashboard-history-row small {
  display: block;
  margin-top: 3px;
  color: var(--text3);
  font-size: 12px;
  font-weight: 500;
}
.dashboard-list-progress {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: var(--bg3);
  border-radius: 999px;
}
.dashboard-list-progress div {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}
.dashboard-history-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.dashboard-history-row b {
  font-size: 14px;
  color: var(--primary);
}
.shop-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.shop-detail-summary div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card2);
  padding: 10px;
  min-width: 0;
}
.shop-detail-summary strong {
  display: block;
  font-size: 17px;
  line-height: 1.1;
}
.shop-detail-summary span,
.shop-detail-date,
.shop-detail-item small {
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.shop-detail-date {
  padding-bottom: 2px;
}
.shop-detail-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.shop-detail-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--card);
}
.shop-detail-item.checked {
  opacity: 0.72;
}
.shop-detail-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}
.shop-detail-check i {
  font-size: 15px;
}
.shop-detail-item strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.shop-detail-item small {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.dashboard-empty-row {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.time-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.time-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 9px;
  align-items: center;
}
.time-stat i {
  grid-row: span 2;
  color: var(--primary);
  font-size: 20px;
}
.time-stat strong {
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
}
.time-stat span {
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.time-disabled-alert {
  border: 1px solid rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.08);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
}
.time-disabled-alert i {
  font-size: 18px;
  flex-shrink: 0;
}
.spend-range-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.spend-range-controls .btn {
  grid-column: 1 / -1;
}
.date-filter-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}
.date-filter-form {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.date-filter-row .form-group {
  min-width: 0;
  margin: 0;
  width: 100%;
}
.date-filter-row input {
  display: block;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.date-filter-actions {
  flex-direction: column;
  min-width: 0;
}
.date-filter-actions .btn {
  flex: none;
  min-width: 0;
  width: 100%;
}
.spend-range-result {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--text2);
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.range-total-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.range-total-row small {
  display: block;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
}
.range-total-row strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}
.range-count {
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  text-align: left;
  min-width: 0;
}
.range-trip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.range-trip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
}
.range-trip-row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.range-trip-row small {
  display: block;
  color: var(--text3);
  font-size: 11px;
  margin-top: 2px;
}
.range-trip-row b {
  color: var(--primary);
  font-size: 13px;
  flex-shrink: 0;
}
.range-error { color: var(--danger); font-weight: 600; }
.range-loading { color: var(--text3); }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.chart-bar {
  flex: 1;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  opacity: 0.6;
  min-height: 4px;
  transition: opacity 0.2s;
  position: relative;
}
.chart-bar:hover { opacity: 1; }
.chart-labels { display: flex; gap: 6px; margin-top: 6px; }
.chart-label { flex: 1; text-align: center; font-size: 9px; color: var(--text3); }

/* Lists page */
.page { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.list-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.list-card:active { transform: scale(0.99); }
.list-card.completed { opacity: 0.6; }
.list-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.list-card-name { font-size: 17px; font-weight: 600; }
.list-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 600;
  flex-shrink: 0;
}
.status-active { background: rgba(25,118,210,0.1); color: var(--primary); }
.status-shopping { background: rgba(245,158,11,0.12); color: var(--warning); }
.status-completed { background: rgba(100,116,139,0.1); color: var(--text3); }
.list-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text2);
}
.friends-list-title {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.friend-list-card {
  border-color: rgba(25,118,210,0.22);
}
.friend-list-owner {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}
.list-progress { margin-top: 10px; }
.progress-bar-track { height: 4px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }
.progress-text { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* List detail */
.list-detail { display: flex; flex-direction: column; height: 100%; }
.list-detail-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.sleep-lock-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  color: var(--primary);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}
.sleep-lock-indicator i { font-size: 13px; }
.list-actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.segmented-control button {
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: 6px;
  min-height: 34px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.segmented-control button.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.list-group-control { margin-top: 10px; }
.shopping-mode .item-row {
  min-height: 70px;
  padding: 16px;
}
.shopping-mode .item-checkbox {
  width: 32px;
  height: 32px;
}
.shopping-mode .item-name { font-size: 17px; }
.store-group { margin-bottom: 0; }
.store-group-title {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px;
  background: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.items-list { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }

.recipe-list-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  overflow: hidden;
}
.recipe-list-group-head {
  width: 100%;
  border: 0;
  background: var(--card2);
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  font-family: inherit;
  font-weight: 700;
  text-align: left;
}
.recipe-list-group-head span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipe-list-group-head small {
  color: var(--text2);
  font-size: 12px;
}
.recipe-list-group-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.recipe-list-group-body.collapsed { display: none; }
.recipe-list-group .item-row { box-shadow: none; }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  touch-action: pan-y;
  position: relative;
  transition: background 0.15s;
  min-height: 56px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.item-row.checked { opacity: 0.5; }
.item-row.checked .item-name { text-decoration: line-through; color: var(--text3); }
.item-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: transparent;
}
.item-row.checked .item-checkbox { background: var(--primary); border-color: var(--primary); }
.item-checkbox-tick { color: #fff; font-size: 14px; opacity: 0; display: flex; align-items: center; }
.item-checkbox-tick i { font-size: 14px; }
.item-row.checked .item-checkbox-tick { opacity: 1; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 12px; color: var(--text2); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.item-qty { font-size: 17px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.item-price { font-size: 14px; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.item-drag-handle {
  color: var(--text3);
  cursor: pointer;
  padding: 0 2px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.item-drag-handle i { font-size: 20px; }

.swipe-delete-bg {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--danger);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
}
.swipe-delete-bg i { font-size: 22px; }
.swipe-edit-bg {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
}
.swipe-edit-bg i { font-size: 22px; }

.add-item-bar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  padding: 10px 16px;
  background: linear-gradient(to top, var(--bg) 82%, rgba(244,246,249,0));
  z-index: 4;
}

.share-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card2);
  padding: 12px;
}
.share-block strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.viewer-link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-top: 10px;
}
.viewer-link-box input {
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text2);
  background: var(--bg);
}
.public-view-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(25, 118, 210, 0.08);
  border: 1px solid rgba(25, 118, 210, 0.22);
  margin-bottom: 12px;
}
.public-view-banner i { color: var(--primary); font-size: 22px; }
.public-view-banner strong { display: block; color: var(--text); font-size: 14px; }
.public-view-banner span {
  display: block;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}
.public-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.public-list-head h3 {
  font-size: 20px;
  margin: 0 0 2px;
}
.public-list-head span {
  color: var(--text3);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.public-list-page .item-row {
  cursor: default;
}

.guide-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.guide-intro {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card2);
}
.guide-intro i {
  font-size: 24px;
  color: var(--primary);
}
.guide-intro strong {
  display: block;
  font-size: 15px;
}
.guide-intro span {
  display: block;
  color: var(--text2);
  font-size: 12px;
  margin-top: 2px;
}
.guide-contents {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.guide-contents button {
  border: 1px solid var(--border);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
}
.guide-contents button i {
  color: var(--primary);
  font-size: 17px;
}
.guide-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.guide-section h4 {
  margin: 0 0 8px;
  font-size: 15px;
}
.guide-section ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}
.guide-section li + li { margin-top: 6px; }

@media (max-width: 420px) {
  .viewer-link-box { grid-template-columns: 1fr; }
  .guide-contents { grid-template-columns: 1fr; }
  .sleep-lock-indicator {
    display: flex;
    margin: 6px 0 0;
    width: max-content;
  }
}

/* Missed items warning */
.missed-items-list {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
}
.missed-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.missed-item-row:last-child { border-bottom: none; }

/* Logged shops */
.logged-shop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  overflow: hidden;
}
.logged-shop-row:last-child { border-bottom: none; }
.logged-shop-row:active { background: var(--bg3); }
.logged-shop-icon { font-size: 20px; color: var(--text3); flex-shrink: 0; }
.logged-shop-info { flex: 1; min-width: 0; }
.logged-shop-name { font-size: 14px; font-weight: 500; }
.logged-shop-date { font-size: 12px; color: var(--text3); margin-top: 1px; }
.logged-shop-total { font-size: 15px; font-weight: 700; color: var(--text); flex-shrink: 0; }

/* Picker step 2 */
.picker-step2 { padding: 0 16px 16px; }
.picker-step2-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  padding: 12px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.picker-step2-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.picker-step2-row:last-child { border-bottom: none; }
.picker-step2-name { flex: 1; font-size: 14px; font-weight: 500; min-width: 0; }
.picker-store-select {
  width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  padding: 7px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-family: inherit;
}

/* Settings toggle */
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 16px 16px 6px;
}
.settings-toggle-row {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  gap: 18px;
}
.settings-toggle-row .settings-item-left {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}
.settings-item-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.toggle-input { display: none; }
.toggle-track {
  width: 44px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.toggle-input:checked ~ .toggle-track { background: var(--primary); }
.toggle-input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }

/* ── Products Page ───────────────────────────────────────── */
.products-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.products-count {
  font-size: 13px;
  color: var(--text2);
  font-weight: 600;
}
.products-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.products-action-grid .btn {
  min-width: 0;
  padding: 10px 8px;
  font-size: 12px;
  flex-direction: column;
  gap: 4px;
  white-space: normal;
  line-height: 1.15;
}
.products-action-grid .btn i {
  font-size: 20px;
}
.products-list { margin-bottom: 8px; }
.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.12s;
}
.product-row:last-child { border-bottom: none; }
.product-row:active { background: var(--bg3); }
.product-row.due { border-left: 4px solid var(--warning); }
.product-row.regular { border-left: 4px solid var(--primary-light); }
.product-row-emoji { font-size: 22px; flex-shrink: 0; }
.product-row-info { flex: 1; min-width: 0; }
.product-row-name { font-size: 15px; font-weight: 500; color: var(--text); }
.product-row-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.product-row-insight { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.25; }
.product-row.due .product-row-insight { color: var(--warning); font-weight: 700; }

.page-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
}

/* Category management modal */
.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cat-row:last-child { border-bottom: none; }
.cat-row-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; color: var(--text2); }
.cat-row-name { flex: 1; font-size: 14px; font-weight: 500; }
.cat-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cat-add-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.cat-name-input {
  flex: 1;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 0 12px;
  outline: none;
  font-family: inherit;
  height: 42px;
}
.cat-name-input:focus { border-color: var(--primary); }
.cat-add-btn { height: 42px; white-space: nowrap; }
.cat-icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text2);
  transition: border-color 0.15s;
}
.cat-icon-btn:hover { border-color: var(--primary); }

/* Quantity stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}
.qty-btn {
  background: var(--bg3);
  border: none;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.12s;
}
.qty-btn:active { background: var(--border); }
#picker-qty-num {
  min-width: 48px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 0 8px;
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  line-height: 44px;
}

/* Store chip grid for picker popup */
.store-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}
.store-chip {
  padding: 8px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--bg3);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.store-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.store-chip:active { background: var(--border); }

/* Store picker button in product form */
.store-pick-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.store-pick-btn:focus { border-color: var(--primary); outline: none; }
.store-pick-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.store-pick-option.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.store-pick-option:active { background: var(--border); }

/* Icon picker sheet */
.icon-picker-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 70dvh;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  z-index: 202;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.1, 0.64, 1);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
}
.icon-picker-sheet.open { transform: translateY(0); }
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 0 12px 24px;
  overflow-y: auto;
}
.icon-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.icon-option:active, .icon-option.selected { background: var(--primary-light); }
.icon-option.selected .icon-option-preview { color: var(--primary); }
.icon-option-preview {
  font-size: 22px;
  color: var(--text2);
  line-height: 1;
}
.icon-option span {
  font-size: 9px;
  color: var(--text3);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

/* ── Product Picker ──────────────────────────────────────── */
.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.picker-backdrop.open { opacity: 1; pointer-events: auto; }

.product-picker {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 88dvh;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.34, 1.1, 0.64, 1);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
}
.product-picker.open { transform: translateY(0); }

.picker-drag-bar { padding: 10px 0 4px; display: flex; justify-content: center; flex-shrink: 0; }
.picker-drag-handle { width: 40px; height: 4px; background: var(--border); border-radius: 99px; }

.picker-header {
  flex-shrink: 0;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border);
}
.picker-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.picker-title { font-size: 17px; font-weight: 700; }

.picker-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}
.picker-search-icon { color: var(--text3); font-size: 18px; flex-shrink: 0; }
.picker-search {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  padding: 10px 0;
}
.picker-create-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.picker-create-btn.hidden { display: none; }

.picker-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
}
.picker-cats::-webkit-scrollbar { display: none; }
.picker-cat {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  color: var(--text2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.picker-cat.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.picker-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.picker-row:last-child { border-bottom: none; }
.picker-row:active, .picker-row.selected { background: var(--bg3); }
.picker-row.already-added {
  cursor: default;
  background: var(--bg3);
}
.picker-row.already-added .picker-row-name { color: var(--text2); }
.picker-add-state {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft, rgba(34, 197, 94, 0.14));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.picker-add-state i { font-size: 20px; }
.picker-add-state.is-added {
  background: var(--primary);
  color: #fff;
}
.picker-row-emoji { font-size: 22px; flex-shrink: 0; }
.picker-row-info { flex: 1; min-width: 0; }
.picker-row-name { font-size: 15px; font-weight: 500; color: var(--text); }
.picker-row-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.picker-row-check {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text3);
  font-size: 18px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.picker-row.selected .picker-row-check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.picker-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.picker-empty {
  padding: 40px 24px;
  text-align: center;
}
.picker-empty-icon { font-size: 40px; margin-bottom: 8px; }
.picker-empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.picker-empty-sub { font-size: 13px; color: var(--text3); }

.picker-footer {
  flex-shrink: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.picker-footer.hidden { display: none; }
.picker-footer-inner { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }

/* Manage Products modal rows */
.manage-product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.manage-product-row:last-child { border-bottom: none; }
.manage-product-emoji { font-size: 20px; flex-shrink: 0; }
.manage-product-info { flex: 1; min-width: 0; }
.manage-product-name { font-size: 14px; font-weight: 500; }
.manage-product-cat { font-size: 12px; color: var(--text3); }

.spinner-sm {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 32px auto;
}
.loading-inner { padding: 32px; display: flex; justify-content: center; }

/* Total bar */
.total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.total-amount { font-size: 18px; font-weight: 700; color: var(--primary); }
.shop-stopwatch {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(245,158,11,0.35);
  background: rgba(245,158,11,0.12);
  color: var(--warning);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}
.shop-duration-note {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}
.shop-duration-note i { color: var(--primary); font-size: 18px; }

/* Recipes */
.recipe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: var(--shadow);
}
.recipe-card:active { transform: scale(0.99); }
.recipe-card-name { font-size: 17px; font-weight: 600; }
.recipe-card-meta { font-size: 13px; color: var(--text2); margin-top: 6px; display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
.recipe-card-meta i { font-size: 15px; color: var(--primary); vertical-align: middle; }
.ingredient-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ingredient-row:last-child { border-bottom: none; }
.ingredient-qty { font-size: 14px; font-weight: 700; color: var(--text2); flex-shrink: 0; }
.recipe-ing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.recipe-ing-row:last-child { border-bottom: none; }
.recipe-ing-name { flex: 1; font-size: 14px; font-weight: 500; }
.ingredient-name { flex: 1; font-size: 14px; }
.ingredient-qty { font-size: 13px; color: var(--text2); }
.ingredient-price { font-size: 13px; color: var(--primary); font-weight: 600; }

.household-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 12px;
  margin-bottom: 10px;
}
.household-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.household-card-head strong {
  display: block;
  font-size: 15px;
}
.household-card-head span {
  display: block;
  color: var(--text2);
  font-size: 12px;
}
.household-members {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.household-member {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}
.household-member small {
  color: var(--text3);
  font-size: 11px;
}
.household-share-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.household-share-chip {
  border: 1px solid var(--border);
  background: var(--card2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  color: var(--text);
}
.household-share-chip .member-dot {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.whats-new {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.whats-new-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card2);
  padding: 12px;
}
.whats-new-hero i {
  font-size: 28px;
  color: var(--primary);
}
.whats-new-hero strong {
  display: block;
  font-size: 16px;
}
.whats-new-hero span {
  display: block;
  color: var(--text2);
  font-size: 13px;
  margin-top: 2px;
}
.whats-new-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.whats-new-list div {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.35;
}
.whats-new-list i {
  color: var(--primary);
  font-size: 19px;
  line-height: 1.1;
}
.member-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding: 0;
  animation: fadeIn 0.15s;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  animation: slideUp 0.25s;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow-x: hidden; }
.modal-actions { display: flex; gap: 10px; padding-top: 8px; }
.modal-actions .btn { flex: 1; }
.product-modal-actions { flex-wrap: wrap; }
.product-modal-actions .btn { min-width: 0; padding-left: 12px; padding-right: 12px; }
.product-modal-actions .product-add-more-btn { flex-basis: 100%; }

/* Toast */
#toast-container { position: fixed; top: 70px; right: 16px; left: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  animation: slideDown 0.2s;
  pointer-events: auto;
}
.toast i { font-size: 18px; }
.toast.success { border-left: 3px solid var(--primary); }
.toast.success i { color: var(--primary); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error i { color: var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.info i { color: var(--info); }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Meals */
.meal-grid { display: grid; gap: 10px; }
.meal-day-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.meal-day-header {
  padding: 10px 14px;
  background: var(--bg3);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.meal-slots { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.meal-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-height: 40px;
}
.meal-slot:last-child { border-bottom: none; }
.meal-slot-type { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; width: 60px; flex-shrink: 0; font-weight: 600; }
.meal-slot-name { font-size: 14px; flex: 1; }
.meal-slot-empty { color: var(--text3); font-style: italic; }
.meal-slot-clear { color: var(--text3); display: flex; align-items: center; cursor: pointer; padding: 4px; }
.meal-slot-clear i { font-size: 18px; }

/* Spending history */
.history-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.history-item:last-child { border-bottom: none; }
.history-icon { display: flex; align-items: center; color: var(--primary); }
.history-icon i { font-size: 22px; }
.history-info { flex: 1; }
.history-name { font-size: 14px; font-weight: 500; }
.history-date { font-size: 12px; color: var(--text2); margin-top: 2px; }
.history-total { font-size: 15px; font-weight: 700; color: var(--primary); }

/* Store color tags */
.store-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.store-tesco { background: rgba(0,82,152,0.1); color: #005298; }
.store-aldi { background: rgba(0,100,55,0.1); color: #006437; }
.store-lidl { background: rgba(0,83,154,0.1); color: #00539a; }
.store-asda { background: rgba(0,153,0,0.1); color: #007a00; }
.store-sainsburys { background: rgba(230,0,0,0.1); color: #cc0000; }
.store-morrisons { background: rgba(0,75,135,0.1); color: #004b87; }
.store-default { background: rgba(100,116,139,0.1); color: var(--text2); }

/* Notifications panel */
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  padding: 14px 44px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s;
}
.notif-item.unread { background: rgba(25,118,210,0.06); border-color: rgba(25,118,210,0.22); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-dot.read { opacity: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: 14px; flex: 1; font-weight: 600; line-height: 1.35; color: var(--text); }
.notif-time { font-size: 11px; color: var(--text3); margin-top: 4px; }
.notif-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.notif-dismiss i { font-size: 18px; }
.notif-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.notif-item .swipe-delete-bg {
  right: 0;
  left: auto;
  width: 90px;
}

/* Profile */
.profile-page { padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.profile-header { text-align: center; padding: 16px 0; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; font-size: 28px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; overflow: hidden; }
.profile-avatar-button { border: 0; cursor: pointer; padding: 0; font-family: inherit; box-shadow: 0 6px 18px rgba(0,0,0,0.14); }
.profile-avatar-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.profile-name { font-size: 20px; font-weight: 600; }
.profile-email { font-size: 14px; color: var(--text2); margin-top: 4px; }

.settings-list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow); }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.settings-item:hover { background: var(--bg3); }
.settings-item:last-child { border-bottom: none; }
.settings-item-left { display: flex; align-items: center; gap: 14px; font-size: 15px; min-width: 0; }
.settings-item-icon { font-size: 20px; width: 28px; color: var(--primary); display: flex; align-items: center; }
.settings-item-icon i { font-size: 20px; }
.settings-item-arrow { color: var(--text3); display: flex; align-items: center; }
.settings-item-arrow i { font-size: 20px; }
.about-copy {
  margin-top: 20px;
  text-align: left;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.55;
}
.about-copy p + p { margin-top: 12px; }

/* Empty states */
.empty-state { text-align: center; padding: 40px 24px; color: var(--text2); }
.empty-icon { font-size: 48px; margin-bottom: 12px; color: var(--text3); opacity: 0.5; }
.empty-icon i { font-size: 48px; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-desc { font-size: 14px; line-height: 1.6; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(25,118,210,0.35);
  z-index: 20;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab i { font-size: 28px; }
.fab:active { transform: scale(0.92); box-shadow: 0 2px 10px rgba(25,118,210,0.25); }

/* Recipe selector in list */
.recipe-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.recipe-select-item:last-child { border-bottom: none; }
.recipe-select-check {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  color: transparent;
}
.recipe-select-check.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.recipe-select-check i { font-size: 15px; }

/* Inline form */
.inline-form { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row .form-group { margin: 0; }

/* Item library */
.item-library-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.item-library-row:last-child { border-bottom: none; }
.item-library-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  color: transparent;
}
.item-library-check.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.item-library-check i { font-size: 13px; }
.item-library-name { flex: 1; font-size: 15px; }
.item-library-meta { font-size: 12px; color: var(--text2); }

/* Misc */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }

/* Scroll snap for list cards */
.list-items-scroll { overflow-x: auto; display: flex; gap: 12px; padding: 4px 2px; scrollbar-width: none; }
.list-items-scroll::-webkit-scrollbar { display: none; }

/* Loading state */
.loading { display: flex; align-items: center; justify-content: center; padding: 32px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive: tablet and up */
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .spend-range-controls { grid-template-columns: 1fr 1fr auto; }
  .spend-range-controls .btn { grid-column: auto; }
  .modal { border-radius: var(--radius); max-width: 500px; margin: auto; border: 1px solid var(--border); }
  .modal-overlay { align-items: center; padding: 20px; }
  .page, .dashboard { max-width: 640px; margin: 0 auto; }
}
@media (min-width: 1024px) {
  .page, .dashboard { max-width: 720px; }
  .form-row { grid-template-columns: 1fr 1fr 1fr; }
}

/* === Calendar-specific === */
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cal-cell {
  /* min-width:0 prevents grid from inflating cells past their 1fr allocation */
  min-width: 0;
  min-height: 78px;
  border-radius: var(--radius-sm);
  background: var(--card2);
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s, box-shadow 0.12s;
  border: 1px solid var(--border);
}
.cal-cell:hover {
  background: var(--bg3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.cal-cell:active { transform: translateY(0); }
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.empty:hover { background: transparent; box-shadow: none; transform: none; }
.cal-cell.today {
  border-color: var(--primary);
  background: rgba(25,118,210,0.08);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.cal-day-num { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1; }
.cal-cell.today .cal-day-num { color: var(--primary); }
.cal-pip {
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.cal-pip-more {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
  margin-top: 2px;
}
@media (max-width: 380px) {
  .cal-grid { gap: 4px; padding: 6px; }
  .cal-cell { padding: 6px 5px 4px; min-height: 64px; gap: 3px; }
  .cal-day-num { font-size: 13px; }
  .cal-pip { height: 5px; }
}
.cal-list-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin: 16px 4px 6px;
}

/* === Desktop layout (>= 900px) — top nav in header, no bottom nav, full-width content === */
.app-header-nav { display: none; }

@media (min-width: 900px) {
  .app-header { height: 64px; padding: 0 28px; justify-content: flex-start; gap: 0; }
  #page-title { display: none; }
  /* "Back to portal" becomes a proper text link, not a round icon button */
  .portal-btn {
    width: auto !important;
    min-width: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
    padding: 0 14px !important;
    background: transparent !important;
    color: var(--text) !important;
    font-weight: 500;
    font-size: 15px;
    gap: 6px;
    display: inline-flex;
    align-items: center;
  }
  .portal-btn:hover { background: transparent !important; color: var(--primary) !important; }
  .portal-btn i { font-size: 18px; }
  .portal-btn-text { display: inline; }
  /* Nav sits immediately after the back link, left-aligned, even spacing */
  .app-header-nav {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-start;
    align-items: stretch;
    gap: 28px;
    margin: 0 0 0 24px;
    height: 100%;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  /* Right side (avatar, notifications) pushed to the far right */
  .header-right { margin-left: auto; }
  .app-header-nav .nav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
    font-size: 15px;
    padding: 0 4px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    transition: color 0.15s;
    flex-direction: row;
    height: 100%;
    min-height: 0;
    width: auto;
    min-width: 0;
  }
  /* Desktop nav is text-only — icons live in the mobile bottom-nav */
  .app-header-nav .nav-btn i,
  .app-header-nav .nav-btn .nav-icon { display: none; }
  /* Override the bottom-nav rule that hides span text — labels are always visible up here */
  .app-header-nav .nav-btn span {
    opacity: 1 !important;
    height: auto;
    line-height: 1;
    font-size: 15px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--primary);
  }
  .app-header-nav .nav-btn span::after { display: none; }
  .app-header-nav .nav-btn { color: var(--primary); }
  .app-header-nav .nav-btn:hover span { opacity: 1 !important; color: var(--primary-dark); }
  /* Active item: underline only the text characters, not the whole button */
  .app-header-nav .nav-btn.active span { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 10px; }
  /* Mobile-only chrome (e.g. Scan barcode) is hidden on desktop */
  .mobile-only { display: none !important; }
  .bottom-nav { display: none; }
  /* Use more of the screen width */
  /* Override the mobile-first 720px constraint — desktop content fills the whole viewport */
  .page, .dashboard { padding: 28px 36px; max-width: none; margin: 0; gap: 18px; }
  /* Calendar grid breathes — square cells, more padding */
  .cal-cell { aspect-ratio: 1 / 1; min-height: 110px; padding: 10px 10px 8px; }
  .cal-day-num { font-size: 16px; }
  .cal-grid { padding: 14px; gap: 8px; }
}

/* === Calendar list rows: round icons + swipe-to-delete === */
.cal-row {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.cal-row-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
.cal-row-icon i { font-size: 18px; }
.cal-row .swipe-delete-bg {
  right: 0;
  left: auto;
  width: 90px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Desktop: FAB sits clear of the (hidden) bottom-nav */
@media (min-width: 900px) {
  .fab { bottom: 32px; right: 32px; }
}

/* === Dark theme — applied via :root[data-theme="dark"] (set by inline boot script in <head>) === */
:root[data-theme="dark"] {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --card: #1e293b;
  --card2: #0f172a;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --primary-light: #1e3a8a;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
  color-scheme: dark;
}

/* === Theme selector segmented control === */
.theme-segments {
  display: inline-flex;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 4px;
  gap: 2px;
  flex-wrap: wrap;
}
.theme-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  color: var(--text2);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.theme-seg:hover { color: var(--text); }
.theme-seg.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
.theme-seg i { font-size: 17px; }

/* === Calendar: month grid fits in viewport on desktop === */
@media (min-width: 900px) {
  .cal-cell {
    aspect-ratio: auto;
    min-height: 60px;
    height: clamp(64px, 11vh, 110px);
    padding: 8px 8px 6px;
  }
  .cal-grid { padding: 12px; gap: 6px; }
}

/* === Event modal: compact form so it fits in one screen === */
.event-form { display: flex; flex-direction: column; gap: 10px; }
.event-form .form-group { gap: 4px; }
.event-form .form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.02em;
}
.event-form .form-input { padding: 10px 12px; }
.event-form textarea.form-input { min-height: 0; resize: vertical; }
.event-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.event-form-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 4px;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.event-form-toggle i { font-size: 18px; color: var(--primary); }
.event-form-toggle > span:first-of-type { flex: 1; }
.event-form-color { padding: 0 4px !important; height: 40px; cursor: pointer; }
.event-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
/* Stack starts/ends and reminder/colour on phone — phones don't have room side-by-side */
@media (max-width: 600px) {
  .event-form-row { grid-template-columns: 1fr; }
}
