/* Immobilien-Kalkulator: dunkles Theme im Stil des HeRo-Management-Tools.
   Radius-Regel: Panels 20px, Kacheln/Tabs-Container 14px, Felder/Buttons/Tabs 10px. */
/* Schriften lokal (kein Google-CDN), Latin-Subset aus Fontsource */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('../fonts/inter-var-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/jetbrains-mono-500-latin.woff2') format('woff2');
}
:root {
  --bg: #0f1012;
  --rail: #141518;
  --panel: #17181b;
  --panel-2: #1e1f23;
  --panel-3: #25262b;
  --line: #26272c;
  --line-2: #33343a;
  --text: #ececee;
  --muted: #9a9ca3;
  --dim: #75777e;
  --accent: #3b82f6;
  --accent-deep: color-mix(in srgb, var(--accent) 82%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-text: var(--accent);
  --on-accent: #fff;
  --pos: #4cc38a;
  --warn: #f59e0b;
  --warn-big: #f59e0b;
  --neg: #f26d6d;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-xl: 20px;
  --r-l: 14px;
  --r-m: 10px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --field-focus: #202127;
  --bar-out: #4a4c53;
  --warn-bg: rgba(245, 158, 11, .1);
  --warn-text: #fcc98a;
  --on-warn: #1a1408;
  --zero-line: #45464d;
  --veil: rgba(255, 255, 255, .03);
  --row-alt: rgba(255, 255, 255, .018);
  --shadow: 0 18px 48px rgba(0, 0, 0, .45);
  --backdrop: rgba(0, 0, 0, .6);
  --c-char: #4a4c53;
  --c-rest: #9a9ca3;
  --in-h: 42px;
  color-scheme: dark;
}

/* Helles Thema: gleiche Flächenlogik, Papier statt Nacht. Werte auf AA gegen Weiß geprüft. */
:root[data-theme="light"] {
  --bg: #f3f4f6;
  --rail: #fafbfc;
  --panel: #ffffff;
  --panel-2: #f2f4f7;
  --panel-3: #e8ebf0;
  --line: #e1e4ea;
  --line-2: #cbd1da;
  --text: #15171c;
  --muted: #555c6b;
  --dim: #6b7280;
  --pos: #18794a;
  --warn: #b45309;
  --warn-big: #d97706;
  --neg: #c0352b;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --field-focus: #ffffff;
  --bar-out: #c3c8d1;
  --warn-bg: #fff4e0;
  --warn-text: #92400e;
  --on-warn: #ffffff;
  --zero-line: #aab0bb;
  --veil: rgba(16, 24, 40, .035);
  --row-alt: rgba(16, 24, 40, .025);
  --shadow: 0 18px 48px rgba(16, 24, 40, .16);
  --backdrop: rgba(16, 24, 40, .35);
  --c-char: #6b7280;
  --c-rest: #a3a9b4;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.o, .in input, .tbl, .stats dd, .dash dd, .hero-cf strong, .wf .v, .kr span:last-child, .objs .m { font-feature-settings: 'tnum' 1; }
.pos { color: var(--pos); }
.warn { color: var(--warn); }
.neg { color: var(--neg); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

/* ---------- App-Rahmen ---------- */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; transition: grid-template-columns .3s var(--ease); }
.app.rail-zu { grid-template-columns: 76px minmax(0, 1fr); }
.rail-zu .rail { padding: 22px 10px 16px; align-items: center; }
.rail-zu .brand { padding: 0 0 18px; }
.objs.mini { width: 100%; }
.objs.mini button { display: grid; justify-items: center; gap: 2px; padding: 8px 0; }
.objs.mini b { font-size: 14px; font-weight: 700; }
.objs.mini em { font-style: normal; font-family: var(--mono); font-size: 9px; color: var(--muted); }
.mini-add { display: grid; gap: 4px; width: 100%; margin-top: 8px; }
.mini-add button { height: 28px; border-radius: 8px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; }
.mini-add button:hover { border-color: var(--accent); color: var(--text); }
.collapse {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  margin-top: auto; height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-m);
  background: transparent; color: var(--muted); font-size: 13px;
}
.collapse:hover { background: var(--panel); color: var(--text); }
.rail-zu .collapse { justify-content: center; padding: 0; font-size: 16px; }
.collapse + .by { margin-top: 0; padding-top: 8px; }
.main { min-width: 0; }

.rail {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--rail); border-right: 1px solid var(--line); padding: 22px 14px 18px;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 18px; }
.brand .mark { font-weight: 800; font-size: 18px; letter-spacing: -0.03em; color: var(--accent-text); }
.brand span:last-child { font-size: 13px; color: var(--muted); }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 6px; }
.rail-add { display: flex; gap: 4px; }
.rail-add button {
  height: 26px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); font-size: 12px; font-weight: 600; color: var(--text);
}
.rail-add button:hover { border-color: var(--accent); }
.objs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.objs button {
  width: 100%; text-align: left; display: grid; gap: 4px; padding: 10px 12px;
  border: 1px solid transparent; border-radius: 12px; background: transparent;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.objs button:hover { background: var(--panel); }
.objs button[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.objs .t { display: flex; gap: 9px; align-items: baseline; font-weight: 500; font-size: 14px; }
.objs .t em {
  font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--muted);
  background: var(--panel-2); border-radius: 6px; padding: 1px 5px; flex: none;
}
.objs .m { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.pf { margin-top: 18px; padding: 16px 10px 0; border-top: 1px solid var(--line); }
.pf .eyebrow { display: block; margin-bottom: 6px; }
.by { margin: auto 0 0; padding-top: 20px; text-align: center; font-size: 12px; color: var(--dim); }
.by b { color: var(--muted); font-weight: 600; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 22px 32px 20px; border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.top p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content { padding: 24px 32px 48px; }

/* ---------- Buttons, Segmente ---------- */
.btn {
  height: 38px; padding: 0 14px; border-radius: var(--r-m); border: 1px solid var(--line-2);
  background: var(--panel-2); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.danger { color: var(--neg); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--neg) 50%, transparent); }

.seg, .tabs {
  display: inline-flex; gap: 2px; padding: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-l);
}
.seg button, .tabs button {
  border: 0; background: transparent; border-radius: var(--r-m); color: var(--muted);
  font-weight: 500; white-space: nowrap; transition: background-color .2s var(--ease), color .2s var(--ease);
}
.seg button { height: 30px; padding: 0 12px; font-size: 13px; }
.tabs button { height: 38px; padding: 0 18px; font-size: 14px; }
.seg button:hover, .tabs button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tabs button[aria-selected="true"] { background: var(--panel-3); color: var(--text); }
.seg button:disabled { opacity: .4; cursor: default; }
.seg.sm button { height: 28px; padding: 0 10px; font-size: 12px; }
.tabs { margin-bottom: 20px; max-width: 100%; overflow-x: auto; }

/* ---------- Dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 0 0 20px; }
.dash div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; min-width: 0; }
.dash dt { font-size: 12px; color: var(--muted); }
.dash dd { margin: 4px 0 2px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.dash span { font-size: 12px; color: var(--dim); }
.dash .pos dd { color: var(--pos); }
.dash .warn dd { color: var(--warn); }
.dash .neg dd { color: var(--neg); }

.panel { animation: enter .45s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Schritte ---------- */
.steps {
  list-style: none; margin: 0 0 20px; padding: 4px; display: flex; gap: 2px; overflow-x: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l);
}
.steps li { flex: 1 0 auto; }
.steps button {
  width: 100%; display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 14px;
  border: 0; border-radius: var(--r-m); background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.steps button span {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); font-size: 12px; font-weight: 600;
}
.steps button:hover { color: var(--text); }
.steps button.done span { background: var(--accent-soft); color: var(--accent-text); }
.steps button[aria-current="step"] { background: var(--panel-3); color: var(--text); }
.steps button[aria-current="step"] span { background: var(--accent); color: var(--on-accent); }
.step-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; }

/* ---------- Kalkulation ---------- */
.kalk { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.blocks { display: grid; gap: 20px; align-content: start; min-width: 0; }

.blk { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); min-width: 0; }
.blk > header { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.blk .ix {
  min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700;
}
.blk h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; min-width: 0; }
.blk .bd { padding: 18px 22px 22px; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 16px; align-items: end; }
.f { display: grid; gap: 7px; align-content: start; min-width: 0; }
.f.w2 { grid-column: span 2; }
.fl { font-size: 13px; color: var(--muted); font-weight: 500; }
.fc { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fc .in { flex: 1; }

.in {
  display: flex; align-items: center; height: 42px; min-width: 0; border-radius: var(--r-m);
  background: var(--panel-2); border: 1px solid transparent;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.in:hover { border-color: var(--line-2); }
.in:focus-within { border-color: var(--accent); background: var(--field-focus); }
.in input, .in select {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; outline: none; background: transparent;
  padding: 0 12px; text-align: right; font-weight: 500; font-size: 14px;
}
.in.txt input, .in.sel select { text-align: left; }
.in.sel select { cursor: pointer; padding-right: 8px; }
.in select option { background: var(--panel-2); color: var(--text); }
.in i { font-style: normal; font-size: 13px; color: var(--muted); padding-right: 12px; white-space: nowrap; }
.in input::placeholder { color: var(--dim); }

.o { font-weight: 600; text-align: right; white-space: nowrap; }
.o.side { min-width: 72px; color: var(--muted); font-weight: 500; font-size: 13px; }
.o.muted { color: var(--muted); font-weight: 500; margin-right: 16px; }
.o.mini { font-weight: 500; font-size: 13px; color: var(--muted); }

.summary { margin-top: 18px; }
.r { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.r .l { color: var(--muted); }
.r .c { display: flex; align-items: baseline; }
.r.sum { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 11px; }
.r.sum .l { color: var(--text); font-weight: 500; }
.r.total { border-top: 1px solid var(--line-2); margin-top: 8px; padding-top: 14px; }
.r.total .l { color: var(--text); font-weight: 600; font-size: 15px; }
.r.total .o { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent-text); }

.grp + .grp { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.grp h4 { margin: 0 0 14px; font-size: 14px; font-weight: 600; }

/* Listen */
.lh, .lr { display: grid; gap: 8px; align-items: center; }
.lh { padding: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 500; }
.lr { padding: 4px 0; }
.lr .in { height: 38px; }
.inv { grid-template-columns: minmax(140px, 2fr) minmax(100px, 1fr) minmax(130px, 1fr) minmax(110px, 1fr) 28px; min-width: 560px; }
.kv { grid-template-columns: minmax(0, 1fr) 140px 28px; margin-top: 8px; }
.eh { grid-template-columns: minmax(110px, 1.5fr) 116px 96px 108px 52px 104px 64px 56px 28px; min-width: 780px; }
.lr.eh.leer .in:not(.sel):not(.txt) { opacity: .5; }
.san { grid-template-columns: 74px minmax(150px, 2fr) 112px 160px 68px 112px 96px 140px 28px; min-width: 990px; }
.na { text-align: center; color: var(--dim); }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }
.del {
  width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent;
  color: var(--dim); font-size: 17px; line-height: 1;
}
.del:hover { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }
.add {
  margin-top: 10px; height: 32px; padding: 0 12px; border-radius: var(--r-m);
  border: 1px dashed var(--line-2); background: transparent; color: var(--muted); font-size: 13px; font-weight: 500;
}
.add:hover { border-color: var(--accent); color: var(--text); }
.add.big { width: 100%; height: auto; min-height: 120px; margin: 0; border-radius: var(--r-xl); font-size: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 500; font-size: 14px; }
.link:hover { text-decoration: underline; }
.hint { margin: 14px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55; max-width: 70ch; }
.empty { margin: 4px 0; color: var(--muted); font-size: 13px; }
.scroll { overflow-x: auto; }

.loans { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; align-items: start; }

/* ---------- Kennzahlen ---------- */
.kpi {
  position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 20px 22px 22px;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kpi-ctl { display: flex; align-items: center; gap: 8px; }
.kpi-sub { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.yr { display: inline-flex; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-m); height: 30px; }
.yr button { width: 28px; height: 100%; border: 0; background: transparent; color: var(--muted); font-size: 16px; border-radius: var(--r-m); }
.yr button:hover { color: var(--text); background: var(--panel-3); }
.yr span { min-width: 44px; text-align: center; font-weight: 600; font-size: 13px; font-feature-settings: 'tnum' 1; }
.blk .bd > .seg { margin-bottom: 16px; }
.in.ro { background: transparent; border: 1px dashed var(--line-2); }
.in.ro output { flex: 1; text-align: right; padding: 0 12px; font-weight: 600; font-feature-settings: 'tnum' 1; }
.kpi h5, .res h5 { margin: 20px 0 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.wf { display: grid; grid-template-columns: minmax(0, 1fr) 56px 80px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; }
.wf .l { color: var(--muted); }
.wf .v { text-align: right; font-weight: 600; white-space: nowrap; }
.wf .bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.wf .bar b { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.wf.out .bar b { background: var(--bar-out); }
.wf.inc .l { color: var(--text); }
.wf.sum { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 9px; }
.wf.sum .l { color: var(--text); font-weight: 600; }
.wf.sum.pos .v { color: var(--pos); } .wf.sum.pos .bar b { background: var(--pos); }
.wf.sum.warn .v { color: var(--warn); } .wf.sum.warn .bar b { background: var(--warn); }
.wf.sum.neg .v { color: var(--neg); } .wf.sum.neg .bar b { background: var(--neg); }

.kr { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; }
.kr span:first-child { color: var(--muted); }
.kr span:last-child { font-weight: 600; white-space: nowrap; }
.kr.sum { border-top: 1px solid var(--line); margin-top: 3px; padding-top: 9px; }
.kr.sum span:first-child { color: var(--text); font-weight: 600; }
.kr.sub span:first-child { padding-left: 12px; color: var(--dim); }

.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notes li { font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: var(--r-m); background: var(--panel-2); color: var(--muted); }
.notes li.warn { background: var(--warn-bg); color: var(--warn-text); }

.results { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.notes-blk { margin-bottom: 20px; }
.hero-cf { padding: 0 0 18px; }
.hero-cf strong { display: block; font-size: 42px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 6px 0 4px; }
.hero-cf .sub { font-size: 13px; color: var(--muted); }
.hero-cf.pos strong { color: var(--pos); }
/* Große Zahlen dürfen das hellere Amber tragen (3:1 reicht ab 18,7 px fett), kleine brauchen 4,5:1 */
.hero-cf.warn strong { color: var(--warn-big); }
@media (min-width: 641px) { .dash .warn dd { color: var(--warn-big); } }
.hero-cf.neg strong { color: var(--neg); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.stats div { background: var(--panel-2); border-radius: var(--r-m); padding: 12px 14px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 3px 0 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- Finanzierung / Sanierung / Prognose ---------- */
.sec-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.sec-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sec-head .seg { margin-left: auto; }

.chart { margin: 0 0 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px 18px 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .gl.zero { stroke: var(--zero-line); }
.chart .yl { font-size: 11px; fill: var(--muted); text-anchor: end; }
.chart .xl { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 13%, transparent); }
.chart .mk { stroke: var(--dim); stroke-dasharray: 3 4; }
.chart .mkl { font-size: 11px; fill: var(--muted); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--veil); }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; color: var(--muted); padding: 8px 4px 0; }
.chart figcaption i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.chart figcaption i.a { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.charts2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.scroll:has(> .tbl) { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: right; font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 16px 14px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { text-align: right; padding: 9px 14px; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 20px; }
.tbl td:first-child { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tbody tr:nth-child(even) td { background: var(--row-alt); }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tbl .tl { text-align: left; white-space: normal; min-width: 160px; }
.tbl tr.hl td { color: var(--text); }
.tbl tr.sp td { border-top: 1px dashed var(--line-2); }
.tbl tr.sp td:first-child::after { content: ' Spekulationsfrist'; font-family: Inter, sans-serif; font-size: 11px; color: var(--dim); }
.tbl tr.zl td { background: var(--accent-soft) !important; }
.tbl small { color: var(--dim); font-family: Inter, sans-serif; }

.san-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0 28px; }
.meter { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin: 14px 0 4px; }
.meter b { display: block; height: 100%; border-radius: 4px; background: var(--pos); }
.meter.warn b { background: var(--warn); }
.meter.neg b { background: var(--neg); }

.stats.wide { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats.wide div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; }
.stats.wide dd { font-size: 22px; }
.stats.wide span { font-size: 12px; color: var(--dim); }

.disclaimer { margin: 40px 0 0; font-size: 12px; color: var(--dim); }

/* ---------- Einstellungen ---------- */
.rail-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-m);
  background: transparent; color: var(--muted); font-size: 13px; margin-top: auto;
}
.rail-btn:hover { background: var(--panel); color: var(--text); }
.rail-btn + .collapse { margin-top: 0; }
.rail-zu .rail-btn { justify-content: center; padding: 0; }
.rail-btn i { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); }

.dlg {
  border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--panel); color: var(--text);
  padding: 0; width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto;
}
.dlg::backdrop { background: var(--backdrop); }
.dlg-in { padding: 22px; }
.dlg-in header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dlg-in h3 { margin: 0; font-size: 18px; font-weight: 600; }
.dlg-in h4 { margin: 0; font-size: 14px; font-weight: 600; }
.dlg-in .hint { margin-top: 6px; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0 20px; }
.swatches button {
  display: grid; justify-items: center; gap: 8px; padding: 12px 6px; border-radius: var(--r-m);
  border: 1px solid var(--line); background: var(--panel-2); font-size: 12px; color: var(--muted);
}
.swatches button:hover { border-color: var(--line-2); color: var(--text); }
.swatches button[aria-pressed="true"] { border-color: var(--text); color: var(--text); }
.swatches i { width: 28px; height: 28px; border-radius: 8px; }
#accentPick { width: 52px; height: 40px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel-2); padding: 3px; cursor: pointer; }
.dlg-in code { font-family: var(--mono); color: var(--muted); font-size: 13px; }
.preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding: 14px; border-radius: var(--r-m); background: var(--panel-2); }
.preview b { color: var(--accent-text); font-size: 20px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ---------- Konto, Speicherstatus, Konflikt ---------- */
.save-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.save-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.save-state.ok::before { background: var(--pos); }
.save-state.busy::before { background: var(--accent); }
.save-state.warn { color: var(--warn); } .save-state.warn::before { background: var(--warn); }
.save-state.neg { color: var(--neg); } .save-state.neg::before { background: var(--neg); }
.save-state:empty { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  width: min(560px, calc(100vw - 32px)); padding: 16px 18px; border-radius: var(--r-l);
  background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.toast p { margin: 0 0 12px; font-size: 14px; }
.toast div { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 8px 12px; font-size: 13px; }
.me span { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me button { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 4px 0; }
.me button:hover { color: var(--text); text-decoration: underline; }
.me + .rail-btn { margin-top: 0; }

.dlg-sec { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.dlg-sec .fields { margin-top: 14px; }
.row-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.upd-last.ok b { color: var(--pos); }
.upd-last.zurueckgerollt b, .upd-last.laeuft b, .upd-last.gesendet b { color: var(--warn); }
.upd-last.fehler b { color: var(--neg); }
.msg { font-size: 13px; color: var(--muted); }
.users { display: grid; gap: 4px; margin-top: 12px; }
.user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: var(--r-m); background: var(--panel-2); font-size: 13px; }
.user span { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user b { color: var(--text); font-weight: 600; margin-right: 6px; }
.user em { font-style: normal; font-size: 11px; color: var(--accent-text); margin-left: 6px; }
.user .hint { margin: 0; }

.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: min(420px, 100%); }
.auth .brand { justify-content: center; padding: 0 0 22px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 28px 26px 26px; }
.auth-card h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .hint { margin: 6px 0 0; }
.auth-fields { display: grid; gap: 16px; margin-top: 22px; }
.auth-msg { min-height: 20px; margin: 14px 0 4px; font-size: 13px; color: var(--neg); }
.auth-card .btn.primary { width: 100%; height: 44px; }
.auth-card .btn:disabled { opacity: .6; cursor: wait; }

/* ---------- Verwaltung ----------
   Gleiche Bausteine wie die Kalkulation. Eigene Formen nur dort, wo der Inhalt es verlangt:
   zweizeilige Zeilen für Vorgänge und Kontakte (Notiz und Erreichbarkeit unter den Feldern),
   die Agenda als Zeitleiste, weil "Steht an" eine Reihenfolge ist und keine Kachelgruppe. */
.vw { animation: enter .45s var(--ease); }
.seg.area { display: flex; margin: 0 0 16px; }
.seg.area button { flex: 1; height: 32px; font-size: 13px; font-weight: 600; }
.rail-zu .seg.area { display: none; }
.objs .t .tag {
  font-style: normal; margin-left: auto; padding: 1px 6px; border-radius: 6px; flex: none;
  background: var(--accent-soft); color: var(--accent-text); font-size: 10px; font-weight: 600; letter-spacing: .04em;
}
.rail-empty { padding: 0 10px; }
.tabs button:disabled { opacity: .4; cursor: default; }
.tabs .badge, .badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 9px; background: var(--warn); color: var(--on-warn); font-size: 11px; font-weight: 700;
}
.vw-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; align-items: start; }
.vw-grid .col { display: grid; gap: 20px; min-width: 0; }
.vw-body > .blk + .blk, .vw-body > .blk.wide { margin-top: 0; }
.san-grid.first { margin-top: 0; }
.vw-grid.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.vw-full { margin-top: 20px; }
.f.full { margin-top: 16px; }
.blk .bd.flush { padding: 14px 0 6px; }
.blk > header .yr { flex: none; }

.in.area { height: auto; align-items: stretch; }
.in.area textarea {
  width: 100%; min-height: 92px; resize: vertical; border: 0; background: transparent; outline: 0;
  padding: 10px 12px; font: inherit; color: inherit; line-height: 1.5;
}

.reach { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; min-width: 0; }
.reach a { color: var(--accent-text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reach a:hover { text-decoration: underline; }

.zs { grid-template-columns: minmax(130px, 1fr) minmax(160px, 1.3fr) minmax(0, 1.3fr) 28px; min-width: 520px; }
.ist { grid-template-columns: 136px 128px minmax(84px, 1fr) minmax(84px, 1fr) 28px; min-width: 470px; }
.blk .bd .summary + .fields { margin-top: 18px; }
.ms { grid-template-columns: 74px minmax(150px, 2fr) 104px 128px minmax(150px, 1.4fr) 104px 140px 76px 28px; min-width: 1060px; }
.lr.ms.done .in:not(.sel) { opacity: .6; }
.vgr { grid-template-columns: 150px minmax(240px, 3fr) 150px 150px 140px 28px; min-width: 820px; }
.vgs { grid-template-columns: minmax(180px, 1.3fr) 120px 84px minmax(200px, 2.2fr) minmax(120px, auto); margin-top: 8px; min-width: 820px; padding-right: 36px; }
.vgs .in { height: 34px; }
.vgs .in input, .vgs .in select { font-size: 13px; }
.ktr { grid-template-columns: minmax(150px, 1.3fr) minmax(140px, 1.2fr) 160px 120px 150px minmax(170px, 1.3fr) 28px; min-width: 960px; }
.vg { padding: 8px 0 12px; border-bottom: 1px solid var(--line); min-width: 820px; }
.vw-body .vg:has(.ktr) { min-width: 960px; }
.vg:last-child { border-bottom: 0; }
.vg .lr { padding: 0; }
.vg-sub { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 8px 16px; align-items: center; margin-top: 8px; }
.vg-sub:not(:has(> .in + .in)) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.vg-sub .in { height: 34px; }
.vg-sub .in input { font-size: 13px; }
.vg.done .lr .in:not(.sel) { opacity: .6; }
.used { font-size: 12px; color: var(--dim); white-space: nowrap; }
.blk.wide .bd > .add:first-child { margin: 0 0 14px; }

.agenda { list-style: none; margin: 0; padding: 0; position: relative; }
.agenda::before { content: ''; position: absolute; left: 66px; top: 6px; bottom: 6px; width: 1px; background: var(--line-2); }
.agenda li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 21px; padding: 8px 0; position: relative; }
.agenda li::after { content: ''; position: absolute; left: 63px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.agenda li.warn::after { background: var(--warn); }
.agenda time { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; text-align: right; }
.agenda b { display: block; font-weight: 600; font-size: 14px; }
.agenda small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

.pick { display: grid; gap: 6px; margin-top: 16px; }
.pick-r { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--r-m); background: var(--panel-2); }
.pick-r span { display: flex; gap: 9px; align-items: baseline; font-weight: 500; min-width: 0; }
.pick-r em { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--muted); }

.upload { display: grid; grid-template-columns: 200px minmax(200px, 320px) minmax(0, 1fr); gap: 16px; align-items: end; }
.drop {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: 42px; padding: 6px 14px 6px 6px;
  border: 1px dashed var(--line-2); border-radius: var(--r-m); color: var(--muted); font-size: 13px;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.blk .bd > .msg { min-height: 20px; margin: 10px 0 4px; }
.doc-kat { margin: 18px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.tbl.doc td:first-child { font-family: inherit; font-size: 13px; color: var(--text); }
.tbl.doc td { padding-top: 7px; padding-bottom: 7px; }
.tbl.doc a { color: var(--accent-text); text-decoration: none; }
.tbl.doc a:hover { text-decoration: underline; }
.tbl.doc .del { margin-left: auto; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); padding-top: 10px; }

/* ---------- Haushaltsbuch ---------- */
.seg.area button { padding: 0 4px; font-size: 12px; }
.hb-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hb-nav .yr span { min-width: 120px; }
.hb-kopf .hero-cf { padding: 4px 0 0; }
.hb-kopf .summary { margin-top: 10px; }
.hb-fix { grid-template-columns: minmax(110px, 2fr) minmax(110px, 1.2fr) 104px 124px 64px 28px; min-width: 580px; }
.hb-ein { grid-template-columns: minmax(100px, 1fr) 104px 124px 28px; min-width: 380px; }
.hb-bu { grid-template-columns: 140px minmax(160px, 2fr) minmax(130px, 1fr) 118px 28px; min-width: 560px; }
.lr.hb-bu.ein .in:last-of-type input { color: var(--pos); }
.lh.hb-fix span:nth-last-child(2), .hb .lr > .o { text-align: right; }
.hb .lr > .o { font-size: 12px; color: var(--muted); }
.hb-immo { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.hb-immo .fl { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.hb-immo .hint { margin-top: 10px; }
.hb-mitte { margin-top: 20px; }
.hb-kat ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hb-kat li { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 4px 10px; align-items: baseline; font-size: 13px; }
.hb-kat .v { font-weight: 600; font-feature-settings: 'tnum' 1; }
.hb-kat .p { color: var(--muted); text-align: right; font-feature-settings: 'tnum' 1; }
.hb-kat .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.hb-kat .bar b { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
@media (max-width: 760px) { .hb .lr > .o { text-align: left; } }

/* ---------- Einstellungen: Darstellung ---------- */
.set-rows { display: grid; gap: 10px; margin: 6px 0 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14px; }
.set-row > span { color: var(--muted); }
.dlg-in .hint + h4 { margin-top: 26px; }

/* ---------- Rückgängig: kurze Leiste unten, ersetzt die Rückfrage beim Entfernen ---------- */
.undo {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 16px; border-radius: var(--r-m);
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
  animation: undo-in .3s var(--ease);
}
.undo button { border: 0; border-radius: 8px; padding: 6px 12px; background: color-mix(in srgb, var(--bg) 16%, transparent); color: var(--bg); font-weight: 600; font-size: 13px; }
.undo button:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
@keyframes undo-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.vg-act { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.vg-act .link { font-size: 13px; }
.vg-act .msg { font-size: 12px; }
.btn.cam { display: none; }
@media (pointer: coarse) { .btn.cam { display: inline-flex; } }

/* ---------- Dichte: kompakt für lange Listen ---------- */
[data-density="compact"] body { font-size: 13px; }
[data-density="compact"] .content { padding-top: 18px; }
[data-density="compact"] .lr .in { height: 32px; }
[data-density="compact"] .lr { padding: 2px 0; }
[data-density="compact"] .in input, [data-density="compact"] .in select { font-size: 13px; }
[data-density="compact"] .fields { gap: 10px 12px; }
[data-density="compact"] .blk > header { padding: 14px 16px 0; }
[data-density="compact"] .blk .bd { padding: 12px 16px 16px; }
[data-density="compact"] .blocks, [data-density="compact"] .vw-grid, [data-density="compact"] .vw-grid .col { gap: 14px; }
[data-density="compact"] .tbl td { padding: 6px 12px; }
[data-density="compact"] .dash { gap: 8px; margin-bottom: 14px; }
[data-density="compact"] .dash div { padding: 10px 12px; }
[data-density="compact"] .dash dd { font-size: 17px; }
[data-density="compact"] .vg { padding: 5px 0 8px; }
[data-density="compact"] .vgs { margin-top: 5px; }
[data-density="compact"] .r { padding: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kalk { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .brand { padding-bottom: 10px; }
  .objs { display: flex; overflow-x: auto; }
  .objs li { flex: 0 0 230px; }
  .pf, .by, .collapse { display: none; }
  .app.rail-zu { grid-template-columns: 1fr; }
  .rail-zu .rail { align-items: stretch; }
  .objs.mini { display: flex; }
  .objs.mini li { flex: 0 0 64px; }
  .mini-add { display: none; }
  .kalk, .results, .charts2, .san-grid, .vw-grid, .vw-grid.even, .upload { grid-template-columns: 1fr; }
  .kpi { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .top { padding: 18px 16px; }
  .content { padding: 16px 16px 40px; }
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash dd { font-size: 17px; }
  .fields { grid-template-columns: 1fr; }
  .f.w2 { grid-column: auto; }
  .blk > header { padding: 18px 16px 0; }
  .blk .bd { padding: 16px 16px 18px; }
  .kpi { padding: 18px 16px; }
  .hero-cf strong { font-size: 34px; }
  .steps button { padding: 0 10px; }
}

/* ---------- Handy: Listen als Karten ----------
   Breite Tabellenzeilen scrollen auf dem Handy seitlich, genau dort, wo man vor Ort einen Schaden erfasst.
   Deshalb zwei Spalten, Beschriftung über jedem Feld, Löschen oben rechts. */
@media (max-width: 760px) {
  .scroll .lh { display: none; }
  .scroll > .lr, .vg { min-width: 0 !important; }
  .scroll > .lr, .vg {
    position: relative; margin: 0 0 10px; padding: 12px 12px 12px; border: 1px solid var(--line-2); border-radius: var(--r-l); background: transparent;
  }
  .vg .lr, .scroll > .lr { display: grid; grid-template-columns: 1fr 1fr !important; gap: 22px 10px; padding: 18px 0 0; min-width: 0 !important; }
  .scroll > .lr { padding: 30px 12px 14px; }
  .vg .lr + .lr, .vg .lr + .vg-sub { margin-top: 22px; padding-top: 0; }
  .vg-sub { display: grid; grid-template-columns: 1fr !important; gap: 22px; padding-right: 0 !important; }
  .vgs { padding-right: 0; }
  .lr .in, .vg-sub .in { position: relative; height: 40px; }
  .lr .in[data-l]::before, .vg-sub .in[data-l]::before {
    content: attr(data-l); position: absolute; left: 1px; top: -18px; font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none;
  }
  .lr .in.wide, .vg-sub .in.wide, .lr .vg-act, .lr > .reach { grid-column: 1 / -1; }
  .lr > .o, .lr > output { align-self: end; padding-bottom: 10px; font-size: 12px; color: var(--muted); }
  .lr > .del { position: absolute; top: 6px; right: 6px; }
  .lr > .chk { align-self: end; padding-bottom: 10px; }
  .lr > .na { display: none; }
  .vg { border-bottom: 1px solid var(--line); }
  .vg .lr > .del { top: 6px; right: 6px; }
  .vg-act { grid-column: 1 / -1; }
  .upload { grid-template-columns: 1fr; }
  .drop { padding: 8px; }
  .drop span { flex-basis: 100%; }
  .undo { left: 16px; right: 16px; transform: none; justify-content: space-between; }
  @keyframes undo-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Druckdialog ---------- */
.pick-opts { display: grid; gap: 8px; margin: 4px 0 18px; }
.pick-opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel-2);
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.pick-opt:hover { border-color: var(--accent); }
.pick-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick-opt input { accent-color: var(--accent); margin-top: 3px; }
.pick-opt b { display: block; font-weight: 600; }
.pick-opt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.45; }
.chks { display: grid; gap: 10px; margin-top: 16px; }
.chks .chk { font-size: 13px; color: var(--text); }
#printDlg .dlg-foot, #vwDelDlg .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }
.pick-opt.danger:has(input:checked) { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, transparent); }
.pick-opt.danger input { accent-color: var(--neg); }
#vwDelDlg .btn.danger { background: color-mix(in srgb, var(--neg) 14%, transparent); border-color: color-mix(in srgb, var(--neg) 50%, transparent); font-weight: 600; }
#vwDelConfirm { margin-bottom: 4px; }

/* ---------- Erklärungen ----------
   Kleines „i“ hinter der Beschriftung statt Fließtext unter jedem Feld: die Erklärung ist da,
   wenn man sie braucht, und die Formulare bleiben so ruhig wie vorher. */
.tip {
  display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 6px; vertical-align: 1px;
  border-radius: 50%; border: 1px solid var(--line-2); color: var(--muted); background: transparent;
  font: 600 10px/1 var(--mono); font-style: normal; cursor: help; user-select: none;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.tip:hover, .tip:focus-visible, .tip[aria-describedby] { border-color: var(--accent); color: var(--accent-text); outline: none; }
.tip:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.tip-box {
  position: fixed; z-index: 100; padding: 10px 12px; border-radius: var(--r-m);
  background: var(--panel-3); border: 1px solid var(--line-2); color: var(--text); box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.5; pointer-events: none; animation: tip-in .16s var(--ease);
}
@keyframes tip-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.dash dt .tip, .stats dt .tip { width: 14px; height: 14px; font-size: 9px; }
.lh .tip { width: 13px; height: 13px; font-size: 9px; margin-left: 4px; }
@media (max-width: 760px) { .tip { width: 18px; height: 18px; font-size: 11px; } }

/* Steuer-Tipps: Liste mit farbiger Marke vorn, gleiche Logik wie die Hinweise der Kalkulation */
.tipps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.tipps li { display: grid; gap: 3px; padding: 11px 0 11px 16px; border-top: 1px solid var(--line); position: relative; }
.tipps li:first-child { border-top: 0; padding-top: 2px; }
.tipps li::before { content: ''; position: absolute; left: 0; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.tipps li:first-child::before { top: 9px; }
.tipps li.warn::before { background: var(--warn); }
.tipps li.pos::before { background: var(--pos); }
.tipps b { font-weight: 600; font-size: 14px; }
.tipps span { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tipps-blk { margin-top: 20px; }
.st-sum { margin-top: 0; }
.st-sum .l small { display: block; font-size: 12px; color: var(--dim); margin-top: 1px; }
.st-check { margin: 16px 0 0; padding: 14px 0 0 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); line-height: 1.5; display: grid; gap: 6px; }
.st-check li::marker { color: var(--dim); }
.st-check .link { font-size: 13px; margin-left: 6px; }

/* ---------- Schreiben ----------
   Links das Formular, rechts das Blatt in echter Größe (per zoom eingepasst): man sieht beim Tippen,
   was auf dem Papier steht. Das Blatt ist immer weiß wie der Ausdruck, auch im dunklen Thema. */
.sw-v { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.doc-kat + .sw-v { border-top: 0; }
.sw-v > span:first-child { min-width: 0; }
.sw-v b { display: block; font-weight: 600; font-size: 14px; }
.sw-v small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 2px; }
.sw-va { display: flex; align-items: center; gap: 10px; flex: none; }
.blk > header > .link { flex: none; font-size: 13px; }
.note-warn { margin: 0 0 14px; padding: 10px 12px; border-radius: var(--r-m); background: var(--warn-bg); color: var(--warn-text); font-size: 13px; line-height: 1.5; }
.note-warn .link { color: inherit; text-decoration: underline; font-size: 13px; }
.sw-list { list-style: none; margin: 0; padding: 0; }
.sw-list li { display: grid; grid-template-columns: 82px minmax(0, 1fr) 28px; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.sw-list li:first-child { border-top: 0; }
.sw-list time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sw-open { text-align: left; background: none; border: 0; padding: 0; min-width: 0; cursor: pointer; }
.sw-open b { display: block; font-weight: 600; font-size: 14px; transition: color .2s var(--ease); }
.sw-open small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-open:hover b { color: var(--accent-text); }
.sw-act { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sw-info { margin: -6px 0 16px; }
.sw-edit { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.sw-form { display: grid; gap: 20px; min-width: 0; }
.sw-form .in.area textarea { min-height: 72px; }
.sw-form textarea[data-bt], #swvText { min-height: 320px !important; font-family: var(--mono); font-size: 13px; }
.sw-an { display: grid; gap: 7px; }
.sw-an .in.area textarea { min-height: 88px; }
.sw-prev { position: sticky; top: 16px; min-width: 0; max-height: calc(100vh - 32px); overflow: auto; padding: 16px; border-radius: var(--r-xl); background: var(--panel-2); border: 1px solid var(--line); }
.sw-paper { width: 210mm; background: #fff; border: 1px solid #D2D8E0; }
.sw-paper .brief { padding-top: 16mm; padding-bottom: 20mm; min-height: 297mm; box-sizing: border-box; }
.sw-paper .fv { background: #E6EEF8; border-radius: 2px; cursor: pointer; box-shadow: 0 0 0 1px #E6EEF8; }
.sw-paper .fv:hover { background: #CFE0F5; }
.sw-paper .fv.leer { background: #FFF3D6; box-shadow: none; }
.sw-help { margin-top: 16px; font-size: 13px; color: var(--muted); }
.sw-help summary { cursor: pointer; color: var(--text); font-weight: 500; }
.sw-help p { line-height: 1.6; margin: 10px 0; }
.sw-help code { font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.sw-keys { display: grid; gap: 10px; margin-top: 12px; }
.sw-keys div { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.sw-keys b { flex-basis: 100%; font-size: 12px; font-weight: 600; color: var(--muted); }
.sw-keys button { height: 26px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--panel-2); font-family: var(--mono); font-size: 11.5px; color: var(--text); cursor: pointer; }
.sw-keys button:hover { border-color: var(--accent); }
@media (max-width: 1100px) {
  .sw-edit { grid-template-columns: 1fr; }
  .sw-prev { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .sw-v { flex-direction: column; align-items: stretch; }
  .sw-va { justify-content: flex-end; }
  .sw-prev { padding: 8px; }
}

/* Das Blatt: DIN 5008 Form B, gleich in Vorschau und Ausdruck. Maße ab Blattoberkante;
   die obersten 16 mm hält im Druck der wiederholte Seitenkopf frei, deshalb ist der Briefkopf 29 mm hoch. */
.brief { --ink: #101010; --txt: #3A3A3B; --mut: #5E6670; --ln: #D2D8E0; color: var(--ink); font: 10.5pt/1.5 Arial, Helvetica, sans-serif; padding: 0 20mm 0 25mm; text-align: left; }
.brief.vertrag { padding: 0 20mm; font-size: 10pt; }
.b-kopf { height: 29mm; box-sizing: border-box; display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 0.6mm; font-size: 8.5pt; color: var(--txt); }
.b-kopf b { font-size: 13pt; color: var(--ink); font-weight: 700; margin-bottom: 1mm; }
.b-feld { height: 45mm; width: 85mm; margin-left: -5mm; padding-left: 5mm; box-sizing: border-box; }
.b-feld small { display: block; height: 17.7mm; padding-top: 12mm; box-sizing: border-box; font-size: 7pt; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-an { font-size: 10.5pt; line-height: 1.35; }
.b-datum { margin: 6mm 0 0; text-align: right; }
.b-betreff { margin: 6mm 0; font-size: 10.5pt; font-weight: 700; line-height: 1.4; }
.b-titel { margin: 0 0 7mm; font-size: 16pt; font-weight: 700; line-height: 1.2; }
.b-text p { margin: 0 0 3.5mm; }
.b-text h3 { margin: 6mm 0 2.5mm; font-size: 10.5pt; font-weight: 700; break-after: avoid; }
.b-text > h3:first-child { margin-top: 0; }
.b-text ul { margin: 0 0 3.5mm; padding-left: 5mm; }
.b-text li { margin: 0 0 1mm; }
.b-text ul.b-chk { list-style: none; padding-left: 0; }
.b-text ul.b-chk li { position: relative; padding-left: 7mm; }
.b-text ul.b-chk li::before { content: ''; position: absolute; left: 0; top: 0.9mm; width: 3.4mm; height: 3.4mm; box-sizing: border-box; border: 0.3mm solid var(--ink); }
.b-text ul.b-chk li.on::after { content: ''; position: absolute; left: 1.1mm; top: 1.2mm; width: 1.2mm; height: 2.2mm; border: solid var(--ink); border-width: 0 0.4mm 0.4mm 0; transform: rotate(45deg); }
.b-tab { width: 100%; border-collapse: collapse; margin: 0 0 4mm; font-variant-numeric: tabular-nums; break-inside: avoid; }
.b-tab th, .b-tab td { padding: 1.6mm 2mm 1.6mm 0; border-bottom: 0.2mm solid var(--ln); text-align: left; vertical-align: top; font-weight: 400; }
.b-tab thead th { font-size: 8.5pt; font-weight: 700; color: var(--mut); border-bottom: 0.3mm solid var(--txt); }
.b-tab.kv th { width: 42%; color: var(--txt); }
.b-tab td.leer, .b-tab th.leer { height: 7mm; }
.b-tab td + td { padding-left: 2mm; }
.b-sig { display: flex; gap: 14mm; margin: 14mm 0 4mm; break-inside: avoid; }
.b-sig > div { flex: 1; display: flex; flex-direction: column; }
.b-sig i { order: 1; display: block; height: 14mm; border-bottom: 0.3mm solid var(--ink); }
.b-sig .b-od { order: 2; font-size: 8pt; color: var(--mut); margin-top: 1mm; }
.b-sig span:last-child { order: 3; font-size: 9pt; margin-top: 1mm; }
.b-sig.brief-sig { margin: 0 0 4mm; max-width: 70mm; }
.b-sig.brief-sig i { height: 12mm; border-bottom: 0; }
.b-sig.brief-sig span:last-child { margin-top: 0; font-size: inherit; }
.brief .fv.leer { display: inline-block; min-width: 32mm; height: 1em; border-bottom: 0.2mm solid var(--mut); vertical-align: -0.15em; }
.b-an .fv.leer { min-height: 18mm; min-width: 70mm; }
.b-marks { display: none; }

/* ---------- Bankfassung ----------
   Ein eigenes Dokument, weil eine Bank eine Unterlage liest und keine App: weißes Papier, Arial,
   ein Blau für Struktur (Titel, Kennzahlen, Summenlinien), Grau für alles Nachrangige.
   Rot nur für negative Überschüsse, kein Grün, damit nichts nach Werbung aussieht.
   Aufbau nach HeRo-Druckvorlage: thead wiederholt den Kopf je Seite, tfoot hält Platz für die feste Fußzeile. */
#printDoc { display: none; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body { color: #101010; font: 9.5pt/1.45 Arial, Helvetica, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app, .dlg, .toast, .undo, .tip-box { display: none !important; }
  #printDoc {
    display: block;
    --b: #00418A; --b-tint: #E6EEF8; --ink: #101010; --txt: #3A3A3B; --mut: #5E6670; --ln: #D2D8E0; --ln2: #E7EBF0; --neg: #B42318;
  }

  .sheet { width: 100%; border-collapse: collapse; }
  .sheet > thead > tr > td, .sheet > tbody > tr > td { padding: 0 16mm; }
  .sheet-head { display: table-header-group; }
  .foot-spacer { display: table-footer-group; }
  .foot-spacer td { height: 18mm; }
  .p-head {
    display: flex; justify-content: space-between; gap: 8mm; padding: 9mm 0 3mm; margin-bottom: 6mm;
    border-bottom: 0.4mm solid var(--b); font-size: 8pt; color: var(--mut);
  }
  .p-head b { color: var(--b); font-weight: 700; }
  .doc-footer {
    position: fixed; left: 16mm; right: 16mm; bottom: 8mm; display: flex; justify-content: space-between; gap: 8mm;
    padding-top: 2.5mm; border-top: 0.2mm solid var(--ln); font-size: 7pt; color: var(--mut);
  }

  .p-title { margin: 0 0 6mm; }
  .p-eyebrow { margin: 0 0 1.5mm; font-size: 7.5pt; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--b); }
  .p-title h1 { margin: 0; font-size: 20pt; line-height: 1.15; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
  .p-sub { margin: 1.5mm 0 0; font-size: 10pt; color: var(--txt); }

  /* Kennzahlen als Band mit Haarlinien statt Kacheln: liest sich wie die Kopfzeile eines Exposés */
  .p-kpis { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 0.4mm solid var(--b); border-bottom: 0.2mm solid var(--ln); margin: 0 0 8mm; break-inside: avoid; }
  .p-kpis div { padding: 3mm 3mm 3mm 0; border-bottom: 0.2mm solid var(--ln2); }
  .p-kpis div:nth-child(n+4) { border-bottom: 0; }
  .p-kpis div:not(:nth-child(3n+1)) { padding-left: 4mm; border-left: 0.2mm solid var(--ln2); }
  .p-kpis span { display: block; font-size: 7.5pt; color: var(--mut); }
  .p-kpis b { display: block; font-size: 14pt; font-weight: 700; color: var(--ink); margin: 0.6mm 0 0.3mm; font-variant-numeric: tabular-nums; }
  .p-kpis small { display: block; font-size: 7.5pt; color: var(--mut); }

  .p-sec { margin: 0 0 7mm; }
  .p-sec.keep { break-inside: avoid; }
  .p-sec h2 { display: flex; align-items: baseline; gap: 3mm; margin: 0 0 3mm; font-size: 11.5pt; font-weight: 700; color: var(--b); break-after: avoid; }
  .p-sec h2 span { font-size: 9pt; color: var(--mut); font-weight: 700; min-width: 4mm; }
  .p-sec h3 { margin: 0 0 1.5mm; font-size: 9pt; font-weight: 700; color: var(--ink); }
  .p-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
  .p-note { margin: 2.5mm 0 0; font-size: 7.5pt; color: var(--mut); line-height: 1.5; }
  .p-ratio { margin-top: 3mm; }

  .pkv { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .pkv.narrow { width: 62%; }
  .pkv th, .pkv td { padding: 1.3mm 0; border-bottom: 0.2mm solid var(--ln2); vertical-align: baseline; }
  .pkv th { text-align: left; font-weight: 400; color: var(--txt); padding-right: 4mm; }
  .pkv td { text-align: right; color: var(--ink); white-space: nowrap; }
  .pkv small { color: var(--mut); font-size: 7.5pt; margin-left: 1.5mm; }
  .pkv tr.sum th, .pkv tr.sum td { font-weight: 700; color: var(--ink); border-top: 0.3mm solid var(--txt); border-bottom: 0.2mm solid var(--ln); }
  .pkv tr.total th, .pkv tr.total td { font-weight: 700; color: var(--b); background: var(--b-tint); border-bottom: 0; padding-left: 2mm; padding-right: 2mm; }
  .pkv tr.total.neg td { color: var(--neg); }
  .pkv.cols thead th { font-size: 7.5pt; color: var(--mut); text-align: right; font-weight: 700; padding-bottom: 1mm; border-bottom: 0.3mm solid var(--txt); }
  .pkv.cols td { width: 24%; }
  .pkv.cols td + td { padding-left: 4mm; }

  .grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .grid th, .grid td { padding: 1.4mm 1.6mm; text-align: right; border-bottom: 0.2mm solid var(--ln2); vertical-align: baseline; }
  .grid th:first-child, .grid td:first-child { padding-left: 0; }
  .grid th:last-child, .grid td:last-child { padding-right: 0; }
  .grid thead th { font-size: 7.5pt; font-weight: 700; color: var(--mut); border-bottom: 0.3mm solid var(--txt); vertical-align: bottom; line-height: 1.25; }
  .grid .l { text-align: left; }
  .grid td small { display: block; font-size: 7pt; color: var(--mut); }
  .grid tfoot td { font-weight: 700; border-top: 0.3mm solid var(--txt); border-bottom: 0; color: var(--ink); }
  .grid tr.mute td { color: var(--mut); }
  .grid tr.mark td { background: var(--b-tint); }
  .grid td.neg { color: var(--neg); }
  .grid tr { break-inside: avoid; }
  .grid td { white-space: nowrap; }
  .grid td.l { white-space: normal; }
  .grid td.jr { white-space: nowrap; }
  .grid td.jr i { font-style: normal; font-size: 7pt; color: var(--mut); }
  .p-note.above { margin: 0 0 2.5mm; }
  .doc-footer span:last-child { white-space: nowrap; }
  .grid.dense { font-size: 8.3pt; }
  .grid.dense th, .grid.dense td { padding: 1.1mm 1.3mm; }

  .p-chart { margin: 0 0 4mm; break-inside: avoid; }
  .p-chart svg { width: 100%; height: auto; display: block; }
  .p-chart .g { stroke: var(--ln2); stroke-width: .6; }
  .p-chart .ya { font: 7px Arial, sans-serif; fill: var(--mut); text-anchor: end; }
  .p-chart .xa { font: 7px Arial, sans-serif; fill: var(--mut); text-anchor: middle; }
  .p-chart .ar { fill: var(--b-tint); }
  .p-chart .lw { fill: none; stroke: var(--b); stroke-width: 1.6; }
  .p-chart .lr { fill: none; stroke: var(--txt); stroke-width: 1.2; stroke-dasharray: 4 2.5; }
  .p-chart .mk { stroke: var(--mut); stroke-width: .6; stroke-dasharray: 1.5 2; }
  .p-chart .mt { font: 6.5px Arial, sans-serif; fill: var(--mut); }
  .p-chart figcaption { display: flex; align-items: center; gap: 2mm; font-size: 7.5pt; color: var(--mut); margin-top: 1mm; }
  .p-chart figcaption span { display: inline-block; width: 6mm; height: 0; margin-left: 3mm; }
  .p-chart figcaption span:first-child { margin-left: 0; }
  .p-chart .k-w { border-top: 1.6px solid var(--b); }
  .p-chart .k-r { border-top: 1.2px dashed var(--txt); }
  .p-chart .k-a { height: 2.5mm !important; background: var(--b-tint); }

  /* Schreiben: Ränder trägt das Blatt selbst, die Tabelle hält oben und unten Platz je Seite frei */
  .b-sheet > thead > tr > td, .b-sheet > tbody > tr > td { padding: 0; }
  .b-top { height: 16mm; }
  .b-sheet + .doc-footer { left: 25mm; right: 20mm; }
  .brief .fv { background: none; }
  /* Falz- und Lochmarken am linken Rand: 105 mm, 148,5 mm, 210 mm */
  .b-marks { display: block; }
  .b-marks i { position: fixed; left: 0; width: 5mm; border-top: 0.2mm solid #9AA3AE; }
  .b-marks i:nth-child(1) { top: 105mm; }
  .b-marks i:nth-child(2) { top: 148.5mm; width: 7mm; }
  .b-marks i:nth-child(3) { top: 210mm; }
}
