/* ---------- Farben ---------- */
:root {
  --bg: #f3f5f8;
  --stage: #eef1f5;
  --grid: #d9dfe8;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceff3;
  --border: #d7dde5;
  --text: #19202c;
  --muted: #677385;
  --accent: #2563eb;
  --accent-soft: #e0e9ff;
  --accent-text: #ffffff;
  --link: #8b97a9;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #c2700a;
  --rack: #232833;
  --rack-2: #2f3542;
  --unit: #3a4252;
  --unit-text: #eef1f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --stage: #13171e; --grid: #1f2530; --surface: #181c24; --surface-2: #1f242e; --surface-3: #262c37;
    --border: #2e3644; --text: #e6e9ef; --muted: #96a1b4; --accent: #5b93ff; --accent-soft: #1c2a47; --accent-text: #0b1220;
    --link: #566275; --ok: #22c55e; --bad: #f87171; --warn: #fbbf24; --rack: #0b0d12; --rack-2: #171b23; --unit: #252b37; --unit-text: #e6e9ef;
    --shadow: 0 1px 3px rgba(0, 0, 0, .45); --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1218; --stage: #13171e; --grid: #1f2530; --surface: #181c24; --surface-2: #1f242e; --surface-3: #262c37;
  --border: #2e3644; --text: #e6e9ef; --muted: #96a1b4; --accent: #5b93ff; --accent-soft: #1c2a47; --accent-text: #0b1220;
  --link: #566275; --ok: #22c55e; --bad: #f87171; --warn: #fbbf24; --rack: #0b0d12; --rack-2: #171b23; --unit: #252b37; --unit-text: #e6e9ef;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45); --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Grundlagen ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.ghost { background: transparent; border-style: dashed; color: var(--muted); }
button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.icon-btn { padding: 4px 9px; min-width: 32px; }
.muted { color: var(--muted); }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand h1 { font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #8b5cf6); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent); }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .5; }
.conn.on { background: var(--ok); opacity: 1; animation: pulse 2.4s ease-in-out infinite; }
.tabs { display: flex; gap: 3px; background: var(--surface-3); padding: 3px; border-radius: 10px; position: relative; }
.tabs button { border: 0; background: transparent; padding: 5px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search-wrap { flex: 1 1 200px; min-width: 150px; max-width: 420px; position: relative; display: flex; }
.search-wrap input { width: 100%; padding: 6px 70px 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.kbd-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); padding: 1px 7px; font-size: 11px; color: var(--muted); background: var(--surface); }
.kbd-btn:active { transform: translateY(-50%); }
.tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.save-state { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 6px; min-width: 110px; text-align: left; }
.save-state.dirty { color: var(--warn); }
.save-state.busy { color: var(--accent); }
.save-state.error { color: var(--bad); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; animation: pop .14s ease-out;
}
.menu[hidden] { display: none; }
.menu button { border: 0; text-align: left; padding: 7px 10px; background: transparent; }
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }

/* ---------- Bühne ---------- */
main { flex: 1; display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; }
.view { position: absolute; inset: 0; opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .22s ease, transform .22s ease, visibility 0s .22s; }
.view.active { opacity: 1; visibility: visible; transform: none; transition: opacity .22s ease, transform .22s ease; }
#view-topology { background-color: var(--stage); background-image: radial-gradient(var(--grid) 1px, transparent 1px); background-size: 22px 22px; }
#view-rack, #view-list { overflow: auto; background: var(--stage); }

/* ---------- Topologie ---------- */
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
#map.panning { cursor: grabbing; }
body.linking #map { cursor: crosshair; }
.node { cursor: pointer; }
.node .inner { transition: transform .18s ease; transform-box: fill-box; transform-origin: center; }
.node:hover .inner { transform: translateY(-2px); }
.node.dragging .inner { transform: scale(1.04); }
.node.dragging .card { filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25)); }
.node .card { fill: var(--surface); stroke: var(--border); stroke-width: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .12)); transition: stroke .15s; }
.node:hover .card { stroke: var(--accent); }
.node.selected .card { stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 55%, transparent)); }
.node.link-source .card { stroke: var(--accent); stroke-dasharray: 5 3; stroke-width: 2.5; animation: march 1s linear infinite; }
.node.match .card { stroke: var(--warn); stroke-width: 2.5; }
.node.dim { opacity: .18; }
.node.st-down .card { stroke: color-mix(in srgb, var(--bad) 70%, var(--border)); stroke-dasharray: 5 3; }
.node.st-down .label { fill: var(--muted); }
.node .icon { font-size: 20px; }
.node .label { fill: var(--text); font-size: 13px; font-weight: 600; }
.node .sub { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.node .badge { fill: var(--muted); font-size: 10px; }
.node .dot { fill: var(--muted); }
.node.st-up .dot { fill: var(--ok); }
.node.st-down .dot { fill: var(--bad); animation: blink 1.6s ease-in-out infinite; }
.node .ring { fill: none; stroke: var(--ok); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: ring 2.4s ease-out infinite; }
.node .inner.enter { animation: enter .5s cubic-bezier(.2, .9, .3, 1.2) both; }
#map.focus .node:not(.hl) { opacity: .35; }
#map.focus .link:not(.hl) { opacity: .15; }
#map.focus .link.hl .line { stroke: var(--accent); stroke-width: 2.4; }
.node, .link { transition: opacity .2s; }

.link { cursor: pointer; }
.link .line { fill: none; stroke: var(--link); stroke-width: 1.6; transition: stroke .15s; }
.link.wan .line { stroke-width: 3; }
.link.wifi .line { stroke-dasharray: 6 5; }
.link.virtual .line { stroke-dasharray: 2 4; stroke-linecap: round; }
.link.flow .line { stroke-dasharray: 6 6; animation: flow 1.4s linear infinite; }
.link.flow.wan .line { stroke-dasharray: 12 8; stroke: var(--accent); animation-duration: 1.8s; }
.link.flow.wifi .line { stroke-dasharray: 3 7; animation-duration: 1.1s; }
.link.flow.virtual .line { stroke-dasharray: 2 4; animation-duration: 2.2s; }
.link.down .line { stroke: color-mix(in srgb, var(--bad) 55%, var(--link)); animation: none; }
.link .hit { fill: none; stroke: transparent; stroke-width: 14; }
.link:hover .line { stroke: var(--accent); }
.link.selected .line { stroke: var(--accent); stroke-width: 3; }
.link.dim { opacity: .12; }
.link .lbl-bg { fill: var(--stage); }
.link .lbl { fill: var(--muted); font-size: 10.5px; }

.room rect { fill-opacity: .06; stroke-opacity: .35; stroke-width: 1.2; stroke-dasharray: 6 4; }
.room text { font-size: 12px; font-weight: 600; opacity: .8; }

.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--accent); color: var(--accent-text); padding: 6px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: drop .25s ease-out; max-width: calc(100% - 32px); text-align: center;
}
.hint[hidden] { display: none; }
.hint { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.hint .hint-btn { background: rgba(255, 255, 255, .18); color: inherit; border: 1px solid rgba(255, 255, 255, .45); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.hint .hint-btn:hover { background: rgba(255, 255, 255, .3); }
.legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 260px); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; box-shadow: var(--shadow);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip .dot.live { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
.chip.off { opacity: .45; text-decoration: line-through; }
.chip.static { cursor: default; }
.zoom { position: absolute; right: 12px; bottom: 122px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 34px; height: 34px; padding: 0; font-size: 16px; box-shadow: var(--shadow); }
.minimap {
  position: absolute; right: 12px; bottom: 12px; width: 160px; height: 100px; border-radius: 10px; overflow: hidden;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow); cursor: crosshair;
}
.mm-node { fill: var(--link); }
.mm-node.mm-up { fill: var(--ok); }
.mm-node.mm-down { fill: var(--bad); }
.mm-view { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 1.4; }

/* ---------- Seitenleiste ---------- */
.panel {
  width: 380px; flex: none; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain;
}
.panel-body { padding: 16px; }
.panel-body.swap { animation: slidein .24s ease-out; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.panel h4 { font-size: 12px; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }
.sheet-hd { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.sheet-hd .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 21px; flex: none; }
.sheet-hd b { font-size: 16px; display: block; word-break: break-word; }
.sheet-hd small { color: var(--muted); display: block; }
.status-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-top: 4px; color: var(--muted); }
.status-line small { color: var(--muted); }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.st-up .sdot, .sdot.on, .svc.up .sdot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: halo 2.2s ease-out infinite; }
.st-down .sdot, .svc.down .sdot { background: var(--bad); }
.status-line.st-up { color: var(--ok); }
.status-line.st-down { color: var(--bad); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.svc-list { list-style: none; padding: 0; margin: 6px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.svc { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); font-size: 12px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
a.svc { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
a.svc:hover { transform: translateY(-1px); border-color: var(--accent); }
.svc .sdot { width: 6px; height: 6px; }

.sec { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); overflow: hidden; }
.sec summary { list-style: none; cursor: pointer; padding: 10px 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; user-select: none; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary small { color: var(--muted); font-weight: 500; font-size: 11.5px; background: var(--surface-3); padding: 0 7px; border-radius: 999px; }
.sec summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.sec[open] summary::after { transform: rotate(-135deg); }
.sec[open] summary { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sec-body { padding: 12px; }
.sec[open] .sec-body { animation: fold .2s ease-out; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; min-width: 0; }
.grid2 .field, .grid3 .field { margin-bottom: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 11.5px; color: var(--muted); }
.field input, .field select, .field textarea, .rows input, .rows select, .gen input, .gen select {
  width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .rows input:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 54px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 6px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint-text { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }
.rows { display: flex; flex-direction: column; gap: 5px; }
.row-ed { display: grid; gap: 5px; align-items: center; animation: fold .18s ease-out; }
.row-ed .icon-btn { padding: 2px 0; min-width: 0; height: 30px; }
.mini-check { display: flex; align-items: center; gap: 2px; font-size: 12px; justify-content: center; cursor: pointer; }
.mini-check input { width: 14px; height: 14px; accent-color: var(--accent); }
.gen { display: grid; grid-template-columns: 64px 1fr 1fr auto; gap: 5px; margin-bottom: 8px; }
.ports-ed .rows { max-height: 260px; overflow-y: auto; padding-right: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.conn-list { list-style: none; padding: 0; margin: 0 0 6px; }
.conn-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; transition: background .15s; }
.conn-list li:hover { background: var(--surface-2); color: var(--accent); }
.conn-list small { color: var(--muted); white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .15); }
.rack-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.live-info { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; margin-bottom: 12px; flex-wrap: wrap; }
.live-info small { color: var(--muted); }
.net-row { display: grid; grid-template-columns: 32px 1fr 1fr 52px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.net-row input { padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); min-width: 0; }
.net-row input[type="color"] { padding: 0; height: 30px; width: 32px; }
.keys { color: var(--muted); font-size: 12.5px; line-height: 2; }
.checklist { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.swatch { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.1); }
.trace { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px; border: 1px dashed var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, transparent); font-size: 12.5px; }
.trace .step { padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; animation: pop .25s ease-out both; }
.trace .step.cable { border: 2px solid var(--c); }
.trace .step.port { font-weight: 600; }
.trace .step.jack { cursor: default; }
.trace .arrow { color: var(--muted); }

/* ---------- Rack ---------- */
.rack-bar { display: flex; gap: 10px; align-items: center; padding: 10px 16px; flex-wrap: wrap; position: sticky; top: 0; z-index: 3; background: color-mix(in srgb, var(--stage) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.seg { display: flex; gap: 3px; background: var(--surface-3); padding: 3px; border-radius: 10px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 7px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.cable-tools { display: flex; align-items: center; gap: 5px; font-size: 12px; flex-wrap: wrap; }
.cable-tools .swatch { width: 18px; height: 18px; }
.cable-tools select { padding: 3px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.rack-main { display: flex; gap: 20px; padding: 18px 16px 40px; align-items: flex-start; }
.rack-canvas { flex: 1 1 auto; min-width: 0; overflow-x: auto; padding-bottom: 6px; }
.rack-frame-wrap { display: flex; flex-direction: column; gap: 8px; width: max-content; margin: 0 auto; }
.rack-frame-wrap.enter { animation: enter .4s ease-out both; }
.led.st-unknown { display: none; }
.rack-title { display: flex; gap: 10px; align-items: baseline; }
.rack-svg { display: block; flex: none; user-select: none; touch-action: none; filter: drop-shadow(0 14px 30px rgba(0, 0, 0, .22)); }
.rk-frame { fill: var(--rack); }
.rk-inner { fill: #0c0e13; }
.rail { fill: var(--rack-2); }
.rk-num { fill: #7f8899; font: 10px ui-monospace, monospace; }
.slot { fill: transparent; stroke: rgba(255, 255, 255, .05); cursor: copy; transition: fill .15s; }
.slot:hover { fill: rgba(91, 147, 255, .12); stroke: rgba(91, 147, 255, .5); stroke-dasharray: 4 3; }
.slot.selected { fill: rgba(91, 147, 255, .18); stroke: #5b93ff; stroke-dasharray: 4 3; }
.item { cursor: grab; }
.item .body { fill: var(--unit); stroke: rgba(255, 255, 255, .08); transition: stroke .15s; }
.item:hover .body { stroke: #5b93ff; }
.item.selected .body { stroke: #5b93ff; stroke-width: 2; filter: drop-shadow(0 0 8px rgba(91, 147, 255, .6)); }
.item.bad .body { stroke: #f87171; stroke-width: 2; }
.item.rear { opacity: .55; }
.item.kind-patchpanel .body { fill: #2b313d; }
.item.kind-blank .body, .item.kind-cablemgmt .body { fill: #1d222b; }
.item.kind-shelf .body { fill: rgba(255, 255, 255, .03); stroke-dasharray: 4 3; }
.item.kind-ups .body { fill: #2a2f22; }
.item.kind-pdu .body { fill: #2d2525; }
.brush { fill: #2a303b; }
.vent { stroke: #2c323d; stroke-width: 2; stroke-linecap: round; }
.shelf-plate { stroke: #7b8496; stroke-width: 3; stroke-linecap: round; }
.slot-node rect { fill: #3b4352; stroke: rgba(255, 255, 255, .1); cursor: pointer; }
.slot-node:hover rect, .slot-node.selected rect { stroke: #5b93ff; }
.it-icon { font-size: 13px; }
.it-label { fill: var(--unit-text); font-size: 11.5px; font-weight: 600; pointer-events: none; }
.it-sub { fill: #a3acbd; font-size: 9.5px; pointer-events: none; }
.it-sub.strong { fill: var(--unit-text); font-weight: 600; }
.it-hint { fill: #7f8899; font-size: 10px; font-style: italic; pointer-events: none; }
.led { fill: #6b7280; }
.led.st-up { fill: #22c55e; animation: blink 2s ease-in-out infinite; }
.led.st-down { fill: #ef4444; }
.port { fill: #08090c; stroke: #5d6678; stroke-width: .8; cursor: crosshair; transition: stroke .12s, fill .12s; }
.port:hover { stroke: #fff; stroke-width: 1.4; }
.port.k-sfp, .port.k-sfpp { stroke: #a78bfa; }
.port.k-power { stroke: #f59e0b; }
.port.used { stroke: #9aa3b2; fill: #1b1f27; }
.port.live { stroke: #22c55e; }
.port.bad { stroke: #ef4444; stroke-width: 1.6; }
.port.selected { stroke: #5b93ff; stroke-width: 2; fill: #5b93ff; }
.cables .cable { fill: none; stroke-width: 2.6; stroke-linecap: round; opacity: .92; pointer-events: none; transition: opacity .15s, stroke-width .15s; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.cables .cable-hit { fill: none; stroke: transparent; stroke-width: 10; cursor: pointer; }
.cables:hover .cable { opacity: .3; }
.cables .cable-g:hover .cable { opacity: 1; stroke-width: 3.6; }
.cables .cable.selected { opacity: 1; stroke-width: 4; animation: cableGlow 1.6s ease-in-out infinite; }
.cable.stub { stroke-dasharray: 3 2; }
.cable.temp { fill: none; stroke-width: 3; stroke-dasharray: 6 4; animation: flow .8s linear infinite; pointer-events: none; }
.ghost { pointer-events: none; stroke-width: 2; stroke-dasharray: 5 3; }
.ghost.ok { fill: rgba(34, 197, 94, .18); stroke: #22c55e; }
.ghost.no { fill: rgba(239, 68, 68, .18); stroke: #ef4444; }
.rack-side { flex: 0 0 340px; min-width: 0; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 64px; max-height: calc(100vh - 140px); overflow-y: auto; }
.zoom-seg button { min-width: 32px; }
.zoom-seg #rack-zoom { min-width: 58px; font-variant-numeric: tabular-nums; }
@media (max-width: 1180px) {
  .rack-main { flex-wrap: wrap; }
  .rack-canvas { flex-basis: 100%; }
  .rack-side { flex: 1 1 100%; position: static; max-height: none; }
}
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.side-card h3 { margin: 0 0 4px; font-size: 13px; }
.unplaced { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.unplaced li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: grab; background: var(--surface-2); touch-action: none; transition: border-color .15s, transform .15s; }
.unplaced li:hover { border-color: var(--accent); transform: translateX(2px); }
.unplaced li.on { border-color: var(--accent); background: var(--accent-soft); }
.unplaced small { color: var(--muted); }
table.patch { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.patch th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.patch td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.patch tr { cursor: pointer; transition: background .15s; }
table.patch tbody tr:hover, table.patch tr.selected { background: var(--accent-soft); }
.jack { display: block; color: var(--muted); }
.empty-card { max-width: 560px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); text-align: center; animation: enter .4s ease-out both; }
.empty-card .big { font-size: 44px; }
.empty-card h2 { margin: 6px 0; }
.empty-card p { color: var(--muted); }
.empty-card .grid3 { text-align: left; margin: 18px 0; }

/* ---------- Seitenspuren, Trassen, Träger ---------- */
.lane { fill: rgba(255, 255, 255, .025); stroke: rgba(255, 255, 255, .06); stroke-dasharray: 4 4; cursor: copy; transition: fill .15s; }
.lane:hover { fill: rgba(91, 147, 255, .1); stroke: rgba(91, 147, 255, .5); }
.lane.selected { fill: rgba(91, 147, 255, .16); stroke: #5b93ff; }
.side-item { cursor: pointer; }
.side-item .body { fill: #262b35; stroke: #3c4452; }
.side-item.kind-vpdu .body { fill: #2d2525; stroke: #5a3d3d; }
.side-item:hover .body, .side-item.selected .body { stroke: #5b93ff; stroke-width: 2; }
.duct-lid { stroke: #4b5363; stroke-dasharray: 2 3; }
.duct-slit { fill: #1b1f27; }
.side-label { fill: #aab3c5; font-size: 9.5px; font-weight: 600; pointer-events: none; letter-spacing: .03em; }
.duct-count { fill: #93c5fd; font-size: 10px; font-weight: 700; pointer-events: none; }
.duct-count.h { font-size: 9px; font-weight: 600; }
.brush-slot { fill: #11141a; stroke: #3b4250; }
.hduct-lid { fill: #2f3541; stroke: #444c5b; }
.item.kind-hduct .body, .item.kind-brush .body { fill: #1d222b; }
.item.kind-carrier .body { fill: #2a303b; }
.carrier-name { fill: #9aa3b2; font-size: 8px; pointer-events: none; }
.cslot { fill: rgba(0, 0, 0, .25); stroke: #5b93ff; stroke-opacity: .55; stroke-dasharray: 3 2; }
.cslot.used { stroke-opacity: .25; }
.slot-node rect { fill: #3b4352; stroke: rgba(255, 255, 255, .1); cursor: pointer; }
.port-num { fill: #cfd5df; font: 6.5px ui-monospace, monospace; pointer-events: none; }
.port-lbl { fill: #e8ecf3; font-size: 7px; font-weight: 600; pointer-events: none; }
.cables .cable.power { stroke-dasharray: none; opacity: .75; }
.slot-list { display: flex; flex-direction: column; gap: 5px; }
.slot-row { display: grid; grid-template-columns: 18px 1fr 62px 30px; gap: 5px; align-items: center; }
.slot-row select, .slot-row input { min-width: 0; padding: 5px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.ed-mk.slot .mk { fill: rgba(34, 197, 94, .18); stroke: #22c55e; }
.ed-mk.slot.sel .mk { fill: rgba(251, 191, 36, .25); stroke: #fbbf24; }

/* ---------- Standorte ---------- */
#view-sites { background: var(--stage); }
.sites-view { position: absolute; inset: 0; display: grid; grid-template-columns: 260px 1fr; }
.sites-tree { border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; padding: 10px 8px 24px; font-size: 13px; }
.tree-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.tree-head button { padding: 3px 9px; font-size: 12px; }
.tree-site { margin-bottom: 6px; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 7px; cursor: pointer; transition: background .12s; }
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { box-shadow: inset 2px 0 0 var(--accent); }
.tree-row.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-row small { color: var(--muted); font-weight: 400; margin-left: auto; white-space: nowrap; }
.tree-ic { width: 18px; text-align: center; flex: none; }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-plus { border: 0; background: transparent; color: var(--muted); padding: 0 5px; font-size: 15px; line-height: 1; opacity: 0; }
.tree-row:hover .tree-plus { opacity: 1; }
.tree-plus:hover { color: var(--accent); }
.tree-children { padding-left: 14px; border-left: 1px dashed var(--border); margin-left: 14px; }
.plan-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.plan-bar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--stage) 85%, transparent); }
.plan-bar select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-width: 260px; }
.crumb { color: var(--muted); font-size: 13px; }
.crumb b { color: var(--text); }
.plan-wrap { flex: 1; overflow: auto; padding: 16px; }
.plan-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.plan-bg { fill: var(--surface); }
.plan-grid line { stroke: var(--grid); stroke-width: 1; }
.room-rect { fill-opacity: .14; stroke-opacity: .9; stroke-width: 2; cursor: move; }
.plan-room:hover .room-rect { fill-opacity: .22; }
.plan-room.selected .room-rect { fill-opacity: .26; stroke-width: 3; stroke-dasharray: 6 4; }
.room-name { fill: var(--text); font-size: .3px; font-weight: 700; pointer-events: none; }
.room-size { fill: var(--muted); font-size: .2px; pointer-events: none; }
.room-handle { fill: var(--accent); stroke: var(--surface); stroke-width: .03; cursor: nwse-resize; }
.plan-rack { cursor: move; }
.rack-body { fill: #1f2937; stroke: #94a3b8; stroke-width: 1.5; }
.plan-rack:hover .rack-body, .plan-rack.selected .rack-body { stroke: var(--accent); stroke-width: 3; }
.rack-front { stroke: #22c55e; stroke-width: 4; stroke-linecap: round; }
.rack-code { fill: #fff; font-size: .2px; font-weight: 700; pointer-events: none; }
.rack-name { fill: var(--text); font-size: .18px; font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: .05px; }
.plan-pin { cursor: move; }
.pin-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.plan-pin.selected .pin-dot { stroke-width: 3.5; fill: var(--accent-soft); }
.pin-icon { font-size: .22px; pointer-events: none; }
.pin-label { fill: var(--text); font-size: .17px; font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: .05px; }
.pin-wifi { fill: none; stroke: var(--accent); stroke-opacity: .25; stroke-width: 1.5; stroke-dasharray: 5 5; pointer-events: none; }
.pin-led { fill: var(--muted); }
.pin-led.st-up { fill: var(--ok); }
.pin-led.st-down { fill: var(--bad); }
.pin-led.st-unknown { display: none; }
.plan-scale { stroke: var(--muted); stroke-width: 2; }
.draw-preview { fill: rgba(91, 147, 255, .15); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.calib-line { stroke: #f59e0b; stroke-width: 3; stroke-dasharray: 6 4; pointer-events: none; }
.room-inherit { padding: 6px 8px; border: 1px dashed var(--border); border-radius: 7px; font-size: 13px; }
.room-inherit small { color: var(--muted); }
.room-pick { display: flex; flex-direction: column; gap: 6px; }
.room-pick select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.dims-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.crumb-btn { border: 0; background: transparent; color: var(--accent); padding: 0; font-size: 12.5px; }
.crumb-btn:hover { text-decoration: underline; }
.site-filter { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
@media (max-width: 860px) {
  .sites-view { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sites-tree { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .tabs button { padding: 5px 8px; }
}

/* ---------- Steckdosen ---------- */
.port.socket { fill: #1b1e24; stroke: #4b5363; stroke-width: 1; cursor: crosshair; }
.port.socket.used { stroke: #9aa3b2; }
.port.socket.live { stroke: #22c55e; }
.port.socket.selected { fill: #233150; stroke: #5b93ff; stroke-width: 2; }
.port.socket:hover { stroke: #fff; }
.socket-recess { fill: #0b0d11; stroke: #2c323d; stroke-width: .6; }
.socket-pin { fill: #000; }
.socket-earth { fill: #a3acbd; }
.socket-num { fill: #7f8899; font: 6.5px ui-monospace, monospace; }
.warn-box { border: 1px solid var(--warn); border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; background: color-mix(in srgb, var(--warn) 7%, transparent); }

/* ---------- Geräte-Katalog ---------- */
.cat-overlay { position: fixed; inset: 0; z-index: 45; background: rgba(6, 8, 12, 0); display: flex; padding: 3vh 3vw; transition: background .16s; }
.cat-overlay.open { background: rgba(6, 8, 12, .55); }
.cat-overlay[hidden] { display: none; }
.cat-box { flex: 1; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; opacity: 0; transform: translateY(-6px); transition: opacity .16s, transform .16s; }
.cat-overlay.open .cat-box { opacity: 1; transform: none; }
.cat-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cat-head input[type="search"] { flex: 1; min-width: 200px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.cat-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); max-height: 92px; overflow-y: auto; }
.cat-chips .chip { cursor: pointer; box-shadow: none; }
.cat-chips .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cat-grid { flex: 1; overflow-y: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; align-content: start; }
.cat-card { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); animation: rowin .25s ease-out both; }
.cat-card b { font-size: 13.5px; }
.cat-card small { font-size: 11.5px; }
.cat-box { position: relative; --cat-img: #0b0d12; }
.cat-img { min-height: 58px; border-radius: 6px; background: var(--cat-img); display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center; padding: 4px; overflow: hidden; margin-bottom: 4px; cursor: zoom-in; transition: box-shadow .15s; }
.cat-img:hover { box-shadow: 0 0 0 2px var(--accent); }
.cat-img img { max-width: 100%; max-height: 52px; object-fit: contain; }
.cat-actions { margin-top: auto; padding-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.cat-actions > button { flex: 1; }
.cat-actions select { width: 100%; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.cat-actions .row-btns { display: flex; gap: 6px; width: 100%; }
.cat-actions .row-btns button { flex: 1; }
.cat-actions .row-btns .ghost { flex: 0 0 auto; }
.cat-actions.big { max-width: 520px; margin: 4px auto 0; width: 100%; }
.cat-preview { position: absolute; inset: 0; z-index: 2; background: rgba(6, 8, 12, .7); display: flex; padding: 2vh 2vw; }
.cat-preview[hidden] { display: none; }
.cat-preview-box { flex: 1; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.cat-preview-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.cat-preview-head button { margin-left: auto; }
.cat-preview figure { margin: 0; background: var(--cat-img); border-radius: 10px; padding: 10px; }
.cat-preview figcaption { color: #aab; font-size: 12px; margin-bottom: 6px; }
.cat-preview figure img { display: block; width: 100%; height: auto; max-height: 40vh; object-fit: contain; }
.cat-note { color: var(--accent); font-size: 11px !important; }
.cat-info { padding: 8px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

/* ---------- Druck ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  @page hoch { size: A4 portrait; margin: 10mm; }
  .pr-page.portrait { page: hoch; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #111 !important; display: block !important; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  .pr-page { page-break-after: always; break-after: page; font: 11px/1.35 system-ui, sans-serif; color: #111; }
  .pr-page:last-child { page-break-after: auto; break-after: auto; }
  .pr-head { display: flex; gap: 14px; align-items: baseline; border-bottom: 1.5px solid #111; padding-bottom: 4px; margin-bottom: 8px; }
  .pr-head b { font-size: 16px; }
  .pr-head .pr-right { margin-left: auto; color: #555; }
  .pr-racks { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; align-items: start; }
  .pr-racks figure { margin: 0; }
  .pr-racks figcaption { font-weight: 700; margin-bottom: 4px; }
  .pr-racks svg { width: 100% !important; height: auto !important; max-height: 165mm; filter: none !important; }
  .pr-page.portrait .pr-racks { gap: 5mm; }
  .pr-page.portrait .pr-racks svg { max-height: 250mm; }
  .pr-section { break-inside: avoid-page; margin-bottom: 7mm; }
  .pr-section h3 { font-size: 13px; margin: 0 0 4px; text-transform: none; letter-spacing: 0; color: #111; }
  .pr-section table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  .pr-section th { text-align: left; border-bottom: 1.5px solid #111; padding: 3px 5px; }
  .pr-section td { border-bottom: .5px solid #bbb; padding: 3px 5px; vertical-align: top; }
  .pr-section td.num, .pr-section th.num { font-weight: 700; width: 1%; white-space: nowrap; padding-right: 10px; }
  .pr-section td.nowrap { white-space: nowrap; }
  .pr-section td.strong { font-weight: 600; }
  .pr-section tr.free td { color: #888; }
  .pr-section .sw { display: inline-block; width: 9px; height: 9px; border: .5px solid #333; margin-right: 4px; vertical-align: -1px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rack-svg.print { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rack-svg.print .rk-frame { fill: #fff; stroke: #111; stroke-width: 1.5; }
  .rack-svg.print .rk-inner { fill: #fff; stroke: #999; }
  .rack-svg.print .rail { fill: #d1d5db; }
  .rack-svg.print .lane { fill: #fafafa; stroke: #ddd; }
  .rack-svg.print .slot { fill: none; stroke: #eee; }
  .rack-svg.print .rk-num, .rack-svg.print .it-label, .rack-svg.print .it-sub, .rack-svg.print .it-sub.strong, .rack-svg.print .port-lbl, .rack-svg.print .port-num, .rack-svg.print .side-label, .rack-svg.print .carrier-name { fill: #111; }
  .rack-svg.print .it-hint { fill: #777; }
  .rack-svg.print .item .body, .rack-svg.print .side-item .body { fill: #f3f4f6; stroke: #374151; }
  .rack-svg.print .slot-node rect { fill: #e5e7eb; stroke: #555; }
  .rack-svg.print .cslot { fill: none; stroke: #999; }
  .rack-svg.print .port { fill: #fff; stroke: #111; }
  .rack-svg.print .port.used { fill: #d1d5db; }
  .pr-plan svg { width: 100% !important; height: auto !important; max-height: 170mm; box-shadow: none; border: 1px solid #999; }
  .plan-svg.print { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: #fff; }
  .plan-svg.print .plan-bg { fill: #fff; }
  .plan-svg.print .plan-grid line { stroke: #e5e7eb; }
  .plan-svg.print .room-name, .plan-svg.print .rack-name, .plan-svg.print .pin-label { fill: #111; stroke: #fff; }
  .plan-svg.print .room-size { fill: #444; }
  .plan-svg.print .pin-dot { fill: #fff; stroke: #1d4ed8; }
  .plan-svg.print .pin-led { display: none; }
  .rack-svg.print .port.socket { fill: #f9fafb; stroke: #111; }
  .rack-svg.print .socket-recess { fill: #e5e7eb; stroke: #555; }
  .rack-svg.print .socket-earth { fill: #555; }
  .rack-svg.print .socket-num { fill: #111; }
  .rack-svg.print .brush, .rack-svg.print .duct-slit, .rack-svg.print .brush-slot, .rack-svg.print .hduct-lid { fill: #d1d5db; stroke: #999; }
  .rack-svg.print .vent, .rack-svg.print .duct-lid { stroke: #999; }
  .rack-svg.print .duct-count { fill: #1d4ed8; }
  .rack-svg.print .led, .rack-svg.print .ghost, .rack-svg.print .temp { display: none; }
  .rack-svg.print .cable { filter: none; opacity: 1; }
  .rack-svg.print .photo-tag { opacity: 1; }
  .rack-svg.print .photo-tag rect { fill: rgba(255, 255, 255, .85); }
  .rack-svg.print .photo-tag text { fill: #111; }
}

/* ---------- Fotos im Rack ---------- */
.item.has-photo .body { fill: #000; }
.photo-frame { fill: none; stroke: rgba(255, 255, 255, .08); pointer-events: none; }
.item.has-photo:hover .photo-frame, .item.has-photo.selected .photo-frame { stroke: #5b93ff; stroke-width: 2; }
.photo { pointer-events: none; }
.photo-tag { pointer-events: none; opacity: 0; transition: opacity .15s; }
.photo-tag rect { fill: rgba(10, 12, 16, .78); }
.item.has-photo:hover .photo-tag, .item.has-photo.selected .photo-tag { opacity: 1; }
.it-hint.on-photo { fill: #fbbf24; font-style: normal; paint-order: stroke; stroke: rgba(0, 0, 0, .7); stroke-width: 3px; }
.port.hot { fill: rgba(91, 147, 255, 0); stroke: rgba(255, 255, 255, .35); stroke-width: 1; }
.port.hot:hover { fill: rgba(91, 147, 255, .35); stroke: #fff; stroke-width: 2; }
.port.hot.used { stroke: #9aa3b2; stroke-width: 1.4; }
.port.hot.live { stroke: #22c55e; stroke-width: 2; }
.port.hot.bad { stroke: #ef4444; stroke-width: 2.2; }
.port.hot.selected { fill: rgba(91, 147, 255, .45); stroke: #5b93ff; stroke-width: 2.6; }
.slot-node.has-photo > rect { fill: transparent; stroke: transparent; }
.slot-node.has-photo:hover > rect, .slot-node.has-photo.selected > rect { stroke: #5b93ff; stroke-width: 2; }
.slot-node .photo-tag rect { fill: rgba(10, 12, 16, .78); stroke: none; }
.slot-node:hover .photo-tag, .slot-node.selected .photo-tag { opacity: 1; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border-style: dashed; min-height: 74px; justify-content: center; }
.thumb.has { border-style: solid; }
.thumb svg { width: 100%; height: 40px; background: #000; border-radius: 4px; }
.thumb .big { font-size: 22px; }
.thumb small { color: var(--muted); font-size: 11.5px; white-space: normal; }
.tpl-row { display: flex; gap: 6px; margin-top: 8px; }
.tpl-row select { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }

/* ---------- Port-Editor ---------- */
.ed-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(6, 8, 12, 0); display: flex; padding: 2vh 2vw; transition: background .18s; }
.ed-overlay.open { background: rgba(6, 8, 12, .6); }
.ed-overlay[hidden] { display: none; }
.ed-box { flex: 1; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; transform: scale(.98); opacity: 0; transition: transform .18s ease-out, opacity .18s; }
.ed-overlay.open .ed-box { transform: none; opacity: 1; }
.ed-head { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ed-head b { font-size: 15px; margin-right: 6px; }
.ed-head .spacer { flex: 1; }
.ed-body { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.ed-stage { position: relative; background: #07090d; display: flex; align-items: center; justify-content: center; padding: 18px; overflow: auto; min-height: 0; }
.ed-stage.drop { outline: 3px dashed var(--accent); outline-offset: -10px; }
.ed-stage.zoomed { align-items: flex-start; justify-content: flex-start; }
.ed-side { border-left: 1px solid var(--border); padding: 14px; overflow-y: auto; }
.ed-side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 0 8px; }
.ed-svg { width: 100%; height: auto; max-height: 100%; touch-action: none; user-select: none; }
.ed-svg.ports { cursor: crosshair; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .6)); }
.ed-mask { fill: rgba(0, 0, 0, .62); pointer-events: none; }
.ed-crop { fill: transparent; stroke: #fbbf24; stroke-width: .35%; stroke-dasharray: 1.2% .8%; cursor: move; }
.ed-guide { stroke: rgba(251, 191, 36, .6); stroke-width: .15%; stroke-dasharray: .8% .8%; pointer-events: none; }
.ed-handle { fill: #fbbf24; stroke: #000; stroke-width: .1%; cursor: grab; }
.ed-frame { fill: none; stroke: rgba(255, 255, 255, .25); stroke-width: 1; pointer-events: none; }
.ed-mk { cursor: move; }
.ed-mk .mk { fill: rgba(91, 147, 255, .28); stroke: #5b93ff; stroke-width: 1.6; }
.ed-mk.sel .mk { fill: rgba(251, 191, 36, .3); stroke: #fbbf24; stroke-width: 2.4; }
.ed-mk .mk-n { fill: #fff; font-weight: 700; paint-order: stroke; stroke: rgba(0, 0, 0, .75); stroke-width: 3px; pointer-events: none; }
.mk-resize { fill: #fbbf24; stroke: #000; cursor: nwse-resize; }
.row-pt { fill: #f59e0b; stroke: #000; stroke-width: 2; }
.row-line { stroke: #f59e0b; stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }
.ed-drop { text-align: center; color: #cfd5df; max-width: 420px; }
.ed-drop .big { font-size: 56px; }
.ed-drop .muted { color: #8b95a7; font-size: 13px; }
.ed-steps { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }
.rot-row { display: grid; grid-template-columns: 1fr 72px; gap: 8px; align-items: center; }
.rot-row input[type="range"] { accent-color: var(--accent); }
.row-box { margin: 8px 0 12px; }
.row-box.on { padding: 10px; border: 1px dashed var(--warn); border-radius: 10px; background: color-mix(in srgb, var(--warn) 7%, transparent); }
.row-box b { display: block; margin-bottom: 8px; font-size: 13px; }
.ed-ports { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 42vh; overflow-y: auto; }
.ed-ports li { display: grid; grid-template-columns: 22px 1fr 96px 28px; gap: 5px; align-items: center; padding: 3px 4px; border-radius: 7px; border: 1px solid transparent; cursor: pointer; }
.ed-ports li.sel { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.ed-ports li input, .ed-ports li select { min-width: 0; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.ed-ports .pin { text-align: center; }
@media (max-width: 860px) {
  .ed-overlay { padding: 0; }
  .ed-box { border-radius: 0; }
  .ed-body { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 1fr) auto; }
  .ed-side { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
}

/* ---------- Liste ---------- */
.list-tools { display: flex; gap: 8px; align-items: center; padding: 12px 16px; flex-wrap: wrap; position: sticky; top: 0; left: 0; z-index: 2; background: color-mix(in srgb, var(--stage) 85%, transparent); backdrop-filter: blur(8px); }
.list-tools select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.list-tools button { margin-left: auto; }
.table-wrap { padding: 0 16px 30px; }
table.devices { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 13px; box-shadow: var(--shadow); }
table.devices th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 9px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; position: sticky; top: 0; user-select: none; }
table.devices th.asc::after { content: " ▲"; font-size: 9px; }
table.devices th.desc::after { content: " ▼"; font-size: 9px; }
table.devices td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.devices tbody tr { cursor: pointer; animation: rowin .3s ease-out both; transition: background .12s; }
table.devices tbody tr:hover { background: var(--surface-2); }
table.devices tbody tr.selected { background: var(--accent-soft); }
table.devices td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
table.devices td.bad { color: var(--bad); font-weight: 600; }
table.devices td.warn { color: var(--warn); font-weight: 600; }
.pill { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.pill.st-up { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.st-down { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.dotlabel { display: inline-flex; align-items: center; gap: 6px; }
.dotlabel i { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Befehlssuche ---------- */
.palette { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, 0); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; transition: background .15s; }
.palette.open { background: rgba(8, 10, 14, .45); }
.palette[hidden] { display: none; }
.pal-box { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; transform: translateY(-8px) scale(.98); opacity: 0; transition: transform .16s ease-out, opacity .16s; }
.palette.open .pal-box { transform: none; opacity: 1; }
.pal-box input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; font-size: 15px; background: transparent; outline: none; }
.pal-box ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.pal-box li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pal-box li.on { background: var(--accent-soft); }
.pal-box li small { color: var(--muted); }
.pal-box li.empty { color: var(--muted); cursor: default; }

/* ---------- Benachrichtigungen ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: calc(100% - 32px); }
.toast { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 8px 8px 8px 12px; box-shadow: var(--shadow-lg); animation: toastin .3s cubic-bezier(.2, .9, .3, 1.2) both; font-size: 13px; }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--bad); }
.toast.out { animation: toastout .25s ease-in both; }
.toast button { padding: 3px 9px; font-size: 12px; }
.toast button.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 0 4px; }

/* ---------- Animationen ---------- */
@keyframes flow { to { stroke-dashoffset: -24; } }
@keyframes march { to { stroke-dashoffset: -16; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(3); opacity: 0; } }
@keyframes halo { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes enter { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes fold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes rowin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes toastin { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(30px); } }
@keyframes cableGlow { 50% { filter: drop-shadow(0 0 5px rgba(255, 255, 255, .7)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 860px) {
  .toolbar { gap: 8px; padding: 8px 16px; }
  .brand h1 { max-width: 140px; }
  .search-wrap { order: 5; flex-basis: 100%; max-width: none; }
  .tools { margin-left: auto; }
  .save-state { min-width: 0; }
  main { flex-direction: column; }
  .panel { width: auto; max-height: 42vh; border-left: 0; border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0, 0, 0, .12); }
  .legend { max-width: calc(100% - 200px); }
  .minimap { width: 120px; height: 76px; }
  .zoom { bottom: 96px; }
  .net-row { grid-template-columns: 32px 1fr 1fr 30px; }
  .net-row .vlan { display: none; }
  .grid3 { grid-template-columns: 1fr; }
  .rack-main { padding: 12px 16px 30px; }
  .rack-side { min-width: 0; }
}
@media (max-width: 480px) {
  .toolbar { gap: 6px 8px; }
  .brand h1 { display: none; }
  .tabs { flex: 1; }
  .tabs button { padding: 5px 9px; flex: 1; }
  .search-wrap { order: 4; flex: 1 1 0; min-width: 0; }
  .search-wrap input { padding-right: 10px; }
  .kbd-btn, #btn-undo, #btn-redo { display: none; }
  .tools { order: 5; margin-left: 0; }
  #btn-add { padding: 6px 9px; }
  .save-state { font-size: 11px; padding: 4px 2px; }
  .legend { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Fußzeile ---------- */
.statusline { display: flex; gap: 14px; align-items: center; padding: 3px 12px; border-top: 1px solid var(--border); background: var(--surface); font-size: 11.5px; color: var(--muted); flex: none; }
.statusline #version { font-variant-numeric: tabular-nums; color: var(--text); opacity: .75; }
.statusline .muted { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs button[data-catalog] { color: var(--accent); }
@media (max-width: 700px) { .statusline .muted { display: none; } }
@media print { .statusline { display: none !important; } }

/* ---------- Glasfaser-Kupplungen ---------- */
.fiber .fib-body { stroke: rgba(0, 0, 0, .45); stroke-width: .5; }
.fiber .fib-hole { fill: #0b0d12; }
.fiber.used .fib-hole { fill: #f8fafc; stroke: #111; stroke-width: .3; }

/* ---------- Kabel zur anderen Seite ---------- */
.stub-tag rect { fill: var(--surface); stroke: var(--border); }
.stub-tag text { fill: var(--muted); font-size: 8px; font-weight: 600; }
.stub-tag.flip rect { stroke: var(--accent); }
.stub-tag.flip text { fill: var(--accent); }
.cable-g[data-flip]:not([data-flip=""]) { cursor: pointer; }
.target-list { margin-top: 4px; }
.target-list li.muted { cursor: default; color: var(--muted); }
@media print { .rack-svg.print .stub-tag rect { fill: #fff; stroke: #999; } .rack-svg.print .stub-tag text { fill: #111; } }

/* ---------- Stellplätze neben dem Schrank ---------- */
.zone-area { fill: rgba(91, 147, 255, .04); stroke: var(--accent); stroke-opacity: .45; stroke-dasharray: 6 5; stroke-width: 1.4; }
.zone.target .zone-area { fill: rgba(91, 147, 255, .08); stroke-opacity: .8; }
.zone.hot .zone-area { fill: rgba(91, 147, 255, .2); stroke-opacity: 1; stroke-width: 2; }
.zone-label { fill: var(--accent); font-size: 10.5px; font-weight: 700; pointer-events: none; }
.slot-node.stack-on > rect:first-child { stroke: var(--accent); stroke-width: 2.5; }
@media print {
  .rack-svg.print .zone-area { fill: none; stroke: #999; }
  .rack-svg.print .zone-label { fill: #333; }
}

/* ---------- PoE ---------- */
.poe-bar { fill: none; stroke: #f59e0b; stroke-width: .6; }
.poe-bar.on { fill: #f59e0b; stroke: none; }
.poe-pd { font-size: 6px; }
.poe-w { fill: #f59e0b; font-size: 6.5px; font-weight: 700; pointer-events: none; }
.poe-tag rect { fill: rgba(17, 24, 39, .85); }
.poe-line { margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: rgba(245, 158, 11, .12); color: #b45309; font-size: 12.5px; }
:root[data-theme="dark"] .poe-line { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .poe-line { color: #fbbf24; } }
@media print { .rack-svg.print .poe-w { fill: #92400e; } }

/* ---------- Dialoge (statt confirm/prompt) ---------- */
.dlg-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(6, 8, 12, 0); backdrop-filter: blur(0); transition: background .14s, backdrop-filter .14s; }
.dlg-overlay.open { background: rgba(6, 8, 12, .5); backdrop-filter: blur(2px); }
.dlg { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 18px 18px 14px; opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .14s, transform .14s ease-out; }
.dlg-overlay.open .dlg { opacity: 1; transform: none; }
.dlg-top { display: flex; gap: 12px; align-items: flex-start; }
.dlg-ic { flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; background: var(--accent-soft); }
.dlg.danger .dlg-ic { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.dlg h3 { margin: 2px 0 4px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.dlg p { margin: 0; color: var(--muted); font-size: 13.5px; white-space: pre-line; }
.dlg-in { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.dlg-in input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 14px; color: var(--text); }
.dlg-in input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dlg-btns button { padding: 6px 14px; font-weight: 600; }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger.solid:hover { filter: brightness(1.08); }

/* ---------- Kontextmenü ---------- */
.ctx-menu { position: fixed; z-index: 75; min-width: 220px; max-width: min(320px, calc(100vw - 12px)); max-height: calc(100vh - 12px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; font-size: 13.5px; animation: pop .12s ease-out; user-select: none; }
.ctx-h { padding: 5px 9px 3px; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-i { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 7px; cursor: pointer; }
.ctx-i.hover { background: var(--accent-soft); color: var(--accent); }
.ctx-i.danger { color: var(--bad); }
.ctx-i.danger.hover { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.ctx-i.off { opacity: .45; cursor: default; }
.ctx-i.off.hover { background: transparent; color: inherit; }
.ctx-ic { width: 18px; text-align: center; flex: none; }
.ctx-l { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-k { color: var(--muted); font-size: 11.5px; margin-left: 10px; white-space: nowrap; }
.ctx-arrow { color: var(--muted); margin-left: 6px; }
.ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
@media (pointer: coarse) { .ctx-i { padding: 9px 10px; } }
/* langes Antippen öffnet das Kontextmenü, nicht die iOS-Textauswahl */
.rack-svg, #view-topology svg, #view-sites svg, table.devices tbody { -webkit-touch-callout: none; }
.rack-svg, #view-topology svg, #view-sites svg { -webkit-user-select: none; user-select: none; }

/* ---------- Rack-Manager ---------- */
.app-rackmanager .logo { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.dims-row.two { grid-template-columns: 1fr 1fr; }
.badge.map { background: var(--accent-soft); color: var(--accent); }
input.from-map, select.from-map { opacity: .75; cursor: not-allowed; }
.netzmap-card { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.netzmap-card h3 { margin-top: 0; }
.nm-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.nm-list li.muted { cursor: default; color: var(--muted); }
