/* KBS – schlicht, gut lesbar, mobilfreundlich. Keine externen Schriften oder Bibliotheken. */
:root {
  --bg: #f6f7f5; --fg: #1d2420; --muted: #5d6762; --card: #ffffff; --line: #d9ddd8;
  --accent: #2f6b4f; --accent-fg: #ffffff; --danger: #a2322a; --ok-bg: #e5f2ea; --err-bg: #fbe9e7; --info-bg: #eef2f8;
  --warn: #8a5a00;
  --field: #858f89; /* Feldrahmen, Kontrast 3,3 : 1 auf Weiß (WCAG 1.4.11) */
  --radius: 8px; --radius-sm: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
footer { max-width: 960px; margin: 32px auto; padding: 0 16px; color: var(--muted); font-size: 14px; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.25rem; margin: 24px 0 8px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
a { color: var(--accent); }

/* Kopfzeile: Zeile 1 Marke + Abmelden, Zeile 2 Menü als Tab-Leiste; an der Inhaltsbreite (960 px) ausgerichtet.
   Am Handy scrollt das Menü waagrecht, der Verlauf rechts zeigt „hier geht's weiter“. */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 960px; margin: 0 auto; padding: 0 16px; display: grid;
  grid-template-columns: 1fr auto; align-items: center; column-gap: 16px; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); font-size: 1.15rem; padding: 10px 0; }
.brand span { font-weight: 400; color: var(--muted); font-size: .9rem; }
.top .logout { grid-column: 2; grid-row: 1; }
.top .logout button.link { font-size: .9rem; color: var(--muted); padding: 10px 0; }
.top nav { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; gap: 0 22px; overflow-x: auto;
  scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { text-decoration: none; white-space: nowrap; padding: 10px 0 8px; border-bottom: 3px solid transparent; }
.top nav a[aria-current="page"] { font-weight: 700; color: var(--fg); border-bottom-color: var(--accent); }
/* Verwaltung: Segment-Leiste mit aktivem Punkt */
.subnav { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; padding: 4px; background: #e9ece8; border-radius: 10px; }
.subnav a { text-decoration: none; padding: 6px 12px; border-radius: 7px; }
.subnav a[aria-current="page"] { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.devbar { margin: 0; padding: 4px 16px; background: #fff4d6; color: var(--warn); font-size: 14px; text-align: center; }
@media (max-width: 560px) {
  .top nav .tab-wide { display: none; }
  .top nav a.current-narrow { font-weight: 700; color: var(--fg); border-bottom-color: var(--accent); }
  .top nav { -webkit-mask-image: linear-gradient(to right, #000 94%, transparent);
             mask-image: linear-gradient(to right, #000 94%, transparent); }
  .devbar { font-size: 13px; padding: 2px 16px; }
}
.dev { background: #fff4d6; padding: 8px 12px; border-radius: var(--radius-sm); word-break: break-all; }

/* Schmale Seiten (Anmelden, Code, 2FA): am Computer zentrierte Karte */
.narrow { max-width: 520px; margin: 16px auto; }
@media (min-width: 561px) {
  .narrow { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px 32px; margin-top: 40px; }
  .narrow h1 { margin-top: 0; }
}
@media (hover: hover) and (pointer: fine) { /* Computer: QR-Code ist der Hauptweg, Handy-Knopf nur Nebenweg */
  .narrow .button-big { background: #fff; color: var(--accent); font-size: 1rem; padding: 10px 18px; }
}

/* Karten: 20 px rundum (Handy 16 px); Rand-Abstände des ersten/letzten Kinds nicht zusätzlich.
   Versteckte csrf-Felder stehen oft vorne, daher die beiden Zusatz-Selektoren. */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 12px 0; }
.card > :first-child,
.card > input[type="hidden"]:first-child + :not(input),
.card > input[type="hidden"]:first-child + input[type="hidden"] + :not(input) { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
@media (max-width: 560px) { .card { padding: 16px; } }
/* Formulare und Bezahl-Karte am Computer nicht breiter als nötig */
form.card, .card.pay { max-width: 680px; }

/* Formular-Steuerelemente: einheitlich 48 px hoch, sichtbarer Rahmen, Akzentfarbe, eigener Fokus */
label { display: block; margin: 12px 0 4px; font-weight: 600; }
label.check { font-weight: 400; display: flex; gap: 12px; align-items: flex-start; min-height: 32px; margin: 8px 0; }
label.check input { margin-top: 2px; }
input, select, textarea { width: 100%; min-height: 48px; font: inherit; padding: 10px 12px; border: 1px solid var(--field);
  border-radius: var(--radius-sm); background: #fff; color: var(--fg); }
input[type="date"] { height: 48px; }
select { -webkit-appearance: none; appearance: none; padding-right: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232f6b4f' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; margin: 2px 0 0;
  flex: none; accent-color: var(--accent); }
input[type="file"] { padding: 7px 8px; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; margin-right: 12px; padding: 6px 14px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background: #fff; color: var(--accent); cursor: pointer; }
input#code { max-width: 14ch; font-size: 1.5rem; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid #c98a00; outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[aria-invalid="true"], select[aria-invalid="true"] { border: 2px solid var(--danger); background: #fffafa; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 16px 0; padding: 8px 12px 12px; }
legend { font-weight: 600; padding: 0 4px; }
.sub { padding-left: 24px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
button, .button { display: inline-block; font: inherit; font-weight: 600; padding: 10px 18px; margin: 12px 0 0;
  border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  cursor: pointer; text-decoration: none; }
button.secondary { background: #fff; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); }
/* Ein einziger „klein“-Stil für Knöpfe und Knopf-Links */
button.small, .button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; margin: 0; }
.button-big { display: block; text-align: center; font-size: 1.1rem; padding: 14px 18px; margin: 8px 0; }
button.link { background: none; border: none; color: var(--accent); padding: 4px 0; margin: 0; font-weight: 400; text-decoration: underline; }
form.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions:empty { display: none; }
/* Handy: Hauptaktionen über die volle Breite (wie „Jetzt bezahlen“) */
@media (max-width: 560px) {
  main button:not(.small):not(.link), main .button:not(.small) { display: block; width: 100%; text-align: center; }
}
.msg { padding: 10px 14px; border-radius: 6px; margin: 8px 0 16px; }
.msg-ok { background: var(--ok-bg); }
.msg-error { background: var(--err-bg); color: var(--danger); }
.msg-info { background: var(--info-bg); }
/* Graue Kleinschrift nur für Text – nie für Knöpfe (sonst graue Schrift auf grünem Grund, Kontrast 1,07 : 1) */
.hint, .muted, .small:not(button):not(.button) { color: var(--muted); font-size: .9rem; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.secret { word-break: break-all; }
.table-wrap { overflow-x: auto; }
/* Computer: Tabellen immer gerahmt (in einer Karte reicht der Kartenrahmen) */
@media (min-width: 561px) {
  .table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
  .card .table-wrap { border: 0; }
  .table-wrap tr:last-child td { border-bottom: 0; }
}
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; font-weight: 600; color: var(--muted); }
td.card-action { vertical-align: middle; }
td a[href^="/rechnungen/"] { white-space: nowrap; } /* „R-2026-005“ nicht umbrechen */
/* Lange Namen ohne Leerzeichen (Dateinamen, Titel, Notizen) umbrechen statt über den Rand zu ragen */
main, td, dd, li, h1, h2, h3, p { overflow-wrap: break-word; }
.num { text-align: right; white-space: nowrap; }
/* Storno: nur der Betrag durchgestrichen, Status als Pille */
tr.cancelled td { color: var(--muted); }
tr.cancelled td.num { text-decoration: line-through; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 8px; } }
/* Eine Pillen-Komponente für Badge und Status; Farbe nur nach Bedeutung */
.badge, .status { display: inline-block; font-size: .8rem; font-weight: 600; line-height: 1.5; padding: 1px 10px;
  border-radius: 999px; white-space: nowrap; vertical-align: .1em; }
.badge { background: var(--ok-bg); }
.badge-warn { background: #fff4d6; color: var(--warn); }
.status-offen { background: var(--err-bg); color: var(--danger); }
.status-ueberwiesen { background: #fff4d6; color: var(--warn); }
.status-erhalten { background: var(--ok-bg); color: var(--accent); }
.status-storniert { background: #eee; color: var(--muted); }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.copy { user-select: all; -webkit-user-select: all; background: var(--bg); }
.qr-head { margin-top: 20px; }
.secret-key { font-size: 1.15rem; letter-spacing: .05em; word-spacing: .3em; }
details.manual, details.confirm { margin: 12px 0; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; }
details.confirm[open] > summary { color: var(--danger); }
.confirm-box { border: 2px solid var(--warn); background: #fff9e8; border-radius: 8px; padding: 12px 16px; margin: 12px 0; }
.confirm-box h2 { margin-top: 0; }
.qr svg { width: 240px; height: 240px; max-width: 100%; display: block; margin: 8px 0; }
.debts li { margin: 6px 0; }

/* --- Dashboard (Start) --- */
/* Reihenfolge im HTML = Handy: Begrüßung → Zu erledigen → Kacheln → „Rechnung erfassen“.
   Am Computer stehen Knopf und Kacheln wie gewohnt über „Zu erledigen“. */
.dash { display: flex; flex-direction: column; }
.dash-head h1 { margin-bottom: 4px; }
.dash-head p { margin: 0 0 4px; }
.dash-new { margin: 0 0 8px; }
.dash-new .button { margin: 8px 0 0; }
@media (min-width: 561px) {
  .dash-head { order: 1; } .dash-msg { order: 2; } .dash-snow { order: 3; } .dash-new { order: 3; } .dash-tip { order: 4; }
  .dash .tiles { order: 5; } .dash .todo { order: 6; } .dash .dash-res { order: 7; }
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--fg); }
.tile:hover, .tile:focus { border-color: var(--accent); }
.tile-label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-note { font-size: .85rem; color: var(--muted); }
.todo-open { border-left: 4px solid var(--warn); }
.todo-done { border-left: 4px solid var(--accent); }
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.todo-list li:last-child { border-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 12px; }
.grid-2 .card h2 { margin-top: 0; }
.units { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.unit { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.unit-mine { border-color: var(--accent); background: var(--ok-bg); }
.unit-label { font-weight: 600; }
.unit-saldo { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0 0 12px; }
.bars progress { grid-column: 1 / -1; width: 100%; height: 10px; appearance: none; -webkit-appearance: none;
  border: 0; border-radius: 5px; background: var(--line); overflow: hidden; }
.bars progress::-webkit-progress-bar { background: var(--line); border-radius: 5px; }
.bars progress::-webkit-progress-value { background: var(--accent); border-radius: 5px; }
.bars progress::-moz-progress-bar { background: var(--accent); border-radius: 5px; }
.soon { background: transparent; border-style: dashed; }
.soon h2 { font-size: 1rem; color: var(--muted); }
@media (max-width: 560px) {
  .todo-list li { grid-template-columns: 1fr; }
  .todo-list li .button { text-align: center; padding: 10px 12px; }
  .units { grid-template-columns: 1fr 1fr; }
  /* Kacheln 2×2 statt einzeln untereinander */
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 12px; }
  .tile-label { font-size: .72rem; }
  .tile-value { font-size: 1.3rem; }
  .tile-note { font-size: .78rem; }
}

/* --- Tabellen am Handy als Karten (table.cards, Beschriftung aus data-label) --- */
@media (max-width: 560px) {
  table.cards td, .facts dd, .facts dt, li, h1, h2, p { overflow-wrap: anywhere; min-width: 0; }
  table.cards td > * { min-width: 0; }
  table.cards, table.cards tbody { display: block; background: none; }
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.cards tr { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 8px 12px; margin: 0 0 10px; }
  /* in einer Karte keine Karte in der Karte, nur Trennlinien */
  .card table.cards tr { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 0; margin: 0; }
  .card table.cards tr:last-child { border-bottom: 0; }
  table.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border: 0; padding: 3px 0; text-align: right; }
  table.cards td.num { font-weight: 600; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--muted); text-align: left; font-size: .9rem; }
  table.cards td.card-title { order: -1; display: block; text-align: left; font-weight: 600; }
  table.cards td.card-action { display: block; text-align: left; padding-top: 6px; }
  table.cards td.card-action .button { display: block; text-align: center; padding: 10px 12px; }
  table.cards td[colspan] { display: block; text-align: left; }
}

/* --- Seite „Mehr“: große Tippflächen --- */
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.link-list a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--fg); }
.link-list a:hover, .link-list a:focus-visible { border-color: var(--accent); }
.link-list strong { color: var(--accent); }
.link-list span { color: var(--muted); font-size: .9rem; }
.lead { margin-top: -8px; color: var(--muted); }

/* --- Dokumente --- */
.energy-card h2 { margin-top: 0; }
.energy-laeuft_ab, .energy-abgelaufen, .energy-fehlt { box-shadow: inset 4px 0 0 var(--warn); }
.energy-gueltig { box-shadow: inset 4px 0 0 var(--accent); }
.hash { word-break: break-all; }
details > fieldset { margin-top: 8px; }
@media (max-width: 560px) { .energy-card .facts { grid-template-columns: max-content 1fr; } .energy-card .facts dd { margin-bottom: 0; } }

/* --- Winterdienst --- */
.dash-snow { margin: 8px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.dash-snow .snow-btn { margin: 0; flex: 1 1 260px; max-width: 420px; }
fieldset.choice { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
fieldset.choice legend { margin-bottom: 8px; font-size: 1.05rem; }
label.choice-item { display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 14px; min-height: 52px;
  border: 1px solid var(--field); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; background: #fff; }
label.choice-item:has(input:checked) { border: 2px solid var(--accent); background: var(--ok-bg); }
.snow-btn { max-width: 420px; }

/* --- Beschlüsse --- */
.prose p { margin: 0 0 8px; }
.notice-text { border-top: 1px solid var(--line); padding-top: 8px; }
.sub-input { margin: 0 0 8px 34px; width: calc(100% - 34px); }
.checks { list-style: none; padding: 0; }
.checks li { padding: 6px 0; }
.checks .ok { color: var(--accent); }
.checks .no { color: var(--muted); }
.result { font-size: 1.15rem; padding: 10px 14px; border-radius: var(--radius-sm); }
.result-angenommen { background: var(--ok-bg); }
.result-abgelehnt { background: var(--err-bg); }
.vote h2 { margin-top: 0; }
a.secondary-link { background: #fff; color: var(--accent); }
.link-list span .status { vertical-align: 0; }
@media (max-width: 560px) { .facts-2 { grid-template-columns: max-content 1fr; } .facts-2 dd { margin-bottom: 0; } }

/* Dashboard: Block „Beschlüsse“ (am Handy nach den Kacheln) */
.dash-res h2 { margin-top: 0; }
.res-list { list-style: none; padding: 0; margin: 0; }
.res-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.res-list li:last-child { border-bottom: 0; }
.res-list a { font-weight: 600; }

/* --- Lange Listen: Filter, Anzahl, Blättern --- */
details.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin: 12px 0; }
details.filters[open] { padding-bottom: 12px; }
details.filters > summary { padding: 10px 0; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.filter-grid label.check { margin-top: 36px; }
.filter-form .actions { align-items: center; gap: 16px; }
.list-count { color: var(--muted); font-size: .9rem; margin: 4px 0 8px; }
th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort-link:hover { text-decoration: underline; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0; }
.pager a, .pager-off { display: inline-flex; align-items: center; min-height: 48px; padding: 0 16px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card); text-decoration: none; font-weight: 600; }
.pager-off { color: var(--muted); font-weight: 400; background: transparent; }
.pager span:not(.pager-off) { color: var(--muted); font-size: .9rem; text-align: center; }
.detail { word-break: break-all; max-width: 380px; }
footer .product { font-size: 12px; }
footer a { display: inline-block; min-height: 44px; line-height: 44px; }

/* Passkeys: Knöpfe bleiben mit dem hidden-Attribut versteckt, bis passkey.js WebAuthn-Unterstützung erkennt */
[hidden] { display: none !important; }
.passkey-box { margin: 16px 0 24px; }
.passkey-box .button-big, .passkey-box button { width: 100%; }
/* Passkey-Knopf ist auch am Computer die Hauptaktion (anders als der otpauth-Knopf der TOTP-Einrichtung) */
.narrow button.button-big[data-passkey] { background: var(--accent); color: var(--accent-fg); font-size: 1.1rem; padding: 14px 18px; }

/* App auf den Home-Bildschirm (PWA): Anleitung mit drei Schritten, in der installierten App ausgeblendet */
.app-steps { list-style: none; margin: 12px 0; padding: 0; counter-reset: schritt; }
.app-steps li { display: flex; align-items: center; gap: 14px; padding: 8px 0; min-height: 56px; }
.step-ico { flex: 0 0 44px; width: 44px; height: 44px; color: var(--accent); }
.app-tip .button-big, .app-help .button-big, .narrow [data-install] { width: 100%; }
.standalone-only { display: none; }
@media (display-mode: standalone) {
  .app-tip, .app-step-ask { display: none; }
  .standalone-only { display: block; }
}
.push-list { list-style: none; padding: 0; margin: 12px 0; }
.push-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--line); }
.push-list li:last-child { border-bottom: 0; }
.push-list form { margin: 0; }
.filelist { margin: 0; padding-left: 1.1rem; }
