:root {
    --paper: #eef1f2;
    --surface: #ffffff;
    --ink: #101a1f;
    --ink-2: #4a5b62;
    --ink-3: #74858c;
    --line: #d3dcdf;
    --accent: #10566b;
    --ok: #2c6a4f;
    --warn: #8a5a12;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Helle Toenungen der Werte oben -- keine neuen Farben, nur Mischungen
       (siehe docs/entwurf/README.md). Ueber color-mix() abgeleitet statt fest
       verdrahtet, damit sie im Dunkelmodus automatisch mitziehen. */
    --accent-flaeche: color-mix(in srgb, var(--accent) 12%, var(--surface));
    --accent-rand: color-mix(in srgb, var(--accent) 35%, var(--surface));
    --ok-flaeche: color-mix(in srgb, var(--ok) 14%, var(--surface));
    --ok-rand: color-mix(in srgb, var(--ok) 38%, var(--surface));
    --warn-flaeche: color-mix(in srgb, var(--warn) 14%, var(--surface));
    --warn-rand: color-mix(in srgb, var(--warn) 38%, var(--surface));
    --line-innen: color-mix(in srgb, var(--line) 55%, var(--surface));
    --tabelle-kopf: color-mix(in srgb, var(--paper) 55%, var(--surface));
    --zeile-hinweis: color-mix(in srgb, var(--warn) 6%, var(--surface));
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
}

.wrap {
    max-width: 780px;
    margin: 0 auto;
    padding-inline: 20px;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    margin-bottom: 36px;
}

.brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-note {
    font-size: 13px;
    color: var(--ink-3);
}

h1 {
    font-size: 1.7rem;
    line-height: 1.2;
    margin: 0 0 0.4em;
    letter-spacing: -0.015em;
}

h2 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-3);
    margin: 34px 0 10px;
    font-weight: 600;
}

.lede {
    color: var(--ink-2);
    margin: 0 0 8px;
    max-width: 60ch;
}

code {
    font-family: var(--mono);
    font-size: 0.87em;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 1px 4px;
}

.status dl {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--line);
}

.status dl > div {
    flex: 1 1 180px;
    padding: 12px 16px;
    border-right: 1px solid var(--line);
}

.status dl > div:last-child { border-right: 0; }

.status dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
    margin-bottom: 2px;
}

.status dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.muted { color: var(--ink-3); font-weight: 400; }

.hint {
    font-size: 14px;
    color: var(--ink-2);
    margin: 10px 0 0;
}

.phases {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
}

.phase {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 12px;
    align-items: baseline;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
}

.phase:last-child { border-bottom: 0; }

.phase-id {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
}

.phase-state {
    font-size: 12px;
    color: var(--ink-3);
}

.phase--laeuft { background: #f5fafb; }
.phase--laeuft .phase-title { font-weight: 600; }
.phase--laeuft .phase-state { color: var(--accent); font-weight: 600; }

.foot {
    margin: 44px auto 40px;
    color: var(--ink-3);
    font-size: 13px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

/* -- Anmeldung und Formulare (Phase 1) ------------------------------- */

.topbar-konto {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.konto-name {
    font-size: 13px;
    color: var(--ink-2);
}

.schmal {
    max-width: 26rem;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 18px 0 0;
}

.feld {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feld-name {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-3);
}

.feld input {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 9px 11px;
}

.feld input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.knopf {
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 9px 16px;
    cursor: pointer;
    align-self: flex-start;
}

.knopf:hover { filter: brightness(1.06); }

.knopf--schlicht {
    color: var(--ink-2);
    background: transparent;
    border-color: var(--line);
}

.form-abbrechen {
    margin-top: 14px;
}

.meldung {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 14px;
    margin: 14px 0 0;
}

.meldung--erfolg {
    color: var(--ok);
    border-color: var(--ok-rand);
    background: var(--ok-flaeche);
}

.meldung--fehler {
    color: var(--warn);
    border-color: var(--warn);
    background: color-mix(in srgb, var(--warn) 8%, transparent);
}

.hinweis {
    font-size: 14px;
    color: var(--ink-2);
    margin: 12px 0 0;
}

.qr {
    width: 200px;
    margin: 18px 0 6px;
    background: #fff;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
}

.qr svg { display: block; width: 100%; height: auto; }

.geheimnis {
    display: inline-block;
    margin-top: 4px;
    font-size: 1rem;
    letter-spacing: 0.14em;
}

.codes {
    list-style: none;
    margin: 10px 0 0;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.95rem;
    columns: 2;
}

.codes li { padding: 3px 0; }

/* -- Stammdaten (Phase 2) --------------------------------------------- */

.topbar-nav {
    display: flex;
    gap: 16px;
    margin-left: 24px;
}

.topbar-nav a {
    font-size: 13px;
    color: var(--ink-2);
    text-decoration: none;
}

.topbar-nav a:hover {
    color: var(--accent);
}

.tabelle-wrap {
    overflow-x: auto;
}

.tabelle {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 14px;
}

.tabelle th,
.tabelle td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.tabelle th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    font-weight: 600;
}

.tabelle tbody tr:last-child td {
    border-bottom: 0;
}

.tabelle a {
    color: var(--accent);
}

.feld select {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 9px 11px;
}

fieldset.feld {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 10px 12px;
    margin: 0;
}

fieldset.feld legend {
    padding: 0 4px;
}

.ankreuzfeld {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 3px 0;
    text-transform: none;
    letter-spacing: normal;
}

/* -- Belege auslesen (Phase 4) ----------------------------------------- */

.wrap--breit {
    max-width: 1100px;
}

.pruefung {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.pruefung-vorschau,
.pruefung-felder {
    flex: 1 1 400px;
    min-width: 0;
}

.pruefung-vorschau iframe,
.pruefung-vorschau img {
    width: 100%;
    height: 70vh;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
}

.pruefung-vorschau img {
    height: auto;
    object-fit: contain;
}

.meldung--warnung {
    color: var(--warn);
    border-color: var(--warn);
    background: color-mix(in srgb, var(--warn) 8%, transparent);
}

/* -- Objektseite, Einheit, Ablesung (Phase 2 der Oberflaeche) --------- */

.wrap--breit {
    max-width: 1100px;
}

/* Brotkrumen-Pfad -- auf jeder Seite oben, Querschnitt-Anforderung. */
.pfad {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--ink-3);
    margin: 0 0 14px;
}

.pfad a {
    color: var(--ink-3);
}

.pfad .pfad-aktuell {
    color: var(--ink);
}

.titelzeile {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin: 0 0 18px;
}

.titelzeile h1 {
    margin: 0 0 4px;
}

.titelzeile .lede {
    margin: 0;
}

.titelzeile-aktion {
    margin-left: auto;
    font-size: 14px;
    white-space: nowrap;
}

.titelzeile-aktion--gruppe {
    display: flex;
    align-items: center;
    gap: 12px;
}

.abschnitt-kopf {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 34px 0 10px;
}

.abschnitt-kopf h2 {
    margin: 0;
}

.abschnitt-kopf-hinweis {
    font-size: 13px;
    color: var(--ink-3);
}

.einheit-kopf {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0 10px;
}

.einheit-kopf h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* Zahlenspalten -- Querschnitt-Anforderung fuer alle Seiten. */
.zahl {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mono {
    font-family: var(--mono);
    font-size: 0.87em;
    color: var(--ink-3);
}

.subtext {
    font-size: 12.5px;
    color: var(--ink-3);
}

/* Chip fuer den Belegungsstatus einer Einheit. */
.chip {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 3px;
    padding: 1px 8px;
    border: 1px solid;
    white-space: nowrap;
}

.chip--ok {
    color: var(--ok);
    background: var(--ok-flaeche);
    border-color: var(--ok-rand);
}

.chip--warn {
    color: var(--warn);
    background: var(--warn-flaeche);
    border-color: var(--warn-rand);
}

/* Hinweisband -- Abrechnungsfrist auf der Objektseite, Kuendigung an der Einheit. */
.hinweisband {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 16px;
    margin: 0 0 22px;
    border: 1px solid var(--accent-rand);
    border-left: 3px solid var(--accent);
    background: var(--accent-flaeche);
}

.hinweisband svg {
    stroke: var(--accent);
    flex-shrink: 0;
}

.hinweisband-text {
    font-size: 14.5px;
}

.hinweisband-aktion {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.hinweisband--warn {
    border-color: var(--warn-rand);
    border-left-color: var(--warn);
    background: var(--warn-flaeche);
}

.hinweisband--warn svg {
    stroke: var(--warn);
}

.frist-resttage {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--accent);
}

.hinweisband--warn .frist-resttage {
    color: var(--warn);
}

.frist-resttage--knapp {
    font-weight: 700;
}

/* Aktionsleiste mit Icon-Schaltflaechen. */
.aktionen {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 30px;
}

.aktion {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 8px 13px;
    font-size: 14px;
    color: var(--ink);
    text-decoration: none;
}

.aktion:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.aktion svg {
    stroke: var(--accent);
    flex-shrink: 0;
}

/* Tabellenzusaetze: Hinweiszeile, Summenzeile, rechtsbuendige Kopfzellen. */
.tabelle th.zahl {
    text-align: right;
}

.tabelle tr.zeile--hinweis td {
    background: var(--zeile-hinweis);
}

.tabelle tfoot td {
    background: var(--tabelle-kopf);
    font-weight: 600;
    border-bottom: 0;
}

/* Zeitleiste der Mietverhaeltnisse (Einheit). */
.zeitleiste {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 20px 24px 16px;
    margin: 0 0 30px;
}

.zeitleiste-jahre {
    position: relative;
    height: 18px;
    margin-bottom: 6px;
    font-size: 11.5px;
    color: var(--ink-3);
}

.zeitleiste-jahre span {
    position: absolute;
    transform: translateX(-50%);
    font-variant-numeric: tabular-nums;
}

.zeitleiste-balken {
    position: relative;
    height: 46px;
    background: var(--paper);
    border: 1px solid var(--line-innen);
}

.zeitleiste-gitter {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--line-innen);
}

.zeitleiste-segment {
    position: absolute;
    top: 7px;
    bottom: 7px;
    display: flex;
    align-items: center;
    padding-left: 10px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.zeitleiste-segment--laufend {
    background: var(--accent);
    color: #fff;
}

.zeitleiste-segment--vergangen {
    background: var(--accent-flaeche);
    border: 1px solid var(--accent-rand);
    color: var(--accent);
}

.zeitleiste-segment--leerstand {
    background: repeating-linear-gradient(
        45deg,
        var(--warn-flaeche),
        var(--warn-flaeche) 4px,
        var(--warn-rand) 4px,
        var(--warn-rand) 8px
    );
    border: 1px solid var(--warn-rand);
}

.zeitleiste-heute {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background: var(--warn);
}

.zeitleiste-marken {
    position: relative;
    height: 20px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--warn);
}

.zeitleiste-marken span {
    position: absolute;
    white-space: nowrap;
}

/* -- Ablesung am Telefon ------------------------------------------------ */

.ablesung {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--paper);
    display: flex;
    flex-direction: column;
}

.ablesung-kopf {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.ablesung-kopf a {
    display: flex;
    color: var(--accent);
}

.ablesung-titel {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.ablesung-untertitel {
    font-size: 12.5px;
    color: var(--ink-3);
}

.ablesung-fortschritt {
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.ablesung-fortschritt-zeile {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 7px;
    font-size: 13.5px;
}

.ablesung-fortschritt-zeile .muted {
    color: var(--ink-3);
}

.ablesung-balken {
    height: 6px;
    background: color-mix(in srgb, var(--line) 70%, var(--surface));
    border-radius: 3px;
    overflow: hidden;
}

.ablesung-balken > div {
    height: 100%;
    background: var(--accent);
}

.ablesung-liste {
    flex-grow: 1;
    padding: 12px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ablesung-karte {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 12px 14px;
}

.ablesung-karte--erledigt {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ablesung-karte--erledigt svg {
    stroke: var(--ok);
    flex-shrink: 0;
}

.ablesung-karte--offen {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.72;
}

.ablesung-karte--offen svg {
    stroke: var(--ink-3);
    flex-shrink: 0;
}

.ablesung-karte--aktiv {
    border-color: var(--accent);
    padding: 14px;
}

.ablesung-karte-titel {
    font-weight: 600;
    font-size: 14.5px;
}

.ablesung-karte-kopf {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 2px;
}

.ablesung-karte-kopf .ablesung-karte-titel {
    font-size: 15px;
}

.ablesung-karte-lage {
    font-size: 12.5px;
    color: var(--ink-3);
    margin-bottom: 12px;
}

.ablesung-eingabe {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.ablesung-feld {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    border: 1.5px solid var(--accent);
    border-radius: 4px;
    padding: 0 14px;
    background: var(--surface);
}

.ablesung-feld input {
    flex-grow: 1;
    min-width: 0;
    border: 0;
    font: inherit;
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    background: transparent;
}

.ablesung-feld input:focus {
    outline: none;
}

.ablesung-feld--warnung {
    border-color: var(--warn);
    background: var(--zeile-hinweis);
}

.ablesung-einheit {
    font-size: 14px;
    color: var(--ink-3);
}

.ablesung-foto-knopf {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    cursor: pointer;
    padding: 0;
}

.ablesung-foto-knopf svg {
    stroke: var(--accent);
}

.ablesung-foto-knopf--gesetzt {
    border-color: var(--ok);
    background: var(--ok-flaeche);
}

.ablesung-vergleich {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 13px;
}

.ablesung-vergleich .muted {
    color: var(--ink-3);
}

.ablesung-verbrauch {
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.ablesung-warnung {
    display: none;
    gap: 9px;
    margin-top: 11px;
    background: var(--warn-flaeche);
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 13px;
    color: color-mix(in srgb, var(--warn) 80%, var(--ink));
}

.ablesung-warnung.ist-sichtbar {
    display: flex;
}

.ablesung-warnung svg {
    stroke: var(--warn);
    flex-shrink: 0;
    margin-top: 2px;
}

.ablesung-warnung a,
.ablesung-warnung button {
    color: var(--warn);
    font-weight: 600;
    text-decoration: underline;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.ablesung-zwischenhinweis {
    font-size: 12.5px;
    color: var(--warn);
}

.ablesung-fuss {
    padding: 12px 16px 18px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    position: sticky;
    bottom: 0;
}

.ablesung-knopf {
    height: 50px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 15px;
    color: var(--ink-2);
    background: var(--surface);
    text-decoration: none;
}

.ablesung-knopf--primaer {
    flex-grow: 2;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    font: inherit;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #0d1418;
        --surface: #141d22;
        --ink: #e2eaec;
        --ink-2: #a9b9bf;
        --ink-3: #7c8d94;
        --line: #2b393f;
        --accent: #6db8ce;
        --ok: #6fbf97;
        --warn: #d9a94e;
    }
    .phase--laeuft { background: #17262c; }
    .knopf { color: #0d1418; }
}
