:root {
  --blue: #1f5fbf;
  --blue-dark: #174a96;
  --blue-soft: #e8f0fc;
  --blue-line: #c9d9f2;
  --link: #1f5fbf;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1c2533;
  --muted: #5d6b80;
  --line: #dde4ee;
  --green: #1f8a4c;
  --green-soft: #e3f5ea;
  --red: #c0392b;
  --red-soft: #fbe9e7;
  --amber: #a86400;
  --amber-soft: #fdf1dc;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: break-word; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar { background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-sub { font-weight: 400; opacity: .8; font-size: 14px; margin-left: 6px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.who button { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.who button:hover { background: rgba(255,255,255,.25); }

.nav { background: var(--blue-dark); display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; }
.nav button { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: rgba(255,255,255,.75); padding: 11px 14px; cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; }
.ico svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button:hover { color: #fff; }
.nav button.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }

.main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.subnav { display: flex; width: max-content; max-width: 100%; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; background: var(--card); }
.subnav button { background: none; border: 0; border-left: 1px solid var(--line); padding: 8px 14px; cursor: pointer; color: var(--text); font-weight: 500; white-space: nowrap; }
.subnav button:first-child { border-left: 0; }
.subnav button.active { background: var(--blue); color: #fff; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.grid .card { margin: 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 6px 0; }

.btn { background: var(--blue); color: #fff; border: 0; border-radius: 7px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--blue-dark); }
.btn.secondary { background: var(--blue-soft); color: var(--blue-dark); }
.btn.secondary:hover { background: var(--blue-line); }
.btn.small { padding: 4px 10px; font-weight: 500; font-size: 14px; }
.btn.danger { background: none; color: var(--red); padding: 4px 8px; }
.btn.danger:hover { background: var(--red-soft); }

.form { display: grid; gap: 10px; }
.form.row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
/* Formulare mit Auswahl-Leisten: jedes Feld mindestens so breit wie sein Inhalt, sonst Umbruch */
.form.flow { display: flex; flex-wrap: wrap; align-items: end; }
.form.flow > * { flex: 1 1 160px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-line); border-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }

.weekbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.weekbar .title { font-weight: 700; font-size: 18px; min-width: 210px; text-align: center; }
.weekbar .range { color: var(--muted); font-weight: 400; font-size: 14px; display: block; }

.tag { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; vertical-align: 1px; }
.tag.prio-wichtig { background: var(--red); color: var(--card); }
.tag.prio-neutral { background: var(--line); color: var(--muted); }
.tag.prio-zusatz { background: var(--green-soft); color: var(--green); }
.tag.alltag { background: var(--amber-soft); color: var(--amber); }
.tag.woche { background: var(--blue-soft); color: var(--blue-dark); }
.tag.problem { background: var(--red-soft); color: var(--red); }
.tag.notiz { background: var(--blue-soft); color: var(--blue-dark); }
.tag.ki { background: var(--card); color: var(--blue-dark); box-shadow: inset 0 0 0 1px var(--blue); }
.tag.admin { background: var(--blue); color: #fff; }
.tag.offen { background: var(--red-soft); color: var(--red); }
.tag.behoben { background: var(--green-soft); color: var(--green); }
.tag.long { white-space: normal; overflow-wrap: anywhere; }
.tag.hinweis { background: var(--amber-soft); color: var(--amber); }

.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; width: 100%; min-width: 420px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.matrix th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.matrix tr.group td { background: var(--bg); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 10px; }
.matrix td.done { background: var(--green-soft); }
.matrix input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--blue); cursor: pointer; }
.warn { color: var(--red); font-size: 12px; font-weight: 600; margin-left: 6px; }
.matrix select.daysel { width: auto; padding: 4px 6px; font-size: 13px; }
/* Wichtigkeit direkt im Wochenplan, sieht aus wie das Schild */
.matrix select.priosel { width: auto; min-height: 0; padding: 2px 6px; font-size: 12px; font-weight: 600; border-radius: 999px; border: 0; cursor: pointer; vertical-align: 1px; }
.matrix select.priosel.prio-wichtig { background: var(--red); color: var(--card); }
.matrix select.priosel.prio-neutral { background: var(--line); color: var(--muted); }
.matrix select.priosel.prio-zusatz { background: var(--green-soft); color: var(--green); }
.matrix select.priosel option { background: var(--card); color: var(--text); }
.fixed { font-size: 13px; font-weight: 600; color: var(--muted); }

.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.tasklist li:first-child { border-top: 0; }
.tasklist input[type=checkbox] { width: 22px; height: 22px; margin: 0; accent-color: var(--green); flex: none; cursor: pointer; }
.tasklist .t { flex: 1; }
.tasklist .done .t-title { text-decoration: line-through; color: var(--muted); }
.t-info { font-size: 13px; color: var(--muted); }
.t-day { font-size: 13px; font-weight: 600; color: var(--link); }
.t-day.today { color: var(--green); }
.cb-space { width: 22px; flex: none; }
/* Häkchen: Tippfläche 44 px, sichtbar wie bisher (negativer Rand gleicht die Fläche aus) */
label.tick { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -11px; cursor: pointer; }
.days { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
label.day { display: inline-block; position: relative; cursor: pointer; }
.day input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day span { display: inline-block; min-width: 34px; padding: 3px 0; text-align: center; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--card); }
.day.today span { border-color: var(--link); color: var(--link); }
.day input:checked + span { background: var(--green); border-color: var(--green); color: var(--card); }
.day input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.day.off span { opacity: .35; border-style: dashed; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--red-soft); color: var(--red); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-weight: 600; }
.filterbar { display: flex; gap: 8px; margin-bottom: 16px; }
.progress { height: 6px; background: var(--blue-soft); border-radius: 3px; overflow: hidden; margin: 6px 0 10px; }
.progress div { height: 100%; background: var(--green); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 160px; }
.rows li > form { flex: 1; }
.note-text { white-space: pre-wrap; margin-top: 4px; }

.login { max-width: 380px; margin: 40px auto; }
.error { color: var(--red); font-size: 14px; min-height: 1em; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px); }
.toast.err { background: var(--red); }
.preview-hint { background: var(--amber-soft); color: var(--amber); padding: 8px 16px; font-size: 14px; text-align: center; }
@media (max-width: 520px) {
  .brand-sub { display: none; }
  /* Kopf bleibt einzeilig: der Name wird notfalls gekürzt */
  .topbar { gap: 8px; }
  .brand { white-space: nowrap; flex: none; }
  .who { min-width: 0; gap: 8px; }
  .who > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who .tag, .who button { flex: none; white-space: nowrap; }
}
.topbar .tag.admin { background: #fff; color: var(--blue-dark); }
/* Auswahl-Leisten (Tage je Person, Ja/Nein, Schweregrad) */
.field { display: grid; gap: 4px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.cap { font-size: 13px; color: var(--muted); font-weight: 600; }
label.seg-opt { display: inline-block; position: relative; cursor: pointer; color: var(--text); font-weight: 500; font-size: 14px; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.plan-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 4px 0; }
.plan-name { min-width: 80px; font-weight: 500; }
.days.plan { margin-top: 0; }
.days.plan input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
/* Tagesleiste im Wochenplan: blau eingeteilt, grün erledigt */
.minidays { display: flex; gap: 2px; justify-content: center; }
.minidays .day span { min-width: 22px; padding: 2px 0; font-size: 11px; }
.minidays .day input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.minidays .day.ok input:checked + span { background: var(--green); border-color: var(--green); }
.tpl summary { cursor: pointer; font-weight: 600; color: var(--link); }
.tpl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.tpl-row input, .tpl-row select { width: auto; flex: 1 1 160px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; width: max-content; max-width: 100%; }
.seg-opt span { display: inline-block; padding: 7px 12px; background: var(--card); border-left: 1px solid var(--line); white-space: nowrap; }
.seg-opt:first-child span { border-left: 0; }
.seg-opt input:checked + span { background: var(--blue); color: #fff; }
.seg-opt.leicht input:checked + span { background: var(--green); color: var(--card); }
.seg-opt.mittel input:checked + span { background: var(--amber); color: var(--card); }
.seg-opt.schwer input:checked + span { background: var(--red); color: var(--card); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: -2px; }
.warn-line { color: var(--red); font-size: 13px; font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: end; }
.row-actions { display: flex; gap: 4px; align-items: center; }

/* Kuhgesundheit */
.hint { font-size: 13px; margin: -6px 0 12px; }
details.add { margin-bottom: 12px; }
details.add summary { cursor: pointer; color: var(--link); font-weight: 600; padding: 4px 0; }
details.add[open] summary { margin-bottom: 10px; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.sev { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }
.sev i { width: 14px; height: 8px; border-radius: 2px; background: var(--line); }
.sev-leicht i.on { background: var(--green); }
.sev-mittel i.on { background: var(--amber); }
.sev-schwer i.on { background: var(--red); }
.sev b { margin-left: 3px; }
.sev-leicht b { color: var(--green); }
.sev-mittel b { color: var(--amber); }
.sev-schwer b { color: var(--red); }

/* Tabellenseite */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card.sheet-card { padding: 0; overflow: hidden; }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 230px); }
table.sheet { border-collapse: collapse; width: 100%; font-size: 14px; }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.sheet th { position: sticky; top: 0; background: var(--blue-soft); color: var(--text); font-weight: 700; white-space: nowrap; z-index: 1; }
.sheet td { min-width: 90px; }
.sheet tbody tr:nth-child(even) td { background: var(--bg); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue-soft: #1d2b44; --blue-line: #2c4166; --link: #8fb4ee; --bg: #10151e; --card: #18202c; --text: #e6ebf2; --muted: #9aa8bb; --line: #2a3442;
    --green: #4cc27e; --green-soft: #183826; --red-soft: #3d1f1c; --amber-soft: #3a2c14; --red: #ef7b6d; --amber: #e0a64a;
  }
  :root:not([data-theme="light"]) .btn.secondary { color: #b9cff2; }
  :root:not([data-theme="light"]) .tag.woche, :root:not([data-theme="light"]) .tag.notiz { color: #b9cff2; }
  :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) select, :root:not([data-theme="light"]) textarea { background: #10151e; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
label.chip { display: inline-block; position: relative; cursor: pointer; font-size: 14px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip > span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.chip input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.chip input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.rights { display: flex; flex-wrap: wrap; gap: 10px 18px; }

/* Druckansicht des Wochenplans */
@media print {
  :root, :root:not([data-theme="light"]) {
    --blue-soft: #e8f0fc; --blue-line: #c9d9f2; --link: #1f5fbf; --bg: #fff; --card: #fff; --text: #000; --muted: #555; --line: #ccc;
    --green: #1f8a4c; --green-soft: #e3f5ea; --red-soft: #fbe9e7; --amber-soft: #fdf1dc; --red: #c0392b; --amber: #a86400;
  }
  body { background: #fff; color: #000; }
  .topbar, .nav, .tabbar, .more-sheet, .stats, .preview-hint, .weekbar button, .tpl, .notice, .pagehead button, .toast, .lead, .card.mine { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .matrix-wrap { overflow: visible; }
  .matrix th, .matrix td { padding: 4px 3px; }
  .minidays .day span { min-width: 15px; font-size: 8px; }
  .day span, .tag { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  /* Bestandsbuch: nur der Ausdruck, quer auf A4 */
  .no-print { display: none !important; }
  body:has(.bb-doc), body:has(.print-doc) { page: querformat; }
  body:has(.bb-doc) .main, body:has(.print-doc) .main { max-width: none; padding: 0; }
  /* Listen mit Drucktabelle: nur die Tabelle drucken */
  body:has(.print-doc) .main > :not(.print-doc) { display: none !important; }
  .print-doc { display: block !important; }
  .print-doc h3 { margin: 12px 0 4px; }
  /* Breite Tabellen auf die Seitenbreite bringen: kleinere Schrift, lange Wörter dürfen umbrechen */
  .print-doc .bb-table { width: 100%; font-size: 7pt; }
  .print-doc .bb-table th, .print-doc .bb-table td { overflow-wrap: break-word; hyphens: auto; min-width: 0; }
  .bb-doc { border: 0 !important; padding: 0; break-inside: auto; }
  .bb-wrap { overflow: visible; max-height: none; }
  .bb-table { font-size: 8pt; }
  .bb-table th { position: static; min-width: 0; }
  .bb-table th, .bb-table td { padding: 3px 4px; border: 1px solid #999; }
  .bb-table tr { break-inside: avoid; }
}
@page querformat { size: A4 landscape; margin: 10mm; }
@page { size: A4 landscape; margin: 10mm; }
.lock { margin-top: 4px; color: var(--red); font-weight: 600; font-size: 14px; }
.ration-rows { display: grid; gap: 8px; }
.ration-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; align-items: center; }
.ration-row.head { font-size: 13px; font-weight: 600; color: var(--muted); }
table.ration td.num, table.ration th.num { text-align: right; white-space: nowrap; }
table.ration tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
table.ration th { position: static; }
.history { margin-top: 10px; }
.history summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 14px; }
.grid.dash { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.grid.dash h3, .card.mine h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 14px 0 2px; }
.grid.dash .progress { margin: 4px 0 0; }
.card-head + .hint { margin-top: 8px; }
.card details.tpl { margin-top: 12px; }

/* Startseite „Heute“: große Zahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: grid; justify-items: start; gap: 2px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.stat:hover { border-color: var(--blue-line); }
.stat-num { font-size: 40px; line-height: 1; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.stat.alert .stat-num { color: var(--red); }
.stat-label { font-weight: 600; }
.stat-sub { font-size: 13px; color: var(--muted); }

/* Finanzen: Summen, Kategorien mit Balken, Monatstabelle */
.fin-zeitraum { max-width: 260px; margin-bottom: 12px; }
.fin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.fin-tile { display: grid; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.fin-big { font-size: 26px; line-height: 1.15; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.fin-big.neg, td.neg { color: var(--red); }
.fin-num, td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-kat > li { display: block; }
.fin-kat summary { cursor: pointer; list-style: none; }
.fin-kat summary::-webkit-details-marker { display: none; }
.fin-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; min-height: 44px; }
.fin-kat summary .fin-name::after { content: ' ›'; color: var(--muted); }
.fin-kat details[open] summary .fin-name::after { content: ' ⌄'; }
.fin-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.fin-bar i { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.fin-bar.einnahme i { background: var(--green); }
.fin-partner { margin: 6px 0 4px 12px; }
.fin-partner select { width: auto; max-width: 200px; }
.fin-table tr.total td { font-weight: 700; border-top: 2px solid var(--blue-line); }
.fin-table .kurz { display: none; }
/* Pläne und Vorschläge */
.fin-monat { width: auto; max-width: 220px; }
.fin-soll { margin-bottom: 8px; }
.fin-info { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.fin-info.neg { color: var(--red); font-weight: 600; }
.fin-bar.drueber i { background: var(--red); }
.fin-ziele { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.fin-vtitel { margin-top: 0; }
/* Folgeaufgaben */
.folge-frage { margin-top: 4px; font-weight: 600; }
.folge-tage { display: grid; gap: 2px; width: 110px; }
.folge-tage input { width: 100%; }
@media (max-width: 700px) { .card.folge .row-actions { width: 100%; } .card.folge .row-actions .btn { flex: 1 1 0; } }
/* Beleg-Nr. mit Knopf zum Scannen */
.scanrow { display: flex; flex-wrap: wrap; gap: 8px; }
.scanrow input { flex: 1 1 140px; width: auto; }
.scanrow .t-info { flex-basis: 100%; overflow-wrap: anywhere; }
.scanrow label.btn { position: relative; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.scanrow label.btn:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; }
/* Rückfrage im Fenster der App */
.frage-hinter { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 25, 40, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.card.frage { width: 100%; max-width: 420px; margin: 0; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.card.frage p { margin: 0 0 16px; font-size: 16px; }
.card.frage .actions { flex-wrap: wrap; }
.card.frage .btn { min-height: 44px; flex: 1 1 120px; }
@media (max-width: 700px) {
  .fin-zeitraum { max-width: none; }
  .fin-tiles { grid-template-columns: 1fr; gap: 8px; }
  .fin-tile { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 14px; }
  .fin-big { font-size: 20px; }
  .fin-table { font-size: 13px; }
  .fin-table th, .fin-table td { min-width: 0; padding: 6px 6px; }
  .fin-table .lang { display: none; }
  .fin-table th { white-space: normal; }
  .fin-table .kurz { display: inline; }
  .fin-partner { margin-left: 0; }
  .fin-ziele { grid-template-columns: 1fr 1fr; }
  .matrix select.priosel { min-height: 44px; padding: 4px 8px; }
  .fin-monat { max-width: 100%; }
  .fin-partner li { flex-wrap: wrap; }
  .fin-partner select { width: 100%; max-width: none; min-height: 44px; }
}

/* Handy: Leiste unten statt Reiter oben, große Tippflächen */
.tabbar, .more-sheet { display: none; }
@media (max-width: 700px) {
  .nav { display: none; }
  .subnav { width: 100%; }
  .subnav button { flex: 1 1 0; min-height: 44px; padding: 8px 4px; }
  /* Viele Reiter: drei Spalten, Trennlinien über den Abstand */
  .subnav.many { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
  .subnav.many button { border-left: 0; background: var(--card); white-space: normal; font-size: 14px; }
  .subnav.many button.active { background: var(--blue); }
  .subnav.many button:last-child:nth-child(3n + 2) { grid-column: span 2; }
  .subnav.many button:last-child:nth-child(3n + 1) { grid-column: span 3; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tab { flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; padding: 6px 2px; }
  .tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.active { color: var(--blue); }
  .tab .ico svg, .more-sheet .ico svg { width: 24px; height: 24px; }
  .more-sheet { display: grid; position: fixed; left: 8px; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 21; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 6px; }
  .more-sheet button { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; background: none; border: 0; border-radius: 8px; text-align: left; font-weight: 600; cursor: pointer; }
  .more-sheet button.active { color: var(--blue); background: var(--blue-soft); }
  .main { padding: 16px 12px calc(84px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }

  .tasklist li { padding: 12px 0; }
  .tasklist input[type=checkbox] { width: 28px; height: 28px; }
  label.tick { margin: -8px; }
  .cb-space { display: none; }
  .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .day span { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; font-size: 13px; }
  .seg-opt span { display: flex; align-items: center; min-height: 44px; padding: 0 14px; }
  .rows .grow { min-width: min(160px, 100%); }
  .form.row > .actions, .form.row > .row-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  /* Alle Knöpfe und Eingabefelder mindestens 44 px hoch (Handschuhe, nasse Finger) */
  .btn, input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; }
  .btn.small { padding: 4px 14px; }
  details.add summary, details.tpl summary { padding: 12px 0; }
}

/* Bestandsbuch */
.filterbar.wrap { flex-wrap: wrap; }
.bb-doc h2 { margin-top: 0; }
.print-doc { display: none; }
.bb-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 0 0 14px; font-size: 14px; }
.bb-meta dt { color: var(--muted); font-weight: 600; }
.bb-meta dd { margin: 0; }
.bb-table td { vertical-align: top; }
.bb-table td:first-child, .bb-table th:first-child { white-space: nowrap; }
.fehlt { color: var(--red); font-weight: 700; }
.bb-changes h3 { font-size: 15px; margin: 14px 0 4px; }
.bb-changes ul { margin: 0; padding-left: 18px; font-size: 13px; }
@media (max-width: 520px) { .bb-meta { grid-template-columns: 1fr; } .bb-meta dd { margin-bottom: 6px; } }
.bb-table th { white-space: normal; min-width: 70px; }

/* Einstellungen: API-Verbindungen und KI-Connector */
.testout { margin-top: 10px; display: grid; gap: 4px; font-size: 14px; }
.test-ok { color: var(--green); font-weight: 600; }
.test-bad { color: var(--red); font-weight: 600; }
.t-info.neg { color: var(--red); }
.verbindung-wert { font-size: 18px; font-weight: 700; color: var(--blue); align-self: center; }
.verbindung .t-info { overflow-wrap: anywhere; }
.ki-adresse { display: flex; gap: 8px; }
.ki-adresse input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.ki-hinweis { margin: 8px 0 4px; }
.ki-bereich .grow { min-width: min(240px, 100%); }
@media (max-width: 700px) { .ki-bereich .seg { display: flex; width: 100%; } .ki-bereich .seg-opt { flex: auto; } .ki-bereich .seg-opt span { justify-content: center; padding: 0 8px; } }
pre.sample { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 7px; max-height: 260px; overflow: auto; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
label.check input { width: auto; }
label.check.full { grid-column: 1 / -1; }
label.check .t-info { font-weight: 400; } label.check strong { color: var(--text); }
/* Termine */
.termin-wann { font-size: 13px; font-weight: 600; color: var(--link); }

/* Einstellungen › Service: Antwort des Betreibers */
.service-antwort { white-space: pre-wrap; background: var(--blue-soft); border-radius: 7px; padding: 8px 10px; margin-top: 6px; }

/* Listen importieren: Zuordnung der Spalten und Fehlerliste */
.import-karte > * { min-width: 0; }
.import-zeile { display: grid; grid-template-columns: 1fr minmax(12em, 16em); gap: 4px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.import-zeile .muted { font-weight: 400; }
@media (max-width: 700px) { .import-zeile { grid-template-columns: 1fr; } .import-zeile select { min-height: 44px; } }
.import-fehler { margin: 6px 0; padding-left: 20px; color: var(--red); font-size: 14px; }

/* Lager */
.lager-bestand { font-weight: 600; font-variant-numeric: tabular-nums; }
.lager-minus { color: var(--red); font-variant-numeric: tabular-nums; }
.lager-plus { color: var(--green); font-variant-numeric: tabular-nums; }
.lager-schnell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.lager-kopf { margin: 0 0 8px; }
.lager-zuordnung { max-width: 15em; }
@media (max-width: 700px) { .lager-zuordnung { max-width: none; width: 100%; min-height: 44px; } }

/* Einklappbare Dashboard-Karten: am PC immer offen, am Handy mit Pfeil */
details.klapp > summary { list-style: none; display: flex; align-items: flex-start; gap: 10px; }
details.klapp > summary::-webkit-details-marker { display: none; }
details.klapp > summary > .card-head { flex: 1; min-width: 0; flex-wrap: nowrap; align-items: center; }
details.klapp > summary > .card-head .tag { flex: none; }
.klapp-pfeil { display: none; }
@media (max-width: 700px) {
  details.klapp > summary { cursor: pointer; min-height: 44px; align-items: center; }
  details.klapp:not([open]) > summary h2 { margin-bottom: 0; }
  .klapp-pfeil { display: block; flex: none; width: 10px; height: 10px; margin: 0 6px 6px 0; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
  details.klapp[open] .klapp-pfeil { transform: rotate(-135deg); margin: 6px 6px 0 0; }
}
/* Als App oder im Vollbild auf großen Bildschirmen: Seite nutzt die Breite, Karten wachsen mit (Max 6.10.) */
@media (display-mode: standalone) and (min-width: 1200px), (display-mode: fullscreen) and (min-width: 1200px) {
  .main { max-width: 1800px; padding: 24px 32px 60px; }
  .dash-oben { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 0 16px; align-items: start; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .grid.dash { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
}

/* Offline (offline.js): Leiste unter dem Kopf */
.offline-leiste { background: var(--amber-soft); color: var(--amber); font-size: 14px; font-weight: 600; padding: 8px 16px; text-align: center; }
.offline-leiste.nur-warten { background: var(--blue-soft); color: var(--blue-dark); }
.offline-fehler { margin-top: 4px; color: var(--red); font-weight: 500; }
