/* Standard: dunkel, neutral. Grün nur für Buttons. */
:root {
  color-scheme: dark;
  --bg: #121212;
  --paper: #1c1c1c;
  --raised: #262626;
  --ink: #ececec;
  --muted: #9b9b9b;
  --line: #2e2e2e;
  --link: #ececec;
  --accent: #2f7a52;          /* Buttons */
  --accent-hover: #37905f;
  --accent-ink: #ffffff;
  --accent-soft: #262626;     /* aktive Navigation, Hervorhebungen (neutral) */
  --sand: #2a2a2a;
  --warn: #e3a857;
  --warn-soft: #33281a;
  --bad: #ef8b84;
  --bad-soft: #3a1f1e;
  --ok-soft: #262626;
  --radius: 12px;
  --shadow: none;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f5; --paper: #ffffff; --raised: #f0f0f1; --ink: #1d1d1f; --muted: #6b6b70;
  --line: #e2e2e5; --link: #1d1d1f; --accent: #2f6e4c; --accent-hover: #285f41;
  --accent-soft: #ececee; --sand: #ececee; --warn: #9a5b13; --warn-soft: #fbf0dc;
  --bad: #9b2c2c; --bad-soft: #f8e3e1; --ok-soft: #ececee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f4f4f5; --paper: #ffffff; --raised: #f0f0f1; --ink: #1d1d1f; --muted: #6b6b70;
    --line: #e2e2e5; --link: #1d1d1f; --accent: #2f6e4c; --accent-hover: #285f41;
    --accent-soft: #ececee; --sand: #ececee; --warn: #9a5b13; --warn-soft: #fbf0dc;
    --bad: #9b2c2c; --bad-soft: #f8e3e1; --ok-soft: #ececee;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; color: var(--muted); font-weight: 600; }

/* ---------- Kopf / Navigation */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1080px; margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; gap: 1rem;
}
.brand { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: .5rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--raised);
  color: var(--ink); display: grid; place-items: center; font-size: .85rem;
  box-shadow: inset 0 0 0 1px var(--line);
}
.brand-logo { height: 30px; max-width: 140px; object-fit: contain; display: block; }
.login .brand-logo { height: 56px; max-width: 220px; margin: 0 auto; }
.nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.nav a {
  color: var(--muted); padding: .45rem .7rem; border-radius: 8px; font-weight: 500;
}
.nav a.on { color: var(--ink); background: var(--accent-soft); }
.nav a:hover { text-decoration: none; color: var(--ink); }
.nav form { margin: 0; }
.nav .linkbtn { color: var(--muted); }

main { max-width: 1080px; margin: 0 auto; padding: 1.2rem 16px 6rem; }

/* Mobile: Tab-Leiste unten */
@media (max-width: 720px) {
  .nav { display: none; }
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(6, 1fr);
    background: var(--paper); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: .5rem 0 .55rem; font-size: .68rem; color: var(--muted);
  }
  .tabs a.on { color: var(--ink); }
  .tabs a:hover { text-decoration: none; }
  .tabs svg { width: 22px; height: 22px; }
  .tabs .plus svg { width: 30px; height: 30px; }
}
@media (min-width: 721px) { .tabs { display: none; } }

/* ---------- Bausteine */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; }
@media (min-width: 721px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.head { display: flex; align-items: flex-start; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.head h1 { margin-right: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.btn, button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: .55rem 1rem; display: inline-flex; align-items: center; gap: .4rem;
  text-decoration: none; min-height: 42px;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover, button.primary:hover { background: var(--accent-hover); filter: none; }
.btn.danger, button.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.small, button.small { padding: .3rem .7rem; min-height: 34px; font-size: .88rem; }
.linkbtn { background: none; border: 0; padding: .45rem .7rem; min-height: 0; font-weight: 500; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-block; font-size: .74rem; font-weight: 600; padding: .12rem .5rem;
  border-radius: 999px; background: var(--sand); color: var(--ink); white-space: nowrap;
}
.badge.kk { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.badge.offen { background: var(--warn-soft); color: var(--warn); }
.badge.bezahlt { background: var(--raised); color: var(--ink); }
.badge.storniert { background: var(--line); color: var(--muted); text-decoration: line-through; }
.badge.overdue { background: var(--bad-soft); color: var(--bad); }

/* ---------- Tabellen / Listen */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600;
  padding: .4rem .5rem; border-bottom: 1px solid var(--line);
}
table.list td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--bg); }
.scroll { overflow-x: auto; }
@media (max-width: 720px) {
  table.list .hide-m { display: none; }
}
.empty { color: var(--muted); padding: 1rem 0; text-align: center; }

/* ---------- Formulare */
form.stack { display: grid; gap: .9rem; }
.fields { display: grid; gap: .8rem; }
@media (min-width: 721px) {
  .fields.c2 { grid-template-columns: 1fr 1fr; }
  .fields.c3 { grid-template-columns: 1fr 1fr 1fr; }
  .fields.c4 { grid-template-columns: 2fr 1fr 1fr 2fr; }
  .span2 { grid-column: span 2; }
}
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; min-height: 42px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
.check input { width: 20px; height: 20px; min-height: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg label {
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; cursor: pointer;
  display: flex; gap: .55rem; align-items: center; color: var(--ink); font-size: .95rem;
}
.seg input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.hint { font-size: .8rem; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; margin-bottom: .6rem; font-size: 1rem; }

.total-preview {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--accent-soft); border-radius: 10px; padding: .7rem .9rem;
}
.total-preview strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }

/* ---------- Meldungen */
.flash { border-radius: 10px; padding: .7rem .9rem; margin-bottom: .8rem; font-weight: 500; }
.flash.ok { background: var(--raised); color: var(--ink); border-left: 3px solid var(--accent); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }
.notice ul { margin: .3rem 0 0 1.1rem; padding: 0; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; }

/* ---------- Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 1.2rem; font-size: 1.15rem; }

/* Eingabefelder in Rastern unten bündig, auch wenn ein Label einen Hinweis hat */
.fields { align-items: end; }
table.list th.num { text-align: right; }

/* Links in Listen als Namen: hell, unterstrichen beim Hover */
table.list a { font-weight: 550; }
.version { color: var(--muted); font-size: .75rem; text-align: center; padding: 2rem 0 0; }
.logo-preview { background: #fff; border-radius: 8px; padding: 10px; display: inline-block; }
.logo-preview img { max-height: 70px; max-width: 260px; display: block; }
.doc-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: var(--raised); font-size: .68rem; font-weight: 700; color: var(--muted); }
input[type=file] { padding: .45rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* Kennzahlen auch auf dem Handy nebeneinander */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .stats .card { padding: .7rem .6rem; margin-bottom: .5rem; }
  .stats .value { font-size: 1rem; }
  .stats .label { font-size: .72rem; }
}

/* Belege erfassen */
.capture-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.capture-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4rem; min-height: 110px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; background: var(--raised);
}
.capture-btn svg { width: 32px; height: 32px; }
.capture-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.capture-btn.primary-tile { background: var(--accent); color: var(--accent-ink); border: 0; }
.beleg-img { max-width: 100%; max-height: 70vh; border-radius: 8px; display: block; background: #fff; }
