/* Resten-Retter — eigenes Design, Limettengrün + warmes Weiss */
:root {
  --lime-50: #f7fee7;
  --lime-100: #ecfccb;
  --lime-200: #d9f99d;
  --lime-400: #a3e635;
  --lime-500: #84cc16;
  --lime-600: #65a30d;
  --lime-700: #4d7c0f;
  --lime-800: #3f6212;

  --warm-white: #fdfdf6;
  --paper: #ffffff;

  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;

  --bg: var(--warm-white);
  --surface: var(--paper);
  --surface-2: #f4f6ec;
  --text: #1c2a14;
  --text-soft: #5b6b4d;
  --text-muted: #82906f;
  --border: #e4e9d6;
  --border-strong: #cfd8b8;
  --accent: var(--lime-600);
  --accent-hover: var(--lime-700);
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(40, 60, 20, .06), 0 6px 18px rgba(40, 60, 20, .07);
  --shadow-soft: 0 1px 3px rgba(40, 60, 20, .08);
  --radius: 16px;
  --radius-sm: 11px;
  --focus: 0 0 0 3px rgba(101, 163, 13, .4);

  --c-green: var(--green);
  --c-green-bg: var(--green-bg);
  --c-amber: var(--amber);
  --c-amber-bg: var(--amber-bg);
  --c-red: var(--red);
  --c-red-bg: var(--red-bg);
}

[data-theme="dark"] {
  --bg: #14180e;
  --surface: #1d2415;
  --surface-2: #232b18;
  --text: #eef3e2;
  --text-soft: #b9c6a4;
  --text-muted: #8a9a72;
  --border: #303a20;
  --border-strong: #3e4b29;
  --accent: var(--lime-500);
  --accent-hover: var(--lime-400);
  --accent-ink: #15200a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, .4);
  --focus: 0 0 0 3px rgba(132, 204, 22, .5);

  --c-green: #4ade80;
  --c-green-bg: #14331f;
  --c-amber: #fbbf24;
  --c-amber-bg: #3a2c0a;
  --c-red: #f87171;
  --c-red-bg: #3a1414;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 100;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, var(--lime-600), var(--lime-700));
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  box-shadow: var(--shadow-soft);
}
[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, var(--lime-700), var(--lime-800));
}
.app-header__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  flex-shrink: 0;
}
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name { font-weight: 800; font-size: 1.18rem; letter-spacing: -.01em; line-height: 1.15; }
.brand__tag { font-size: .76rem; opacity: .9; }

.icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .18);
  cursor: pointer;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  color: #fff;
  transition: background .15s ease, transform .1s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .3); }
.icon-btn:active { transform: scale(.94); }
.icon-btn__moon { display: none; }
[data-theme="dark"] .icon-btn__sun { display: none; }
[data-theme="dark"] .icon-btn__moon { display: block; }

/* Layout */
.container {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 28px;
}

.section-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.stat__num { display: block; font-size: 1.75rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat__label { display: block; font-size: .72rem; color: var(--text-muted); margin-top: 6px; }
.stat--soon { border-top: 3px solid var(--c-amber); }
.stat--soon .stat__num { color: var(--c-amber); }
.stat--expired { border-top: 3px solid var(--c-red); }
.stat--expired .stat__num { color: var(--c-red); }
.stat--total { border-top: 3px solid var(--accent); }
.stat--total .stat__num { color: var(--accent); }

/* Add card */
.add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--name { grid-column: 1 / -1; }
.field label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-soft);
}
.field input,
.field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.field input.is-invalid,
.field select.is-invalid {
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px var(--c-red-bg);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn--primary {
  grid-column: 1 / -1;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--border); }
.btn--danger { background: var(--c-red); color: #fff; }
.btn--danger:hover { filter: brightness(1.06); }

/* List */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.list-head .section-title { margin: 0; }
.filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip:hover { background: var(--surface-2); }
.chip:focus-visible { outline: none; box-shadow: var(--focus); }
.chip.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  animation: pop .22s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.item--green { border-left-color: var(--c-green); }
.item--amber { border-left-color: var(--c-amber); }
.item--red { border-left-color: var(--c-red); }

.item__check {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 1rem;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.item__check:hover { border-color: var(--accent); }
.item__check:focus-visible { outline: none; box-shadow: var(--focus); }

.item__body { flex: 1; min-width: 0; }
.item__name {
  font-weight: 700;
  font-size: 1rem;
  word-break: break-word;
}
.item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.item__days {
  font-size: .82rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.item__days--green { color: var(--c-green); background: var(--c-green-bg); }
.item__days--amber { color: var(--c-amber); background: var(--c-amber-bg); }
.item__days--red { color: var(--c-red); background: var(--c-red-bg); }
.item__cat {
  font-size: .74rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}
.item__date { font-size: .74rem; color: var(--text-muted); }

.item__del {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}
.item__del:hover { background: var(--c-red-bg); color: var(--c-red); }
.item__del:focus-visible { outline: none; box-shadow: var(--focus); }

/* Empty */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty__icon { font-size: 2.8rem; display: block; margin-bottom: 10px; }
.empty__title { font-weight: 700; color: var(--text-soft); margin: 0 0 4px; }
.empty__text { margin: 0; font-size: .9rem; max-width: 30ch; margin-inline: auto; }

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  color: var(--text-muted);
  font-size: .78rem;
}

/* Toast */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: .9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toastIn .25s ease;
  pointer-events: auto;
}
.toast--ok { background: var(--accent); color: var(--accent-ink); }
.toast--info { background: var(--text); color: var(--bg); }
.toast.is-out { animation: toastOut .25s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(12px); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 14, .55);
  backdrop-filter: blur(2px);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: min(100%, 360px);
  box-shadow: var(--shadow);
  animation: pop .2s ease;
}
.modal__title { margin: 0 0 8px; font-size: 1.15rem; }
.modal__text { margin: 0 0 18px; color: var(--text-soft); font-size: .92rem; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal__actions .btn { padding: 10px 16px; }

/* Responsive */
@media (max-width: 420px) {
  .stat__num { font-size: 1.45rem; }
  .stat__label { font-size: .68rem; }
  .add-form { grid-template-columns: 1fr; }
  .field--name { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
