:root {
  --bg: #f5faf8;
  --surface: #ffffff;
  --surface-2: #f0f7f4;
  --ink: #12211c;
  --ink-2: #4a5b55;
  --ink-3: #7d8e88;
  --line: #e3ede9;
  --mint: #3ecf9f;
  --mint-strong: #12a37a;
  --mint-deep: #0b7a5b;
  --mint-soft: #e3f8f0;
  --mint-softer: #f1fcf8;
  --up: #d9534f;
  --up-soft: #fdecec;
  --down: #12a37a;
  --warn: #c98a12;
  --warn-soft: #fff6e2;
  --aldi: #23336e;
  --lidl: #0a5cc2;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(18, 33, 28, .04), 0 6px 20px rgba(18, 33, 28, .05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar: 236px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--mint-deep); }
img { display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--mint-soft); color: var(--mint-deep); font-weight: 600; }
.nav svg, .tabbar svg { width: 20px; height: 20px; flex: none; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--ink-3); padding: 0 10px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; outline: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.loading { padding: 60px 0; color: var(--ink-3); text-align: center; }

.shell.noside { grid-template-columns: minmax(0, 1fr); }
.shell.noside .sidebar, .shell.noside .tabbar { display: none !important; }
.shell.noside .main { margin: 0 auto; }

/* ---------- Bausteine ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head a, .link { font-size: 13px; font-weight: 600; color: var(--mint-deep); text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; }
.card.mint { background: linear-gradient(160deg, #e9fbf4 0%, #ffffff 70%); border-color: #cdeee1; }

.kpi .label { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.kpi-ring { display: flex; align-items: center; gap: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 999px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); min-height: 40px; }
.btn:hover { border-color: #c9ddd5; background: var(--surface-2); }
.btn.primary { background: var(--mint-strong); border-color: var(--mint-strong); color: #fff; }
.btn.primary:hover { background: var(--mint-deep); border-color: var(--mint-deep); }
.btn.soft { background: var(--mint-soft); border-color: transparent; color: var(--mint-deep); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.btn.icon { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; user-select: none; }
.chip.on { background: var(--mint-soft); border-color: #bfe9d8; color: var(--mint-deep); font-weight: 600; }
.chip.off-red.on { background: var(--up-soft); border-color: #f4c9c7; color: var(--up); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.badge.save { background: var(--mint); color: #053d2d; }
.badge.plus { background: #fff3c4; color: #6b5300; }
.badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--mint-soft); color: var(--mint-deep); }
.mk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.mk::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.mk.aldi::before { background: var(--aldi); }
.mk.lidl::before { background: var(--lidl); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; min-height: 42px; outline: none; }
.input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(62, 207, 159, .18); }
.input-group { display: flex; gap: 8px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); }
.search .input { padding-left: 38px; }

/* ---------- Angebote ---------- */
.offer-rail { display: grid; grid-auto-flow: column; grid-auto-columns: 200px; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.offer-rail .offer { scroll-snap-align: start; }
.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.offer { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.offer .img { height: 108px; border-radius: 12px; background: var(--mint-softer); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.offer .img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.offer .img .ph { font-size: 34px; }
.offer .tags { position: absolute; top: 18px; left: 18px; display: flex; gap: 6px; flex-wrap: wrap; }
.offer .name { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.offer .meta { font-size: 12px; color: var(--ink-3); }
.offer .price { display: flex; align-items: baseline; gap: 8px; }
.offer .price b { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.offer .price s { color: var(--ink-3); font-size: 13px; }
.offer .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.add-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--mint-soft); color: var(--mint-deep); font-size: 20px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.add-btn:hover { background: var(--mint); color: #053d2d; }
.add-btn.done { background: var(--mint-strong); color: #fff; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .r { text-align: right; flex: none; }
.li .thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--mint-softer); flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 20px; }
.li .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid #c6d8d1; flex: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: #fff; }
.check.on { background: var(--mint-strong); border-color: var(--mint-strong); color: #fff; }
.li.done .t { text-decoration: line-through; color: var(--ink-3); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; line-height: 1; }
.qty span { min-width: 18px; text-align: center; font-weight: 600; }
.group-title { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 2px; display: flex; justify-content: space-between; }

/* ---------- Empfehlung ---------- */
.reco { display: flex; gap: 14px; align-items: flex-start; }
.reco .icon { width: 44px; height: 44px; border-radius: 14px; background: var(--mint); color: #053d2d; display: flex; align-items: center; justify-content: center; flex: none; }
.reco .icon svg { width: 24px; height: 24px; }
.reco .title { font-weight: 700; font-size: 16px; }
.reco .why { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.calc { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 13px; margin-top: 10px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.calc .total { font-weight: 700; border-top: 1px solid var(--line); padding-top: 4px; }

.compare-row { display: grid; grid-template-columns: 1fr 118px 118px; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.compare-row:last-child { border-bottom: 0; }
.compare-row.head { font-size: 12px; color: var(--ink-3); font-weight: 600; padding-top: 0; }
.compare-row .cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.compare-row .best { color: var(--mint-deep); font-weight: 700; }
.compare-row .best::after { content: ' ✓'; }

.trend-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.trend-item:last-child { border-bottom: 0; }
.trend-item .r { flex: none; white-space: nowrap; }
.trend-item .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--mint); border-radius: 999px; }
.progress.over > div { background: var(--up); }

.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }
.empty .big { font-size: 36px; margin-bottom: 6px; }

.banner { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--mint-soft); color: var(--mint-deep); margin-bottom: 18px; font-weight: 500; }
.banner.warn { background: var(--warn-soft); color: #7a5307; }
.banner .grow { flex: 1; }

/* ---------- Modal & Toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(18, 33, 28, .35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 22px; width: min(560px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.modal-body { padding: 6px 20px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Login ---------- */
.auth { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth .logo { width: 56px; height: 56px; margin-bottom: 14px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: var(--ink-3); font-size: 11px; }

/* ---------- Kassenbon ---------- */
.receipt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.receipt-table td { padding: 4px 4px; border-bottom: 1px solid var(--line); }
.receipt-table input { width: 100%; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: var(--surface-2); }
.receipt-table input:focus { border-color: var(--mint); outline: none; background: #fff; }
.receipt-table td.p { width: 96px; }
.receipt-table td.x { width: 34px; }
.preview-img { max-height: 220px; border-radius: 12px; margin: 0 auto 12px; }

/* ---------- Filialen ---------- */
.stores-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.store-map { height: 260px; border-radius: 14px; overflow: hidden; background: var(--mint-softer); border: 1px solid var(--line); z-index: 0; }
@media (max-width: 860px) { .stores-grid { grid-template-columns: minmax(0, 1fr); } .store-map { height: 200px; } }

/* ---------- Scannen ---------- */
.nav-scan { margin: 6px 4px 0; }
.scan-mobile { display: none; }
.scan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scan-opt { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); font: inherit; }
.scan-opt:hover { border-color: var(--mint); background: var(--mint-softer); }
.scan-opt .big { font-size: 28px; }
.scan-opt span:last-child { font-size: 13px; color: var(--ink-3); }
@media (max-width: 860px) { .scan-mobile { display: inline-flex; } }
@media (max-width: 420px) { .scan-grid { grid-template-columns: 1fr; } }

/* ---------- Essensplan ---------- */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.day.today { border-color: #bfe9d8; box-shadow: 0 0 0 3px rgba(62, 207, 159, .15), var(--shadow); }
.day .li.meal { align-items: flex-start; }
.day .li .s { white-space: normal; }
.ic-s { width: 13px; height: 13px; vertical-align: -2px; }
.meal-tile { background: var(--mint-softer); border: 1px solid #d5f1e6; border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.meal-tile:hover { border-color: var(--mint); }
.meal-tile .t { font-weight: 700; margin: 2px 0; }
.steps { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: calc(18px + var(--safe-t)) 16px calc(96px + var(--safe-b)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 40; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; padding: 4px 0; }
  .tabbar a.active { color: var(--mint-deep); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .span2 { grid-column: auto; }
  h1 { font-size: 23px; }
  .kpi .value { font-size: 21px; }
  .kpi-ring { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-ring svg { width: 60px; height: 60px; }
  .card { padding: 15px; }
  .offers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .offer-rail { grid-auto-columns: 168px; }
  .offer .img { height: 88px; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; max-height: 92vh; }
  .compare-row { grid-template-columns: 1fr 96px 96px; font-size: 13px; }
}
@media (max-width: 380px) {
  .g4 { grid-template-columns: 1fr; }
}
