:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #17201d;
  --muted: #5d6b66;
  --line: #dde3df;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d9f0ec;
  --red: #c2410c;
  --red-soft: #fde8dd;
  --amber: #a16207;
  --amber-soft: #fbf0cf;
  --green: #15803d;
  --green-soft: #dcf3e3;
  --blue: #1d4ed8;
  --blue-soft: #e0e8fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --surface: #171e1b; --surface-2: #1f2824; --text: #e7eeea; --muted: #9aa9a3; --line: #2b3632;
    --brand: #2dd4bf; --brand-ink: #062a26; --brand-soft: #123b36;
    --red: #fb923c; --red-soft: #3a2116; --amber: #facc15; --amber-soft: #3a3214;
    --green: #4ade80; --green-soft: #15301f; --blue: #93b4ff; --blue-soft: #1b2645;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .78rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: .35rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { padding: 4rem 1rem; text-align: center; color: var(--muted); }

/* Layout */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(var(--safe-t) + 14px) 16px 10px; display: flex; align-items: center; gap: 12px;
}
.topbar .logo { width: 30px; height: 30px; border-radius: 8px; }
.topbar .title { font-weight: 650; flex: 1; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 4px 16px calc(96px + var(--safe-b)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; max-width: 160px; text-decoration: none; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 9px 4px 8px; font-size: .74rem; font-weight: 550; position: relative;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--brand); }
.tabbar .dot { position: absolute; top: 6px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* Komponenten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 11px;
  padding: 10px 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 44px; text-decoration: none; color: var(--text);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.btn.ok { background: var(--green-soft); border-color: transparent; color: var(--green); }
.btn.empty { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 6px 11px; font-size: .88rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 1.1rem; border-radius: 14px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.low { background: var(--amber-soft); color: var(--amber); }
.pill.empty { background: var(--red-soft); color: var(--red); }
.pill.info { background: var(--blue-soft); color: var(--blue); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 550; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.banner { border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; align-items: flex-start; }
.banner.warn { background: var(--amber-soft); color: var(--text); }
.banner.alert { background: var(--red-soft); }
.banner.info { background: var(--brand-soft); }
.banner svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 13px; font-size: .88rem; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Vorrat */
.item { display: flex; gap: 12px; align-items: center; }
.item + .item { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.item .name { font-weight: 620; }
.item .meta { font-size: .82rem; color: var(--muted); }
.item .actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 420px) {
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; }
  .item .actions .btn { flex: 1; }
}

/* Liste */
.list > .li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > .li:first-child { border-top: 0; padding-top: 2px; }
.list > .li:last-child { padding-bottom: 2px; }

/* Admin-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); }
.tile svg { width: 26px; height: 26px; color: var(--brand); }
.tile b { font-size: 1rem; }
.tile span { font-size: .82rem; color: var(--muted); }

/* Mikrofon */
.mic {
  width: 112px; height: 112px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; margin: 8px auto; cursor: pointer; box-shadow: 0 6px 20px rgba(15, 118, 110, .3);
}
.mic svg { width: 46px; height: 46px; }
.mic.on { background: var(--red); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 65, 12, .45); } 70% { box-shadow: 0 0 0 22px rgba(194, 65, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(194, 65, 12, 0); } }
.parsed-row { display: grid; grid-template-columns: 28px 1fr 74px 110px; gap: 8px; align-items: center; }
.parsed-row + .parsed-row { margin-top: 8px; }
.parsed-row input[type=text], .parsed-row input[type=number] { min-height: 40px; padding: 8px 10px; }
@media (max-width: 520px) { .parsed-row { grid-template-columns: 28px 1fr 64px; } .parsed-row .unit { grid-column: 2 / 4; } }

/* Krank */
.sick-hero { text-align: center; padding: 22px 16px; }
.sick-hero .big { font-size: 2.6rem; font-weight: 750; line-height: 1; margin: 6px 0; }

/* Login */
.login { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-t) + 9vh) 16px 40px; }
.login .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 18px; }

/* Toast + Modal */
#toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 550; z-index: 30;
  max-width: calc(100% - 32px); transition: .2s; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); color: #fff; }
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 12, .45); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
#modal .sheet {
  background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
}
@media (min-width: 700px) { #modal { align-items: center; } #modal .sheet { border-radius: 18px; } }
#modal .sheet.viewer { max-width: 900px; height: 90vh; display: flex; flex-direction: column; }
#modal .sheet.viewer iframe, #modal .sheet.viewer img { flex: 1; width: 100%; border: 0; object-fit: contain; background: var(--surface); border-radius: 10px; min-height: 0; }

table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.simple tr:first-child td { border-top: 0; }
.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
