/* Split – Gestaltung. Systemschriften, keine externen Ressourcen. */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #16202a;
  --muted: #5d6b78;
  --line: #e2e7ec;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #e6f6f4;
  --plus: #0a7d4f;
  --minus: #c2410c;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --pad: clamp(16px, 2vw, 24px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #182028;
    --text: #e6edf3;
    --muted: #9aa7b4;
    --line: #2a3540;
    --brand: #2dd4bf;
    --brand-2: #5eead4;
    --brand-soft: #123532;
    --plus: #4ade80;
    --minus: #fb923c;
    --danger: #f87171;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.break { word-break: break-all; }

/* Kopf und Fuß */
.test-band { background: #b91c1c; color: #fff; text-align: center; font-weight: 700; letter-spacing: .3em; padding: 2px 0; position: sticky; top: 0; z-index: 50; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--pad); background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 1.2rem; }
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.navlink { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.navlink:hover { background: var(--brand-soft); }
.main { flex: 1; width: 100%; padding: var(--pad); }
.footer { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; padding: 18px var(--pad) 28px; font-size: .85rem; }
.footer a { color: var(--muted); }
.loading { color: var(--muted); }

/* Karten, Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.row2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); display: grid; gap: 14px; justify-items: center; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); margin-left: 8px; vertical-align: middle; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); margin: 0 0 14px; }
.notice.error { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.ok-box { padding: 14px; border-radius: 10px; background: color-mix(in srgb, var(--plus) 12%, transparent); }

/* Formulare */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .82rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.self-end { align-self: end; margin-bottom: 20px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: .9rem; padding: 0 6px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.actions.wrap { margin-top: 0; }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn.big { min-height: 50px; padding: 10px 28px; font-size: 1.05rem; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #062c28; } }

/* Anmelden */
.auth { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: center; max-width: 1100px; margin: 4vh auto; }
.auth-hero { padding: 12px; }
.logo-big { font-size: clamp(2.8rem, 7vw, 4.5rem); font-weight: 900; color: var(--brand); letter-spacing: -.03em; }
.auth-hero p { font-size: 1.25rem; color: var(--muted); margin: 0; }
.auth-card { max-width: 460px; width: 100%; justify-self: center; }
.lead { font-size: 1.05rem; }

/* Übersicht */
.dash { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: start; }
.summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.sum-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.sum-label { color: var(--muted); font-size: .9rem; }
.sum-value { font-size: 1.5rem; font-weight: 800; }
.sum-tile.plus .sum-value { color: var(--plus); }
.sum-tile.minus .sum-value { color: var(--minus); }
.sum-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.group-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.group-card { display: grid; gap: 6px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .08s, border-color .08s; }
.group-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.group-card.archived { opacity: .65; }
.gc-top { display: flex; gap: 8px; align-items: center; }
.gc-type { font-size: 1.3rem; }
.gc-name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-meta { color: var(--muted); font-size: .85rem; }
.bal { font-weight: 700; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.even { color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed a { display: block; padding: 10px 2px; color: var(--text); text-decoration: none; }
.feed a:hover { background: var(--brand-soft); }
.feed li.unread a { border-left: 3px solid var(--brand); padding-left: 10px; }
.feed-who { font-weight: 700; }
.feed-meta { display: block; color: var(--muted); font-size: .8rem; }

/* Gruppe */
.group-head { display: grid; gap: 10px; grid-template-columns: 1fr auto; align-items: center; margin-bottom: 16px; }
.gh-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gh-title h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-actions { display: flex; gap: 8px; }
.back { text-decoration: none; font-size: 1.4rem; color: var(--muted); padding: 2px 8px; border-radius: 8px; }
.back:hover { background: var(--brand-soft); }
.tabs { grid-column: 1 / -1; display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.group-body { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; }
.side { position: sticky; top: 76px; }
.bal-list, .share-list, .member-list, .plain, .debt-list { list-style: none; margin: 0; padding: 0; }
.bal-list li, .share-list li, .member-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bal-list li:last-child, .share-list li:last-child, .member-list li:last-child { border-bottom: 0; }
.amt { font-weight: 700; white-space: nowrap; }
.who { overflow: hidden; text-overflow: ellipsis; }
.member-list li.left { opacity: .55; }
.member-actions { display: flex; gap: 2px; }

.search { margin-bottom: 8px; }
.month { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 6px; }
.exp-list { display: grid; gap: 6px; }
.exp-row { display: grid; grid-template-columns: 44px 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); }
.exp-row:hover { border-color: var(--brand); }
.exp-row.deleted { opacity: .6; }
.exp-date { display: grid; text-align: center; line-height: 1.1; color: var(--muted); }
.exp-date .d { font-weight: 800; font-size: 1.15rem; color: var(--text); }
.exp-date .m { font-size: .72rem; text-transform: uppercase; }
.exp-cat { font-size: 1.5rem; text-align: center; }
.exp-desc { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-sub { color: var(--muted); font-size: .85rem; }
.exp-impact { text-align: right; font-weight: 700; }
.exp-impact .small { font-weight: 500; font-size: .75rem; }
.pay-row { color: var(--text); text-decoration: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; background: var(--brand-soft); border-radius: 12px; font-size: .92rem; }
.plain .pay-row { margin-bottom: 6px; }
.trash { margin-top: 20px; }
.trash summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.debt { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.debt:last-child { border-bottom: 0; }
.debt-actions { display: flex; gap: 6px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-value { font-size: 1.4rem; font-weight: 800; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-sub { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; }
.hb-val { font-weight: 700; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.disabled td { opacity: .5; }

/* Ausgabe-Formular */
.ef-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ef-head h1 { margin: 0; }
.ef-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.amount-row { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.amount-input { font-size: 1.6rem !important; font-weight: 800; }
.seg { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 8px; overflow-x: auto; }
.seg-btn { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 10px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.seg-btn.active { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
.person-grid { display: grid; gap: 6px; margin: 8px 0; }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(70px, 120px) auto auto; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.person input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.person input[type=text] { min-height: 36px; padding: 6px 8px; text-align: right; }
.person > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview { color: var(--muted); font-size: .85rem; min-width: 70px; text-align: right; }
.unit { color: var(--muted); }
.status { font-size: .9rem; font-weight: 600; min-height: 1.4em; }
.status.bad { color: var(--minus); }
.status.good { color: var(--plus); }
.rate-box { background: var(--brand-soft); padding: 10px 12px 2px; border-radius: 10px; margin-bottom: 12px; }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn { cursor: pointer; justify-self: start; }
.thumbs, .receipts { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.thumb, .receipt { position: relative; }
.thumb img, .receipt img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.receipt img { width: 160px; height: 160px; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }

/* Ausgabe ansehen */
.ev-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.ev-title { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.ev-title h1 { margin: 0; }
.ev-cat { font-size: 2.4rem; }
.ev-amount { font-size: 1.8rem; font-weight: 800; }
.note { white-space: pre-wrap; background: var(--bg); padding: 10px 12px; border-radius: 10px; }
.comments { list-style: none; padding: 0; margin: 0 0 12px; }
.comments li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.c-head { display: flex; align-items: center; gap: 4px; }
.c-text { white-space: pre-wrap; }
.comment-form { display: grid; gap: 8px; }
details summary { cursor: pointer; font-weight: 600; }

/* Dialog, Hinweis */
.modal { border: 0; border-radius: var(--radius); padding: 22px; background: var(--card); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(10, 20, 30, .45); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: #16202a; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100vw - 32px); transition: transform .2s; z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #b91c1c; }
.noscript { text-align: center; padding: 20px; }

/* Rechtstexte und intern */
.legal-main { width: 100%; }
.prose { max-width: 80ch; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 6px; }
body.legal .prose:has(.tiles) { max-width: none; background: transparent; border: 0; padding: 0; }
.two-col { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.bars { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; align-items: end; height: 120px; margin-bottom: 8px; }
.bar { height: 100%; display: flex; align-items: flex-end; }
.bar-fill { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.h0 { height: 2px; } .h1 { height: 5%; } .h2 { height: 10%; } .h3 { height: 15%; } .h4 { height: 20%; } .h5 { height: 25%; } .h6 { height: 30%; } .h7 { height: 35%; } .h8 { height: 40%; } .h9 { height: 45%; } .h10 { height: 50%; }
.h11 { height: 55%; } .h12 { height: 60%; } .h13 { height: 65%; } .h14 { height: 70%; } .h15 { height: 75%; } .h16 { height: 80%; } .h17 { height: 85%; } .h18 { height: 90%; } .h19 { height: 95%; } .h20 { height: 100%; }

/* Mobil */
@media (max-width: 960px) {
  .dash, .group-body { grid-template-columns: 1fr; }
  .side { position: static; }
  .dash-side { order: 2; }
}
@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .group-head { grid-template-columns: 1fr; }
  .gh-actions { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); z-index: 30; }
  .gh-actions .btn { flex: 1; }
  .group { padding-bottom: 70px; }
  .exp-row { grid-template-columns: 38px minmax(0, 1fr) auto; padding: 10px; }
  .exp-cat { display: none; }
  .person { grid-template-columns: auto minmax(0, 1fr) 90px; }
  .person .preview { grid-column: 2 / -1; text-align: left; min-width: 0; }
  .card { padding: 14px; }
  .prose { padding: 18px; }
}
