/*
 * Fristwerk – Oberfläche
 * Verwendet ausschließlich Design-Tokens (--fw-*). Die Werte kommen zur
 * Laufzeit aus dem CI-Profil des Mandanten (App\Darstellung\CiProfil).
 */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--fw-schrift);
    font-size: 15px;
    line-height: 1.5;
    color: var(--fw-tinte);
    background: var(--fw-flaeche);
    font-variant-numeric: tabular-nums;
}

a { color: var(--fw-primaer); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 3px solid var(--fw-primaer);
    outline-offset: 2px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }

p { margin: 0 0 .75em; max-width: 72ch; }

/* ── Kopfleiste ─────────────────────────────────────────────── */

.kopfleiste {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: .6rem 1.5rem;
    background: var(--fw-papier);
    border-bottom: 1px solid var(--fw-linie);
}

.marke { display: flex; align-items: baseline; gap: .75rem; text-decoration: none; color: var(--fw-tinte); }
.marke-wort { font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; }
.marke-mandant { color: var(--fw-tinte-leise); font-size: .9rem; }

.navigation { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.navigation a {
    display: block;
    padding: .4rem .75rem;
    border-radius: var(--fw-radius);
    color: var(--fw-tinte);
    text-decoration: none;
}
.navigation a:hover { background: var(--fw-flaeche); }
.navigation a[aria-current="page"] { background: var(--fw-flaeche); box-shadow: inset 0 -2px 0 var(--fw-primaer); }

.abmelden { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.nutzer { color: var(--fw-tinte-leise); font-size: .9rem; }
.abmelden .knopf { border-color: var(--fw-linie); color: var(--fw-tinte); font-weight: 500; }

/* ── Inhalt ─────────────────────────────────────────────────── */

.inhalt { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }

.abschnitt {
    background: var(--fw-papier);
    border: 1px solid var(--fw-linie);
    border-radius: var(--fw-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.leise { color: var(--fw-tinte-leise); }
.klein { font-size: .875rem; }

.meldung { padding: .75rem 1rem; border-radius: var(--fw-radius); margin: 0 0 1.25rem; border-left: 4px solid; background: var(--fw-papier); }
.meldung p { margin: 0; }
.meldung-erfolg { border-color: var(--fw-bestaetigt); }
.meldung-fehler { border-color: var(--fw-frist); }
.meldung-hinweis { border-color: var(--fw-geschaetzt); }

/* ── Formulare und Knöpfe ───────────────────────────────────── */

label { display: block; font-weight: 550; margin-bottom: .25rem; }
.feld { margin-bottom: 1rem; }
.feldhinweis { display: block; font-weight: 400; color: var(--fw-tinte-leise); font-size: .85rem; }

input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
    font: inherit;
    color: inherit;
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--fw-linie);
    border-radius: var(--fw-radius);
    background: var(--fw-papier);
}
textarea { min-height: 4.5rem; resize: vertical; }
input[type=file] { font: inherit; }

.knopf {
    font: inherit;
    font-weight: 550;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--fw-radius);
    border: 1px solid var(--fw-primaer);
    background: var(--fw-primaer);
    color: var(--fw-primaer-text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.knopf:hover { filter: brightness(1.08); }
.knopf[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.knopf-leise { background: transparent; color: var(--fw-primaer); }
.knopf-klein { padding: .2rem .55rem; font-size: .85rem; }
.knopf-gefahr { background: transparent; color: var(--fw-frist); border-color: transparent; }
.knopf-gefahr:hover { border-color: var(--fw-linie); }

.zeile { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.zeile > .feld { flex: 1 1 14rem; margin-bottom: 0; }

/* ── Tabellen ───────────────────────────────────────────────── */

.tabelle { width: 100%; border-collapse: collapse; background: var(--fw-papier); }
.tabelle th, .tabelle td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--fw-linie); vertical-align: top; }
.tabelle th { font-weight: 600; font-size: .875rem; color: var(--fw-tinte-leise); }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle .zahl { text-align: right; }

.reiter { display: flex; gap: .25rem; margin: 0 0 1rem; padding: 0; list-style: none; flex-wrap: wrap; }
.reiter a { display: block; padding: .3rem .7rem; border-radius: 999px; text-decoration: none; color: var(--fw-tinte); border: 1px solid var(--fw-linie); background: var(--fw-papier); }
.reiter a[aria-current="true"] { border-color: var(--fw-primaer); color: var(--fw-primaer); font-weight: 600; }

.status { font-size: .85rem; white-space: nowrap; }
.status-zu_pruefen, .status-neu, .status-in_erkennung { color: var(--fw-geschaetzt); }
.status-freigegeben { color: var(--fw-bestaetigt); }

/* ── Datumsstempel: das Erkennungszeichen von Fristwerk ─────── */

.stempel {
    display: inline-block;
    font-family: var(--fw-schrift-zahlen);
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--fw-primaer);
    border: 2px solid currentColor;
    border-radius: 4px;
    padding: .05rem .4rem;
    transform: rotate(-1.5deg);
    white-space: nowrap;
}
.stempel-frist { color: var(--fw-frist); }
.stempel-geschaetzt { border-style: dashed; color: var(--fw-geschaetzt); }
.stempel-erledigt { color: var(--fw-bestaetigt); transform: none; }

.zustaendig { font-size: .875rem; }

/* ── Anmeldung ──────────────────────────────────────────────── */

.anmeldung { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.karte { width: min(26rem, 100%); background: var(--fw-papier); border: 1px solid var(--fw-linie); border-radius: var(--fw-radius); padding: 2rem; }
.anmeldung h1 { margin-bottom: 1rem; }
.anmeldung .nebenaktion { margin: 1rem 0 0; font-size: .9rem; }
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: 200px; height: 200px; }
.schluessel, .codes code { font-family: var(--fw-schrift-zahlen); font-size: .95rem; letter-spacing: .03em; }
.codes { columns: 2; list-style: none; padding: 0; margin: 1rem 0 1.5rem; }
.codes li { margin-bottom: .35rem; }
.anmeldung .marke-wort { display: block; margin-bottom: 1.5rem; color: var(--fw-primaer); }

/* ── Übersicht ──────────────────────────────────────────────── */

.pruefhinweis { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.pruefhinweis p { margin: 0; font-size: 1.05rem; }

/* ── Prüfansicht ────────────────────────────────────────────── */

.pruefansicht-koerper { overflow: hidden; }
.pruefansicht {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(24rem, 1fr);
    height: calc(100vh - 53px);
}

.scan {
    overflow-y: auto;
    padding: 1.25rem;
    background: color-mix(in srgb, var(--fw-tinte) 8%, var(--fw-flaeche));
}
.scan-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; gap: 1rem; }
.scan-kopf h1 { font-size: 1.1rem; margin: 0; overflow-wrap: anywhere; }

.seite { position: relative; margin: 1.5rem auto 1.25rem; max-width: 900px; background: var(--fw-papier); box-shadow: 0 1px 3px color-mix(in srgb, var(--fw-tinte) 25%, transparent); user-select: none; }
.seite img { display: block; width: 100%; height: auto; }
.seite-nr { position: absolute; top: -1.1rem; left: 0; font-size: .75rem; color: var(--fw-tinte-leise); }
.seite.markieren { cursor: crosshair; }

.markierung {
    position: absolute;
    border: 2px solid var(--m);
    background: color-mix(in srgb, var(--m) 14%, transparent);
    border-radius: 2px;
    cursor: pointer;
    padding: 0;
}
.markierung::after {
    content: attr(data-nr);
    position: absolute;
    top: 50%;
    right: 100%;
    margin-right: 4px;
    transform: translateY(-50%);
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 .25rem;
    border-radius: 999px;
    background: var(--m);
    color: #fff;
    font: 600 .75rem/1.35rem var(--fw-schrift);
    text-align: center;
}
.markierung.erledigt { background: transparent; border-style: dotted; opacity: .55; }
.markierung.aktiv { background: color-mix(in srgb, var(--m) 30%, transparent); outline: 3px solid var(--m); outline-offset: 2px; }
.markierung.neu { border-style: dashed; --m: var(--fw-primaer); }

.angaben {
    overflow-y: auto;
    background: var(--fw-papier);
    border-left: 1px solid var(--fw-linie);
    display: flex;
    flex-direction: column;
}
.angaben-inhalt { padding: 1.25rem 1.5rem; flex: 1; }
.angaben h2 { margin: 1.5rem 0 .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--fw-linie); }
.angaben h2:first-of-type { margin-top: 0; }

.angabe { padding: .65rem 0 .65rem .6rem; border-left: 3px solid transparent; margin-left: -.6rem; }
.angabe + .angabe { border-top: 1px solid color-mix(in srgb, var(--fw-linie) 60%, transparent); }
.angabe.aktiv { border-left-color: var(--m, var(--fw-primaer)); background: color-mix(in srgb, var(--m, var(--fw-primaer)) 6%, transparent); }
.angabe:target { border-left-color: var(--m, var(--fw-primaer)); }

.angabe-kopf { display: flex; align-items: baseline; gap: .5rem; }
.angabe-nr {
    flex: none;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 .25rem;
    border-radius: 999px;
    background: var(--m);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.35rem;
    border: 0;
    cursor: pointer;
}
.angabe-titel { font-weight: 600; font-size: .9rem; }
.angabe-wert { margin: .15rem 0 .25rem; font-size: 1rem; overflow-wrap: anywhere; }
.angabe-wert.fehlt { color: var(--fw-tinte-leise); font-style: italic; }
.angabe-meta { font-size: .82rem; color: var(--fw-tinte-leise); margin: 0 0 .35rem; }
.angabe-status { font-size: .8rem; font-weight: 600; }
.angabe-status-vorgeschlagen { color: var(--fw-geschaetzt); }
.angabe-status-bestaetigt, .angabe-status-korrigiert { color: var(--fw-bestaetigt); }
.angabe-status-verworfen { color: var(--fw-tinte-leise); text-decoration: line-through; }
.angabe-aktionen { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.angabe-aktionen form { margin: 0; }

details.korrektur summary { list-style: none; display: inline-flex; }
details.korrektur summary::-webkit-details-marker { display: none; }
details.korrektur[open] { flex-basis: 100%; }
details.korrektur form { margin-top: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; }
details.korrektur form > :is(input, select, textarea) { flex: 1 1 12rem; }

.freigabeleiste {
    position: sticky;
    bottom: 0;
    padding: .9rem 1.5rem;
    background: var(--fw-papier);
    border-top: 1px solid var(--fw-linie);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.freigabeleiste p { margin: 0; font-size: .9rem; }

.vonhand { margin-top: 1.5rem; padding: 1rem; border: 1px dashed var(--fw-linie); border-radius: var(--fw-radius); }
.vonhand summary { cursor: pointer; font-weight: 600; }

@media (max-width: 900px) {
    .pruefansicht-koerper { overflow: auto; }
    .pruefansicht { display: block; height: auto; }
    .scan, .angaben { overflow: visible; }
    .kopfleiste { flex-wrap: wrap; gap: .75rem; }
    .abmelden { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
    .angabe { transition: background-color .15s; }
}

/* ── Seitennavigation ───────────────────────────────────────── */
.pagination { display: flex; gap: .25rem; list-style: none; padding: 0; margin: 1rem 0; flex-wrap: wrap; }
.pagination li > * { display: block; padding: .25rem .6rem; border: 1px solid var(--fw-linie); border-radius: var(--fw-radius); background: var(--fw-papier); text-decoration: none; }
.pagination .active > * { border-color: var(--fw-primaer); color: var(--fw-primaer); font-weight: 600; }
.pagination .disabled > * { opacity: .5; }

/* Meldungen in der Prüfansicht schweben über dem Raster */
.pruefansicht > .meldung {
    position: fixed;
    top: 64px;
    right: 1.5rem;
    z-index: 10;
    max-width: 26rem;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--fw-tinte) 20%, transparent);
}
.angabe-status { margin-left: auto; white-space: nowrap; }

@media (max-width: 760px) {
    .tabelle { display: block; overflow-x: auto; }
    .inhalt { padding: 1.25rem 1rem 3rem; }
}

/* ── Erledigung und Nachweise ───────────────────────────────── */
details.erledigung form { flex-direction: column; align-items: stretch; min-width: 16rem; }
details.erledigung label { font-weight: 500; }
.nachweis { min-width: 14rem; }
.nachweis .kommentar { white-space: normal; color: var(--fw-tinte); margin: .25rem 0; }
.anhaenge { list-style: none; margin: .25rem 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.anhaenge li { display: flex; gap: .5rem; align-items: center; font-size: .85rem; }
.anhaenge a { display: inline-flex; align-items: center; gap: .4rem; }
.anhaenge img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; border: 1px solid var(--fw-linie); }

/* ── Verwaltung ─────────────────────────────────────────────── */
.farbraster { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0 1.25rem; }
.farbfeld { display: flex; gap: .4rem; align-items: center; }
.farbfeld input[type=color] { width: 2.4rem; height: 2.2rem; padding: 0; border: 1px solid var(--fw-linie); border-radius: var(--fw-radius); background: none; }
.tabelle.stufen td { vertical-align: middle; }
.tabelle.stufen .zeile { flex-wrap: nowrap; }

/* Abgrenzung der Verantwortung */
.hinweisliste { padding-left: 1.2rem; margin: 1rem 0 1.25rem; }
.hinweisliste li { margin-bottom: .55rem; line-height: 1.45; }
.bestaetigung { display: flex; gap: .55rem; align-items: flex-start; margin: 0 0 1rem; line-height: 1.4; font-weight: normal; }
.bestaetigung input { margin-top: .2rem; flex: none; }
.haftungshinweis { font-size: .82rem; color: var(--fw-tinte-leise); margin: .75rem 0 0; }
.freigabeleiste .bestaetigung { font-size: .85rem; margin: .5rem 0 .75rem; max-width: 46rem; }

/* Zusatzmodul Garantien */
.kopfzeile { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.kennzahlen { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0; }
.kennzahlen > div { background: var(--fw-papier); border: 1px solid var(--fw-linie); border-radius: var(--fw-radius); padding: .75rem 1rem; min-width: 14rem; }
.kennzahlen dt { font-size: .85rem; color: var(--fw-tinte-leise); }
.kennzahlen dd { margin: .2rem 0 0; font-size: 1.35rem; font-weight: 600; font-family: var(--fw-schrift-zahlen); }
.kennzahlen dd.klein { font-size: .8rem; font-weight: 400; font-family: inherit; }
.formular-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0 1.25rem; max-width: 60rem; }
.formular-raster .feld-breit { grid-column: 1 / -1; }
.formular-raster input, .formular-raster select, .formular-raster textarea { width: 100%; }
