/* HausKasse – warm, ruhig, Mobile First */
:root {
  --bg: #F8F3EA;
  --bg-2: #F1E9DB;
  --card: #FFFCF6;
  --line: #E6DCCB;
  --line-2: #D9CDB8;
  --text: #3B372F;
  --muted: #7A7366;
  --sage: #7F9172;
  --sage-d: #5E7052;
  --sage-l: #E3E9DC;
  --sage-xl: #EEF2E9;
  --beige: #E9DFCC;
  --amber: #C98F2E;
  --amber-l: #F7EAD0;
  --red: #B85C50;
  --red-l: #F5DFDA;
  --green: #5E8A4E;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(80, 64, 40, .06), 0 4px 14px rgba(80, 64, 40, .06);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--sage-d); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 3px solid rgba(95, 112, 82, .55); outline-offset: 2px; border-radius: 8px; }

/* ---------- Grundgerüst ---------- */
.app { max-width: 720px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 16px calc(var(--nav-h) + var(--safe-b) + 28px); min-height: 100vh; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; }
.page-head h1 { flex: 1; }
.page-head .back { margin-left: -8px; }
.section { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.section h2 { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Karten ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; }
.card.tint { background: var(--sage-xl); border-color: var(--sage-l); }
.hero { background: linear-gradient(160deg, #8C9E7E 0%, #6F8263 100%); color: #FFFDF7; border: 0; }
.hero .muted { color: rgba(255, 253, 247, .82); }
.hero .big { font-size: 36px; font-weight: 700; letter-spacing: -.02em; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; }
.tile .label { font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.tile .value { font-size: 18px; font-weight: 650; margin-top: 4px; }
.hero .tile { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); }
.hero .tile .label { color: rgba(255, 253, 247, .85); }

/* ---------- Listen ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 56px; }
.list > .item:first-child { border-top: 0; }
.list > button.item, .list > a.item { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; text-decoration: none; color: inherit; }
.list > .item:first-child { border-top: 0; }
.list > button.item:active, .list > a.item:active { background: var(--bg-2); }
.item .title { font-weight: 560; }
.item .sub { font-size: 13.5px; color: var(--muted); }
.item .amount { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 4px 6px; text-transform: uppercase; letter-spacing: .04em; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty .icon { font-size: 34px; margin-bottom: 6px; }
.chev { color: var(--line-2); flex: none; width: 20px; height: 20px; }
.thumb svg { width: 22px; height: 22px; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation; transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--sage-d); border-color: var(--sage-d); color: #FFFDF7; }
.btn.primary:active { background: #536447; }
.btn.soft { background: var(--sage-l); border-color: var(--sage-l); color: #3F4D36; }
.btn.danger { background: var(--card); color: var(--red); border-color: #E5C3BD; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--sage-d); padding: 0 10px; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14.5px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--sage-d); flex: none; }
.icon-btn:active { background: var(--bg-2); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chips, Badges, Segmente ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line-2); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14.5px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--sage-d); border-color: var(--sage-d); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--muted); white-space: nowrap; }
.badge.red { background: var(--red-l); color: #8E3F35; }
.badge.amber { background: var(--amber-l); color: #87601C; }
.badge.green { background: var(--sage-l); color: #3F5934; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.segment { display: flex; background: var(--bg-2); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segment a, .segment button { flex: 1; text-align: center; padding: 9px 4px; border-radius: 10px; font-weight: 600; font-size: 14.5px; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; }
.segment [aria-current="page"], .segment [aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(80, 64, 40, .12); }

/* ---------- Formulare ---------- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.grid2 > .field + .field, .grid3 > .field + .field { margin-top: 0; }
.field > span, .label-text { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 5px 2px; font-weight: 550; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px;
  background: #FFFEFB; font-size: 16px; appearance: none; -webkit-appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px rgba(127, 145, 114, .25); }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }
input[type="date"].input { min-height: 46px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--sage-d); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: left .15s; }
.switch input:checked { background: var(--sage-d); }
.switch input:checked::after { left: 23px; }
.form-error { color: var(--red); font-size: 14px; margin-top: 8px; }
.search { position: relative; }
.search .input { padding-left: 40px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

/* ---------- Navigation unten ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255, 252, 246, .94);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.nav ul { list-style: none; margin: 0 auto; padding: 0 6px; display: flex; max-width: 720px; height: var(--nav-h); align-items: center; }
.nav li { flex: 1; display: flex; justify-content: center; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 6px 4px; border-radius: 12px; min-width: 60px; }
.nav a svg { width: 25px; height: 25px; }
.nav a[aria-current="page"] { color: var(--sage-d); }
.nav a.scan { background: var(--sage-d); color: #fff; width: 56px; height: 56px; min-width: 0; border-radius: 20px; justify-content: center; margin-top: -18px; box-shadow: 0 6px 16px rgba(94, 112, 82, .4); }
.nav a.scan svg { width: 28px; height: 28px; }

/* ---------- Dialoge ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: calc(100% - 24px - var(--safe-t));
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text); box-shadow: 0 -8px 30px rgba(50, 40, 25, .18);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet.full { height: calc(100% - 12px - var(--safe-t)); }
dialog.sheet::backdrop { background: rgba(45, 38, 28, .38); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 22px; max-height: 88vh; } dialog.sheet.full { height: 88vh; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 10px 18px; border-bottom: 1px solid var(--line); background: var(--card); }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { padding: 16px 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-foot { padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
@keyframes slideup { from { transform: translateY(40px); } to { transform: none; } }
dialog.sheet[open] { animation: slideup .18s ease-out; }

/* ---------- Toasts und Laden ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #3B372F; color: #FFFDF7; padding: 11px 16px; border-radius: 14px; font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 520px; pointer-events: auto; animation: slideup .18s ease-out; }
.toast.error { background: #9C4A40; }
.toast.ok { background: #50643F; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.loading .spin { width: 22px; height: 22px; border: 3px solid var(--line-2); border-right-color: var(--sage); border-radius: 50%; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 0%, #F7F0E4 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); height: 110px; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-box { background: var(--red-l); color: #7E3A31; border-radius: var(--radius-s); padding: 12px 14px; }
.notice { border-radius: var(--radius-s); padding: 12px 14px; font-size: 14.5px; display: flex; gap: 10px; align-items: flex-start; }
.notice.ok { background: var(--sage-l); color: #3F5934; }
.notice.warn { background: var(--amber-l); color: #6E4E14; }
.notice.bad { background: var(--red-l); color: #7E3A31; }
.notice strong { display: block; }

/* ---------- Diagramme und Balken ---------- */
.bar { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--sage); }
.bar.yellow > i { background: var(--amber); }
.bar.red > i { background: var(--red); }
.hero .bar { background: rgba(255, 255, 255, .25); }
.hero .bar > i { background: #FFFDF7; }
.donut-wrap { display: flex; gap: 16px; align-items: center; }
@media (max-width: 480px) { .donut-wrap { flex-direction: column; align-items: stretch; } .donut-wrap svg { align-self: center; } }
.donut-wrap svg { flex: none; }
.legend { list-style: none; padding: 0; margin: 0; flex: 1; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; }
.legend li .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 14px; padding: 4px 0; }
.hbar .bar { height: 12px; }

/* ---------- Belegprüfung ---------- */
.pos { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-top: 8px; }
.pos > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; }
.pos > summary::-webkit-details-marker { display: none; }
.pos[open] > summary { border-bottom: 1px solid var(--line); }
.pos .pos-body { padding: 12px; }
.pos .name { font-weight: 560; }
.qtyrow { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1.2fr; gap: 8px; }
.qtyrow .field + .field { margin-top: 0; }
.sumcheck { position: sticky; top: -16px; z-index: 2; margin: -16px -16px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.sumcheck.ok { background: var(--sage-l); color: #3F5934; }
.sumcheck.bad { background: var(--red-l); color: #7E3A31; }

/* ---------- Upload ---------- */
.dropzone { display: grid; gap: 12px; }
.big-action { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; }
.big-action .ico { width: 52px; height: 52px; border-radius: 16px; background: var(--sage-l); color: var(--sage-d); display: flex; align-items: center; justify-content: center; flex: none; }
.big-action .ico svg { width: 28px; height: 28px; }
.big-action strong { display: block; font-size: 17px; }
.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--muted); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.done { color: var(--green); }
.steps .mark { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.preview-strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 12px; }
.preview-strip img { height: 120px; width: auto; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Rezepte und Plan ---------- */
.rcard { display: flex; gap: 12px; align-items: center; }
.thumb { width: 60px; height: 60px; border-radius: 14px; object-fit: cover; background: var(--beige); flex: none; display: flex; align-items: center; justify-content: center; font-size: 26px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-photo { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); background: var(--beige); }
.stars { display: inline-flex; gap: 2px; color: #D2A64B; }
.stars button { background: none; border: 0; padding: 4px; font-size: 26px; line-height: 1; cursor: pointer; color: var(--line-2); }
.stars button.on { color: #D2A64B; }
.stepper { display: inline-flex; align-items: center; background: var(--bg-2); border-radius: 14px; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--sage-d); }
.stepper output { min-width: 34px; text-align: center; font-weight: 650; }
.ing-list { list-style: none; padding: 0; margin: 0; }
.ing-list li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.ing-list li:first-child { border-top: 0; }
.ing-list .q { min-width: 86px; font-variant-numeric: tabular-nums; font-weight: 600; }
.instructions { white-space: pre-wrap; }
.plan-day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.plan-day + .plan-day { margin-top: 10px; }
.plan-day.today { border-color: var(--sage); box-shadow: 0 0 0 2px var(--sage-l); }
.plan-day h3 { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.slot { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--bg-2); }
.slot:first-of-type { border-top: 0; }
.slot .slot-name { width: 78px; flex: none; font-size: 13px; color: var(--muted); padding-top: 9px; }
.slot .entries { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; }
.entry { background: var(--sage-xl); border: 1px solid var(--sage-l); border-radius: 10px; padding: 6px 10px; font-size: 14.5px; cursor: pointer; text-align: left; }
.add-mini { width: 36px; height: 36px; border-radius: 10px; border: 1px dashed var(--line-2); background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.shop-item { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; border-top: 1px solid var(--line); min-height: 54px; }
.shop-item:first-child { border-top: 0; }
.shop-item .check { padding: 0 8px; }
.shop-item.done .title { text-decoration: line-through; color: var(--muted); }
.shop-item .edit { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 8px 4px; cursor: pointer; }
.addbar { display: flex; gap: 8px; }
.addbar .input { flex: 1; }

/* ---------- Anmeldung ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand .name { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }

@media (min-width: 560px) { .grid-auto { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid-auto > .card + .card { margin-top: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
