/* Fernwartung: salewski.it-Design (Papier, Tinte, Dunkelgrün, Lime), Apple-Stil, Daumenzone unten rechts. */
@font-face {
  font-family: 'DM Sans'; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(/static/fonts/dmsans-opsz-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans'; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(/static/fonts/dmsans-opsz-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --papier: #f7f8f2; --tinte: #152c28; --muted: #52615b; --gruen: #275b45; --gruen-hover: #1d4634;
  --auf-gruen: #ffffff; --lime: #d9ed99; --lime-hell: #eef5d6; --linie: #dce2d8; --flaeche: #ffffff;
  --flaeche-2: #f1f3ec; --gefahr: #b4463b; --gefahr-hell: #f8e6e3; --warnung: #d9630b; --warnung-hell: #fdebd9;
  --erfolg: #2f7a55; --erfolg-hell: #e3f1e8; --buehne: #101614;
  --schatten: 0 14px 30px rgba(21, 44, 40, .12);
  --feld-h: 44px; --kopf-h: 56px; --leiste-h: 60px;
  --sicher-oben: env(safe-area-inset-top, 0px); --sicher-unten: env(safe-area-inset-bottom, 0px);
  --sicher-links: env(safe-area-inset-left, 0px); --sicher-rechts: env(safe-area-inset-right, 0px);
  --rand: max(16px, var(--sicher-links)); --rand-r: max(16px, var(--sicher-rechts));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papier: #0f1f1b; --tinte: #d6e0da; --muted: #9fb0a8; --gruen: #5aa682; --gruen-hover: #6cb894;
    --auf-gruen: #0f1f1b; --lime-hell: #1c3a33; --linie: #27423b; --flaeche: #152c28; --flaeche-2: #1c3a33;
    --gefahr: #e8857a; --gefahr-hell: #3a2320; --warnung: #f0a55a; --warnung-hell: #3a2a17; --erfolg: #6cc497;
    --erfolg-hell: #17382b; --buehne: #070c0a; --schatten: 0 14px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--papier); color: var(--tinte);
  font: 15px/1.45 'DM Sans', 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  font-optical-sizing: auto; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gruen); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; text-wrap: balance; }
.td { display: inline-block; width: 1ch; text-align: center; }
.leise { color: var(--muted); }
.klein { font-size: 13px; }

/* ---------- Knöpfe (Druck-Rückmeldung beim Drücken, Federn zurück) ---------- */
a.knopf { text-decoration: none; }
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--feld-h);
  padding: 0 18px; border: 1px solid var(--linie); border-radius: 10px; background: var(--flaeche); color: var(--tinte);
  font-weight: 600; white-space: nowrap; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), background .15s, opacity .15s; }
@media (hover: hover) { .knopf:hover { background: var(--lime-hell); } }
.knopf:active { transform: scale(.97); transition-duration: .1s; }
.knopf.primaer { background: var(--gruen); border-color: var(--gruen); color: var(--auf-gruen); }
@media (hover: hover) { .knopf.primaer:hover { background: var(--gruen-hover); } }
.knopf.gefahr { background: var(--gefahr); border-color: var(--gefahr); color: #fff; }
.knopf.voll { width: 100%; }
.knopf:disabled { opacity: .45; cursor: default; transform: none; }
@media (prefers-reduced-motion: reduce) { .knopf:active { transform: none; opacity: .7; } }

/* ---------- Anmeldeseite ---------- */
body.login-seite { display: flex; align-items: center; justify-content: center; min-height: 100%;
  padding: calc(24px + var(--sicher-oben)) 16px calc(24px + var(--sicher-unten)); }
.login-karte { width: 100%; max-width: 400px; padding: 32px; background: var(--flaeche); border: 1px solid var(--linie);
  border-radius: 16px; box-shadow: 0 1px 2px rgba(21, 44, 40, .04); }
.login-logo { display: block; width: 56px; height: 56px; margin-bottom: 18px; border-radius: 12px; }
.eyebrow { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; color: var(--muted); font-size: 11px;
  font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.punkt { width: 7px; height: 7px; border-radius: 50%; background: var(--gruen); }
.login-karte h1 { font-size: 26px; margin-bottom: 8px; }
.login-text { margin: 0 0 22px; color: var(--muted); }
.login-meldung { min-height: 1.4em; margin: 14px 0 0; font-size: 14px; }
.login-meldung[data-art="fehler"] { color: var(--gefahr); }
.login-meldung[data-art="ok"] { color: var(--erfolg); }
.feld { display: block; margin-bottom: 16px; }
.feld span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.feld input { width: 100%; height: var(--feld-h); padding: 0 12px; border: 1px solid var(--linie); border-radius: 10px;
  background: var(--flaeche); font-size: 16px; }

/* ---------- App-Rahmen ---------- */
body.app { display: flex; flex-direction: column; min-height: 100%; }
.kopf { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  min-height: calc(var(--kopf-h) + var(--sicher-oben)); padding: var(--sicher-oben) var(--rand-r) 0 var(--rand);
  background: rgba(247, 248, 242, .92); border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
@media (prefers-color-scheme: dark) { .kopf { background: rgba(15, 31, 27, .9); } }
.kopf.gescrollt { border-bottom-color: var(--linie); }
.kopf-marke { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kopf-marke img { width: 30px; height: 30px; border-radius: 7px; flex: none; }
.kopf-marke strong { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.kopf-zustand { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  white-space: nowrap; }
.lampe { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.lampe.ok { background: var(--erfolg); }
.lampe.warn { background: var(--warnung); }
.lampe.aus { background: var(--gefahr); }

main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 12px var(--rand-r) calc(var(--leiste-h) + var(--sicher-unten) + 24px) var(--rand); }
.ansicht { display: flex; flex-direction: column; gap: 14px; }

/* Untere Leiste (Daumenzone), am Rechner oben im Kopf */
.leiste { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px var(--rand-r) var(--sicher-unten) var(--rand); min-height: calc(var(--leiste-h) + var(--sicher-unten));
  background: rgba(247, 248, 242, .94); border-top: 1px solid var(--linie);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
@media (prefers-color-scheme: dark) { .leiste { background: rgba(15, 31, 27, .94); } }
.leiste button { height: 52px; border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  font-size: 15px; font-weight: 600; transition: transform .26s cubic-bezier(.2, .8, .2, 1), background .15s; }
.leiste button:active { transform: scale(.95); transition-duration: .1s; }
.leiste button[aria-current="page"] { color: var(--tinte); background: var(--lime); }
@media (prefers-color-scheme: dark) { .leiste button[aria-current="page"] { color: #152c28; } }
@media (min-width: 900px) {
  /* am Rechner: Reiter mittig im Kopf (eigenes Element, weil backdrop-filter im Kopf fixed-Kinder einfängt) */
  .leiste { top: var(--sicher-oben); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); z-index: 25;
    display: flex; align-items: center; gap: 4px; height: var(--kopf-h); min-height: 0; padding: 0; background: transparent;
    border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .leiste button { height: 38px; padding: 0 18px; }
  @media (hover: hover) { .leiste button:hover:not([aria-current="page"]) { background: var(--flaeche-2); } }
  main { padding-bottom: 32px; }
}

/* ---------- Karten ---------- */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; padding: 18px;
  box-shadow: 0 1px 2px rgba(21, 44, 40, .04); }
.karte h2 { font-size: 17px; margin-bottom: 10px; }
.karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.karte-kopf h2 { margin: 0; }
.hinweis { padding: 12px 16px; border-radius: 12px; border: 1px solid; font-size: 14px; }
.hinweis.warn { background: var(--warnung-hell); border-color: color-mix(in srgb, var(--warnung) 45%, transparent); }
.hinweis.fehler { background: var(--gefahr-hell); border-color: color-mix(in srgb, var(--gefahr) 45%, transparent); }
.hinweis.info { background: var(--lime-hell); border-color: color-mix(in srgb, var(--gruen) 35%, transparent); }

/* Zustand groß */
.zustand { display: grid; grid-template-columns: 1fr; gap: 14px; }
.zustand-titel { display: flex; align-items: center; gap: 12px; }
.zustand-titel .lampe { width: 16px; height: 16px; }
.zustand-titel h1 { font-size: 26px; }
.zustand-unter { color: var(--muted); font-size: 14px; }

/* Weg: Hetzner -> Tunnel -> AMT -> Büro-Host (gemessen, Punkt läuft nur auf gesunden Strecken) */
.weg { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto; align-items: center; gap: 0;
  margin-top: 4px; }
.weg-knoten { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 62px; text-align: center; }
.weg-knoten .knoten { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--muted);
  background: var(--flaeche); }
.weg-knoten.ok .knoten { border-color: var(--erfolg); background: var(--erfolg-hell); }
.weg-knoten.warn .knoten { border-color: var(--warnung); background: var(--warnung-hell); }
.weg-knoten.aus .knoten { border-color: var(--gefahr); background: var(--gefahr-hell); }
.weg-knoten b { font-size: 13px; font-weight: 650; }
.weg-knoten small { font-size: 12px; color: var(--muted); min-height: 1.3em; }
.weg-strecke { position: relative; height: 3px; margin: 0 4px 34px; border-radius: 2px; background: var(--linie);
  overflow: hidden; }
.weg-strecke.ok { background: color-mix(in srgb, var(--erfolg) 45%, var(--linie)); }
.weg-strecke.aus { background: repeating-linear-gradient(90deg, var(--gefahr) 0 6px, transparent 6px 11px); }
.weg-strecke.ok::after { content: ""; position: absolute; top: -2px; left: 0; width: 7px; height: 7px; border-radius: 50%;
  background: var(--erfolg); animation: fluss 2.4s linear infinite; }
@keyframes fluss { from { left: -8px; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .weg-strecke.ok::after { animation: none; display: none; } }

/* Werte-Raster: füllt die Breite, Karten nur so hoch wie ihr Inhalt */
.werte { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .werte { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wert { padding: 12px 14px; border: 1px solid var(--linie); border-radius: 12px; background: var(--flaeche); min-width: 0; }
.wert span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; }
.wert b { display: block; margin-top: 3px; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.wert small { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Aktionsreihe unten rechts (Daumenzone) */
.aktionen { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.aktionen .knopf { min-width: 150px; }
@media (max-width: 560px) { .aktionen .knopf { flex: 1 1 0; min-width: 0; } }

/* Tabellenartige Listen */
.liste { width: 100%; border-collapse: collapse; font-size: 14px; }
.liste th { text-align: left; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 600; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--linie); }
.liste td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--linie); vertical-align: top; overflow-wrap: anywhere; }
.liste tr:last-child td { border-bottom: 0; }
.liste td.zeit { white-space: nowrap; color: var(--muted); width: 1%; }
.mehr-inhalt h3 { margin: 20px 0 4px; font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.mehr-inhalt h3:first-child { margin-top: 4px; }
.zeilen { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; column-gap: 16px; font-size: 14px; }
.zeilen > div { padding: 8px 0; border-bottom: 1px solid var(--linie); overflow-wrap: anywhere; }
.zeilen > div:nth-child(odd) { color: var(--muted); }
.zeilen > div:nth-last-child(-n+2) { border-bottom: 0; }
.marke { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--flaeche-2); white-space: nowrap; }
.marke.ok { background: var(--erfolg-hell); color: var(--erfolg); }
.marke.warn { background: var(--warnung-hell); color: var(--warnung); }
.marke.aus { background: var(--gefahr-hell); color: var(--gefahr); }
@media (max-width: 640px) {
  .liste.stapel thead { display: none; }
  .liste.stapel tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--linie); }
  .liste.stapel tr:last-child { border-bottom: 0; }
  .liste.stapel td { display: block; padding: 1px 0; border: 0; width: auto; }
  .liste.stapel td.zeit { font-size: 13px; }
}

/* ---------- Bildschirm ---------- */
.ansicht-bildschirm { gap: 10px; }
body.ist-bildschirm main { display: flex; flex-direction: column; }
body.ist-bildschirm #ansicht-bildschirm { flex: 1; min-height: 0; }
.bild-status { display: flex; align-items: center; gap: 10px; min-height: 24px; font-size: 14px; color: var(--muted); }
.bild-status .lampe { width: 9px; height: 9px; }
.bild-flaeche { position: relative; flex: 1; min-height: 240px; border-radius: 14px; overflow: hidden;
  background: var(--buehne); border: 1px solid var(--linie); touch-action: none; }
body.ist-bildschirm .bild-flaeche { height: calc(100dvh - var(--kopf-h) - var(--sicher-oben) - var(--leiste-h)
  - var(--sicher-unten) - 190px); }
@media (min-width: 900px) {
  body.ist-bildschirm .bild-flaeche { height: calc(100dvh - var(--kopf-h) - var(--sicher-oben) - 150px); }
}
.bild-flaeche > div { width: 100%; height: 100%; }
.bild-leer { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; color: #c9d3cd; }
.bild-leer h2 { color: #f7f8f2; font-size: 19px; }
.bild-leer p { margin: 0; max-width: 460px; font-size: 14px; }
.tasten { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 900px) { .tasten { grid-template-columns: repeat(15, minmax(0, 1fr)); } }
@media (max-width: 420px) { .tasten .knopf { font-size: 13px; } }
.tasten .knopf { min-height: 44px; padding: 2px 4px; font-size: 14px; line-height: 1.15; white-space: normal;
  text-align: center; }
.tasten .knopf[aria-pressed="true"] { background: var(--lime); color: #152c28; border-color: var(--lime); }
.tastatur-eingabe { position: fixed; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0;
  font-size: 16px; pointer-events: none; resize: none; }
.bild-aktionen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bild-aktionen .knopf { padding: 0 8px; }
.bild-aktionen #b-trennen { grid-column: 2; }
@media (min-width: 900px) { .bild-aktionen { display: flex; justify-content: flex-end; }
  .bild-aktionen .knopf { min-width: 140px; padding: 0 18px; } }

/* ---------- Strom ---------- */
.strom-liste { display: grid; gap: 10px; }
@media (min-width: 900px) { .strom-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.strom-knopf { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; min-height: 76px;
  padding: 14px 18px; border: 1px solid var(--linie); border-radius: 14px; background: var(--flaeche); text-align: left;
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), background .15s; }
.strom-knopf:active { transform: scale(.98); transition-duration: .1s; }
@media (hover: hover) { .strom-knopf:hover:not(:disabled) { background: var(--lime-hell); } }
.strom-knopf b { font-size: 17px; }
.strom-knopf span { color: var(--muted); font-size: 14px; }
.strom-knopf.gefahr b { color: var(--gefahr); }
.strom-knopf:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- Mehr: Liste links, Inhalt rechts (am Handy nacheinander) ---------- */
.mehr { display: grid; gap: 14px; }
@media (min-width: 900px) { .mehr { grid-template-columns: 280px minmax(0, 1fr); align-items: start; } }
.mehr-liste { display: flex; flex-direction: column; padding: 6px; }
.mehr-liste button { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; font-weight: 600; text-align: left; }
.mehr-liste button::after { content: "›"; color: var(--muted); font-size: 20px; }
.mehr-liste button[aria-current="true"] { background: var(--lime); color: #152c28; }
@media (hover: hover) { .mehr-liste button:hover:not([aria-current="true"]) { background: var(--flaeche-2); } }
.mehr-liste hr { width: 100%; border: 0; border-top: 1px solid var(--linie); margin: 6px 0; }
@media (max-width: 899px) {
  .mehr[data-offen="ja"] .mehr-liste { display: none; }
  .mehr[data-offen="nein"] .mehr-inhalt { display: none; }
}
@media (min-width: 900px) { .zurueck { display: none !important; } }
.zurueck { align-self: flex-start; }

/* ---------- Dialog (Blatt von unten am Handy) ---------- */
dialog.blatt { width: min(560px, 100%); max-width: 100%; max-height: calc(100dvh - var(--sicher-oben) - 24px); margin: auto;
  padding: 0; border: 1px solid var(--linie); border-radius: 18px; background: var(--flaeche); color: var(--tinte);
  box-shadow: var(--schatten); }
dialog.blatt::backdrop { background: rgba(10, 20, 17, .45); }
.blatt-innen { display: flex; flex-direction: column; gap: 14px; padding: 22px 22px calc(18px + var(--sicher-unten)); }
.blatt-innen h2 { font-size: 21px; }
.blatt-innen p { margin: 0; }
.blatt-aktionen { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.blatt-aktionen .knopf { min-width: 140px; }
@media (max-width: 640px) {
  dialog.blatt { margin: auto 0 0; width: 100%; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .blatt-aktionen { flex-direction: column-reverse; }
  .blatt-aktionen .knopf { width: 100%; }
}
.schritte { margin: 0; padding-left: 20px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.standbild-bild { display: block; width: 100%; height: auto; border-radius: 10px; background: #000; image-rendering: auto; }
.standbild-rahmen { max-height: 65dvh; overflow: auto; border-radius: 10px; -webkit-overflow-scrolling: touch; }
.standbild-rahmen.voll .standbild-bild { width: auto; max-width: none; }

.toast { position: fixed; left: 50%; bottom: calc(var(--leiste-h) + var(--sicher-unten) + 16px); z-index: 50;
  transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--tinte); color: var(--papier); font-size: 14px; box-shadow: var(--schatten); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* Handy hochkant: Bildfläche im Seitenverhältnis des Bildschirms, damit die Tasten in die Daumenzone rücken */
@media (max-width: 899px) and (orientation: portrait) {
  body.ist-bildschirm .bild-flaeche { flex: none; height: auto; min-height: 0; aspect-ratio: 16 / 10; }
  body.ist-bildschirm .bild-leer { position: absolute; }
  .ansicht-bildschirm .bild-leer p { font-size: 13px; }
}
@media (max-width: 899px) and (orientation: portrait) {
  body.ist-bildschirm .tasten { margin-top: auto; }
}
/* Weg am Handy: vier gleich breite Knoten auf einer Linie */
@media (max-width: 560px) {
  .weg { position: relative; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .weg::before { content: ""; position: absolute; top: 8px; left: 12.5%; right: 12.5%; height: 3px; border-radius: 2px;
    background: var(--linie); }
  .weg-strecke { display: none; }
  .weg-knoten { position: relative; min-width: 0; }
}
