:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --woolworths: #15803d;
  --woolworths-bg: #dcfce7;
  --coles: #dc2626;
  --coles-bg: #fee2e2;
  --aldi: #1d4ed8;
  --aldi-bg: #dbeafe;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 84px;
}

header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}
.dot.offline { background: #fbbf24; }

.suburb-bar {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.suburb-bar select, .suburb-bar button {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
}
.suburb-bar select option { color: var(--text); background: #fff; }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px;
}

.summary-card {
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}
.summary-label { font-size: 0.72rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.summary-val { font-size: 1.25rem; font-weight: 800; margin-top: 2px; }
.summary-val.save { color: #fde047; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.muted-note { font-size: 0.74rem; color: var(--muted); font-weight: 500; }

.retailer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.retailer-box {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 0.8rem;
  transition: 0.15s;
}
.retailer-box.disabled { opacity: 0.48; background: var(--surface-alt); }
.retailer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 4px;
}
.branch-select {
  width: 100%;
  margin-top: 4px;
  font-size: 0.72rem;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.quick-add-row {
  display: flex;
  gap: 8px;
}
.quick-add-row input {
  flex: 1;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
}
.quick-add-row input:focus { outline: none; border-color: var(--primary); }
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-voice.listening { background: #dc2626; color: #fff; animation: pulse 1.2s infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.action-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  cursor: pointer;
}

.store-section { margin-bottom: 16px; }
.store-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.store-banner.woolworths { background: var(--woolworths-bg); color: var(--woolworths); }
.store-banner.coles { background: var(--coles-bg); color: var(--coles); }
.store-banner.aldi { background: var(--aldi-bg); color: var(--aldi); }

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
}
.item-row.checked { opacity: 0.55; text-decoration: line-through; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 700; font-size: 0.92rem; }
.item-meta { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-right: 4px;
}
.badge.woolworths { background: var(--woolworths-bg); color: var(--woolworths); }
.badge.coles { background: var(--coles-bg); color: var(--coles); }
.badge.aldi { background: var(--aldi-bg); color: var(--aldi); }

.qty-controls {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--text);
}
.qty-val {
  min-width: 30px;
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px;
}

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px;
  z-index: 50;
}
.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
}
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 1.15rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-title { margin: 0 0 6px 0; }
.modal-desc { font-size: 0.86rem; color: var(--muted); margin: 0 0 10px 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.flex-1 { flex: 1; }
.full-width { width: 100%; }
.form-group { margin: 10px 0; }
.form-label { font-size: 0.8rem; font-weight: 700; display: block; margin-bottom: 4px; }
.file-summary { font-size: 0.78rem; color: var(--primary); margin-top: 6px; }
.cart-textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
}
.value-box {
  background: var(--amber-bg);
  border: 1.5px solid #f59e0b;
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}
.hidden { display: none !important; }
