:root {
  --ink: #12161a;
  --ink-2: #1b2229;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e4ded2;
  --line-2: #efeae1;
  --text: #1a1f24;
  --muted: #5d656e;
  --accent: #c2610a;
  --accent-soft: #fdf1e3;
  --ok: #157347;
  --ok-soft: #e7f4ec;
  --warn: #a8600a;
  --warn-soft: #fdf3e0;
  --bad: #a5231f;
  --bad-soft: #fbeae8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 22, 26, .06), 0 8px 24px -16px rgba(18, 22, 26, .35);
  --nav-h: 62px;
  font-synthesis: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- Gerüst ---------- */

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--ink);
  color: #fff;
  padding: 14px 18px calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(145deg, #e08a2e, #c2610a);
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #1a1206;
  flex: 0 0 auto;
}
.topbar .titles { min-width: 0; }
.topbar .kicker {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: #9aa4ae; font-weight: 600;
}
.topbar h1 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar button {
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14);
  color: #fff; border-radius: 9px; padding: 7px 11px; font-size: 12.5px; cursor: pointer;
}
.topbar button:hover { background: rgba(255,255,255,.16); }

main { padding: 16px 16px 108px; max-width: 1080px; width: 100%; margin: 0 auto; flex: 1; }

/* ---------- Navigation ---------- */

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav button {
  background: none; border: 0; cursor: pointer;
  padding: 9px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.nav button .ico { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .55; }
.nav button[aria-current="true"] { color: var(--accent); }
.nav button[aria-current="true"] .ico { filter: none; opacity: 1; }
.nav button .dot {
  position: absolute; transform: translate(13px, -3px);
  width: 6px; height: 6px; border-radius: 50%; background: var(--bad);
}

/* ---------- Bausteine ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card.flush { padding: 0; overflow: hidden; }

.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 10px;
}
.section-title h2 { font-size: 15px; }
.section-title span { font-size: 12.5px; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  background: var(--line-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { border-color: #d3cbbc; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); border-color: #f0d3d0; background: var(--bad-soft); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(194, 97, 10, .7);
}
.fab:active { transform: scale(.96); }

/* ---------- Kennzahlen ---------- */

.hero {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
}
.hero .label { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: #98a2ac; font-weight: 650; }
.hero .big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.hero .sub { color: #b9c1c9; font-size: 13px; margin-top: 2px; }

.bar { height: 7px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s; }
.bar.ok > i { background: var(--ok); }
.bar.bad > i { background: var(--bad); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; }
.kpi .n { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- Listen ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: #fbfaf7; }
.item .lead {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 16px;
}
.item .lead.neutral { background: #fff; color: var(--muted); border: 1.5px solid #d7d0c3; font-size: 13px; }

.check {
  width: 22px; height: 22px; flex: 0 0 auto;
  border-radius: 50%; border: 1.6px solid #b3a997; background: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--ok); line-height: 1;
}
.check.done { background: var(--ok-soft); border-color: #86bf9d; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: 14.5px; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amount { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.item .chev { color: #c3b9a8; font-size: 18px; }

.empty {
  text-align: center; padding: 30px 18px; color: var(--muted);
}
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }

/* ---------- Formulare ---------- */

.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,97,10,.12); }
textarea { resize: vertical; min-height: 84px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Dialog ---------- */

dialog {
  border: 0; padding: 0; border-radius: 18px;
  width: min(560px, calc(100vw - 20px));
  max-height: 88vh;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 60px -20px rgba(18,22,26,.5);
}
dialog::backdrop { background: rgba(18, 22, 26, .55); backdrop-filter: blur(2px); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px; position: sticky; top: 0; background: var(--card); z-index: 2;
}
.sheet-body { padding: 6px 18px 18px; overflow-y: auto; }

/* ---------- Tabellen (Bericht) ---------- */
@media (max-width: 899px) {
  #view table { font-size: 11.5px; }
  #view table th, #view table td { padding-left: 8px !important; padding-right: 8px !important; }
}

/* ---------- Sonstiges ---------- */

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-sm); padding: 12px 13px;
  font-size: 13px;
}
.banner.warn { background: var(--warn-soft); color: #6c4506; }
.banner.info { background: #eef2f6; color: #33465a; }
.banner .ico { font-size: 16px; line-height: 1.2; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.thumb {
  width: 46px; height: 46px; border-radius: 9px; object-fit: cover;
  border: 1px solid var(--line); flex: 0 0 auto; background: var(--line-2);
}

.hr { height: 1px; background: var(--line-2); margin: 14px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 78px);
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 550;
  padding: 10px 16px; border-radius: 999px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Desktop ---------- */

.desk-only { display: none; }

@media (min-width: 900px) {
  .app { padding-bottom: 0; padding-left: 220px; }
  .nav {
    top: 0; right: auto; width: 220px; height: 100dvh;
    grid-template-columns: 1fr; grid-auto-rows: min-content;
    padding: 74px 12px 12px; gap: 2px; border-top: 0; border-right: 1px solid var(--line);
    background: #fff; backdrop-filter: none;
    z-index: 35;
  }
  .nav button {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 10px; font-size: 14px; width: 100%;
  }
  .nav button[aria-current="true"] { background: var(--accent-soft); }
  .topbar { position: fixed; top: 0; left: 0; width: 220px; height: 64px; z-index: 45; }
  .topbar .kicker { display: none; }
  .topbar h1 { font-size: 13.5px; letter-spacing: -.02em; }
  .topbar .mark { width: 28px; height: 28px; font-size: 14px; }
  .topbar button { padding: 6px 9px; }
  .topbar #btn-settings { display: none; }
  .desk-only { display: inline-flex; }
  .fab { display: none; }
  main { padding: 84px 28px 40px; }
  .fab { right: 30px; bottom: 30px; }
  .toast { bottom: 30px; left: calc(50% + 110px); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  main { padding-bottom: 96px; }
}

@media print {
  .topbar, .nav, .fab, .no-print { display: none !important; }
  .app { padding: 0; }
  main { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11pt; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}
