:root {
  --bg: #f5f6f5;
  --card: #ffffff;
  --ink: #1c2321;
  --muted: #6b7772;
  --brand: #e8710a;
  --brand-dark: #b8560a;
  --line: #e2e6e4;
  --danger: #c0392b;
  --warn: #b8860b;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 72px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--card); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 360px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* App shell */
header.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
header.topbar h1 { font-size: 18px; margin: 0; }
header.topbar .user { font-size: 13px; opacity: .9; }
main { padding: 16px; padding-bottom: 90px; max-width: 900px; margin: 0 auto; }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
}
nav.tabs button {
  background: none; border: none; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 8px;
}
nav.tabs button .ic { font-size: 20px; }
nav.tabs button.active { color: var(--brand); font-weight: 600; }
nav.tabs button .ic svg.ico { width: 24px; height: 24px; margin: 0; vertical-align: middle; }

/* Duotone-Icons: Strich in currentColor, dezent gefüllt. */
svg.ico {
  width: 18px; height: 18px; vertical-align: -3px; margin-right: 7px; flex: none;
  stroke: currentColor;
  fill: color-mix(in srgb, currentColor 15%, transparent);
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
h1 svg.ico, h2 svg.ico { width: 22px; height: 22px; vertical-align: -4px; }
.login-card h1 svg.ico { width: 24px; height: 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.btn { background: var(--brand); color: #fff; border: none; border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.btn:active { background: var(--brand-dark); }
.btn.secondary { background: #eef1f0; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.section-head h2 { margin: 0; font-size: 20px; }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef1f0; color: var(--muted); }
.badge.brand { background: #fbe9d5; color: var(--brand-dark); }
.badge.warn { background: #fbf3dd; color: var(--warn); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .l { font-size: 12px; color: var(--muted); }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 13px; color: var(--muted); }
.list-item .title { font-weight: 600; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.ok { color: var(--brand-dark); font-size: 13px; margin-top: 8px; }

.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.bubble { padding: 10px 13px; border-radius: 14px; max-width: 85%; white-space: pre-wrap; line-height: 1.4; }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; }
.bubble.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: end center; z-index: 50; }
.modal { background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); }
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.offline-flag { color: var(--warn); font-size: 12px; }

/* Inventar */
.inv-row { display: flex; gap: 12px; align-items: flex-start; }
.inv-main { flex: 1; min-width: 0; }
.inv-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line); background: #f0f2f1; }
.inv-thumb.ph { display: grid; place-items: center; color: var(--muted); }
.inv-thumb.ph svg.ico { width: 28px; height: 28px; margin: 0; }
@media (prefers-color-scheme: dark) { .inv-thumb { background: #242b28; } }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.chk input { width: auto; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.rev-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.rev-item .chk { margin-bottom: 4px; font-weight: 600; }

/* Verrechnung */
.settle-card .settle-line { font-size: 17px; }
.settle-line { display: flex; align-items: center; gap: 8px; }
.settle-line svg.ico { width: 18px; height: 18px; margin: 0; }
.settle-amt { margin-left: auto; font-weight: 700; color: var(--brand-dark); white-space: nowrap; }
.cal-month { font-weight: 700; font-size: 13px; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.cal-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cal-row:last-child { border-bottom: none; }
.cal-date { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; min-width: 44px; color: var(--muted); }
.cal-main { flex: 1; min-width: 0; }
.cal-dir { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.cal-dir svg.ico { width: 15px; height: 15px; margin: 0; }
/* Aufteilungs-Slider */
.split-head { display: flex; justify-content: space-between; font-size: 14px; margin: 6px 0 2px; }
.split-range { width: 100%; accent-color: var(--brand); height: 28px; }

/* Eingabefeld + Button nebeneinander */
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { flex: none; white-space: nowrap; }

/* Toast-Benachrichtigungen */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 460px; width: max-content;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.22); font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast svg.ico { width: 20px; height: 20px; margin: 0; stroke: #fff; fill: rgba(255,255,255,.22); }
.toast.ok { background: var(--brand); }
.toast.error { background: var(--danger); }
.toast.error svg.ico, .toast.ok svg.ico { stroke: #fff; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#151917; --card:#1e2422; --ink:#e8ecea; --muted:#9aa7a2; --line:#2c3532; }
  input, select, textarea { background:#242b28; color: var(--ink); }
  .btn.secondary { background:#2c3532; color: var(--ink); }
  nav.tabs { background:#1e2422; }
}
