:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --hairline: #2c2c2a;
  --axis: #383835;
  /* Status: fest, immer mit Symbol + Text */
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;
  --none: #898781;
}

* { box-sizing: border-box; margin: 0; }

/* Skaliert mit dem Bildschirm; die Höhe begrenzt die Schrift, damit die ganze Anzeige ohne Scrollen auf den Flur-Monitor passt */
html { font-size: clamp(13px, min(calc(0.45vw + 0.75vh + 4px), calc(100vh / 54)), 34px); }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.2rem 1.8rem;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.25;
}

/* Kopf */
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 1rem; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.01em; }
.brand span { color: var(--ink-2); font-weight: 400; }
.logo { display: block; height: 2.6rem; width: auto; }
.clock { text-align: right; }
.clock time { font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock span { display: block; color: var(--ink-2); font-size: 0.9rem; }

main { flex: 1; display: flex; flex-direction: column; gap: 1.1rem; }

/* Gesamtstatus */
.banner {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.9rem 2rem;
  border-radius: 1rem;
  background: var(--none);
  color: var(--ink);
}
.banner h1 { font-size: 2.6rem; font-weight: 700; line-height: 1.1; }
.banner p { font-size: 1.2rem; margin-top: 0.3rem; opacity: 0.95; }
.banner-icon { flex: none; width: 4.2rem; height: 4.2rem; }
.banner-icon svg, .chip svg { width: 100%; height: 100%; display: block; }
.banner.is-ok { background: var(--good); }
.banner.is-warn { background: var(--warn); color: #0b0b0b; }
.banner.is-down { background: var(--crit); }
.banner.is-stale { background: var(--none); color: #0b0b0b; }

/* Kacheln */
.tiles {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.1rem;
}
.tile, .flow {
  background: var(--surface);
  border-top: 0.4rem solid var(--none);
  border-radius: 1rem;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 1.4rem 1rem;
}
.tile.s-ok, .flow.s-ok { border-top-color: var(--good); }
.tile.s-slow, .flow.s-slow { border-top-color: var(--warn); }
.tile.s-down, .flow.s-down { border-top-color: var(--crit); }
.tiles.is-stale .tile, .flow.is-stale { opacity: 0.45; }

.tile-head h2 { font-size: 1.7rem; font-weight: 700; }
.tile-head .host { color: var(--ink-2); font-size: 1.1rem; font-variant-numeric: tabular-nums; margin-top: 0.1rem; overflow-wrap: anywhere; }
.tile-head .sub { color: var(--ink-3); font-size: 0.9rem; margin-top: 0.1rem; }

.state { display: flex; align-items: center; gap: 0.9rem; }
.chip { flex: none; width: 3rem; height: 3rem; }
.state-word { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.state-msg { color: var(--ink-2); font-size: 0.95rem; margin-top: 0.1rem; }

.metrics { display: flex; gap: 1.8rem; }
.metrics dt { color: var(--ink-3); font-size: 0.8rem; }
.metrics dd { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: 0; }

.strip-wrap { margin-top: auto; }
.strip { display: flex; gap: 2px; height: 1.4rem; }
.strip i { flex: 1; border-radius: 2px; background: var(--hairline); }
.strip i.s-ok { background: var(--good); }
.strip i.s-slow { background: var(--warn); }
.strip i.s-down { background: var(--crit); }
.strip-axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 0.75rem; margin-top: 0.3rem; }

/* Datenfluss: drei zuletzt gemeldete Gateways */
/* Datenfluss und Leica stehen nebeneinander (der Flur-Bildschirm darf nicht scrollen); allein nimmt eine Kachel die ganze Breite */
.lower { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(34rem, 100%), 1fr)); gap: 1.1rem; }
.flow {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem 1.4rem;
}
.flow[hidden] { display: none; }
.flow-state { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.flow .tile-head h2 { font-size: 1.5rem; }
.flow .state-word { font-size: 1.6rem; }
.flow .state-msg { max-width: 22rem; }
.recent { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.recent-card { background: var(--page); border-radius: 0.8rem; padding: 0.8rem 1.1rem; min-width: 0; }
.recent-gw { color: var(--ink-2); font-size: 1rem; font-weight: 600; }
.recent-ago { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.recent-sub { color: var(--ink-3); font-size: 0.85rem; margin-top: 0.1rem; overflow-wrap: anywhere; }

/* Leica Totalstationen: je Projekt eine Karte, rein informativ (keine Statusfarben) */
.leica .recent { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.7rem; }
.leica .recent-card { padding: 0.7rem 0.9rem; }
.leica .recent-ago { font-size: 1.35rem; white-space: nowrap; }
.leica .recent-sub { font-size: 0.8rem; white-space: nowrap; }
@media (min-width: 1100px) {
  /* Leica braucht mehr Breite (mehrere Projekte nebeneinander) als die drei Datenfluss-Einträge */
  .lower:has(#flow:not([hidden])):has(#leica:not([hidden])) { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
}
.leica .flow-state .state-msg { text-align: right; }
.flow.leica.is-stale { opacity: 0.45; }
.stations { margin-top: 0.5rem; display: grid; gap: 0.2rem; }
.station { display: flex; justify-content: space-between; gap: 0.6rem; color: var(--ink-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.station-name { min-width: 0; overflow-wrap: anywhere; }
.state-msg.warn { color: var(--warn); }

/* Fuß */
footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  color: var(--ink-3);
  font-size: 0.85rem;
}
footer .warn { color: var(--warn); }
.legend { display: flex; align-items: center; gap: 0.4rem 0.5rem; flex-wrap: wrap; }
.dot { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-left: 0.7rem; background: var(--hairline); }
.dot:first-child { margin-left: 0; }
.dot.s-ok { background: var(--good); }
.dot.s-slow { background: var(--warn); }
.dot.s-down { background: var(--crit); }

/* Anmeldung */
.login-body { align-items: center; justify-content: center; }
.login { flex: none; width: min(26rem, 100%); display: flex; flex-direction: column; gap: 1.4rem; padding: 2rem; background: var(--surface); border-radius: 1rem; }
.login form { display: flex; flex-direction: column; gap: 0.7rem; }
.login label { color: var(--ink-2); font-size: 0.95rem; }
.login input { font: inherit; font-size: 1.1rem; padding: 0.7rem 0.8rem; color: var(--ink); background: var(--page); border: 2px solid var(--axis); border-radius: 0.5rem; }
.login input:focus { outline: none; border-color: var(--ink-2); }
.login button { font: inherit; font-size: 1.1rem; font-weight: 600; padding: 0.7rem; margin-top: 0.4rem; color: #fff; background: #256abf; border: 0; border-radius: 0.5rem; cursor: pointer; }
.login button:hover { background: #2a78d6; }
.login .err { color: #ffb3b3; font-size: 0.95rem; }
.login .hint { color: var(--ink-3); font-size: 0.85rem; }

@media (max-width: 900px) {
  .flow-state { flex-direction: column; align-items: flex-start; }
  .leica .flow-state .state-msg { text-align: left; }
}
@media (max-width: 700px) {
  body { padding: 1rem; gap: 1rem; }
  .banner { padding: 1.2rem; gap: 1rem; }
  .banner h1 { font-size: 2rem; }
  .banner-icon { width: 3.2rem; height: 3.2rem; }
  .recent { grid-template-columns: 1fr; }
}
