:root {
  --bg: #0a0c10;
  --panel: #12161d;
  --line: #263041;
  --text: #e8edf4;
  --muted: #8a97a8;
  --ecg: #37f06a;
  --spo2: #2fd7e6;
  --nibp: #f4c542;
  --ibp: #ff6a60;
  --co2: #e6c34a;
  --accent: #4a9eff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* schlaegt Klassen-Regeln mit display */

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- schlichte Seiten (Start, Pairing, Control) ---------- */
.page-plain { padding: env(safe-area-inset-top) 0 0; }

.card {
  max-width: 460px;
  margin: 8vh auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card h1 { margin-top: 0; font-size: 1.3rem; }
.card h2 { font-size: 1rem; margin-bottom: .4rem; }
.card section { margin-top: 1.5rem; }

label { display: block; margin: .6rem 0 .25rem; color: var(--muted); font-size: .85rem; }

input, select, button {
  font: inherit;
  color: var(--text);
}
input[type="number"], input[type="text"], select {
  width: 100%;
  padding: .6rem .7rem;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 8px;
}
button, .btn-secondary {
  display: inline-block;
  margin-top: .8rem;
  padding: .7rem 1.1rem;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn-secondary { background: #23303f; }

/* ---------- Trainer-Pad (qubeCONTROL-Stil, Querformat) ---------- */
body.page-trainer {
  position: fixed; inset: 0; width: 100%; height: 100%;
  overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
.tp {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0a0c10;
  color: var(--text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.tp__top {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 14px;
  background: #12161d;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
}
.tp__app { font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.tp__code { font-weight: 700; font-size: 1rem; letter-spacing: .14em; }
.tp__scn { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp__dev { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tp__clock { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp__conn { color: var(--muted); font-size: .8rem; }
.tp__conn[data-state="online"] { color: var(--ecg); }
.tp__conn[data-state="offline"], .tp__conn[data-state="unknown-session"] { color: #ff6b6b; }
.tp__resus {
  margin: 0; padding: 5px 12px;
  background: #7a1620; border: 1px solid #b33; border-radius: 999px;
  color: #fff; font: inherit; font-weight: 700; font-size: .8rem;
  -webkit-tap-highlight-color: transparent;
}
.tp__resus[aria-pressed="true"] { background: #d33; animation: alarmblink 1.1s steps(1) infinite; }
.tp__pause {
  margin: 0; padding: 5px 12px;
  background: #23303f; border: 1px solid var(--line); border-radius: 999px;
  color: #fff; font: inherit; font-weight: 700; font-size: .8rem;
  -webkit-tap-highlight-color: transparent;
}
.tp__pause[aria-pressed="true"] { background: #b8641f; border-color: #e0a060; }
.tp--paused .tp__body { position: relative; }
.tp--paused .tp__cols::after {
  content: "Szenario pausiert";
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 14, .72);
  color: #e6e9ee; font-size: 1.1rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
}
.tp--paused .tp__cols { position: relative; pointer-events: none; }
.tp__burger {
  display: none; margin: 0; padding: 4px 8px;
  background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.tp__burger .ic { width: 20px; height: 20px; vertical-align: -4px; }

.tp__msgs { list-style: none; margin: 0; padding: 6px 14px; position: absolute; top: 44px; left: 0; right: 0; z-index: 10; }

.tp__body {
  display: grid;
  grid-template-columns: 158px minmax(0, 1fr) 216px;
  min-height: 0;
}

.tp__tools {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.tool { display: flex; flex-direction: column; gap: 4px; }
.tool__k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tool select {
  padding: .5rem .5rem; background: #0c1016; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.tool__hint { font-size: .68rem; color: var(--muted); }
.tp__tools form { margin: 0; }
.tool__btn {
  width: 100%; margin: 0; padding: .58rem .4rem;
  background: #23303f; border: 0; border-radius: 8px;
  color: #fff; font: inherit; font-weight: 600; font-size: .78rem;
  line-height: 1.15;
}
.tool__btn--danger { background: #7a1620; }
.tool__btn--toggle { background: transparent; border: 1px solid var(--line); }
.tool__btn--toggle small { font-weight: 400; opacity: .8; }
.tool__btn--toggle[aria-pressed="true"] { background: #b8641f; border-color: #d88; color: #fff; }

.tool__chips { display: flex; gap: 6px; }
.tool__chip {
  flex: 1; margin: 0; padding: .45rem .3rem;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font: inherit; font-weight: 700; font-size: .74rem;
  -webkit-tap-highlight-color: transparent;
}
.tool__chip[aria-pressed="true"] { background: #1f6b3a; border-color: var(--ecg); color: #fff; }

.side__link {
  display: inline-block; margin: 0;
  color: var(--accent); font-size: .82rem; font-weight: 600;
  text-decoration: none;
}
.side__link:hover { text-decoration: underline; }

.side__resus {
  border: 1px solid #7a1620; border-radius: 10px;
  padding: 10px; background: #1a0f10;
  display: flex; flex-direction: column; gap: 8px;
}
.side__resus-mode { margin: 0; font-weight: 700; color: #f88; font-size: .95rem; }
.side__resus-defi { margin: 0; font-size: .8rem; color: var(--muted); }

.tp__cols {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 14px;
  min-height: 0;
}
.pcol {
  display: grid;
  /* feste Zeilen: Kopf / Ist / Trend / Regler / Zahl -- die Trend-Zeile
     haelt ihre Hoehe auch ohne Chip, damit alle Regler gleich hoch starten */
  grid-template-rows: auto auto 26px minmax(0, 1fr) auto;
  justify-items: center;
  gap: 10px;
  padding: 10px 6px 12px;
  background: #12161d;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 0;
}
.pcol > .pcol__head { grid-row: 1; }
.pcol > .pcol__ist { grid-row: 2; }
.pcol > .pcol__trend { grid-row: 3; }
.pcol > .pcol__slider,
.pcol > .pcol__rr { grid-row: 4; }
.pcol > .pcol__num { grid-row: 5; }
.pcol__head {
  width: 100%; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px; border-radius: 7px;
  border: 1px solid #a33;
  background: #7a1620; color: #fff;
  font-weight: 700; letter-spacing: .05em; font-size: .95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pcol__head[aria-pressed="false"] {
  background: transparent;
  border-color: #6a2530;
  color: #c98;
}
.pcol__head[aria-pressed="true"] { box-shadow: inset 0 0 0 1px #d55; }
.pcol__state { font-size: .58rem; font-weight: 600; letter-spacing: .02em; opacity: .85; }
.pcol__head[aria-pressed="true"] .pcol__state { display: none; }

/* nicht aktivierte Spalte gedämpft */
.pcol--off .pcol__ist b,
.pcol--off .pcol__slider,
.pcol--off .pcol__num,
.pcol--off .pcol__rr { opacity: .4; }

.pcol__ist { text-align: center; line-height: 1.05; }
.pcol__ist b { display: block; font-size: clamp(1.6rem, 4.5vw, 2.5rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.pcol__ist span { font-size: .68rem; color: var(--muted); }
.pcol--hf .pcol__ist b { color: var(--ecg); }
.pcol--spo2 .pcol__ist b { color: var(--spo2); }
.pcol--rr .pcol__ist b { color: var(--nibp); }

/* laufender Trend: Ziel + Restzeit, Tippen bricht ab */
.pcol__trend {
  margin: 0;
  padding: 3px 9px;
  border: 1px solid #6b5a2a;
  border-radius: 999px;
  background: #2a2410;
  color: #e8c766;
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.pcol__trend b { color: #fff; }
.pcol__trend:active { background: #3a3016; }

/* Vertikaler Regler = rotierter Horizontal-Regler (robust auf jedem Browser).
   JS setzt die Breite = Höhe des Containers. */
.pcol__slider { position: relative; align-self: stretch; width: 100%; min-height: 0; }
.vslider {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  width: 160px;               /* wird per JS an die Container-Höhe angepasst */
  height: 46px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: none;
}
.vslider::-webkit-slider-runnable-track {
  height: 18px; border-radius: 9px;
  background: #2c3644;
}
.vslider::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -11px;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: #e3eaf5;
  border: 3px solid var(--thumb, var(--accent));
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.vslider::-moz-range-track { height: 18px; border-radius: 9px; background: #2c3644; }
.vslider::-moz-range-thumb {
  width: 40px; height: 40px; border-radius: 11px;
  background: #e3eaf5; border: 3px solid var(--thumb, var(--accent));
}
.pcol--hf .vslider { --thumb: var(--ecg); }
.pcol--spo2 .vslider { --thumb: var(--spo2); }
.pcol--rr .vslider { --thumb: var(--nibp); }
.pcol--ibp .vslider { --thumb: var(--ibp); }
.pcol--co2 .vslider { --thumb: var(--co2); }
.pcol--ibp .pcol__ist b { color: var(--ibp); }
.pcol--co2 .pcol__ist b { color: var(--co2); }

.pcol__num {
  width: 88px; padding: .45rem; text-align: center;
  background: #0c1016; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 700;
}
.pcol__num--sm { width: 62px; padding: .35rem; font-size: .85rem; }

/* RR-Spalte: zwei schmale Regler (sys | dia) nebeneinander */
.pcol__rr {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  min-height: 0; width: 100%; justify-items: center;
}
.pcol__rr-slot {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center; gap: 6px; min-height: 0;
}
.pcol__rr-k { font-size: .68rem; color: var(--muted); }

.tp__side {
  width: 232px;
  border-left: 1px solid var(--line);
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
  background: #12161d;
}
.side__block { display: flex; flex-direction: column; gap: 2px; }
.side__k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side__code { font-size: 1.5rem; font-weight: 700; letter-spacing: .14em; }
.side__conn { font-size: .95rem; }
.side__conn[data-state="online"] { color: var(--ecg); }
.side__conn[data-state="offline"], .side__conn[data-state="unknown-session"] { color: #ff6b6b; }
.side__pair summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.side__pair img { margin-top: 8px; background: #fff; padding: 6px; border-radius: 8px; max-width: 150px; }
.side__pair a { font-size: .72rem; word-break: break-all; }
.side__note { font-size: .74rem; color: var(--muted); line-height: 1.45; margin: 0; }
.side__note b { color: var(--text); }

/* ---- schmalere Geräte: Seitenleiste als Overlay, Werkzeuge ggf. Reihe ---- */
@media (max-width: 940px) {
  .tp__body { grid-template-columns: 142px minmax(0, 1fr); }
  .tp__burger { display: inline-flex; }
  .tp__side {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
    transform: translateX(100%); transition: transform .2s ease;
    box-shadow: -12px 0 32px rgba(0,0,0,.5);
  }
  .tp__side[data-open] { transform: none; }
}
/* ---- Handy Hochformat: gestapelte Liste mit WAAGERECHTEN Reglern ---- */
@media (max-width: 620px) {
  body.page-trainer { position: static; overflow: auto; height: auto; }
  .tp {
    position: static; inset: auto;
    display: block; min-height: 100%;
  }
  .tp__top { flex-wrap: wrap; gap: 8px 12px; }
  .tp__scn { display: none; }
  .tp__clock { margin-left: auto; }

  .tp__body { display: block; }
  .tp__tools {
    flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .tool { flex: 1 1 44%; }
  .tp__tools form { flex: 1 1 44%; }
  .tp__tools form .tool__btn { height: 100%; }

  .tp__cols { display: flex; flex-direction: column; gap: 10px; padding: 12px; }

  /* Spalte -> flache Karte: Kopf oben, darunter Ist + waagerechter Regler + Zahl */
  .pcol {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 12px;
  }
  .pcol > .pcol__head { grid-column: 1 / -1; grid-row: 1; }
  .pcol > .pcol__ist  { grid-column: 1; grid-row: 2; justify-self: start; text-align: left; display: flex; align-items: baseline; gap: 6px; }
  .pcol__ist b { font-size: 1.7rem; }
  .pcol > .pcol__trend { grid-column: 2; grid-row: 2; justify-self: end; }
  .pcol > .pcol__slider { grid-column: 1; grid-row: 3; }
  .pcol > .pcol__num   { grid-column: 2; grid-row: 3; }
  .pcol > .pcol__rr    { grid-column: 1 / -1; grid-row: 3; }

  .pcol__slider { position: static; align-self: auto; min-height: 0; height: auto; }
  .vslider {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: 40px; min-height: 40px;
    display: block;
  }
  .pcol__num { width: 74px; }

  /* RR / IABP / etCO2: die zwei Sub-Regler untereinander */
  .pcol__rr { grid-template-columns: 1fr; gap: 8px; }
  .pcol__rr-slot { grid-template-columns: 44px 1fr auto; grid-template-rows: auto; align-items: center; gap: 8px; }
  .pcol__rr-slot .pcol__slider { grid-column: 2; }
  .pcol__rr-k { grid-column: 1; }
  .pcol__num--sm { width: 62px; }

  .tp__side { width: 86vw; max-width: 340px; }
}

/* ---------- Monitor (dem Corpuls C3 nachempfunden) ---------- */
/* echtes Vollbild: Seite fixiert, kein Scrollen / Gummiband, kein Doppeltipp-Zoom */
body.page-monitor {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.page-monitor .mon button,
.page-monitor .mon select { touch-action: manipulation; }

/* Monitor nur im Querformat -- im Hochformat Hinweis, Inhalt ausblenden */
.mon__rotate { display: none; }
@media (orientation: portrait) {
  .page-monitor .mon { visibility: hidden; }
  .page-monitor .mon__rotate {
    display: flex; position: fixed; inset: 0; z-index: 500;
    flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: #000; color: #cdd3dc;
    font-size: 1.05rem; text-align: center; padding: 24px;
  }
  .page-monitor .mon__rotate p { margin: 0; max-width: 18ch; }
}

/* ---------- Ein/Aus-Knopf + Boot-/Selbsttest-Screen ---------- */
/* Knopf: eckig, im oberen Rahmen des jeweiligen Skins (position: absolute
   relativ zu .mon bzw. .corpuls__bezel). */
.mon__power {
  position: absolute; top: 8px; right: 8px; z-index: 620;
  width: 54px; height: 44px; margin: 0; padding: 0;
  border-radius: 7px;
  border: 2px solid #2f7d33;
  background: linear-gradient(#54b859, #1e5e22);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 9px rgba(76,175,80,.45), inset 0 1px 2px rgba(255,255,255,.4);
  -webkit-tap-highlight-color: transparent;
}
.mon__power svg { width: 22px; height: 22px; }
.mon__power:active { filter: brightness(.85); }
.mon__power[data-state="off"] {
  border-color: #5a5f66;
  background: linear-gradient(#3a3f47, #1c1f24);
  box-shadow: none;
}
.mon__power[data-state="booting"] { animation: alarmblink 1s steps(1) infinite; }
.page-monitor .mon__status { padding-right: 68px; }

.mon__boot {
  position: absolute; inset: 0; z-index: 560;
  background-color: #FF6800;
  background-image: url("../img/pknm-screensaver.png");
  background-repeat: no-repeat; background-position: center; background-size: contain;
  display: flex; align-items: flex-end; justify-content: center;
}
.mon__boot[hidden] { display: none; }
.mon__boot-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 24px 7%;
}
.mon__boot-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: bootspin .8s linear infinite;
}
@keyframes bootspin { to { transform: rotate(360deg); } }
.mon__boot-txt { margin: 0; color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: .03em; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.mon__boot-bar {
  width: min(280px, 55%); height: 6px; border-radius: 999px;
  background: rgba(255,255,255,.3); overflow: hidden;
}
.mon__boot-bar i { display: block; height: 100%; width: 0%; background: #fff; border-radius: 999px; }

/* Szenario pausiert: dunkles Overlay ueber dem Display */
.mon__paused {
  position: absolute; inset: 0; z-index: 545;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 10, .86);
  color: #e6e9ee;
}
.mon__paused[hidden] { display: none; }
.mon__paused p {
  margin: 0; font-size: clamp(1.3rem, 3.4vw, 2rem); font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
}

/* Ausgeschaltet / im Selbsttest: PKNM-Skin (Vollbild) schwarz, nur der Knopf bleibt.
   (corpuls³ behaelt das Gehaeuse -- Regeln dazu in corpuls3.css) */
.page-monitor.is-off .mon:not(.corpuls) > *:not(.mon__power),
.page-monitor.is-booting .mon:not(.corpuls) > *:not(.mon__power):not(.mon__boot) { visibility: hidden; }
.page-monitor.is-off .mon:not(.corpuls) { background: #000; }

.mon {
  position: fixed;
  inset: 0;
  display: grid;
  /* feste Zeilen: Status / Alarmbalken / Parameter / Kurven / Softkeys --
     explizite grid-row je Kind, damit ein ausgeblendeter Alarmbalken die
     Kurvenzeile nicht aus dem 1fr-Track schiebt */
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.mon__status { grid-row: 1; }
.mon__alarmbar { grid-row: 2; }
.mon__params { grid-row: 3; }
.mon__main { grid-row: 4; }
.mon__softkeys { grid-row: 5; }

/* --- Farbschemata: Tag (hell) / Nacht (dunkel), wie am echten Geraet --- */
.mon[data-theme="day"] {
  --bg: #c7ccd1;
  --panel: #eceef1;
  --line: #9aa4af;
  --text: #16181c;
  --muted: #59636f;
  --grid: rgba(0, 0, 0, 0.10);
  --hf: #0a8f3c;
  --ecg-trace: #16181a;
  --spo2: #10788b;
  --pleth-trace: #46409a;
  --nibd: #b83220;
  --co2: #b07d10;
  --co2-trace: #a9791b;
  --sk-bg: #2f2f63;
  --sk-text: #f2f3f8;
  --sk-line: #45457e;
}
.mon[data-theme="night"] {
  --bg: #000;
  --panel: #14181f;
  --line: #2b3340;
  --text: #e8edf4;
  --muted: #808c9d;
  --grid: rgba(255, 255, 255, 0.06);
  --hf: #3bf06e;
  --ecg-trace: #3bf06e;
  --spo2: #33d9e8;
  --pleth-trace: #33d9e8;
  --nibd: #ff6a60;
  --co2: #e6c34a;
  --co2-trace: #e6c34a;
  --sk-bg: #12163a;
  --sk-text: #dbe3f1;
  --sk-line: #2a2f5a;
}

.ic {
  width: 1.05em; height: 1.05em;
  display: inline-block;
  vertical-align: -0.17em;
  flex: none;
}

.mon__status {
  display: flex;
  align-items: center;
  gap: 14px;
  /* feste Hoehe: der erst bei Alarm eingeblendete "Quittieren"-Knopf ist etwas
     hoeher als der uebrige Text -- ohne feste Hoehe wuerde die Statuszeile beim
     Alarm um ~2 px wachsen, die Kurvenzeile schrumpfen und die Canvas-Engines
     per ResizeObserver links neu starten. */
  height: 2rem;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
}
.mon__patient { font-weight: 700; letter-spacing: .08em; }
.mon__batt, .mon__clock { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mon__clock { margin: 0 auto; letter-spacing: .04em; color: var(--text); }
.mon__ack {
  margin: 0;
  padding: 3px 12px;
  border: 1px solid var(--nibd);
  border-radius: 999px;
  background: transparent;
  color: var(--nibd);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.mon__ack:not([hidden]) { display: inline-flex; }
.mon__ack.is-active { background: var(--nibd); color: #fff; animation: alarmblink 1s steps(1) infinite; }
.mon__conn { color: var(--muted); }
.mon__conn[data-state="online"] { color: var(--hf); }
.mon__conn[data-state="offline"],
.mon__conn[data-state="unknown-session"] { color: var(--nibd); }

.mon__params {
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.par {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 4px 16px;
  border-right: 1px solid var(--line);
}
button.par {
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.par:active { background: color-mix(in srgb, var(--text) 6%, var(--panel)); }
.par__label { grid-row: 1; grid-column: 1; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.par__unit { grid-row: 2; grid-column: 1; font-size: .66rem; color: var(--muted); }
.par__val {
  grid-row: 1 / span 2; grid-column: 2;
  font-size: clamp(1.9rem, 6.5vw, 3.4rem);
  font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 2.6ch; text-align: right;
}
.par__lim { grid-row: 1 / span 2; grid-column: 3; display: flex; flex-direction: column; font-size: .6rem; color: var(--muted); line-height: 1.4; }
.par__sub { grid-row: 1 / span 2; grid-column: 2; font-size: 1rem; color: var(--muted); text-align: left; padding-left: 4px; }
.par--hf .par__val { color: var(--hf); }
.par--spo2 .par__val { color: var(--spo2); }
.par--pp .par__val { color: var(--hf); }
.mon__params > *:last-child { border-right: 0; }

/* IBP / etCO2: schlankere gestapelte Box (Label / grosse Zahl / Zusatz) */
.par--ibp, .par--co2 {
  display: flex; flex-direction: column; justify-content: center;
  gap: 1px; row-gap: 0;
  padding: 4px 12px;
}
.par--ibp .par__val, .par--co2 .par__val {
  min-width: 0; text-align: left;
  font-size: clamp(1.3rem, 3.4vw, 2rem);
}
.par--ibp .par__val { color: var(--nibd); }
.par--co2 .par__val { color: var(--co2); }
.par--ibp .par__sub, .par--co2 .par__sub {
  padding-left: 0; text-align: left;
  font-size: .74rem; color: var(--muted);
}
.par--ibp .par__unit, .par--co2 .par__unit { font-size: .62rem; }
.par--ibp .par__lim, .par--co2 .par__lim {
  flex-direction: row; gap: 5px;
  font-size: .58rem;
}

/* Alarm: Wert ausserhalb der Grenzen -- Farbe nach Priorität */
@keyframes alarmblink { 50% { opacity: .4; } }
.par.is-alarm--niedrig { background: color-mix(in srgb, #e6b400 20%, var(--panel)); }
.par.is-alarm--niedrig .par__val { color: #b8860b; animation: alarmblink 1.4s steps(1) infinite; }
.par.is-alarm--hoch { background: color-mix(in srgb, var(--nibd) 20%, var(--panel)); }
.par.is-alarm--hoch .par__val { color: var(--nibd); animation: alarmblink .6s steps(1) infinite; }
.nibd.is-alarm--niedrig .nibd__title { color: #b8860b; }
.nibd.is-alarm--hoch { animation: alarmblink .6s steps(1) infinite; }

/* Alarmbalken unter der Statusleiste.
   Feste Hoehe, immer im Layout -- der Balken erscheint/verschwindet nur ueber
   Hintergrund/Text, ohne die Kurvenzeile zu verkleinern. Sonst wuerde der
   ResizeObserver der Canvas-Engines feuern und die Kurven links neu starten. */
.mon__alarmbar {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 1.9rem;
  padding: 0 12px;
  overflow: hidden;
  font-weight: 800; font-size: 1rem; line-height: 1.2; letter-spacing: .04em;
  text-transform: uppercase;
  color: transparent;
}
/* Ruhezustand: unsichtbar, verschmilzt optisch mit der Statuszeile darueber */
.mon__alarmbar:not(.is-active) { background: var(--panel); pointer-events: none; }
.mon__alarmbar--hoch.is-active { background: #c62828; color: #fff; animation: alarmblink .6s steps(1) infinite; }
.mon__alarmbar--niedrig.is-active { background: #e6b400; color: #1a1a1a; animation: alarmblink 1.4s steps(1) infinite; }
.mon__alarmbar.is-acked { animation: none; opacity: .9; }
.mon__alarmbar-more { font-size: .8rem; opacity: .85; }

/* Alarmpause-Chip in der Statusleiste */
.mon__pause {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px;
  background: #e6b400; color: #1a1a1a;
  font-size: .78rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mon__pause[hidden] { display: none; }

.nibd__edit {
  margin: 0; padding: 2px 5px;
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); line-height: 1;
}
.nibd__edit .ic { width: .9em; height: .9em; }

.mon__main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(150px, 23vw, 268px);
  min-height: 0;
}
.mon__waves {
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  min-width: 0;
  border-right: 1px solid var(--line);
}
.trace {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.trace[hidden] { display: none; }
.mon__waves .trace:last-of-type { border-bottom: 0; }
.trace__gutter {
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.trace__tag {
  display: flex; justify-content: center;
  padding-top: 4px;
  font-size: .7rem; font-weight: 700;
}
.trace--ecg .trace__tag { color: var(--hf); }
.trace--pleth .trace__tag { color: var(--spo2); }
.trace--ibp .trace__tag { color: var(--nibd); }
.trace--co2 .trace__tag { color: var(--co2); }

/* kleine Skala links neben der Kurve (Ticks per --y = Bruchteil der Höhe) */
.trace__scale {
  position: relative;
  flex: 1; min-height: 0;
  margin: 4px 0 4px 2px;
}
.trace__scale-u {
  position: absolute; top: -1px; right: 3px;
  font-size: .46rem; font-weight: 400; color: var(--muted);
}
.trace__scale i {
  position: absolute; right: 0; top: var(--y);
  width: 5px; border-top: 1px solid var(--muted);
}
.trace__scale i em {
  position: absolute; right: 6px; top: -0.62em;
  font-size: .5rem; font-style: normal; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.wave {
  position: relative;
  min-height: 0;
  background-color: var(--bg);
}
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave__note {
  position: absolute;
  top: 3px; left: 6px;
  z-index: 1;
  font-size: .72rem;
  color: var(--hf);
  font-weight: 600;
  pointer-events: none;
}
.wave__note[hidden] { display: none; }
.wave__off {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  color: var(--muted); font-size: .95rem; letter-spacing: .03em;
  pointer-events: none;
}
.wave__off[hidden] { display: none; }
.nibd__off {
  margin-top: 6px;
  font-size: .78rem; color: var(--muted);
}
.nibd__off:not([hidden]) { display: block; }

.mon__side {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.nibd {
  grid-row: 1;
  display: flex; flex-direction: column;
  padding: 6px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.nibd__head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px; margin-bottom: 3px;
}
.nibd__title { font-size: .8rem; font-weight: 700; color: var(--nibd); letter-spacing: .04em; }
.nibd__unit { font-size: .64rem; color: var(--muted); }
.nibd__row {
  display: grid;
  grid-template-columns: 3em 1fr;
  align-items: baseline;
  column-gap: 8px;
  padding: 7px 0;
}
.nibd__k { font-size: .86rem; color: var(--muted); }
.nibd__v {
  text-align: right;
  font-size: clamp(1.7rem, 4.8vw, 2.8rem);
  font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--nibd);
}
.nibd__next { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 4px; }
.nibd__next:not([hidden]) { display: inline-flex; align-items: center; gap: 4px; }
.clockbox__k { display: inline-flex; align-items: center; gap: 5px; }

.nibd.is-measuring { opacity: .18; }
.nibd--measuring {
  position: absolute;
  inset: 0 0 auto 0;
  min-height: 46%;
  z-index: 3;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  padding: 18px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.nibd--measuring .nibd__press {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--nibd);
  animation: pulse 1s ease-in-out infinite;
}
.nibd__hint { font-size: .78rem; color: var(--muted); }
.nibd--measuring:not([hidden]) { display: flex; }
@keyframes pulse { 50% { opacity: .45; } }

.clockbox {
  grid-row: 3;
  display: flex; flex-direction: column;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
}
.clockbox__k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.clockbox__v { font-size: clamp(1.2rem, 3.2vw, 1.8rem); font-weight: 700; font-variant-numeric: tabular-nums; }

.mon__softkeys {
  display: flex;
  align-items: stretch;
  gap: 1px;
  background: var(--sk-line);
}
.sk {
  margin: 0; border: 0; border-radius: 0;
  padding: .6rem 1rem;
  background: var(--sk-bg);
  color: var(--sk-text);
  font-size: .82rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.sk--sel select {
  background: transparent; border: 0;
  color: var(--sk-text); font: inherit; font-weight: 700;
}
.sk--sel select option { color: #000; }
.sk__spacer { flex: 1; background: var(--sk-bg); }
.sk[aria-pressed="true"] { color: var(--hf); }
.sk:disabled, .sk--sel:has(select:disabled) { opacity: .38; }
.sk--sel select:disabled { color: var(--sk-text); }

/* Reanimation / Defi -- ueberlagert die rechte Spalte */
.resus {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: clamp(150px, 23vw, 268px);
  z-index: 8;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-left: 2px solid var(--nibd);
  overflow-y: auto;
}
.resus[hidden] { display: none; }
.resus__head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-weight: 800; letter-spacing: .05em; color: var(--nibd);
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
.resus__step { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.resus__step[hidden] { display: none; }
.resus__prompt { margin: 12px 0 4px; font-size: 1.15rem; font-weight: 800; text-align: center; }
.resus__hint { margin: 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }
.resus__aed-msg { margin: 6px 0; font-size: .95rem; font-weight: 700; min-height: 2.6em; }
.resus__btn {
  margin: 0; padding: .7rem .6rem;
  background: #23303f; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font: inherit; font-weight: 700; font-size: .9rem;
}
.resus__btn[aria-pressed="true"] { background: #1f6b3a; border-color: var(--hf); }
.resus__btn--shock { background: #b3241c; border-color: #f55; color: #fff; font-size: 1.05rem; animation: alarmblink 1s steps(1) infinite; }
.resus__charge {
  position: relative;
  height: 20px; border-radius: 6px;
  background: #23303f; border: 1px solid var(--line);
  overflow: hidden;
}
.resus__charge[hidden] { display: none; }
.resus__charge > i {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  background: var(--nibd);
  transition: width .08s linear;
}
.resus__charge > span {
  position: relative;
  display: block; text-align: center; line-height: 20px;
  font-size: .74rem; font-weight: 700; color: #fff;
  mix-blend-mode: difference;
}
.resus__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.resus__step-btn {
  margin: 0; width: 44px; height: 44px; border-radius: 9px;
  background: #23303f; border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 1.3rem; font-weight: 700;
}
.resus__energy { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.resus__end {
  margin: 0; margin-top: auto; padding: .55rem;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font: inherit; font-size: .82rem;
}

.mon__shockflash {
  position: fixed; inset: 0; z-index: 40;
  background: #fff;
  animation: shockfade .26s ease-out;
}
.mon__shockflash[hidden] { display: none; }
@keyframes shockfade { from { opacity: .9; } to { opacity: 0; } }

.mon__conn-toast {
  position: fixed;
  top: calc(34px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--nibd);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: .85rem; font-weight: 600;
}
.mon__conn-toast:not([hidden]) { display: block; }
.mon__ended {
  position: fixed; inset: 0; z-index: 20;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.9); color: #fff;
  text-align: center;
}
.mon__ended:not([hidden]) { display: flex; }

/* Alarmgrenzen-Dialog */
.alarmdlg {
  position: fixed; inset: 0; z-index: 25;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
.alarmdlg:not([hidden]) { display: flex; }
.alarmdlg__box {
  width: min(340px, 88vw);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px 16px;
}
.alarmdlg__title { margin: 0 0 12px; font-size: 1.05rem; }
.alarmdlg__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 10px 0;
  font-size: .95rem;
}
.alarmdlg__row input {
  width: 96px; padding: .5rem .6rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; text-align: right;
}
.alarmdlg__auto {
  width: 100%; margin: 6px 0 4px;
  padding: .55rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit;
}
.alarmdlg__pgroup {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center; gap: 8px;
  margin: 8px 0;
}
.alarmdlg__plabel { font-size: .9rem; font-weight: 600; }
.alarmdlg__pgroup label { display: flex; align-items: center; gap: 5px; margin: 0; font-size: .72rem; color: var(--muted); }
.alarmdlg__pgroup input {
  width: 66px; padding: .4rem .5rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; text-align: right;
}
.alarmdlg__row--prio { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.alarmdlg__row--prio select {
  padding: .45rem .5rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.alarmdlg__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.alarmdlg__actions button { margin: 0; }
.mon__ended-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.mon__ended-code { font-size: 1.1rem; color: #9aa; letter-spacing: .15em; margin: .3rem 0 0; }

/* ---------- Flash-Messages ---------- */
.messages {
  list-style: none; margin: 0;
  position: fixed; top: 8px; left: 0; right: 0; z-index: 50;
  padding: 0 16px; pointer-events: none;
}
.message {
  max-width: 460px;
  margin: 0 auto 8px;
  padding: .6rem .9rem;
  border-radius: 8px;
  background: #23303f;
  border-left: 3px solid var(--accent);
  font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.message--success { border-left-color: var(--ecg); }
.message--error { border-left-color: #ff6b6b; }

/* ---------- Start: laufende Sessions ---------- */
.session-list { list-style: none; margin: 0; padding: 0; }
.session-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.session-list__meta { color: var(--muted); font-size: .8rem; flex: 1; }
.btn-link {
  margin: 0;
  padding: .3rem .5rem;
  background: none;
  color: #ff8a8a;
  font-weight: 400;
  font-size: .85rem;
}

/* ---------- Control: Session-Aktionen ---------- */
.ctl-group--session { border-top: 1px solid var(--line); padding-top: 1rem; }
.ctl-row--actions { gap: 14px; flex-wrap: wrap; }
.ctl-row--actions form { margin: 0; }
.ctl-row--actions button { margin: 0; }
.btn-danger { background: #7a1620; }

/* ---------- Debriefing-Protokoll ---------- */
.prot {
  max-width: 960px;
  margin: 4vh auto;
  padding: 0 20px 40px;
}
.prot__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px;
}
.prot__head h1 { margin: 0 0 4px; font-size: 1.3rem; }
.prot__meta { margin: 0; color: var(--muted); font-size: .85rem; }
.prot__desc { margin: 8px 0 0; font-size: .9rem; }
.prot__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.prot__actions button, .prot__actions .btn-secondary { margin: 0; }
.prot__back { color: var(--muted); font-size: .85rem; text-decoration: none; }
.prot__table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.prot__table th {
  text-align: left; padding: 6px 10px; color: var(--muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
.prot__table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prot__t { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.prot__art { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.prot__detail { color: var(--text); }
.prot__row--vitalwerte { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.prot__row--aktion td:nth-child(3) { font-weight: 700; }
.prot__empty { color: var(--muted); }

@media print {
  html, body { background: #fff; color: #000; }
  .messages, .prot__actions { display: none !important; }
  .prot { margin: 0; max-width: none; }
  .prot__table th, .prot__table td { border-color: #999; }
  .prot__row--vitalwerte { background: #f0f0f0; }
  .prot__meta, .prot__art, .prot__t { color: #333; }
}
