* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f6f5;
  color: #1a2e22;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font-family: inherit; }

/* ---------- Login ---------- */

.login-screen {
  display: none;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1b7a4d, #124e33);
}
.login-screen.show { display: flex; }

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .2);
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: #5b6960; margin-bottom: 24px; }

.google-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid #d7ded9;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

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

.app { display: flex; flex-direction: column; height: 100dvh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(135deg, #1b7a4d, #22945e);
  color: #fff;
}
.app-header .logo { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; }

.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 150px;
}

.tab { display: none; }
.tab.active { display: block; }

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: #1b7a4d; color: #fff; }
.btn-secondary { background: #e7ede9; color: #1b7a4d; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  color: inherit;
}
.icon-btn:active { background: rgba(0, 0, 0, .06); }

/* ---------- Einkauf tab ---------- */

.list-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.category-group {
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e3e8e5;
}
.category-title {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}
.category-title::-webkit-details-marker { display: none; }
.category-title .count { color: #7c8a80; font-weight: 500; font-size: 13px; }

.item-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid #eef1ef; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 6px 0 14px;
  border-bottom: 1px solid #eef1ef;
}
.item-row:last-child { border-bottom: none; }

.item-check { display: flex; align-items: center; gap: 12px; flex: 1; min-height: 52px; cursor: pointer; }
.item-check input[type="checkbox"] { width: 24px; height: 24px; flex-shrink: 0; accent-color: #1b7a4d; }
.item-name { font-size: 16px; }
.item-name--checked { text-decoration: line-through; color: #9aa5a0; }
.item-qty { color: #7c8a80; font-size: 14px; }

.clear-done-btn { margin: 8px 14px 12px; }
.empty-hint { color: #7c8a80; padding: 24px 8px; text-align: center; }

/* ---------- Katalog tab ---------- */

.inline-add-form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.inline-add-form input[type="text"] {
  flex: 1 1 45%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #d7ded9;
  border-radius: 10px;
  font-size: 16px;
}

.edit-form { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; width: 100%; }
.edit-form input, .edit-form select {
  min-height: 40px;
  border: 1px solid #d7ded9;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 14px;
}
.edit-actions { display: flex; gap: 8px; width: 100%; }
.item-row--edit { display: block; }

.category-select {
  min-height: 44px;
  border: 1px solid #d7ded9;
  border-radius: 10px;
  font-size: 14px;
  padding: 0 6px;
}

/* ---------- Sticky quick-add bar (above bottom nav, thumb reach) ---------- */

.quick-add-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(64px + env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border-top: 1px solid #e3e8e5;
  z-index: 4;
}
#quick-add-input {
  flex: 1 1 40%;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #d7ded9;
  border-radius: 10px;
  font-size: 16px;
}
.quick-add-save-catalog {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #5b6960;
  white-space: nowrap;
}
.quick-add-submit { display: flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; padding: 0; }

/* ---------- Bottom tab navigation ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid #e3e8e5;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  min-height: 56px;
  border: none;
  background: transparent;
  color: #7c8a80;
}
.nav-btn span { font-size: 11px; }
.nav-btn.active { color: #1b7a4d; font-weight: 600; }

/* ---------- Katalog-Picker modal ---------- */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 10;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; }
#picker-content { overflow-y: auto; }
.modal-confirm { margin-top: 10px; min-height: 48px; }

/* ---------- Wider screens: constrain width, keep everything else identical ---------- */

@media (min-width: 640px) {
  .app-main { max-width: 560px; margin: 0 auto; width: 100%; }
  .quick-add-bar, .bottom-nav { max-width: 560px; margin: 0 auto; }
}
