/* ==========================================================================
   Digitaler Zwilling — Vollbild-App (Concept B „Clean Editorial" + Dark)
   Default = helles Editorial-Theme (Tokens: #36647f Petrol, #fbab00 Amber)
   ========================================================================== */

.cyt-twin {
  /* Concept B — Clean Editorial (Default) */
  --bg: #f4f8fb;
  --bg-grad: radial-gradient(circle at 65% 25%, #eef5fa 0, #f4f8fb 45%);
  --panel: #ffffff;
  --panel2: #f4f8fb;
  --line: #dbe4ea;
  --text: #1b2830;
  --muted: #63727d;
  --cyan: #36647f;
  --green: #2f9e6e;
  --amber: #e09a00;
  --red: #c74a48;
  --h2: #2d7600;
  --water: #3700cc;
  --ve: #006eaf;
  --o2: #d6b656;
  --elec: #e5484d;
  --card-bg: #ffffff;
  --accent: #36647f;
  --grid-line: rgba(54, 100, 127, .06);
  --shadow: rgba(32, 57, 77, .12);
  /* Iso-Leitstand: Boden, Insel-Seiten/-Deckfarben, Zylinder-Gradient, Vents */
  --iso-ground: #eaf1f6;
  --iso-side1: #d4e0e8;
  --iso-side2: #bccdd9;
  --iso-edge: #b9cbd8;
  --iso-line: #b9cbd8;
  --iso-vent: #9fb2bd;
  --iso-z01: #fff8ea;
  --iso-z02: #f3f7fa;
  --iso-z03: #f1f7fb;
  --iso-z04: #f6f4fa;
  --iso-cyl1: #e3ecf2;
  --iso-cyl2: #ffffff;
  --iso-cyl3: #c9d8e2;

  /* In den Seitenfluss eingebettet (nicht fixed): füllt per Flex-Kette den
     Platz zwischen Site-Header und -Footer, siehe Block "Seiten-Einbettung".
     Mindestens eine Viewport-Höhe, damit das Schema die volle App-Größe hat. */
  position: relative;
  z-index: 0;
  flex: 1 1 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 60px auto;
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font: 13px Roboto, Arial, system-ui, sans-serif;
}
/* Desktop: 56px-Icon-Rail als echte Grid-Spalte links neben dem Inhalt */
@media (min-width: 851px) {
  .cyt-twin { grid-template-columns: 56px 1fr; }
}

.cyt-twin[data-theme="dark"] {
  /* Petrol-Nacht — dunkle Variante desselben Farbsystems */
  --bg: #14222d;
  --bg-grad: radial-gradient(circle at 65% 25%, #1e3242 0, #14222d 45%);
  --panel: #1c2e3c;
  --panel2: #243a4a;
  --line: #33505f;
  --text: #e7eff4;
  --muted: #93aab8;
  --cyan: #7ab2d4;
  --green: #3ecf8e;
  --amber: #fbab00;
  --red: #e0706e;
  --h2: #66b03a;
  --water: #8b7cf6;
  --ve: #4fb0ec;
  --o2: #e0c26e;
  --elec: #ff7b7b;
  --card-bg: #243a4a;
  --accent: #4a86a8;
  --grid-line: rgba(122, 178, 212, .07);
  --shadow: rgba(0, 0, 0, .45);
  /* Iso-Leitstand (dunkle Varianten) */
  --iso-ground: #16262f;
  --iso-side1: #26394a;
  --iso-side2: #1b2b38;
  --iso-edge: #33505f;
  --iso-line: #33505f;
  --iso-vent: #5f7c8e;
  --iso-z01: #2c2a1e;
  --iso-z02: #1f2d38;
  --iso-z03: #1f2c36;
  --iso-z04: #252636;
  --iso-cyl1: #2a3f50;
  --iso-cyl2: #3b566b;
  --iso-cyl3: #20303e;
}

.cyt-twin * { box-sizing: border-box; }
.cyt-twin button { font: inherit; cursor: pointer; }
.cyt-twin a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.cyt-twin__header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 30;
}
.cyt-twin__logo { font-size: 22px; font-weight: 900; color: var(--accent); letter-spacing: .5px; }
.cyt-twin__logo::after { content: ""; display: inline-block; width: 5px; height: 5px; background: var(--o2); margin-left: 3px; }
.cyt-twin__brand b { font-size: 15px; }
.cyt-twin__brand small { display: block; color: var(--muted); margin-top: 2px; }
.cyt-twin__status { margin-left: auto; color: var(--green); display: flex; align-items: center; gap: 6px; font-size: 12px; }
.cyt-twin__status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.cyt-twin__status.stale { color: var(--amber); } .cyt-twin__status.stale i { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.cyt-twin__status.hist { color: var(--cyan); } .cyt-twin__status.hist i { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.cyt-twin__status.off { color: var(--red); } .cyt-twin__status.off i { background: var(--red); box-shadow: 0 0 10px var(--red); }

.cyt-btn, .cyt-twin__range button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 4px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.cyt-btn:hover, .cyt-twin__range button:hover { color: var(--accent); border-color: var(--accent); }
.cyt-btn:active { transform: translateY(1px); }
.cyt-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cyt-btn--primary:hover { color: #fff; filter: brightness(1.08); }
.cyt-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cyt-twin__range { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.cyt-twin__range button { border: 0; background: transparent; padding: 6px 10px; }
.cyt-twin__range button.active { background: var(--accent); color: #fff; }

.cyt-badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 4px; letter-spacing: .5px; }
.cyt-badge--demo { background: #fff1d4; color: #8a6100; }
.cyt-badge--hist { background: var(--accent); color: #fff; }
.cyt-badge--sim { background: #6d28a8; color: #e9ccff; }

/* ---------- Icon-Rail (56px Desktop) / Drawer (mobil) ---------- */
.cyt-twin .cyt-twin__aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 -14px 40px var(--shadow);
  transition: width .28s cubic-bezier(.4, 0, .2, 1), transform .32s cubic-bezier(.4, 0, .2, 1);
}
.cyt-twin__aside {
  position: absolute; left: 14px; top: 74px; bottom: 12px; z-index: 40;
  width: min(260px, 82vw); padding: 34px 8px 8px; overflow: hidden;
}
.cyt-sheetclose { position: absolute; top: 8px; right: 8px; z-index: 5; padding: 4px 7px; }
.cyt-twin__aside-label { text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-size: 9px; padding: 8px 6px 5px; }
.cyt-twin__nav button, .cyt-twin__nav a {
  width: 100%; border: 0; background: none; color: var(--muted); text-align: left;
  padding: 10px 12px; border-radius: 4px; display: flex; gap: 9px; align-items: center;
  transition: background .15s, color .15s;
}
.cyt-twin__nav button:hover, .cyt-twin__nav a:hover { background: var(--panel2); color: var(--text); }
.cyt-twin__nav button.active, .cyt-twin__nav a.active { background: color-mix(in srgb, var(--accent) 8%, var(--panel2)); color: var(--text); box-shadow: inset 3px 0 var(--o2); }
.cyt-twin__nav .ico { width: 18px; text-align: center; color: var(--cyan); font-weight: 800; font-size: 11px; flex: none; }
.cyt-twin__nav .count { margin-left: auto; color: var(--muted); font-size: 10px; }
.cyt-twin__nav .count.alarm { color: var(--red); font-weight: 700; }

/* Desktop: Rail = Grid-Spalte (icons only), nav-open = Overlay darüber */
@media (min-width: 851px) {
  .cyt-twin__aside {
    position: sticky; top: 60px; align-self: start;
    grid-row: 2; grid-column: 1; height: calc(100dvh - 78px);
    width: auto; left: auto; bottom: auto; padding: 8px 5px; overflow: hidden;
    margin-top: 9px;
    border-radius: 0; border-left: 0; border-top: 0; border-bottom: 0;
  }
  .cyt-twin__aside-label, .cyt-sheetclose { display: none; }
  .cyt-twin__nav button, .cyt-twin__nav a { justify-content: center; text-align: center; gap: 0; padding: 9px 4px; }
  .cyt-twin__nav .lbl { display: none; }
  .cyt-twin__nav .count { position: absolute; top: 3px; right: 4px; margin: 0; }
  .cyt-twin__nav button, .cyt-twin__nav a { position: relative; }
  /* Aufgeklappt: beschrifteter Drawer als Overlay über dem Inhalt */
  .cyt-twin.nav-open .cyt-twin__aside {
    /* Bezugsrahmen = komplette App (Grid-Zelle würde den Offset verdoppeln) */
    grid-row: 1 / -1; grid-column: 1 / -1;
    position: absolute; left: 0; top: 69px; bottom: auto; height: calc(100dvh - 78px);
    margin-top: 0;
    width: min(260px, 82vw); z-index: 45; overflow: auto; padding: 34px 8px 8px;
    border-right: 1px solid var(--line); border-radius: 0 8px 8px 0;
  }
  .cyt-twin.nav-open .cyt-twin__aside-label, .cyt-twin.nav-open .cyt-sheetclose { display: block; }
  .cyt-twin.nav-open .cyt-twin__nav button, .cyt-twin.nav-open .cyt-twin__nav a { justify-content: flex-start; text-align: left; gap: 9px; padding: 10px 12px; }
  .cyt-twin.nav-open .cyt-twin__nav .lbl { display: inline; }
  /* Explizit platziert: rutscht sonst in die Rail-Spalte, sobald nav-open
     die Rail per position:absolute aus dem Grid-Fluss nimmt. */
  .cyt-twin__main { grid-row: 2; grid-column: 2; }
}

/* ---------- Main / Leitstand-Board ---------- */
.cyt-twin__main { min-width: 0; min-height: 0; width: 100%; max-width: 2000px; margin: 0 auto; padding: 9px 14px; }
.cyt-board { display: grid; grid-template-columns: minmax(0, 1fr) 436px; gap: 9px; min-height: 0; }
.cyt-board__mid { display: flex; flex-direction: column; gap: 9px; min-width: 0; min-height: 0; }
/* Szenen-Zeile: Inhaltsgesteuert, ~56vh hoch — die Seite wächst statt zu clippen */
.cyt-board__mid > .cyt-panel--schema { height: 56vh; min-height: 460px; }
.cyt-panel--schema { display: flex; flex-direction: column; }
.cyt-panel--schema .cyt-canvas { flex: 1 1 auto; }
.cyt-twin section+section { margin-top: 0; }
.cyt-panel { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 12px 32px var(--shadow); }
/* Kopfzeile schwebt ohne Trennung über dem Inhalt ("aus einem Guss") */
.cyt-twin__main .cyt-panel__head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  border-bottom: 0; pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 85%, transparent), transparent);
}
.cyt-twin__main .cyt-panel__head .cyt-panel__tools { pointer-events: auto; }
.cyt-panel__head { min-height: 52px; display: flex; align-items: center; padding: 8px 16px; gap: 10px; }
.cyt-panel__head h1 { font-size: 16px; margin: 0; }
.cyt-panel__head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.cyt-panel__tools { margin-left: auto; display: flex; gap: 7px; align-items: center; }
/* Bereichsbeschreibung als Info-Popover hinter dem Titel */
.cyt-viewhead { display: flex; align-items: center; gap: 9px; }
.cyt-info { position: relative; display: inline-flex; pointer-events: auto; }
.cyt-info__btn {
  width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid var(--muted); background: transparent; color: var(--muted);
  font: italic 700 11px/1 Georgia, serif;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: help;
}
.cyt-info:hover .cyt-info__btn, .cyt-info:focus-within .cyt-info__btn { color: var(--accent); border-color: var(--accent); }
.cyt-info .cyt-info__pop {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 7;
  width: min(440px, 72vw);
  margin: 0; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 32px var(--shadow);
  color: var(--text); font-size: 12px; line-height: 1.55;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.cyt-info:hover .cyt-info__pop, .cyt-info:focus-within .cyt-info__pop { opacity: 1; visibility: visible; transform: none; }
.cyt-panel--chart { min-height: 300px; height: 46%; }
/* Schema-Panel: rahmenlos — das P&ID liegt offen auf der App-Fläche */
.cyt-panel--schema { background: transparent; border: 0; border-radius: 0; box-shadow: none; }

.cyt-canvas { position: relative; height: 100%; min-height: 340px; overflow: hidden; background: transparent; }
.cyt-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cyt-chart { height: 100%; min-height: 240px; padding-top: 54px; box-sizing: border-box; }

/* ---------- Schema (SVG) ---------- */
.pipe { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pipe.h2 { stroke: var(--h2); } .pipe.water { stroke: var(--water); } .pipe.ve { stroke: var(--ve); } .pipe.o2 { stroke: var(--o2); } .pipe.elec { stroke: var(--elec); } .pipe.hot { stroke: var(--red); }
.pipe.flow { stroke-dasharray: 6 9; animation: cyt-flow 1.4s linear infinite; }
.pipe.inactive { opacity: 1; animation: none; stroke-dasharray: none; }
@keyframes cyt-flow { to { stroke-dashoffset: -30; } }

.pid-zone { fill: color-mix(in srgb, var(--panel) 80%, transparent); stroke: var(--line); stroke-width: 1; stroke-dasharray: 6 5; cursor: pointer; }
.pid-zone:hover { fill: color-mix(in srgb, var(--cyan) 8%, transparent); stroke: var(--cyan); stroke-dasharray: 7 5; }
.pid-zone-label { fill: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.pid-zone-count { fill: var(--muted); font-size: 8px; }
.pid-card { fill: color-mix(in srgb, var(--card-bg) 93%, transparent); stroke: var(--line); stroke-width: 1; }
.pid-card.good { stroke: var(--green); } .pid-card.warn { stroke: var(--amber); } .pid-card.alarm { stroke: var(--red); }
.pid-small { fill: var(--muted); font-size: 8px; }
.pid-value { fill: var(--text); font-size: 10px; font-weight: 800; }
.pid-unit { fill: var(--muted); font-size: 8px; }
.pid-title { fill: var(--text); font-size: 12px; font-weight: 800; letter-spacing: .8px; }
.pid-sub { fill: var(--muted); font-size: 9px; }
.pid-bg { fill: transparent; }
.pid-tag { fill: var(--panel); stroke: var(--line); }
.pid-tag-text { fill: var(--muted); font-size: 8px; font-weight: 800; }

.sensor { cursor: pointer; }
.sensor circle { fill: var(--card-bg); stroke: var(--green); stroke-width: 2; }
.sensor text { fill: var(--text); font-size: 9px; font-weight: 700; }
.sensor:hover circle { stroke: var(--cyan); }
.cyt-twin[data-theme="dark"] .sensor:hover circle { stroke: #fff; }
.sensor.warn circle { stroke: var(--amber); }
.sensor.alarm circle { stroke: var(--red); filter: drop-shadow(0 0 6px var(--red)); }
.sensor.stale circle { stroke: var(--muted); stroke-dasharray: 3 3; }
.sensor.selected circle { stroke-width: 3; filter: drop-shadow(0 0 8px var(--cyan)); }

.component { cursor: default; }
.component[data-sensor] { cursor: pointer; }
.component .body { fill: var(--panel2); stroke: var(--muted); stroke-width: 1.6; }
.component .symbol { fill: none; stroke: var(--muted); stroke-width: 1.7; }
.component .label { fill: var(--text); font-size: 10px; font-weight: 700; }
.component .small { fill: var(--muted); font-size: 8px; }
.component.active .body, .component.active .symbol { stroke: var(--green); }
.valve-s { fill: var(--panel); stroke: var(--muted); stroke-width: 1.5; }
.component.open .valve-s { stroke: var(--green); }
.component.closed .valve-s { stroke: var(--red); }
.pump-c { fill: var(--panel2); stroke: var(--muted); stroke-width: 1.5; }
.component.running .pump-c { stroke: var(--green); filter: drop-shadow(0 0 5px rgba(56, 232, 155, .4)); }
.component.sim-edited .body { stroke: var(--amber); stroke-dasharray: 4 3; }

.vessel { fill: var(--panel2); stroke: var(--muted); stroke-width: 1.4; filter: drop-shadow(0 6px 12px var(--shadow)); }
.instr { fill: var(--card-bg); stroke: var(--muted); stroke-width: 1.4; filter: drop-shadow(0 3px 7px var(--shadow)); }
.instr-text { fill: var(--muted); font-size: 7px; font-weight: 800; }

/* Textur-Overlay (Punktraster) für Karten/Behälter — Pattern aus defs() */
.tex { fill: url(#dotTex); stroke: none; pointer-events: none; }
.pid-tex { fill: var(--muted); opacity: .14; }
.pid-card { filter: drop-shadow(0 5px 12px var(--shadow)); }
.valve-s, .pump-c { filter: drop-shadow(0 3px 6px var(--shadow)); }

.leader { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.tap { fill: var(--muted); }
.bundle-fill { fill: var(--h2); opacity: .32; transition: y .5s, height .5s; }
.bundle-fill.elec { fill: var(--elec); }
.pid-frame { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 8 6; }
.pid-note { fill: var(--muted); font-size: 8px; }
.pid-link { cursor: pointer; }
.pid-link:hover, .sectionTarget:focus-visible .pid-link { fill: var(--cyan); }
.pid-legend-text { fill: var(--muted); font-size: 8px; }

/* Status-Tabelle (z. B. Peripherie/Sicherheit): Symbol | Statusmeldung */
.pid-trow { fill: color-mix(in srgb, var(--panel) 80%, transparent); stroke: var(--line); stroke-width: 1; }
.pid-thead { fill: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.statusrow .sico { fill: none; stroke: var(--cyan); stroke-width: 1.6; }
.statusrow .sico-fill { fill: var(--cyan); stroke: none; }
.statusrow .stag { fill: var(--text); font-size: 9px; font-weight: 700; }
.statusrow .sname { fill: var(--muted); font-size: 7.5px; }
.statusrow .sval { fill: var(--text); font-size: 11px; font-weight: 800; }
.statusrow.warn .sico, .statusrow.warn .sico-fill { stroke: var(--amber); fill: var(--amber); }
.statusrow.warn .sval { fill: var(--amber); }
.statusrow.alarm .sico, .statusrow.alarm .sico-fill { stroke: var(--red); fill: var(--red); }
.statusrow.alarm .sval { fill: var(--red); }
.statusrow.stale .sico, .statusrow.stale .sico-fill { stroke: var(--muted); fill: var(--muted); stroke-dasharray: 3 2; }
.statusrow.stale .sval { fill: var(--muted); }
.sensor .small { fill: var(--muted); font-size: 8px; font-weight: 400; }
.sensor .val { fill: var(--text); font-weight: 800; }
.sectionTarget:focus-visible .pid-zone { stroke: var(--cyan); stroke-width: 2; }

/* ---------- Inspector (Panel im Leitstand-Layout) ---------- */
.cyt-inspector { padding: 6px 16px 14px; flex: 1; min-height: 0; overflow: auto; }
.cyt-inspector__top { display: flex; gap: 10px; align-items: center; }
.cyt-inspector__icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 900; font-size: 11px; }
.cyt-inspector__top h2 { margin: 0; font-size: 17px; }
.cyt-inspector__value { font-size: 32px; font-weight: 800; margin-top: 14px; }
.cyt-inspector__trend { color: var(--green); margin: 3px 0 12px; min-height: 16px; font-size: 12px; }
.cyt-inspector__chart { height: 140px; }
.muted { color: var(--muted); }
.cyt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cyt-stat { border: 1px solid var(--line); padding: 8px; border-radius: 4px; }
.cyt-stat small { display: block; color: var(--muted); } .cyt-stat b { display: block; margin-top: 3px; }
.cyt-meta { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); line-height: 1.8; color: var(--muted); font-size: 11px; }
.cyt-meta b { color: var(--text); }

/* ---------- Modal / Panels ---------- */
.cyt-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: none; align-items: center; justify-content: center; z-index: 100; }
.cyt-modal.show { display: flex; }
.cyt-modal__box { position: relative; width: 640px; max-width: 92vw; max-height: 85vh; overflow: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 20px; box-shadow: 0 30px 80px var(--shadow); }
/* X oben rechts in Modals — bleibt beim Scrollen sichtbar */
.cyt-modal__x {
  position: sticky; float: right; top: 0; margin: -8px -8px 0 8px; z-index: 5;
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 6px;
}
.cyt-modal__x:hover { color: var(--text); }
.cyt-modal__box--wide { width: 860px; }
.cyt-modal__box h2 { margin: 0 0 14px; font-size: 17px; }
.cyt-modal__row label { color: var(--muted); display: block; font-size: 11px; }
.cyt-modal input, .cyt-modal select { display: block; width: 100%; margin-top: 5px; background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 8px; border-radius: 4px; font: inherit; }
.cyt-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.cyt-stepper { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.cyt-stepper button { background: var(--panel); border: 1px solid var(--line); color: var(--muted); padding: 6px 9px; border-radius: 4px; }
.cyt-stepper button:hover { color: var(--text); border-color: var(--cyan); }

/* ---------- Listen / Tabellen im Panel ---------- */
.cyt-list { padding: 4px 0; }
.cyt-list .row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.cyt-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); flex: none; }
.cyt-list .dot.warn { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.cyt-list .dot.alarm { background: var(--red); box-shadow: 0 0 7px var(--red); }
.cyt-list .dot.stale { background: var(--muted); box-shadow: none; }
.cyt-list small { margin-left: auto; color: var(--muted); }
.cyt-list .ack { font-size: 10px; padding: 3px 7px; }

.cyt-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cyt-kv { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 6px 0; font-size: 12px; }
.cyt-kv b { font-weight: 700; }
.cyt-kv input { width: 90px; display: inline-block; padding: 4px 6px; margin: 0; text-align: right; }

.sim-hint { background: color-mix(in srgb, var(--ve) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ve) 45%, transparent); border-radius: 4px; padding: 10px; font-size: 11px; color: var(--text); margin-bottom: 10px; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 4px; z-index: 200; box-shadow: 0 15px 40px var(--shadow); font-size: 12px; }
.cyt-twin .empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.cyt-twin .empty b { color: var(--text); }

/* Simulation: editierbare Sensor-Felder */
.sensor.sim-editable { cursor: copy; }
.sensor.sim-editable circle { stroke-dasharray: 4 3; }
.sim-input { position: fixed; z-index: 300; background: var(--panel2); border: 1px solid var(--amber); border-radius: 4px; padding: 8px; display: flex; gap: 6px; }
.sim-input input { width: 90px; background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 6px; border-radius: 4px; }
.sim-input button { background: var(--accent); border: 0; color: #fff; border-radius: 4px; padding: 6px 9px; }

/* H2K-Sim-Panel: generierte Eingabemaske, Ergebnis, Kennlinie, Läufe */
.sim-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.sim-form { display: grid; gap: 14px; }
.sim-group { background: color-mix(in srgb, var(--panel2) 60%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.sim-group h3 { margin: 0 0 4px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.sim-group > p { margin: 0 0 10px; font-size: 11px; }
.sim-level { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; color: var(--muted); }
.sim-level--erweitert { border-color: var(--accent); color: var(--accent); }
.sim-level--test { border-color: var(--amber); color: var(--amber); }
.sim-field { margin: 8px 0; }
.sim-field > label { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 3px; }
.sim-src { font-size: 9px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); border-radius: 3px; padding: 1px 5px; }
.sim-field__ctl { display: flex; align-items: center; gap: 6px; }
.sim-field__ctl input[type=number], .sim-field__ctl input[type=text], .sim-field__ctl input[type=datetime-local], .sim-field__ctl select, .sim-field__ctl textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; font-size: 12px; min-width: 0; }
.sim-field__ctl textarea { width: 100%; font-family: monospace; }
.sim-unit { color: var(--muted); font-size: 11px; }
.sim-events { display: grid; gap: 6px; margin: 6px 0; }
.sim-event { display: grid; grid-template-columns: 1fr 1fr 90px 34px; gap: 6px; }
.sim-event input, .sim-event select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; font-size: 12px; min-width: 0; }
.sim-warning { background: color-mix(in srgb, var(--amber) 14%, transparent); border-left: 3px solid var(--amber); padding: 7px 10px; font-size: 11px; border-radius: 3px; margin-bottom: 6px; }
.sim-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.sim-kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; }
.sim-kpi small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.sim-kpi b { font-size: 14px; }
.sim-chsel { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; margin: 8px 0; }
.sim-chsel label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.sim-meta { font-size: 11px; margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sim-runs { width: 100%; border-collapse: collapse; font-size: 12px; }
.sim-runs th, .sim-runs td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.sim-runs tbody tr { cursor: pointer; }
.sim-runs tbody tr:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sim-status { font-size: 10px; border-radius: 3px; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted); }
.sim-status--done { border-color: var(--green); color: var(--green); }
.sim-status--running, .sim-status--queued { border-color: var(--accent); color: var(--accent); }
.sim-status--failed, .sim-status--expired { border-color: var(--red); color: var(--red); }

/* ---------- Schema Pan/Zoom ---------- */
#plant { touch-action: none; }
.cyt-canvas__zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 5; }
.cyt-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  max-width: calc(100% - 110px);
  padding: 6px 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--line);
  font-size: 10px; color: var(--muted); white-space: nowrap;
}
.cyt-legend__item { display: inline-flex; align-items: center; gap: 5px; }
.cyt-legend .sw { width: 20px; height: 4px; border-radius: 2px; flex: none; }
.cyt-legend .sw.h2 { background: var(--h2); }
.cyt-legend .sw.water { background: var(--water); }
.cyt-legend .sw.ve { background: var(--ve); }
.cyt-legend .sw.o2 { background: var(--o2); }
.cyt-legend .sw.elec { height: 0; border-top: 2px dashed var(--elec); }
.cyt-canvas__zoom .cyt-btn { min-width: 34px; height: 34px; padding: 0 8px; font-size: 15px; line-height: 1; border-radius: 4px; }

/* ---------- Gesamtschema: Symbol-Übersicht 2D (1256×800) ---------- */
.ov-bg { fill: #f4f8fb; }
.ov-zone { fill: #ffffff; stroke: #9fb2bd; stroke-width: 1.25; stroke-dasharray: 6 5; }
.ov-zlabel { fill: #63727d; font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.ov-box { fill: #dceaf6; stroke: #5b8db8; stroke-width: 1.4; }
.ov-name { fill: #63727d; font-size: 11px; }
.ov-icon { stroke: #5b8db8; stroke-width: 1.6; fill: #ffffff; }
.ov-bolt { fill: #c9a227; stroke: none; }
.ov-lbl { font-size: 11px; }
.ov-lbl.h2 { fill: var(--h2); } .ov-lbl.water { fill: var(--water); } .ov-lbl.o2 { fill: var(--o2); } .ov-lbl.ve { fill: var(--ve); }
.ov-lbl.hot { fill: var(--red); } .ov-lbl.vent { fill: #63727d; }
.ov-sym, #plant .sectionTarget { cursor: pointer; }
#plant .sectionTarget:hover .ov-box,
#plant .sectionTarget:focus-visible .ov-box { stroke: #36647f; stroke-width: 2.2; }
.pipe.vent { stroke: #9fb2bd; }

/* ---------- Gesamtschema: Figma-Artwork (1256×800) ---------- */
/* Unsichtbare Section-Hitflächen über dem Artwork (Navigation in Detailansichten) */
#plant .asx-sect { fill: transparent; pointer-events: all; cursor: pointer; }
#plant .sectionTarget:hover .asx-sect,
#plant .sectionTarget:focus-visible .asx-sect { fill: rgba(54, 100, 127, .08); stroke: #36647f; stroke-width: 1.5; }

/* Sensor-/Armatur-Hotspots im Artwork (geliefert aus schema-h2.svg) */
#plant .lv-sensor { cursor: pointer; outline: none; }
#plant .lv-sensor .lv-ring { fill: none; stroke: #9fb2bd; stroke-width: 1.5; }
#plant .lv-sensor .lv-val { fill: #36647f; font-size: 10px; font-weight: 700; }
#plant .lv-sensor:hover .lv-ring,
#plant .lv-sensor:focus-visible .lv-ring { stroke: #17619e; stroke-width: 2; }
#plant .lv-sensor.good .lv-ring { stroke: #2f9e6e; }
#plant .lv-sensor.warn .lv-ring { stroke: #e09a00; stroke-width: 2.5; }
#plant .lv-sensor.alarm .lv-ring { stroke: var(--red); stroke-width: 2.5; }
#plant .lv-sensor.stale .lv-ring { stroke: #9fb2bd; stroke-dasharray: 3 3; }
#plant .lv-sensor.selected .lv-ring { stroke: #17619e; stroke-width: 2.5; }

/* Proxy-Klickflächen oberhalb der Section-Rects (werden von twin.js erzeugt) */
#plant .lv-proxy-hit { fill: transparent; pointer-events: all; cursor: pointer; }
#plant .lv-proxy-hit.selected { stroke: #17619e; stroke-width: 1.5; stroke-dasharray: 3 2; }

/* ---------- Seiten-Einbettung (Header/Footer der Site bleiben sichtbar) ----------
   Die App hängt im Content unter #main. Alle Vorfahren werden zur
   Flex-Spalte, damit .cyt-twin den Raum zwischen Site-Header und -Footer
   füllt; #body bekommt mindestens Viewport-Höhe (Sticky-Footer).
   z-index 0 auf .cyt-twin hält die App unter den Nav-Dropdowns (z-20). */
#body:has(.cyt-twin) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
#main:has(.cyt-twin) { display: flex; flex-direction: column; }
#main:has(.cyt-twin) *:has(.cyt-twin) {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Leitstand-Layout: KPI-Leiste, Spalte, Panel-Reihe ---------- */
/* KPI-Leiste: 7 Kacheln (data-live über den generischen Updater) */
.iso-kpibar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.iso-kpi {
  text-align: left; min-width: 0; padding: 9px 11px;
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--kacc, var(--line));
  border-radius: 8px; box-shadow: 0 8px 20px var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.iso-kpi:hover { border-color: var(--accent); }
.iso-kpi__t { font-size: 10px; font-weight: 800; letter-spacing: .4px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iso-kpi__tag { font-size: 9px; color: var(--muted); }
.iso-kpi__v { font-size: 19px; font-weight: 800; margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.iso-kpi__sub { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iso-bar { display: inline-block; height: 5px; width: 56px; border-radius: 3px; background: var(--line); overflow: hidden; vertical-align: middle; }
.iso-bar u { display: block; height: 100%; width: 0; background: var(--green); transition: width .5s, height .5s; }
.iso-bar--ve u { background: var(--ve); }
.iso-bar--col { width: 10px; height: 20px; display: inline-flex; align-items: flex-end; }
.iso-bar--col u { width: 100%; height: 0; background: var(--cyan); }

/* Leitstand-Spalte: eine Karte je Schema-Section (aus /api/plant generiert) */
.cyt-board__stand {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  min-height: 0; align-self: start; box-shadow: 0 12px 32px var(--shadow);
}
.ls-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; background: inherit; }
.ls-head b { font-size: 15px; }
.ls-head small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.ls-pill { flex: none; font-size: 10px; font-weight: 800; padding: 4px 9px; border-radius: 10px; }
.ls-pill.ok { background: #e8f7f0; color: #1e7a4d; }
.ls-pill.warn { background: #fdf3dd; color: #8a6100; }
.ls-pill.alarm { background: #fce8e8; color: #a03230; }
.cyt-twin[data-theme="dark"] .ls-pill.ok { background: rgba(62, 207, 142, .16); color: var(--green); }
.cyt-twin[data-theme="dark"] .ls-pill.warn { background: rgba(251, 171, 0, .16); color: var(--amber); }
.cyt-twin[data-theme="dark"] .ls-pill.alarm { background: rgba(224, 112, 110, .16); color: var(--red); }
.ls-cards { display: flex; flex-direction: column; gap: 9px; padding: 0 10px 12px; }
.ls-card { border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-radius: 6px; padding: 8px; }
.ls-card.warn { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); border-left-color: var(--amber); }
.ls-card.alarm { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); border-left-color: var(--red); }
.ls-card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.ls-card > header b { font-size: 11px; }
.ls-go { border: 0; background: none; color: var(--cyan); font-size: 10px; padding: 0; white-space: nowrap; }
.ls-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.ls-cell {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--panel2);
  padding: 5px 6px; text-align: left; min-width: 0;
}
.ls-cell .t { font-size: 8px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.ls-cell .v { font-size: 10.5px; font-weight: 800; color: var(--text); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-cell .dot { position: absolute; top: 4px; right: 4px; }
.ls-cell.on { background: color-mix(in srgb, var(--green) 9%, var(--panel)); border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.ls-cell.warn { border-color: var(--amber); }
.ls-cell.alarm { border-color: var(--red); }
.ls-cell.stale { opacity: .6; }
.ls-cell.selected { outline: 2px solid var(--cyan); }

/* Statuspunkte (HTML-Seite) */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.dot.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.alarm { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.stale { background: var(--muted); }

/* Panel-Reihe unter der Szene (Leitstand-Raster).
   Das Vierspalt-Raster darf erst greifen, wenn die mittlere Board-Spalte die
   Mindestbreite wirklich hergibt (Rail 56 + Padding 28 + Leitstand 436 + Gap):
   300 + 520 + 220 + 220 + 3×9 = 1287 → Viewport ≥ ~1816, abgerundet 1900.
   Darunter zweispaltig gestapelt — so kann nichts über #leitstand ragen.
   ≥1900:  Inspector 300 (2 Zeilen) | Verlauf 1fr | Batterie ~260 | Energie ~260
                                     | Alarme über die Restbreite              */
/* Verlauf volle Breite, darunter drei gleiche Spalten
   (Inspector | Batterie | Energiemessung), Alarme vollflächig unten */
.ls-panels { display: grid; gap: 9px; min-height: 0; }
@media (min-width: 851px) {
  .ls-panels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 220px auto auto;
    grid-template-areas:
      "chart chart chart"
      "insp bat energy"
      "alarm alarm alarm";
  }
}
.lp-insp { grid-area: insp; display: flex; flex-direction: column; min-height: 0; }
.lp-insp .cyt-inspector { padding-top: 56px; }
#chartPanel { grid-area: chart; }
#alarmPanel { grid-area: alarm; }
#batPanel { grid-area: bat; }
#energyPanel { grid-area: energy; }
.ls-panels > .cyt-panel { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.lp-body { padding: 58px 12px 10px; font-size: 12px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.lp-val { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.lp-val:last-child { border-bottom: 0; }
.lp-val > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-val b { white-space: nowrap; }
.lp-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lp-barrow { display: flex; align-items: center; gap: 8px; }
.lp-barrow > span { font-size: 9px; font-weight: 700; color: var(--muted); width: 60px; flex: none; }
.lp-barrow .iso-bar { flex: 1; width: auto; height: 8px; }
.lp-barrow b { min-width: 46px; text-align: right; }
/* Freigabe-Pills (Sollwerte-Karte im Leitstand): grau, grün sobald Wert = 1 */
.lp-sws { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 2px; }
.lp-sw { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 16px; padding: 5px 10px; font-size: 11px; background: var(--panel2); }
.lp-sw.on { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--panel)); }
.lp-alarms { padding: 56px 12px 10px; font-size: 12px; overflow: auto; }
.lp-alarmbox { border-radius: 6px; padding: 8px 10px; font-size: 11.5px; font-weight: 600; }
.lp-alarmbox.ok { background: #e8f7f0; color: #1e7a4d; }
.lp-alarmbox.alarm { background: #fce8e8; color: #a03230; }
.cyt-twin[data-theme="dark"] .lp-alarmbox.ok { background: rgba(62, 207, 142, .14); color: var(--green); }
.cyt-twin[data-theme="dark"] .lp-alarmbox.alarm { background: rgba(224, 112, 110, .14); color: var(--red); }
.lp-alarmrow { padding: 2px 0; }
.lp-events { margin-top: 8px; }
.lp-event { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 11px; }
.lp-event:last-child { border-bottom: 0; }
.lp-event small { color: var(--muted); white-space: nowrap; flex: none; }
.lp-event__txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-event .lp-event__end { margin-left: auto; }
.lp-seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.lp-seg button { border: 0; background: transparent; color: var(--muted); padding: 4px 9px; border-radius: 4px; font-size: 11px; }
.lp-seg button.active { background: var(--accent); color: #fff; }
#chartPanel .cyt-panel__tools { flex-wrap: nowrap; gap: 5px; }
#chartPanel .cyt-btn, #chartPanel .lp-seg button { font-size: 11px; padding: 4px 8px; }
#chartPanel .cyt-chart { padding-top: 46px; height: 100%; min-height: 130px; box-sizing: border-box; }
.cyt-inspector__chart { height: 70px; }

/* ---------- Iso-Leitstand (3D-Gesamtansicht) ---------- */
.iso-ground { fill: var(--iso-ground); stroke: var(--iso-edge); stroke-width: 1; stroke-dasharray: 6 5; }
.iso-frame { fill: none; stroke: var(--iso-edge); stroke-width: .8; stroke-dasharray: 5 4; }
.iso-pipe.flow { stroke-dasharray: 7 8; animation: cyt-flow 1.4s linear infinite; }
.iso-pipe.off { opacity: 1; animation: none; stroke-dasharray: none; }
@media (prefers-reduced-motion: reduce) { .iso-pipe.flow { animation: none; } }
.iso-sect { fill: transparent; pointer-events: all; cursor: pointer; }
#plant .sectionTarget:hover .iso-sect,
#plant .sectionTarget:focus-visible .iso-sect { fill: rgba(54, 100, 127, .08); stroke: var(--cyan); stroke-width: 1.5; }
.iso-pldot { fill: var(--cyan); }
.iso-pldot.acc { fill: var(--amber); }
.iso-plnum { fill: #fff; font-size: 8.5px; font-weight: 800; }
.iso-pltitle { fill: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .8px; }
.iso-note { fill: var(--muted); font-size: 8px; }
.iso-btag { fill: var(--cyan); font-size: 9px; font-weight: 800; }
.iso-ctag { fill: var(--muted); font-size: 7.5px; font-weight: 700; }
.iso-itag { fill: var(--muted); font-size: 8px; font-weight: 700; }
.iso-idisc { fill: var(--panel); stroke: var(--muted); stroke-width: 1.2; }
.iso-valve { cursor: pointer; }
.iso-bow { fill: #eef2f5; stroke: #8a9aa5; stroke-width: 1; }
.iso-bow--p { fill: var(--panel); stroke: var(--cyan); }
.iso-valve.on .iso-bow { fill: #ddf2e8; stroke: var(--green); }
.iso-valve.alarm .iso-bow { stroke: var(--red); }
.cyt-twin[data-theme="dark"] .iso-bow { fill: #243a4a; stroke: #5f7c8e; }
.cyt-twin[data-theme="dark"] .iso-valve.on .iso-bow { fill: #1d4534; stroke: var(--green); }
.iso-bb { cursor: pointer; }
.iso-foot { fill: var(--panel); stroke: var(--muted); }
.iso-stem { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.iso-cardbg { fill: var(--panel); stroke: var(--line); filter: drop-shadow(0 4px 8px var(--shadow)); }
.iso-card.warn .iso-cardbg { stroke: var(--amber); }
.iso-card.alarm .iso-cardbg { stroke: var(--red); }
.iso-card.stale .iso-cardbg { stroke-dasharray: 3 3; }
.iso-card.selected .iso-cardbg,
.iso-pin.selected .iso-pill { stroke: var(--cyan); stroke-width: 2; }
.iso-tag { fill: var(--muted); font-size: 8px; font-weight: 700; }
.iso-val { fill: var(--text); font-size: 10px; font-weight: 800; }
.iso-pin .iso-val { font-size: 9px; }
.iso-pill { fill: var(--panel); stroke: var(--line); filter: drop-shadow(0 2px 5px var(--shadow)); }
.iso-pin.warn .iso-pill { stroke: var(--amber); }
.iso-pin.alarm .iso-pill { stroke: var(--red); }
.iso-fill { fill: var(--h2); opacity: .28; }

/* Ebenen-Schalter (nur Iso-Gesamtansicht): layer-off-* am Root */
.cyt-layers {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}
.cyt-layers button { border: 0; background: transparent; color: var(--muted); padding: 5px 9px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.cyt-layers button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cyt-twin.layer-off-zones #plant .iso-plaque,
.cyt-twin.layer-off-zones #plant .iso-frame-g { display: none; }
.cyt-twin.layer-off-pipes #plant .iso-pipe,
.cyt-twin.layer-off-pipes #plant .iso-pshd { display: none; }
.cyt-twin.layer-off-bodies #plant .iso-body,
.cyt-twin.layer-off-bodies #plant .iso-vent { display: none; }
.cyt-twin.layer-off-values #plant .iso-billboards,
.cyt-twin.layer-off-values #plant .iso-vpin { display: none; }
.cyt-twin.layer-off-valves #plant .iso-valve,
.cyt-twin.layer-off-valves #plant .iso-ivalve,
.cyt-twin.layer-off-valves #plant .iso-instr,
.cyt-twin.layer-off-valves #plant .iso-vpin { display: none; }

/* ---------- Responsive ---------- */
/* bis 1600: schmalere Leitstand-Spalte, Leitstand-Zellen dreispaltig */
@media (min-width: 851px) and (max-width: 1600px) {
  .cyt-board { grid-template-columns: minmax(0, 1fr) 380px; }
  .ls-grid { grid-template-columns: repeat(3, 1fr); }
}
/* 851–1280: Leitstand-Spalte wandert unter die Panels, Karten zweispaltig */
@media (min-width: 851px) and (max-width: 1280px) {
  .cyt-board { grid-template-columns: minmax(0, 1fr); }
  .ls-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
}
/* ≤850: alles gestapelt, KPI-Leiste horizontal scrollbar, Drawer-Nav */
@media (max-width: 850px) {
  .cyt-twin { grid-template-rows: 52px auto; }
  .cyt-twin__header { overflow-x: auto; gap: 8px; }
  .cyt-twin__range { display: none; }
  .cyt-board { grid-template-columns: 1fr; }
  .iso-kpibar { grid-template-columns: repeat(7, 148px); overflow-x: auto; padding-bottom: 4px; }
  .cyt-board__mid > .cyt-panel--schema { height: auto; min-height: 360px; }
  .cyt-board__mid > .cyt-panel--schema .cyt-canvas { min-height: 360px; }
  .ls-panels {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: "insp" "chart" "alarm" "bat" "energy";
  }
  #chartPanel .cyt-chart { height: 260px; }
  .ls-grid { grid-template-columns: repeat(4, 1fr); }
  /* Rail → Off-Canvas-Drawer (fixed: kein Fluss-/Layout-Beitrag, komplett aus dem Viewport) */
  .cyt-twin__aside {
    position: fixed; top: 62px; left: 8px; bottom: 12px; width: min(260px, 82vw); z-index: 60;
    overflow: auto; transform: translateY(110dvh); visibility: hidden;
    transition: transform .32s cubic-bezier(.4, 0, .2, 1), visibility 0s .32s;
  }
  .cyt-twin.nav-open .cyt-twin__aside { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.4, 0, .2, 1); }
  .cyt-twin__nav .lbl { display: inline; }
  .cyt-layers { top: 56px; left: 10px; transform: none; flex-wrap: wrap; max-width: calc(100% - 130px); }
  .cyt-legend { left: 10px; bottom: 10px; gap: 8px; padding: 5px 8px; max-width: calc(100% - 90px); }
  /* Mobilkürzung der Szene: nur Karten, keine Pins/Instrumenten-Beschriftungen */
  #plant .iso-pin, #plant .iso-vpin, #plant .iso-itag { display: none; }
}
@media (max-width: 520px) { .ls-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Leitstand-Karte „Sollwerte & Freigaben“ (letzte Karte der Spalte) ----------
   Untertitel im Kopf, Sollwerte als kompakte 2-Spalten-Zellen (gilt an allen
   Breakpoints, steht daher hinter den Responsive-Regeln), darunter die
   Freigabe-Pills (.lp-sw, grün via .on wenn Wert = 1). */
.ls-card > header small { display: block; color: var(--muted); font-size: 9px; font-weight: 400; margin-top: 1px; }
.ls-card--param > header { align-items: center; }
.ls-grid--2 { grid-template-columns: repeat(2, 1fr); }

/* Sensor-Auswahl im „+ Sensor"-Dialog: kompaktes Grid statt Endlos-Liste */
.cyt-sensorpick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 7px; margin-top: 10px;
}
.cyt-sensorpick__item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; cursor: pointer; padding: 7px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
}
.cyt-sensorpick__item:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel2)); }
.cyt-sensorpick__item b { font-size: 11px; color: var(--text); }
.cyt-sensorpick__item span { font-size: 10px; color: var(--muted); }
.cyt-sensorpick__item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel2)); }
.cyt-sensorpick__item.on b::after { content: ' ✓'; color: var(--accent); }

/* Theme-Umschalter vorerst nicht anbieten — Funktion bleibt im Code */
#themeToggle { display: none; }

/* ---------- SIM-Lauf-Wiedergabe (sim-playback.js) ---------- */
.cyt-twin__status.sim { color: #c9a0f0; }
.cyt-twin__status.sim i { background: #a855f7; box-shadow: 0 0 10px #a855f7; }

/* Dunkles Dock unten über die volle Breite — einzige SIM-Steuerleiste */
/* Dock liegt fixiert unten — Seite braucht Platz zum Durchscrollen */
.cyt-twin.sim-dock { padding-bottom: 60px; }
.cyt-simtl {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: #1b2830; color: #e7eff4;
  border-top: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 -8px 24px rgba(0,0,0,.28);
}
.cyt-simtl__badge {
  flex: none; font-size: 10px; font-weight: 800; letter-spacing: 1px;
  background: #a855f7; color: #fff; border-radius: 5px; padding: 5px 8px;
}
.cyt-simtl__controls { display: flex; align-items: center; gap: 4px; flex: none; }
.cyt-simtl__btn {
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06);
  color: #e7eff4; border-radius: 6px; padding: 5px 9px; font-size: 12px;
  cursor: pointer; line-height: 1;
}
.cyt-simtl__btn:hover { background: rgba(255,255,255,.14); }
.cyt-simtl__play { background: #a855f7; border-color: #a855f7; min-width: 34px; }
.cyt-simtl__slider { flex: 1; min-width: 80px; accent-color: #a855f7; height: 4px; }
.cyt-simtl__time {
  flex: none; font-size: 11px; color: #93aab8;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.cyt-simtl__speed {
  flex: none; background: rgba(255,255,255,.06); color: #e7eff4;
  border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
  padding: 4px 6px; font-size: 11px;
}
.cyt-simtl__speed option { color: #1b2830; background: #fff; }
.cyt-simtl__kpis {
  flex: none; font-size: 11px; color: #e7eff4; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; padding: 5px 12px; white-space: nowrap;
}
.cyt-simtl__kpis:hover { background: rgba(168,85,247,.3); }
.cyt-simtl__warn { flex: none; font-size: 11px; color: #fbab00; cursor: help; }
.cyt-simtl__exit {
  flex: none; margin-left: auto; border: 0; background: #fff; color: #1b2830;
  border-radius: 7px; padding: 7px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.cyt-simtl__exit:hover { background: #dbe4ea; }

/* Sensoren ohne Sim-Kanal während Wiedergabe abdimmen (Schema, Leitstand, KPI-Leiste) */
#plant [data-sensor].sim-na,
#leitstand [data-csel].sim-na,
#kpiBar [data-ksel].sim-na { opacity: .35; }

/* SIM-Markierung: Elemente mit Sim-Daten violett kennzeichnen */
#leitstand [data-csel].sim-on,
#kpiBar [data-ksel].sim-on { box-shadow: inset 3px 0 0 #a855f7; }
#plant [data-sensor].sim-on circle { stroke: #a855f7; }
.lp-insp.sim-mode { border-top: 3px solid #a855f7; }

/* ---- SIM-Job-Status oben rechts (#simNotify) ---- */
/* Zustandsgetönte Karte (Penpot V1): pastell + dicke Zustandskante —
   läuft = violett, fertig = grün, Fehler = rot */
.cyt-simnotify {
  position: fixed; top: 60px; right: 16px; z-index: 1200;
  display: flex; align-items: center; gap: 10px;
  background: #f5f0fd; border: 1px solid #dcc7f5; border-left: 5px solid #a855f7;
  border-radius: 10px; padding: 8px 12px;
  box-shadow: 0 6px 22px rgba(27,40,48,.16); color: var(--text);
  max-width: min(560px, calc(100vw - 32px));
}
.cyt-simnotify.is-running { border-radius: 999px; padding-bottom: 12px; }
.cyt-simnotify.is-done {
  display: block; min-width: 340px; padding: 10px 14px 12px;
  background: #eaf7f0; border-color: #9ed8bb; border-left-color: var(--green);
}
.cyt-simnotify.is-done .cyt-btn--primary {
  background: var(--green); border-color: var(--green); color: #fff;
}
.cyt-simnotify.is-done .cyt-btn--primary:hover { background: #278a5d; }
.cyt-simnotify.is-error {
  background: #fceaea; border-color: #e5a9a8; border-left-color: var(--red);
}
.cyt-simnotify__head { display: flex; align-items: center; gap: 8px; }
.cyt-simnotify__head b { flex: 1; font-size: 14px; }
.cyt-simnotify__sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.cyt-simnotify.is-done .cyt-simnotify__hl { display: block; font-size: 11px; margin-top: 2px; }
.cyt-simnotify.is-done .cyt-simnotify__acts { display: flex; gap: 8px; margin-top: 10px; }
.cyt-simnotify.is-done .cyt-simnotify__acts .cyt-btn { flex: 1; }
.cyt-simnotify__play { border: 1.5px solid #a855f7 !important; color: #a855f7 !important; background: none !important; }
.cyt-simnotify__txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cyt-simnotify__txt b { font-size: 12px; }
.cyt-simnotify.is-running .cyt-simnotify__txt b { color: #a855f7; }
.cyt-simnotify__txt small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cyt-simnotify__hl { color: var(--amber); }
.cyt-simnotify__spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2.5px solid #dcc7f5; border-top-color: #a855f7;
  animation: cyt-simspin 0.9s linear infinite;
}
@keyframes cyt-simspin { to { transform: rotate(360deg); } }
.cyt-simnotify__ok {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.cyt-simnotify__link, .cyt-simnotify__x {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font-size: 11px; padding: 4px; flex: none;
}
.cyt-simnotify__x { color: var(--muted); font-size: 14px; }
.cyt-simnotify__acts { display: flex; align-items: center; gap: 6px; flex: none; }
.cyt-simnotify__prog {
  position: absolute; left: 10px; right: 10px; bottom: 3px; height: 2px;
  background: #dcc7f5; border-radius: 1px; overflow: hidden;
}
.cyt-simnotify__prog i { display: block; height: 100%; background: #a855f7; transition: width .3s; }

/* ---- Ergebnis-Dialog (simulation.js showResultDialog) ---- */
/* Warnungen-/Meta-Tabs vorerst ausgeblendet — Feature bleibt im Code */
.sim-dlg .sim-tabs { display: none; }
.sim-dlg__foot { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: flex-end; }
#simDlgRuns { display: none; } /* zurück zu Läufe vorerst nicht */
/* Der Sim-Dialog bringt seinen eigenen Schließen-Button mit —
   den generischen Modal-Footer dann nicht doppelt zeigen */
#panelModal .cyt-modal__box:has(.sim-dlg) .cyt-modal__actions { display: none; }
.sim-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-top: 10px;
}
.sim-kpi-cell {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
}
.sim-kpi-cell b { font-size: 16px; color: var(--accent); }
.sim-kpi-cell small { font-size: 10px; color: var(--muted); line-height: 1.3; }
.sim-meta-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; }
.sim-meta-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 10px 4px 0; white-space: nowrap; width: 110px; }
.sim-meta-table td { padding: 4px 0; word-break: break-all; }

/* ---- SIM-Modus des Verlauf-Panels (#chartPanel.sim-mode) ---- */
/* Violettes Band oben als klare SIM-Markierung */
#chartPanel.sim-mode { border-top: 3px solid #a855f7; }
/* Live-Controls gelten nicht für Sim-Daten */
#chartPanel.sim-mode #chartRange,
#chartPanel.sim-mode #chartCompareSensor,
#chartPanel.sim-mode #chartCompareRange,
#chartPanel.sim-mode #chartExport { display: none; }
/* Platz für die Kanal-Rail rechts */
#chartPanel.sim-mode #chart { margin-right: 158px; }

/* Kanal-Rail: scrollbare Checkliste aller Sim-Kanäle */
.cyt-simrail {
  position: absolute; right: 6px; top: 52px; bottom: 6px; z-index: 7;
  width: 146px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px; display: flex; flex-direction: column; gap: 1px;
}
.cyt-simrail__item {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 10px; color: var(--muted); padding: 4px 6px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cyt-simrail__item:hover { background: var(--bg); }
.cyt-simrail__item i {
  flex: none; width: 9px; height: 9px; border-radius: 3px;
  border: 1.5px solid transparent; opacity: .35;
}
.cyt-simrail__item.on { color: var(--text); font-weight: 600; }
.cyt-simrail__item.on i { opacity: 1; }
