/* Konstanze – Gestaltungssystem nach DESIGN.md. Tokens auf :root, Papier statt Kacheln. */
:root {
  --tinte: #14213D;
  --gruen: #1E6B4E;
  --rot: #B42318;
  --hinweis: #9A5B00;
  --grau: #5B6472;
  --linie: #DDE1E7;
  --papier: #F7F8FA;
  --blatt: #FFFFFF;
  --durchschlag: #E6EAF1;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --mass: 68ch;
  --rand: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  min-width: 320px;
}
a { color: var(--tinte); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--gruen); }
:focus-visible { outline: 2px solid var(--tinte); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin-top: 2.5rem; }
h3 { font-size: 1.1rem; font-weight: 500; }
p { margin: 0 0 1em; max-width: var(--mass); }
small, .klein { font-size: .875rem; }
.grau { color: var(--grau); }
.zahl, td.zahl, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.notiz { font-family: var(--serif); font-style: italic; color: var(--grau); }
.notiz.rot { color: var(--rot); }
.versteckt { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.seite { max-width: 1040px; margin: 0 auto; padding: 0 max(var(--rand), env(safe-area-inset-right)) calc(4rem + env(safe-area-inset-bottom)) max(var(--rand), env(safe-area-inset-left)); }
button, a, label, input { touch-action: manipulation; }
.kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1.25rem 0 2rem; flex-wrap: wrap; }
.wortmarke { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; text-decoration: none; letter-spacing: -0.01em; }
.wortmarke::after { content: "."; color: var(--gruen); }
.kopf nav { display: flex; gap: 1.25rem; font-size: .95rem; }
.kopf nav a { color: var(--grau); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.kopf nav a:hover { color: var(--tinte); text-decoration: underline; }

.lead { font-size: 1.15rem; max-width: var(--mass); }
.hero { display: grid; grid-template-columns: 1fr; gap: 2rem; align-items: start; margin-top: 1rem; }
@media (min-width: 860px) { .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 3rem; } }
.durchschlag { width: 100%; height: auto; display: block; max-width: 560px; }

.blatt {
  background: var(--blatt);
  border: 1px solid var(--linie);
  border-radius: 2px;
  padding: 1.5rem;
}
@media (max-width: 480px) { .blatt { padding: 1.1rem; } }

/* Upload */
.ablage {
  display: block;
  border: 1.5px dashed var(--grau);
  border-radius: 2px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.ablage:hover, .ablage.aktiv { border-color: var(--tinte); background: var(--papier); }
.ablage input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; left: 0; top: 0; }
.ablage:focus-within { border-color: var(--tinte); outline: 2px solid var(--tinte); outline-offset: 3px; }
.ablage strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 1.1rem; }
.ablage .datei { color: var(--gruen); font-family: var(--mono); font-size: .9rem; word-break: break-all; }
.einwilligung { margin: 1.25rem 0 0; display: grid; grid-template-columns: 1fr auto; gap: 0 .5rem; align-items: center; }
.einwilligung label { display: grid; grid-template-columns: 24px 1fr; gap: .75rem; align-items: center; font-size: .95rem; line-height: 1.45; cursor: pointer; min-height: 44px; }
.einwilligung input { width: 20px; height: 20px; margin: 0; accent-color: var(--tinte); cursor: pointer; }
.einwilligung .info { font: 500 .85rem/1 var(--serif); font-style: italic; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--grau); color: var(--grau); background: transparent; cursor: pointer; padding: 0; box-sizing: content-box; margin: 10px; }
.einwilligung .info:hover, .einwilligung .info[aria-expanded="true"] { border-color: var(--tinte); color: var(--tinte); }
.einwilligung .info-text { grid-column: 1 / -1; margin: .25rem 0 0 calc(24px + .75rem); line-height: 1.5; }
.knopf {
  font: inherit;
  font-weight: 500;
  background: var(--tinte);
  color: #fff;
  border: 1px solid var(--tinte);
  border-radius: 2px;
  padding: .8rem 1.4rem;
  min-height: 44px;
  cursor: pointer;
  width: 100%;
  margin-top: 1.25rem;
}
.knopf:hover { background: #0e182d; }
.knopf:disabled { opacity: .5; cursor: default; }
.knopf.leise { background: transparent; color: var(--tinte); }
.knopf.leise:hover { background: var(--papier); }
.fehler { border-left: 3px solid var(--rot); padding: .5rem 0 .5rem 1rem; margin-top: 1rem; }
.fehler p { margin: 0; }

/* Ladezustand */
.laden { text-align: center; padding: 2rem 0; }
.laden .schritt { margin-top: 1rem; font-family: var(--serif); font-style: italic; color: var(--grau); }
.laden .spruch { margin: .5rem auto 0; max-width: 28rem; min-height: 2.6em; }

/* Modul-Pills */
.module { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1rem; list-style: none; padding: 0; }
@media (min-width: 640px) { .module { grid-template-columns: repeat(3, 1fr); } }
.module li { display: grid; grid-template-columns: 28px 1fr; gap: .75rem; align-items: start; }
.module h3 { margin: 0 0 .2rem; }
.module p { margin: 0; font-size: .95rem; color: var(--grau); }

/* Tabellen (Hauptbuch) */
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.tabelle-rahmen { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.5rem; padding: 0 1.5rem; }
@media (max-width: 480px) { .tabelle-rahmen { margin: 0 -1.1rem; padding: 0 1.1rem; } }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--linie); text-align: left; vertical-align: baseline; white-space: nowrap; }
th { font-weight: 500; color: var(--grau); font-size: .8rem; }
td.zahl, th.zahl { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
th.zahl { font-family: var(--sans); }
tr.summe td { font-weight: 600; }
tr.ergebnis td { font-weight: 600; border-bottom: 3px double var(--tinte); }
tr.leer td { color: var(--grau); }
td.vermerk { white-space: normal; min-width: 11rem; font-size: .9rem; }
tr.marginalie { display: none; }
tr.marginalie td { border-bottom: 1px solid var(--linie); padding-top: .2rem; padding-bottom: .5rem; white-space: normal; }
tr.marginalie td .abw, tr.marginalie td .ok { display: inline-flex; margin-right: .4rem; }
tr.marginalie td .notiz { display: block; margin: 0 0 .3rem 1.6rem; }
@media (max-width: 720px) {
  td.vermerk:not(tr.marginalie td), th:last-child { display: none; }
  tr.marginalie { display: table-row; }
  tr.marginalie td { display: table-cell; position: sticky; left: 0; max-width: calc(100vw - 2 * var(--rand) - 2.2rem); }
  tr.marginalie td .abw, tr.marginalie td .ok { margin-right: .4rem; }
}
th:first-child, td:first-child { position: sticky; left: 0; background: var(--blatt); z-index: 1; }
tr.summe td:first-child, tr.ergebnis td:first-child { background: var(--blatt); }
td.vermerk .ok { color: var(--gruen); display: inline-flex; align-items: center; gap: .35rem; }
td.vermerk .abw { color: var(--rot); display: inline-flex; align-items: center; gap: .35rem; }
td.vermerk .notiz { display: block; margin-top: .1rem; }
td.zahl button.wert {
  font: inherit; background: none; border: 0; padding: 0 .15rem; color: inherit; cursor: text; border-radius: 2px; min-height: 28px;
}
td.zahl button.wert:hover { background: var(--papier); outline: 1px solid var(--linie); }
td.zahl button.wert.korrigiert { text-decoration: underline dotted var(--grau); }
td.zahl input { font: inherit; font-family: var(--mono); width: 9ch; text-align: right; border: 1px solid var(--tinte); border-radius: 2px; padding: 0 .2rem; }
.kringel-wrap { position: relative; display: inline-block; }
.kringel-wrap svg { position: absolute; left: -10px; top: -7px; width: calc(100% + 20px); height: calc(100% + 14px); overflow: visible; pointer-events: none; }
.spaltenlegende { font-size: .85rem; color: var(--grau); margin-top: .75rem; }

/* Einordnung */
.einordnung { list-style: none; padding: 0; margin: 0; display: grid; gap: .9rem; max-width: var(--mass); }
.einordnung li { display: grid; grid-template-columns: 26px 1fr; gap: .8rem; align-items: start; }
.einordnung li svg { margin-top: 2px; }
.einordnung li.frage { font-family: var(--serif); font-style: italic; }

.kpi-raster { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.5rem; margin-top: 1rem; }
@media (min-width: 720px) { .kpi-raster { grid-template-columns: repeat(4, 1fr); } }
.kpi .label { font-size: .8rem; color: var(--grau); }
.kpi .wert { font-family: var(--mono); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpi .vj { font-size: .85rem; color: var(--grau); font-family: var(--mono); }
.kpi .vj span { white-space: nowrap; }
.kpi .plus { color: var(--gruen); }
.kpi .minus { color: var(--rot); }

.aktionen { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.aktionen .knopf { width: auto; margin: 0; }
.abschluss { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--linie); color: var(--grau); font-size: .9rem; }
.fuss { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--linie); display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .9rem; color: var(--grau); }
.fuss a { color: var(--grau); display: inline-flex; align-items: center; min-height: 44px; }
.fuss span { display: inline-flex; align-items: center; min-height: 44px; }

/* Rechtstexte */
.text h2 { margin-top: 2rem; font-size: 1.25rem; }
.text h3 { margin-top: 1.5rem; }
.text ul, .text ol { max-width: var(--mass); padding-left: 1.3rem; }
.text li { margin-bottom: .35rem; }
.text table { max-width: var(--mass); }
.text th, .text td { white-space: normal; vertical-align: top; }
.text th:first-child, .text td:first-child { position: static; }
.todo { background: #FFF4E0; color: var(--hinweis); padding: 0 .3rem; border-radius: 2px; font-family: var(--mono); font-size: .9em; }

@media (pointer: coarse) {
  td.zahl button.wert { min-height: 44px; padding: 0 .35rem; }
  th, td { padding: .35rem .6rem; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .kopf nav, .aktionen, .fuss, .korrektur-hinweis { display: none !important; }
  .blatt { border: 0; padding: 0; }
  .tabelle-rahmen { overflow: visible; margin: 0; padding: 0; }
  td.zahl button.wert { padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
