/* ============================================================
   stn Monteur-PWA — Layout & Komponenten
   Body: Poppins · Überschriften: Zilla Slab · Akzent: #ca4e43

   Ausgelegt auf ein Samsung-Tablet in Landschafts- wie Hochformat:
   große Trefferflächen (min. 48 px), kräftige Kontraste, keine
   Hover-Abhängigkeiten.
   ============================================================ */

:root {
    --maxw-app: 1100px;
    --tap: 48px;

    --blau: #23639e;
    --blau-hell: #e6f0f8;
    --gruen-hell: #ecfdf3;
    --orange-hell: #fff7ee;
    --rot-hell: #fdecea;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Poppins', system-ui, -apple-system, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

h1, h2, h3 {
    font-family: 'Zilla Slab', Georgia, serif;
    font-weight: 600;
    color: var(--anthrazit);
    margin: 0 0 .4em;
    line-height: 1.2;
}

a { color: var(--rot); }

[hidden] { display: none !important; }

code {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: .9em;
    background: #eef0f2;
    border-radius: 4px;
    padding: 1px 5px;
}

/* ---------- Kopfzeile ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--weiss);
    border-bottom: 1px solid var(--rahmen-soft);
    padding: 10px 20px;
    padding-top: max(10px, env(safe-area-inset-top));
}
.topbar__logo { height: 40px; width: auto; flex: 0 0 auto; }
.topbar__titel {
    font-family: 'Zilla Slab', Georgia, serif;
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--anthrazit);
    flex: 1 1 auto;
    min-width: 0;
}
.topbar__aktionen { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.topbar__mitarbeiter {
    display: inline-flex;
    align-items: center;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--anthrazit);
    background: #f1f3f5;
    border: 1px solid var(--rahmen-soft);
    border-radius: 999px;
    padding: 5px 12px;
}

#syncBtn.is-aktiv .fa-cloud-arrow-up { animation: puls 1.1s ease-in-out infinite; }
@keyframes puls { 50% { opacity: .35; transform: translateY(-2px); } }

/* ---------- Statusleiste ---------- */
.statusleiste {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--rahmen-soft);
    background: var(--gruen-hell);
    color: #1c7a3c;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    text-align: left;
}
.statusleiste.is-offen  { background: var(--orange-hell); color: var(--orange-dark); }
.statusleiste.is-offline { background: #eef0f2; color: var(--anthrazit); }
.statusleiste.is-fehler { background: var(--rot-hell); color: #9b2c22; }

.statusleiste__teil { display: inline-flex; align-items: center; gap: 7px; }
.statusleiste__trenner { width: 1px; height: 16px; background: currentColor; opacity: .3; }
.statusleiste__pfeil { margin-left: auto; opacity: .6; }

.testhinweis {
    margin: 0;
    padding: 8px 20px;
    background: #fff8e1;
    border-bottom: 1px solid #f2e2b0;
    color: #8a6d1a;
    font-size: .82rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Rahmen ---------- */
.wrap {
    max-width: var(--maxw-app);
    margin: 0 auto;
    padding: 24px 20px 64px;
    padding-bottom: max(64px, env(safe-area-inset-bottom));
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: .78rem;
    padding: 8px 16px 32px;
}

.laedt { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Karten / Blöcke ---------- */
.karte {
    background: var(--weiss);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 26px 24px;
    margin: 8px auto 28px;
}
.karte--schmal { max-width: 520px; }
.karte__titel { font-size: 1.5rem; text-align: center; }
.karte__lead { color: var(--muted); text-align: center; margin: 0 0 22px; font-size: .92rem; }

.block { margin: 0 0 28px; }
.block__titel {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1.1rem;
    margin: 0 0 14px;
}
.block__titel i { color: var(--muted); font-size: .9em; }

.leer {
    color: var(--muted);
    font-size: .92rem;
    background: var(--weiss);
    border: 1px dashed var(--rahmen);
    border-radius: var(--radius-lg);
    padding: 22px;
    text-align: center;
    margin: 0;
}
.leer--gross { padding: 46px 22px; }
.leer--gross p { margin: 6px 0 0; }
.leer__icon { font-size: 2.4rem; color: var(--rahmen); display: block; margin-bottom: 12px; }
.leer__hinweis { font-size: .85rem; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.feldblock { display: flex; flex-direction: column; gap: 7px; }

.feld__label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--anthrazit);
}
.feld__einheit { color: var(--muted); font-weight: 400; }
.feld__pflicht { color: var(--rot); }

.feld__eingabe {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    padding: 10px 14px;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
    background: #fff;
}
.feld__eingabe--gross { font-size: 1.3rem; letter-spacing: .06em; min-height: 60px; }
.feld__eingabe--mehrzeilig { resize: vertical; line-height: 1.45; min-height: 90px; }
.feld__eingabe:focus {
    outline: none;
    border-color: var(--rot);
    box-shadow: 0 0 0 3px rgba(202, 78, 67, .16);
}
/* Eigener Pfeil, damit ein Auswahlfeld nicht wie ein Textfeld aussieht
   (die Systemdarstellung fällt auf Android sehr unterschiedlich aus). */
select.feld__eingabe {
    appearance: none;
    padding-right: 44px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236f7173' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 15px;
}

.feld__mitliste { display: contents; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: var(--tap);
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--rot); color: #fff; }
.btn--primary:not(:disabled):active { background: var(--rot-dark); }
.btn--ghost {
    background: #fff;
    color: var(--anthrazit);
    border-color: var(--rahmen);
}
.btn--ghost:not(:disabled):active { background: #f1f1f1; }
.btn--gefahr { background: var(--rot); color: #fff; }
.btn--gefahrtext { color: #9b2c22; }
.btn--block { width: 100%; }
.btn--klein { min-height: 40px; padding: 8px 14px; font-size: .88rem; }
.btn.is-laedt { opacity: .6; pointer-events: none; }

/* ---------- Meldungen ---------- */
.msg {
    border-radius: var(--radius);
    padding: 12px 15px;
    font-size: .9rem;
    margin: 0;
}
.msg--fehler { background: var(--rot-hell); border: 1px solid #f5c6c2; color: #9b2c22; }
.msg--info   { background: var(--blau-hell); border: 1px solid #cfe0fb; color: #1d4ed8; }

/* ---------- Projektliste ---------- */
.projektliste {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.projektkachel {
    position: relative;
    background: var(--weiss);
    border: 1px solid var(--rahmen-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
.projektkachel__flaeche {
    display: block;
    padding: 16px 18px;
    /* Platz für den Entfernen-Knopf oben rechts. */
    padding-right: 62px;
    text-decoration: none;
    color: var(--text);
    border-radius: inherit;
}
.projektkachel:has(.projektkachel__flaeche:active) { border-color: var(--rot); }

.projektkachel__entfernen {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
}
.projektkachel__entfernen:hover,
.projektkachel__entfernen:focus-visible {
    background: var(--rot-hell);
    border-color: #f5c6c2;
    color: #9b2c22;
    outline: none;
}
.projektkachel__entfernen:active { background: #f9d7d3; }

.projektkachel__kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.projektkachel__nummer {
    font-family: 'Zilla Slab', Georgia, serif;
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--anthrazit);
}
.projektkachel__titel { font-weight: 600; margin-top: 6px; }
.projektkachel__zeile { color: var(--muted); font-size: .88rem; }
.projektkachel__fuss {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--rahmen-soft);
    font-size: .78rem;
    color: var(--muted);
}
.projektkachel__fuss i { margin-right: 5px; }
.projektkachel__fuss-links { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Projektkopf & Tabs ---------- */
.projektkopf { margin-bottom: 22px; }
.projektkopf__zeile {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.projektkopf__nummer {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: .88rem;
    color: var(--anthrazit);
    background: #f1f3f5;
    border: 1px solid var(--rahmen-soft);
    border-radius: 999px;
    padding: 7px 14px;
    margin-left: auto;
}
.projektkopf__titel { font-size: 1.45rem; margin: 0; }
.projektkopf__adresse { color: var(--muted); margin: 4px 0 0; font-size: .95rem; }
.projektkopf__meta { color: var(--muted); margin: 6px 0 0; font-size: .8rem; }

.tabs { display: flex; gap: 10px; margin-top: 18px; }
.tabs__knopf {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: var(--tap);
    padding: 10px 14px;
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    background: #fff;
    color: var(--anthrazit);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
}
.tabs__knopf.is-aktiv { background: var(--anthrazit); color: #fff; border-color: var(--anthrazit); }
.tabs__zahl {
    font-size: .78rem;
    background: rgba(0, 0, 0, .08);
    border-radius: 999px;
    padding: 1px 8px;
}
.tabs__knopf.is-aktiv .tabs__zahl { background: rgba(255, 255, 255, .22); }

/* ---------- Feldgruppen (Akkordeon) ---------- */
.gruppe {
    background: var(--weiss);
    border: 1px solid var(--rahmen-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 14px;
    overflow: hidden;
}
.gruppe__kopf {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    cursor: pointer;
    list-style: none;
    min-height: var(--tap);
}
.gruppe__kopf::-webkit-details-marker { display: none; }
.gruppe__icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f3f5;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.gruppe__titel {
    flex: 1 1 auto;
    font-family: 'Zilla Slab', Georgia, serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--anthrazit);
    min-width: 0;
}
.gruppe__zaehler { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.gruppe__fortschritt { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.gruppe__pfeil { color: var(--muted); transition: transform .18s; }
.gruppe[open] .gruppe__pfeil { transform: rotate(180deg); }
.gruppe[open] .gruppe__kopf { border-bottom: 1px solid var(--rahmen-soft); }

.gruppe__koerper { padding: 6px 18px 18px; }
.gruppe__hinweis { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }

/* ---------- Einzelfelder ---------- */
.felder {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4px 24px;
}
.feld {
    padding: 14px 0;
    border-top: 1px solid var(--rahmen-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.feld--mehrzeilig { grid-column: 1 / -1; }

.feld--lesen { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 16px; }
.feld--lesen .feld__label { font-weight: 400; color: var(--muted); }
.feld__wert { font-weight: 500; text-align: right; overflow-wrap: anywhere; white-space: pre-line; }
.feld--lesen.feld--mehrzeilig { flex-direction: column; }
.feld--lesen.feld--mehrzeilig .feld__wert { text-align: left; }

.feld__hinweis { color: var(--muted); font-size: .78rem; margin: 0; }

.feld__status { font-size: .78rem; margin: 0; color: var(--orange-dark); display: flex; align-items: center; gap: 6px; }
.feld--fehler .feld__status { color: #9b2c22; }
.feld__status--ok { color: var(--gruen-dark); }

.feld--offen .feld__eingabe,
.feld--offen .janein { box-shadow: 0 0 0 2px rgba(232, 145, 28, .35); border-radius: var(--radius); }
.feld--fehler .feld__eingabe,
.feld--fehler .janein { box-shadow: 0 0 0 2px rgba(202, 78, 67, .4); border-radius: var(--radius); }

/* ---------- Ja/Nein ---------- */
.janein { display: flex; gap: 0; }
.janein__knopf {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 10px 14px;
    border: 1px solid var(--rahmen);
    background: #fff;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.janein__knopf:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.janein__knopf:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left-width: 0; }
.janein__knopf--ja.is-aktiv {
    background: var(--gruen-dark);
    border-color: var(--gruen-dark);
    color: #fff;
}
.janein__knopf--nein.is-aktiv {
    background: #eef0f2;
    border-color: var(--muted);
    color: var(--anthrazit);
}

/* ---------- Tabelle (Teilprojekte) ---------- */
.tabelle-huelle {
    background: var(--weiss);
    border: 1px solid var(--rahmen-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow-x: auto;
}
.tabelle { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tabelle th {
    text-align: left;
    font-size: .76rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rahmen-soft);
    white-space: nowrap;
}
.tabelle td { padding: 14px 16px; border-bottom: 1px solid var(--rahmen-soft); vertical-align: middle; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle__zeile { cursor: pointer; }
.tabelle__zeile:active { background: #fdf3f2; }
.tabelle__eng { width: 1%; white-space: nowrap; }
.tabelle__pfeil { color: var(--muted); }

/* ---------- Chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .74rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.chip--ok { background: var(--gruen-hell); color: var(--gruen-dark); }
.chip--offen { background: var(--orange-hell); color: var(--orange-dark); }
.chip--fehler { background: var(--rot-hell); color: #9b2c22; }
.chip--neu { background: var(--blau-hell); color: var(--blau); margin-left: 8px; }

/* ---------- Warteschlange ---------- */
.queue {
    background: var(--weiss);
    border: 1px solid var(--rahmen-soft);
    border-left: 4px solid var(--orange);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.queue--fehler { border-left-color: var(--rot); }
.queue__kopf { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.queue__label { font-weight: 600; }
.queue__nummer { color: var(--muted); font-size: .82rem; }
.queue__wert { font-size: .88rem; color: var(--text); margin-top: 4px; overflow-wrap: anywhere; }
.queue__zeit { font-size: .76rem; color: var(--muted); margin-top: 4px; }
.queue__fehler { font-size: .84rem; color: #9b2c22; margin-top: 8px; display: flex; align-items: center; gap: 7px; }
.queue__aktionen { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(92vw, 520px);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 11px;
    background: var(--anthrazit);
    color: #fff;
    border-radius: var(--radius);
    padding: 13px 17px;
    font-size: .92rem;
    box-shadow: var(--shadow);
    animation: toastRein .2s ease-out;
}
.toast--ok { background: var(--gruen-dark); }
.toast--fehler { background: var(--rot); }
.toast--weg { opacity: 0; transition: opacity .3s; }
@keyframes toastRein { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Dialog ---------- */
.dialog {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 26px 24px;
    max-width: 440px;
    width: calc(100vw - 40px);
    color: var(--text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog__titel { font-size: 1.25rem; margin: 0 0 10px; }
.dialog__text { color: var(--muted); font-size: .92rem; margin: 0 0 22px; }
.dialog__aktionen { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.dialog__aktionen .btn { flex: 1 1 auto; }

/* ---------- Schmale Geräte ---------- */
@media (max-width: 620px) {
    .topbar { padding: 10px 14px; gap: 10px; }
    .topbar__titel { font-size: 1rem; }
    .topbar__label { display: none; }
    .statusleiste, .testhinweis { padding-left: 14px; padding-right: 14px; }
    .wrap { padding: 18px 14px 56px; }
    .karte { padding: 20px 16px; }
    .gruppe__koerper { padding: 4px 14px 14px; }
    .felder { grid-template-columns: 1fr; }
    .feld--lesen { flex-direction: column; align-items: stretch; gap: 2px; }
    .feld__wert { text-align: left; }
    .projektkopf__nummer { margin-left: 0; }
}

/* ---------- Drucken (Ortstermin auf Papier) ---------- */
@media print {
    .topbar, .statusleiste, .testhinweis, .footer, .tabs, .btn, .toasts { display: none !important; }
    .gruppe { break-inside: avoid; box-shadow: none; }
    .gruppe__koerper { display: block !important; }
}
