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

:root {
  --green: #2D7D46;
  --green-light: #EBF5EE;
  --red: #C0392B;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text-secondary: #6C6C70;
  --border: #E5E5EA;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

/* ── Screens ── */
.screen { display: flex; flex-direction: column; min-height: 100dvh; }
.screen[hidden] { display: none !important; }

/* ── Login ── */
.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  padding: 40px 32px;
}
.login-icon { font-size: 3rem; }
.login-card h1 { font-size: 1.8rem; font-weight: 700; }

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
#login-form input,
#login-form button {
  height: 50px;
  border-radius: var(--radius);
  font-size: 1rem;
  padding: 0 16px;
  width: 100%;
  border: 1.5px solid var(--border);
}
#login-form button {
  background: var(--green);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
.error { color: var(--red); font-size: 0.875rem; min-height: 1.25em; text-align: center; }

/* ── App header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.app-header h1 { font-size: 1.15rem; font-weight: 700; }

.btn-pill {
  background: var(--green-light);
  color: var(--green);
  border: none;
  border-radius: 20px;
  padding: 0 14px;
  min-height: 44px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* ── Add form ── */
.add-form {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.add-row { display: flex; gap: 8px; }
.add-row input,
.add-row select {
  flex: 1;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.add-row select { max-width: 150px; flex-shrink: 0; }
.btn-add {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* ── Item list ── */
#item-list {
  flex: 1;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.category-header {
  padding: 12px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.item.checked { opacity: 0.45; }
.item.checked .item-name { text-decoration: line-through; }

.check-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.item.checked .check-btn {
  background: var(--green);
  border-color: var(--green);
}

.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 1rem; font-weight: 500; display: block; }
.item-qty { font-size: 0.8rem; color: var(--text-secondary); display: block; }

.delete-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  border: none;
  background: #FFECEC;
  color: var(--red);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── In-cart section ── */
.in-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  margin-top: 8px;
}
.clear-btn {
  background: var(--red);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}
