:root {
  --red: #A72920;
  --red-dark: #8a2119;
  --red-light: #fbeeed;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e6e6e9;
  --bg: #f5f5f7;
  --card: #ffffff;
  --ok: #2e8b57;
  --warn: #c98a00;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
body.public { padding-bottom: 0; }
a { color: var(--red); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .78rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); font-size: .85rem; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--red); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.topbar img { width: 38px; height: 38px; border-radius: 8px; background: #fff; object-fit: contain; }
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar .title small { display: block; color: #fff; opacity: .85; font-weight: 400; font-size: .75rem; }
.topbar a { color: #fff; }
.topbar .btn-icon { background: rgba(255,255,255,.15); border-radius: 10px; padding: 8px 10px; font-size: .85rem; }

/* Inhalt */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack > * + * { margin-top: 10px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #fff; background: var(--muted); }
.pill.ok { background: var(--ok); } .pill.warn { background: var(--warn); } .pill.err { background: var(--red); } .pill.grey { background: #9a9aa0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.neg { color: var(--red); } .amount.pos { color: var(--ok); }
.big { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }

/* Formulare */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date],
input[type=time], input[type=url], select, textarea {
  width: 100%; padding: 12px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; color: var(--ink); -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(167,41,32,.15); }
textarea { min-height: 90px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b70' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--red); vertical-align: middle; margin-right: 6px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 500; color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 12px; border: 0; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--red); color: #fff; text-align: center; min-height: 46px;
}
.btn:active { background: var(--red-dark); }
.btn.full { width: 100%; }
.btn.secondary { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; min-height: 0; font-size: .85rem; border-radius: 9px; }
.btn.ok { background: var(--ok); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }
form.inline { display: inline; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; }
.list .s { color: var(--muted); font-size: .85rem; }
.list a.item { display: flex; align-items: center; gap: 12px; color: inherit; width: 100%; }
.chev { color: #c4c4c8; font-size: 1.2rem; }
.datebox { width: 52px; text-align: center; border-radius: 10px; background: var(--red-light); color: var(--red); padding: 5px 0; line-height: 1.1; flex-shrink: 0; }
.datebox b { display: block; font-size: 1.3rem; }
.datebox small { color: var(--red); font-size: .7rem; text-transform: uppercase; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.chip { white-space: nowrap; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: .85rem; font-weight: 500; }
.chip.on { background: var(--red); color: #fff; border-color: var(--red); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 6px; text-align: left; border-top: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
td.r, th.r { text-align: right; }

/* Meldungen */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 500; font-size: .92rem; }
.flash.ok { background: #e6f4ec; color: #1f6b43; }
.flash.warn { background: #fff4d6; color: #7a5200; }
.flash.error { background: var(--red-light); color: var(--red); }

/* Untere Navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--red); display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b)); box-shadow: 0 -2px 10px rgba(0,0,0,.15);
}
.tabbar a { color: rgba(255,255,255,.75); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 600; flex: 1; padding: 4px 0; border-radius: 10px; }
.tabbar a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: #fff; background: rgba(255,255,255,.14); }

/* Oeffentliche Seiten */
.hero { background: var(--red); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 28px) 16px 60px; text-align: center; border-radius: 0 0 36px 36px; }
.hero img { width: 120px; height: 120px; border-radius: 24px; background: #fff; padding: 6px; object-fit: contain; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.hero h1 { margin-top: 14px; font-size: 1.4rem; }
.hero p { opacity: .9; margin: 0; }
.public .wrap { margin-top: -40px; }
.qr { display: flex; gap: 14px; align-items: center; }
.qr svg { width: 110px; height: 110px; border-radius: 10px; background: #fff; flex-shrink: 0; }
.links { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: .9rem; }
.install-banner { display: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; gap: 10px; align-items: center; }
.install-banner.show { display: flex; }
.code-input { font-size: 1.8rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* Monatsansicht */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.month .wd { text-align: center; font-size: .7rem; color: var(--muted); padding: 4px 0; font-weight: 600; }
.month .d { min-height: 56px; background: #fff; border-radius: 8px; padding: 4px; font-size: .78rem; }
.month .d.out { opacity: .35; }
.month .d.today { outline: 2px solid var(--red); }
.month .d .n { font-weight: 600; }
.month .d .ev { display: block; margin-top: 2px; padding: 1px 4px; border-radius: 4px; color: #fff; font-size: .62rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Kuehlschrank */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; text-align: center; cursor: pointer; }
.tile.on { border-color: var(--red); background: var(--red-light); }
.tile b { display: block; } .tile span { color: var(--muted); font-size: .85rem; }
.qty { display: flex; align-items: center; gap: 12px; justify-content: center; }
.qty button { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-size: 1.4rem; }
.qty output { font-size: 1.6rem; font-weight: 700; min-width: 40px; text-align: center; }

/* Upload */
.drop { border: 2px dashed #d8d8dc; border-radius: var(--radius); padding: 28px 16px; text-align: center; background: #fff; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--red); width: 0; transition: width .2s; }

.menu a { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.menu a:first-child { border-top: 0; }
.menu .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--red-light); color: var(--red); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.badge { background: var(--red); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .75rem; font-weight: 700; }

@media (min-width: 720px) {
  .tabbar { max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0; }
}
