:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --error-bg: #fee2e2;
  --error-fg: #991b1b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.06);
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--surface-muted);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg);
  color: #f8fafc;
  gap: 0.75rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
}

.brand {
  font-weight: 700;
  color: #f8fafc;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-header nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

.nav-link {
  color: #cbd5f5;
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-btn {
  background: transparent;
  color: #cbd5f5;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.who {
  color: #e2e8f0;
  font-size: 0.85rem;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-main {
  flex: 1;
  padding: 1rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.site-footer {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

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

.card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.card h2 {
  margin-top: 1.5rem;
  font-size: 1.1rem;
}

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

.small {
  font-size: 0.85rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.stack label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

textarea,
input[type="text"] {
  font: inherit;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  min-height: var(--tap);
}

textarea:focus,
input[type="text"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 0 0.75rem;
  font-size: 0.85rem;
}

.google-g {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: white;
  color: #4285f4;
  font-weight: 800;
  font-family: "Segoe UI", Arial, sans-serif;
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.banner-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.banner-error {
  background: var(--error-bg);
  color: var(--error-fg);
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* Groceries */
.groceries h1 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
}

.add-form {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 0;
  padding: 0.5rem 0;
  background: var(--surface-muted);
  z-index: 5;
}

.add-form input {
  flex: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.list:empty::after {
  content: "Nothing here.";
  display: block;
  padding: 1rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--tap);
}

.item:last-child {
  border-bottom: 0;
}

.item .check {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 0;
}

.item .check:hover {
  background: var(--surface-muted);
}

.item .check .box {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  align-items: center;
  justify-content: center;
  background: transparent;
  color: white;
  font-size: 16px;
  line-height: 1;
}

.item.completed .check .box {
  background: var(--success);
  border-color: var(--success);
}

.item .name {
  flex: 1;
  font-size: 1rem;
  word-break: break-word;
  padding: 0.5rem 0;
}

.item.completed .name {
  color: var(--text-muted);
  text-decoration: line-through;
}

.item .remove {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.item .remove:hover {
  background: var(--surface-muted);
  color: var(--danger);
}

.item.pending {
  opacity: 0.6;
  pointer-events: none;
}

.completed-details {
  margin-top: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.completed-details summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  min-height: var(--tap);
}

.completed-details summary::-webkit-details-marker {
  display: none;
}

.completed-details[open] summary {
  border-bottom: 1px solid var(--border);
}

.completed-details .list {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.toast {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  max-width: calc(100% - 2rem);
  text-align: center;
}

.user-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.user-info {
  min-width: 0;
}

.user-name {
  font-weight: 600;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.user-email,
.user-reason {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-reason {
  margin-top: 0.25rem;
  font-style: italic;
}

.user-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--border);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pill-approved {
  background: #dcfce7;
  color: #166534;
}

.pill-pending {
  background: #fef3c7;
  color: #92400e;
}

.pill-denied {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 480px) {
  .site-main {
    padding: 0.75rem;
  }
  .card {
    padding: 1rem;
  }
  .who {
    display: none;
  }
}
