/* ShoppingList — visual identity: a list kept on the kitchen counter, not a SaaS dashboard.
   Warm paper base, one confident accent (a produce-sticker green), Bitter for anything with
   weight, Inter for everything read at small sizes. */

:root {
  --paper: #FBF7EF;
  --paper-raised: #FFFFFF;
  --ink: #2B2620;
  --ink-soft: #6B6155;
  --line: #E3DACB;
  --accent: #3E7D50;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EFE3;
  --danger: #B4483A;
  --warn-bg: #FBEFD9;
  --warn-ink: #7A5A17;

  --radius-sm: 6px;
  --radius-md: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-display: 'Bitter', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-3);
  color: var(--ink);
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 var(--space-3); color: var(--ink-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper-raised);
  font-weight: 600;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
button:hover { opacity: 0.88; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

button.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.ghost:hover { background: var(--paper-raised); opacity: 1; }
button.danger { background: var(--danger); color: #fff; }
button.small { padding: 6px 12px; font-size: 0.875rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--space-1);
}

.field { margin-bottom: var(--space-4); }

/* ---- App shell ---- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
}
.brand-mark::before {
  content: '✓';
  display: inline-block;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 5px;
  width: 22px;
  height: 22px;
  text-align: center;
  line-height: 22px;
  font-size: 0.85rem;
  margin-right: var(--space-2);
}

nav#main-nav { display: flex; gap: var(--space-2); flex-wrap: wrap; }
nav#main-nav a {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
nav#main-nav a:hover { background: var(--paper-raised); text-decoration: none; }
nav#main-nav a.active { background: var(--ink); color: var(--paper-raised); }

#app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

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

.banner {
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 0.9rem;
}
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.error { background: #FBE8E5; color: var(--danger); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

/* ---- Auth ---- */

.auth-wrap {
  max-width: 380px;
  margin: var(--space-7) auto;
  padding: 0 var(--space-4);
}
.auth-toggle {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  justify-content: center;
}
.auth-toggle button { background: transparent; color: var(--ink-soft); }
.auth-toggle button.active { background: var(--ink); color: var(--paper-raised); }

/* ---- Lists ---- */

.list-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}
.list-item-row:last-child { border-bottom: none; }

.check-toggle {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--paper-raised);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.check-toggle.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.item-text { flex: 1; min-width: 0; }
.item-generic { font-weight: 600; }
.item-specific { font-size: 0.85rem; color: var(--ink-soft); }
.item-quantity {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  flex-shrink: 0;
}

.list-item-row.completed .item-generic,
.list-item-row.completed .item-specific {
  text-decoration: line-through;
  color: var(--ink-soft);
  opacity: 0.6;
}

.add-item-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.add-item-row input { flex: 1; }

.list-grid {
  display: grid;
  gap: var(--space-3);
}
.list-summary-card {
  display: block;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: var(--ink);
}
.list-summary-card:hover { border-color: var(--accent); text-decoration: none; }
.list-summary-card .muted { margin: 0; }

/* ---- Receipts ---- */

.upload-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  background: var(--paper-raised);
}
.upload-zone input[type="file"] { max-width: 320px; margin: var(--space-3) auto 0; }

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
  gap: var(--space-3);
}
.receipt-row:last-child { border-bottom: none; }
.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.status-pill.done { background: var(--accent-soft); color: var(--accent); }

.reconcile-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.reconcile-row .raw-line { font-weight: 600; margin-bottom: var(--space-2); }
.reconcile-row .price { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: var(--space-3); }
.reconcile-row.matched { border-color: var(--accent); background: var(--accent-soft); }

.reconcile-options { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.reconcile-options > div { flex: 1; min-width: 220px; }

.datalist-hint { font-size: 0.8rem; color: var(--ink-soft); margin-top: var(--space-1); }

/* ---- Admin ---- */

table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.admin-table th, table.admin-table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}
table.admin-table th { color: var(--ink-soft); font-weight: 600; }

/* ---- Groups ---- */

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.85rem;
  margin: 2px 4px 2px 0;
}

.search-results {
  position: relative;
  margin-top: var(--space-1);
}
.search-results-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  max-height: 200px;
  overflow-y: auto;
}
.search-results-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  border-radius: 0;
  padding: 8px 12px;
}
.search-results-list button:hover { background: var(--accent-soft); opacity: 1; }

/* ---- Utility ---- */

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--ink-soft); }

@media (max-width: 480px) {
  #app-header { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 1.35rem; }
}
