*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-header-bg: #1e2330;
  --color-header-text: #e8ecf4;
  --color-border: #e0e4eb;
  --color-accent: #3b82f6;
  --color-danger: #dc2626;
  --color-muted: #6b7280;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--color-bg);
  color: #1f2937;
}

/* ── Header ─────────────────────────────────────── */

.header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  height: 48px;
  font-size: 1rem;
  font-weight: 600;
}

.header-owner {
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(232, 236, 244, 0.8);
  margin-left: 1rem;
}

.owner-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-header-bg);
  border: none;
  color: rgba(232, 236, 244, 0.8);
  font-size: 0.85rem;
  font-weight: 400;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
  outline: none;
  margin-left: 1rem;
}

.owner-select option {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

.header-logo {
  font-size: 1.2rem;
  margin-right: 0.4rem;
  color: var(--color-accent);
}

.header-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.header-email {
  font-size: 0.8rem;
  font-weight: 400;
  color: rgba(232, 236, 244, 0.65);
}

.header-right button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--color-header-text);
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s, border-color 0.1s;
}

.header-right button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ── Page content ────────────────────────────────── */

.page {
  max-width: 560px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1.25rem;
}

/* ── Add item form ───────────────────────────────── */

.add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.add-input {
  flex: 1;
  padding: 0.55rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  background: var(--color-surface);
}

.add-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.qty-input {
  width: 4rem;
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: var(--font);
  text-align: center;
  background: var(--color-surface);
  outline: none;
}

.qty-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.btn-add {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.btn-add:hover { background: #2563eb; }

/* ── Grocery list ────────────────────────────────── */

.list-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.list-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  gap: 0.75rem;
}

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

.list-item.purchased .item-name {
  text-decoration: line-through;
  color: #9ca3af;
}

.item-name {
  flex: 1;
  font-size: 1rem;
}

.item-user {
  font-size: 0.75rem;
  color: #c0c8d8;
  flex-shrink: 0;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.item-date {
  font-size: 0.72rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.btn-purchase {
  background: none;
  border: 1px solid #10b981;
  color: #10b981;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s;
  white-space: nowrap;
}

.btn-purchase:hover { background: #d1fae5; }

.btn-undo {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s;
  white-space: nowrap;
}

.btn-undo:hover { background: #f3f4f6; }

.btn-delete {
  background: none;
  border: none;
  color: #d1d5db;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  transition: color 0.1s;
}

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

/* ── Section header ─────────────────────────────── */

.list-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

/* ── Footer actions ──────────────────────────────── */

.list-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

.btn-clear {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.btn-clear:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: #fff5f5;
}

/* ── Flash messages ──────────────────────────────── */

.flash {
  padding: 0.6rem 1rem;
  border-radius: 5px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.flash-ok   { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-warn { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.flash-err  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
