/* ---------------------------------------------------------------
   Instandhaltung - Oberflaeche
   Ausgelegt auf Bedienung am Handy und Tablet vor Ort: grosse
   Trefferflaechen, hoher Kontrast, keine Feinmotorik noetig.
   --------------------------------------------------------------- */

:root {
    --blau:        #1f4e79;
    --blau-hell:   #2f6ea5;
    --blau-zart:   #eaf1f8;
    --gruen:       #1f7a44;
    --gruen-zart:  #e6f4ec;
    --rot:         #b3261e;
    --rot-zart:    #fbeae9;
    --gelb:        #8a6100;
    --gelb-zart:   #fdf3dc;
    --text:        #1a1d21;
    --text-leise:  #5c6470;
    --linie:       #d8dde4;
    --flaeche:     #ffffff;
    --grund:       #f4f6f9;
    --radius:      10px;
    --schatten:    0 1px 3px rgba(16, 24, 40, .08),
                   0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--grund);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .75rem; }
h3 { font-size: 1rem;    margin: 1.25rem 0 .5rem; }

/* --- Rahmen ---------------------------------------------------- */

.huelle        { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.huelle-schmal { max-width: 430px;  margin: 0 auto; padding: 2.5rem 1rem 4rem; }

.kopf {
    background: var(--blau);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: env(safe-area-inset-top);
}
.kopf-innen {
    max-width: 1180px;
    margin: 0 auto;
    padding: .6rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.marke { display: flex; align-items: center; gap: .6rem;
         color: #fff; text-decoration: none; }
.marke-zeichen {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    background: rgba(255,255,255,.16);
    border-radius: 8px;
    font-weight: 700; font-size: .8rem; letter-spacing: .04em;
}
.marke-text strong { display: block; font-size: .95rem; line-height: 1.2; }
.marke-text small  { display: block; font-size: .75rem; opacity: .75; }

.hauptnav { display: flex; gap: .25rem; flex-wrap: wrap;
            margin-inline-start: auto; }
.hauptnav a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: .5rem .7rem;
    border-radius: 7px;
    font-size: .92rem;
    white-space: nowrap;
}
.hauptnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.hauptnav a.aktiv { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }

.kopf-benutzer { display: flex; align-items: center; gap: .6rem; }
.benutzername  { font-size: .88rem; opacity: .9; }

.fuss {
    max-width: 1180px; margin: 0 auto;
    padding: 1.5rem 1rem 2.5rem;
    color: var(--text-leise); font-size: .85rem;
    display: flex; gap: 1rem;
}

/* --- Flaechen -------------------------------------------------- */

.karte {
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 1.1rem;
    margin-bottom: 1rem;
}
.karte > :first-child { margin-top: 0; }
.karte > :last-child  { margin-bottom: 0; }

.kopfzeile {
    display: flex; align-items: flex-start; gap: 1rem;
    flex-wrap: wrap; margin-bottom: 1.25rem;
}
.kopfzeile .rechts { margin-inline-start: auto; display: flex;
                     gap: .5rem; flex-wrap: wrap; }
.unterzeile { color: var(--text-leise); font-size: .92rem; }

/* --- Kennzahlen ------------------------------------------------ */

.kennzahlen {
    display: grid; gap: .75rem; margin-bottom: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.kennzahl {
    background: var(--flaeche); border: 1px solid var(--linie);
    border-radius: var(--radius); padding: .9rem 1rem;
}
.kennzahl .wert  { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kennzahl .titel { color: var(--text-leise); font-size: .85rem; margin-top: .15rem; }
.kennzahl.gut    .wert { color: var(--gruen); }
.kennzahl.warn   .wert { color: var(--gelb); }
.kennzahl.schlecht .wert { color: var(--rot); }

/* --- Knoepfe --------------------------------------------------- */

.knopf {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .6rem 1.1rem;
    background: var(--blau); color: #fff;
    border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer;
    transition: background .12s;
}
.knopf:hover  { background: var(--blau-hell); }
.knopf:active { transform: translateY(1px); }
.knopf[disabled], .knopf.laedt { opacity: .55; pointer-events: none; }

.knopf.stumm  { background: var(--flaeche); color: var(--text);
                border-color: var(--linie); }
.knopf.stumm:hover { background: var(--grund); }
.knopf.still  { background: rgba(255,255,255,.14); color: #fff; }
.knopf.still:hover { background: rgba(255,255,255,.24); }
.knopf.gruen  { background: var(--gruen); }
.knopf.rot    { background: var(--rot); }
.knopf.klein  { min-height: 34px; padding: .35rem .7rem; font-size: .85rem; }
.knopf.breit  { width: 100%; }

/* --- Formulare ------------------------------------------------- */

.feld { margin-bottom: 1rem; }
.feld > label {
    display: block; margin-bottom: .3rem;
    font-weight: 600; font-size: .9rem;
}
.feld .hilfe { color: var(--text-leise); font-size: .85rem; margin-top: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=search], select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid var(--linie); border-radius: 8px;
    background: var(--flaeche); color: var(--text);
    font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--blau-hell); outline-offset: 1px;
    border-color: var(--blau-hell);
}
.feldreihe { display: flex; gap: .75rem; flex-wrap: wrap; }
.feldreihe > .feld { flex: 1 1 180px; }

/* --- Meldungen ------------------------------------------------- */

.hinweis {
    padding: .8rem 1rem; border-radius: 8px;
    margin-bottom: 1rem; border: 1px solid;
    font-size: .95rem;
}
.hinweis.erfolg { background: var(--gruen-zart); border-color: #bfe0cd; color: #14532d; }
.hinweis.fehler { background: var(--rot-zart);   border-color: #f0c3c0; color: #7f1d1d; }
.hinweis.info   { background: var(--blau-zart);  border-color: #c4d8ec; color: #17395c; }
.hinweis.warn   { background: var(--gelb-zart);  border-color: #ecd9a6; color: #713f12; }

/* --- Marken (Status) ------------------------------------------- */

.marke-status {
    display: inline-block; padding: .18rem .55rem;
    border-radius: 999px; font-size: .78rem; font-weight: 600;
    white-space: nowrap;
}
.st-offen      { background: #eceff3; color: #454c56; }
.st-geplant    { background: var(--blau-zart); color: #17395c; }
.st-laeuft     { background: var(--gelb-zart); color: var(--gelb); }
.st-erledigt   { background: var(--gruen-zart); color: var(--gruen); }
.st-ueberfaellig,
.st-dringend   { background: var(--rot-zart); color: var(--rot); }
.st-verschoben { background: #f2ecfa; color: #5b21b6; }
.st-entfallen  { background: #eceff3; color: #8a919c; text-decoration: line-through; }

/* --- Tabellen -------------------------------------------------- */

.tabellenrahmen { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.liste { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.liste th, table.liste td {
    padding: .6rem .7rem; text-align: left;
    border-bottom: 1px solid var(--linie);
    vertical-align: top;
}
table.liste th {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-leise); font-weight: 600;
    background: var(--grund); white-space: nowrap;
    position: sticky; top: 0;
}
table.liste tbody tr:hover { background: var(--blau-zart); }
table.liste td.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.ref { font-variant-numeric: tabular-nums; color: var(--text-leise);
       font-size: .85rem; white-space: nowrap; }

/* --- Jahresplan-Raster ----------------------------------------- */

/* Monatskopf ueber den zwoelf Kaestchen - ohne ihn muesste man
   abzaehlen, in welchem Monat etwas geplant ist. */
table.liste th.monatskopf {
    text-align: center;
    padding: .3rem .1rem;
    font-size: .66rem;
    letter-spacing: 0;
    min-width: 24px;
    cursor: pointer;
}
table.liste th.monatskopf.aktuell {
    background: var(--blau);
    color: #fff;
    border-radius: 4px 4px 0 0;
}
/* Anklickbare Spaltenhervorhebung - bleibt beim Scrollen sichtbar,
   da sie auf jeder einzelnen Zelle sitzt statt nur im Kopf. */
table.liste td.spalte-hervor,
table.liste th.monatskopf.spalte-hervor {
    background: #cfe0f2;
}
table.liste th.monatskopf.aktuell.spalte-hervor {
    background: var(--blau);
}

.monatsraster { display: flex; gap: 2px; }
.monatsraster span {
    width: 20px; height: 20px; border-radius: 4px;
    background: #eceff3; display: grid; place-items: center;
    font-size: .62rem; color: #98a0ac;
}
/* Geplant = ausgefuelltes Kaestchen ohne Zeichen, wie in der Vorlage */
.monatsraster span.geplant  { background: #365f91; }
.monatsraster span.erledigt { background: var(--gruen); color: #fff; font-weight: 700; }
.monatsraster span.offen    { background: var(--gelb-zart); color: var(--gelb); font-weight: 700; }
.monatsraster span.faellig  { background: var(--rot); color: #fff; font-weight: 700; }

/* --- Checkliste ------------------------------------------------ */

.schrittgruppe {
    margin: 1.5rem 0 .5rem; font-size: .82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--blau); padding-bottom: .35rem;
    border-bottom: 2px solid var(--blau-zart);
}

.schritt {
    display: flex; gap: .85rem; align-items: flex-start;
    background: var(--flaeche); border: 1px solid var(--linie);
    border-radius: var(--radius); padding: .85rem;
    margin-bottom: .6rem;
    transition: border-color .12s, background .12s;
}
.schritt.erledigt   { background: var(--gruen-zart); border-color: #bfe0cd; }
.schritt.nicht-ok   { background: var(--rot-zart);   border-color: #f0c3c0; }
.schritt.entfaellt  { opacity: .6; }
.schritt.gespeichert { animation: aufblitzen .8s ease-out; }
@keyframes aufblitzen {
    from { box-shadow: 0 0 0 3px rgba(31,122,68,.35); }
    to   { box-shadow: 0 0 0 0 rgba(31,122,68,0); }
}

/* Grosse Trefferflaeche - bedienbar auch mit Arbeitshandschuhen */
.haken {
    flex: none; width: 30px; height: 30px; margin: 0;
    accent-color: var(--gruen); cursor: pointer;
}
.schritt-text  { flex: 1; min-width: 0; }
.schritt-hinweis {
    margin-top: .5rem; padding: .5rem .7rem;
    background: var(--gelb-zart); border-left: 3px solid #e0b955;
    border-radius: 0 6px 6px 0; font-size: .88rem; color: #6b4d0f;
}
/* Unterlagen, die zu genau diesem Arbeitsschritt gehoeren */
.schritt-unterlagen {
    display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
    margin-top: .55rem; padding: .5rem .6rem;
    background: var(--blau-zart); border-radius: 8px;
}
.schritt-unterlagen .knopf { background: var(--flaeche); }

.schritt-fuss {
    display: flex; gap: .5rem; align-items: center;
    margin-top: .55rem; flex-wrap: wrap;
    font-size: .82rem; color: var(--text-leise);
}
.schritt.typ-hinweis {
    background: var(--gelb-zart); border-color: #ecd9a6;
    color: #6b4d0f; font-size: .92rem;
}
.schritt.typ-sicherheit { background: var(--blau-zart); border-color: #c4d8ec; }

.fortschritt {
    height: 10px; background: #e3e7ed; border-radius: 999px;
    overflow: hidden; margin: .6rem 0;
}
.fortschritt > i {
    display: block; height: 100%; background: var(--gruen);
    border-radius: 999px; transition: width .3s ease;
}

/* Am unteren Rand angeheftete Aktionsleiste auf dem Handy */
.aktionsleiste {
    position: sticky; bottom: 0;
    background: var(--flaeche); border-top: 1px solid var(--linie);
    padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
    margin: 1.5rem -1rem 0;
    display: flex; gap: .6rem; flex-wrap: wrap;
    box-shadow: 0 -2px 8px rgba(16,24,40,.06);
}
.aktionsleiste .knopf { flex: 1 1 160px; }

/* --- Kachelliste (Instandhaltungstag) -------------------------- */

.kacheln { display: grid; gap: .8rem;
           grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.kachel {
    background: var(--flaeche); border: 1px solid var(--linie);
    border-left: 4px solid var(--linie);
    border-radius: var(--radius); padding: 1rem;
    display: flex; flex-direction: column; gap: .5rem;
    text-decoration: none; color: inherit;
}
.kachel:hover     { border-color: var(--blau-hell); box-shadow: var(--schatten); }
.kachel.frei      { border-left-color: var(--blau); }
.kachel.meins     { border-left-color: var(--gelb); }
.kachel.fertig    { border-left-color: var(--gruen); }
.kachel.fremd     { opacity: .72; }
.kachel h3        { margin: 0; font-size: 1.02rem; }
.kachel .zeile    { display: flex; gap: .5rem; align-items: center;
                    flex-wrap: wrap; font-size: .85rem; color: var(--text-leise); }

/* --- Bilder ---------------------------------------------------- */

.bilderreihe { display: flex; gap: .5rem; flex-wrap: wrap; }
.bilderreihe img {
    width: 110px; height: 110px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--linie);
}
.bildfeld input[type=file] {
    width: 100%; padding: .8rem; min-height: 56px;
    border: 2px dashed var(--linie); border-radius: 8px;
    background: var(--flaeche);
}

/* --- QR -------------------------------------------------------- */

.qr-block { text-align: center; }
.qr-block svg { max-width: 320px; width: 100%; height: auto;
                border: 1px solid var(--linie); border-radius: var(--radius); }
.qr-link {
    display: block; margin-top: .75rem; word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .88rem; background: var(--grund);
    padding: .6rem; border-radius: 8px;
}

/* --- Kleinkram ------------------------------------------------- */

.leer {
    text-align: center; padding: 3rem 1rem;
    color: var(--text-leise);
}
.leise { color: var(--text-leise); }
.klein { font-size: .85rem; }
.trenner { height: 1px; background: var(--linie); margin: 1.25rem 0; }
.reihe { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.abstand-oben { margin-top: 1.25rem; }

/* Sprachwahl - nur fuer Helfer/Mitarbeiter, oben rechts */
.sprachwahl {
    position: absolute; top: .6rem; right: .75rem; z-index: 30;
    padding-top: env(safe-area-inset-top);
}
.sprachwahl select {
    min-height: 34px; padding: .2rem .5rem;
    font-size: .82rem; border-radius: 7px;
    background: rgba(255,255,255,.92); border: 1px solid var(--linie);
    box-shadow: var(--schatten);
}
body.schlicht .sprachwahl { position: fixed; }

.live-punkt {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--gruen); margin-right: .35rem;
    animation: pulsieren 2s ease-in-out infinite;
}
@keyframes pulsieren { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

@media (max-width: 640px) {
    .kopf-innen  { padding: .5rem .75rem; }
    .hauptnav    { order: 3; width: 100%; margin-inline-start: 0;
                   overflow-x: auto; padding-bottom: .2rem; }
    .benutzername { display: none; }
    .huelle      { padding: 1rem .75rem 4rem; }
    .karte       { padding: .9rem; }
    h1           { font-size: 1.3rem; }
}

@media print {
    .kopf, .fuss, .aktionsleiste, .knopf { display: none !important; }
    body { background: #fff; }
    .karte { border: none; box-shadow: none; padding: 0; }
}
