:root {
  --bg: #f3f5f7; --panel: #ffffff; --ink: #17212b; --muted: #627182; --line: #dde3e9;
  --side: #10202c; --side-ink: #b8c7d3; --side-active: #1c3445;
  --accent: #0b7285; --accent-ink: #ffffff; --accent-soft: #e3f4f7;
  --ok: #1f8a4c; --ok-soft: #e2f4e9; --warn: #b26a00; --warn-soft: #fdf1dc; --bad: #c0392b; --bad-soft: #fbe6e3; --idle: #627182; --idle-soft: #e9edf1;
  --radius: 10px; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d151c; --panel: #15212b; --ink: #e4ebf1; --muted: #90a2b2; --line: #263643;
    --side: #0a1118; --side-ink: #9fb1c0; --side-active: #16283a;
    --accent: #3bb3c6; --accent-ink: #06222a; --accent-soft: #12333b;
    --ok: #4cc27c; --ok-soft: #133022; --warn: #e2a33c; --warn-soft: #3a2c10; --bad: #ef7a6d; --bad-soft: #3d1b17; --idle: #90a2b2; --idle-soft: #1f2d39;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1 { font-size: 21px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 12px; margin: 0 0 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0 0 12px; }
.sub { color: var(--muted); margin-bottom: 20px; }
a { color: var(--accent); }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 20px 16px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: 0.01em; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--side-ink); margin-top: 2px; font-family: var(--mono); }
.nav { flex: 1; padding: 4px 10px; }
.nav button { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 9px 12px; border-radius: 7px; cursor: pointer; margin-bottom: 2px; }
.nav button:hover { background: var(--side-active); color: #fff; }
.nav button.on { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { padding: 14px 20px; border-top: 1px solid #ffffff14; font-size: 12.5px; }
.side-foot .row { display: flex; gap: 8px; margin-top: 8px; }
.side-foot button { background: #ffffff12; border: 0; color: #fff; font: inherit; font-size: 12px; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.side-foot button:hover { background: #ffffff24; }

.main { padding: 28px 32px 80px; max-width: 1280px; width: 100%; min-width: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.big { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 14px; font-size: 13px; margin-top: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.idle { color: var(--idle); background: var(--idle-soft); }

.bar { height: 6px; border-radius: 3px; background: var(--idle-soft); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); white-space: nowrap; }
td.act { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; margin: 0 -8px; }
.empty { color: var(--muted); padding: 22px 10px; text-align: center; }

button.btn, a.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; }
button.btn:hover, a.btn:hover { border-color: var(--accent); color: var(--accent); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
button.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
button.btn.small { padding: 3px 9px; font-size: 12px; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
textarea { font-family: var(--mono); font-size: 12px; min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }

.tip { position: relative; display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: var(--idle-soft); color: var(--muted); font-size: 11px; font-weight: 700; align-items: center; justify-content: center; cursor: help; flex: none; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; left: 22px; top: -6px; z-index: 30; width: 270px; background: var(--side); color: #fff; padding: 9px 11px; border-radius: 7px; font-size: 12px; font-weight: 400; line-height: 1.45; white-space: pre-line; box-shadow: 0 6px 20px #0005; }

.note { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--accent-soft); color: var(--accent); }

.dirty { position: fixed; left: 232px; right: 0; bottom: 0; background: var(--panel); border-top: 2px solid var(--accent); padding: 12px 32px; display: flex; align-items: center; gap: 12px; z-index: 20; box-shadow: 0 -6px 24px #0002; }
.dirty .grow { flex: 1; font-weight: 600; }

.modal { position: fixed; inset: 0; background: #0b141ccc; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 40; overflow-y: auto; }
.modal .box { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; padding: 24px 26px; box-shadow: 0 20px 60px #0006; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 16px; }
.login .box { background: var(--panel); border-radius: 14px; padding: 32px 30px; width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 2px; }

.log { font-family: var(--mono); font-size: 12px; max-height: 480px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .error { color: var(--bad); } .log .warn { color: var(--warn); } .log .debug { color: var(--muted); }
.toast { position: fixed; top: 18px; right: 18px; z-index: 60; padding: 11px 16px; border-radius: 8px; background: var(--side); color: #fff; box-shadow: 0 8px 28px #0005; max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; }
  .side { position: static; height: auto; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { white-space: nowrap; width: auto; }
  .main { padding: 18px 14px 90px; }
  .dirty { left: 0; padding: 10px 14px; }
}
.narrow { max-width: 420px; }
.modal .box.wide { max-width: 1080px; }
.tablewrap.browse { max-height: 50vh; overflow: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.tablewrap.browse th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.tablewrap.browse td { padding: 6px 10px; }
.tree-cell { display: flex; align-items: center; gap: 7px; }
.tree-pad { display: inline-block; flex: none; }
.twisty { width: 22px; height: 22px; padding: 0; flex: none; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); font-size: 11px; cursor: pointer; }
.twisty:hover { border-color: var(--accent); color: var(--accent); }
.strong { font-weight: 600; }
tr.dim td { color: var(--muted); }
select.mini { width: auto; padding: 3px 6px; font-size: 12.5px; }
.hint { color: var(--muted); font-size: 13px; }
.adopt { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.toolbar input.grow { flex: 1; width: auto; min-width: 160px; }
/* ---- Plattform ---- */
.split { display: grid; grid-template-columns: minmax(240px, 330px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }
.tree { font-size: 13.5px; max-height: 72vh; overflow: auto; }
.tree button.node { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.tree button.node:hover { background: var(--idle-soft); }
.tree button.node.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree .cnt { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tree .code { font-family: var(--mono); font-size: 12.5px; }
.tree .lvl { color: var(--muted); font-size: 11px; }
.path { font-family: var(--mono); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--idle-soft); }
tr.sel td { background: var(--accent-soft); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: var(--accent); opacity: 0.14; stroke: none; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart .tt { position: absolute; pointer-events: none; background: var(--side); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -115%); box-shadow: 0 4px 14px #0004; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); color: var(--ink); font: inherit; font-size: 12.5px; padding: 5px 11px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.linkbox { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; overflow-wrap: anywhere; margin-bottom: 12px; user-select: all; }
.tenant-pick button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; }
.tenant-pick button:hover { border-color: var(--accent); }
.brand .tn { display: block; font-weight: 400; font-size: 12.5px; color: var(--side-ink); margin-top: 3px; }
.login .box.widebox { max-width: 520px; }
select.inline { width: auto; max-width: 260px; padding: 4px 8px; font-size: 12.5px; }
td select { max-width: 190px; }
.linkbox { user-select: all; }

/* ---------- R3: Leitstand ---------- */
.grid.tight { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card.stat .big { font-size: 28px; }
.card.stat.alert { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.card.stat.alert .big { color: var(--bad); }
.card.stat.warnc { box-shadow: inset 4px 0 0 var(--warn); }
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--accent); }
.toolbar.filters input[type="search"] { flex: 1 1 260px; min-width: 200px; width: auto; }
.toolbar.filters select { width: auto; min-width: 150px; }
.toolbar.spaced { margin: 12px 0 4px; }
button.btn.on { border-color: var(--accent); color: var(--accent); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.msg { color: var(--muted); font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
td.cb { width: 28px; }
th input[type="checkbox"], td.cb input { width: auto; margin: 0; }
.empty.ok { color: var(--ok); font-weight: 600; }
h2.gap { margin-top: 22px; }
textarea.plain { font-family: inherit; font-size: 14px; min-height: 70px; }

/* Zustand nach ISA-18.2: unquittiert blinkt, quittiert leuchtet, gegangen + unquittiert blinkt grau */
.lamp { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; background: var(--idle); }
tr.alarm td:first-child + td, tr.alarm td:first-child { white-space: nowrap; }
.alarm.s-act-unack .lamp { background: var(--bad); animation: tms-blink 1s steps(2, jump-none) infinite; box-shadow: 0 0 0 3px var(--bad-soft); }
.alarm.s-act-ack .lamp { background: var(--bad); }
.alarm.s-rtn-unack .lamp { background: var(--idle); animation: tms-blink 1s steps(2, jump-none) infinite; }
.alarm.s-shelved .lamp { background: transparent; border: 2px solid var(--idle); }
tr.alarm.s-act-unack td { background: color-mix(in srgb, var(--bad-soft) 55%, transparent); }
tr.alarm.s-act-unack td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
tr.alarm.s-act-ack td:first-child { box-shadow: inset 4px 0 0 color-mix(in srgb, var(--bad) 45%, transparent); }
tr.alarm.s-rtn-unack td:first-child { box-shadow: inset 4px 0 0 var(--idle); }
tr.alarm .st { font-size: 12.5px; font-weight: 600; }
@keyframes tms-blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .alarm .lamp { animation: none !important; } }
.acklist { margin: 0 0 14px; padding-left: 18px; }
.acklist li { margin-bottom: 4px; }
details { border-top: 1px solid var(--line); padding: 8px 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details[open] summary { margin-bottom: 10px; }

/* ---------- R3: Tickets ---------- */
.card.ticket { border-color: var(--accent); }
.card.ticket h2.tt { font-size: 19px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 2px 0 12px; }
.split2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
@media (max-width: 980px) { .split2 { grid-template-columns: 1fr; } }
.desc { background: var(--bg); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.timeline { list-style: none; margin: 0 0 14px; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline .ev { position: relative; padding: 0 0 12px 10px; }
.timeline .ev::before { content: ""; position: absolute; left: -21px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); }
.timeline .ev-comment::before { border-color: var(--accent); }
.timeline .ev-status::before { border-color: var(--ok); }
.timeline .evh { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.pbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.edit { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.overdue { color: var(--bad); font-weight: 600; }
.pname { font-size: 16px; }
@media (max-width: 760px) {
  .grid.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card.stat { padding: 12px 14px; }
  .card.stat .big { font-size: 22px; }
  .toolbar.filters > * { flex: 1 1 100%; min-width: 0; }
  .toolbar.filters .grow { display: none; }
  .modal .box.wide { padding: 18px 16px; }
}
.cols > * { min-width: 0; }
p.mono, .hint.mono { overflow-wrap: anywhere; }
.head > .btn, .head > button { white-space: nowrap; flex: none; }
.note.upsell { border-left: 4px solid var(--accent); } label.check.modrow { align-items: flex-start; font-weight: 400; } label.check.modrow input { margin-top: 3px; width: auto; }
