/* Schrift lokal – keine Verbindung zu Google (DSGVO) */
@font-face { font-family: Figtree; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/figtree-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: Figtree; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/figtree-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: Figtree; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/figtree-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: Figtree; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/figtree-latin-700-normal.woff2') format('woff2'); }

:root {
  --ink: #17212b;
  --muted: #5b6773;
  --line: #dde2e7;
  --bg: #eef1f4;
  --surface: #ffffff;
  --b: #1f5fbf;
  --open: #9a5b00;   --open-bg: #fff1d6;
  --paid: #1d7446;   --paid-bg: #e2f3e8;
  --late: #b3261e;   --late-bg: #fde6e3;
  --draft: #5b6773;  --draft-bg: #e8ecf0;
  --radius: 12px;
  --nav-h: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 Figtree, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
}
[x-cloak] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--b); }
:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }

/* ---------- Kopf ---------- */
.top {
  background: var(--b); color: #fff; transition: background .25s;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 16px;
}
.top-inner { max-width: 880px; margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.brands { display: flex; gap: 18px; flex-wrap: wrap; }
.brands button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: rgba(255,255,255,.45);
  border-bottom: 3px solid transparent; line-height: 1.25;
}
.brands button.on { color: #fff; border-bottom-color: #fff; }
.year { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 8px; padding: 6px 8px; font-weight: 600; }
.year option { color: var(--ink); }

/* ---------- Navigation ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav button {
  flex: 1; max-width: 140px; height: var(--nav-h); border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--b); }

main { max-width: 880px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 8px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Flächen ---------- */
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }

/* ---------- Übersicht ---------- */
.big { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.meter { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.meter i { display: block; height: 100%; background: var(--paid); border-radius: 99px; transition: width .4s; }
.meter i.warn { background: #d08a00; }
.meter i.over { background: var(--late); }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 70px; margin-top: 14px; }
.months div { background: var(--b); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.months-l { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 10px; color: var(--muted); text-align: center; margin-top: 3px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }

/* ---------- Listen ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.search { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); margin-bottom: 10px; }

.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: #f7f9fa; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-weight: 700; text-align: right; }
.item .sub { font-size: 13px; color: var(--muted); }
.item.strike .amt, .item.strike .name { text-decoration: line-through; color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; justify-self: end; }
.s-entwurf { color: var(--draft); background: var(--draft-bg); }
.s-offen { color: var(--open); background: var(--open-bg); }
.s-ueberfaellig { color: var(--late); background: var(--late-bg); }
.s-bezahlt, .s-angenommen { color: var(--paid); background: var(--paid-bg); }
.s-storniert, .s-storno, .s-abgelehnt { color: var(--muted); background: var(--draft-bg); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); z-index: 21;
  height: 54px; padding: 0 20px; border-radius: 27px; border: 0; background: var(--b); color: #fff;
  font-weight: 700; font-size: 16px; cursor: pointer; box-shadow: 0 6px 18px rgba(20,30,40,.25);
}

/* ---------- Formulare ---------- */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.f input, .f select, .f textarea, .inp {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: #fff; min-height: 44px;
}
.f textarea { min-height: 70px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .inp:focus { border-color: var(--b); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--b) 18%, transparent); }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--b); }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; cursor: pointer; min-height: 44px; background: var(--bg); }
.btn.pri { background: var(--b); color: #fff; }
.btn.ok { background: var(--paid); color: #fff; }
.btn.danger { background: var(--late-bg); color: var(--late); }
.btn.ghost { background: none; color: var(--b); padding-left: 6px; padding-right: 6px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1 1 auto; }

/* ---------- Sheets & Modals ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px; display: flex; align-items: center; gap: 8px;
}
.sheet-head .t { flex: 1; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { max-width: 760px; margin: 0 auto; padding: 14px 14px 110px; }

.pos { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fff; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr 1.3fr 1fr; gap: 8px; }
.pos-grid.ku { grid-template-columns: 1fr 1fr 1.3fr; }
@media (max-width: 480px) { .pos-grid, .pos-grid.ku { grid-template-columns: 1fr 1fr; } }
.pos .f { margin-bottom: 8px; }
.sum { display: flex; justify-content: space-between; padding: 4px 0; }
.sum.grand { font-size: 19px; font-weight: 700; border-top: 1.5px solid var(--ink); margin-top: 6px; padding-top: 8px; }

.detail-amt { font-size: 38px; font-weight: 700; letter-spacing: -.03em; }
.warn { background: var(--open-bg); color: #6d4100; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.logline { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }

.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(15,22,30,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
}
@media (min-width: 620px) { .backdrop { align-items: center; } .modal { border-radius: 16px; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 80;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 84px);
  background: var(--ink); color: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 600; max-width: 90vw;
}
.toast.err { background: var(--late); }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--b); }
.login .panel { width: 100%; max-width: 380px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.item .badge { align-self: start; }
