:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #141922;
  --panel2: #191f2a;
  --border: #2a3240;
  --text: #eef2f7;
  --muted: #8d98a9;
  --accent: #5da9ff;
  --good: #4fd18b;
  --bad: #ff6b6b;
  --warn: #e7b85c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 Inter, ui-sans-serif, system-ui, sans-serif; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 20px 52px; }
h1,h2,p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
h2 { margin-bottom: 0; }
.eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .16em; font-weight: 800; }
.topbar,.toolbar,.dialog-head,.dialog-actions,.input-action { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.topbar { margin-bottom: 18px; }
.health { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 6px 10px; color: var(--muted); }
.toolbar { margin-bottom: 8px; align-items: flex-end; }
.tabs { display:flex; flex-wrap:wrap; gap:7px; }
button { border:0; border-radius:8px; min-height:36px; padding:0 12px; font:inherit; font-weight:700; cursor:pointer; }
button.primary { background:var(--accent); color:#06111d; }
button.secondary,.tab { background:var(--panel2); color:var(--text); border:1px solid var(--border); }
.tab.active { border-color:var(--accent); color:var(--accent); }
button.danger { background:transparent; border:1px solid #6c3138; color:#ff8b94; }
button.icon { width:40px; padding:0; font-size:24px; background:transparent; color:var(--muted); }
.network-info { color:var(--muted); margin: 6px 0 11px; }
.nodes { display:grid; grid-template-columns:1fr; gap:9px; }
.node { background:var(--panel); border:1px solid var(--border); border-radius:11px; padding:11px 13px; }
.node-head { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.node-title { display:flex; gap:9px; align-items:center; min-width:0; }
.node-title h3 { margin:0; font-size:17px; line-height:1.2; overflow-wrap:anywhere; }
.dot { width:10px; height:10px; border-radius:50%; background:#596273; flex:0 0 auto; }
.dot.online { background:var(--good); box-shadow:0 0 0 3px rgba(79,209,139,.12); }
.node-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; align-items:flex-start; }
.auth-port-stack { display:grid; gap:5px; }
.auth-port-stack > button { width:100%; }
button.node-add-port { min-height:30px; }
.grid { display:grid; grid-template-columns:repeat(5,180px); gap:20px; justify-content:start; margin-top:9px; }
.item span { display:block; color:var(--muted); font-size:12px; line-height:1.2; margin-bottom:2px; }
.item strong { line-height:1.25; font-weight:650; overflow-wrap:anywhere; }
.badge { display:inline-flex; align-items:center; justify-content:center; height:24px; line-height:1; border-radius:999px; padding:0 8px; font-size:12px; font-weight:750; vertical-align:middle; }
.badge.good { background:rgba(79,209,139,.12); color:var(--good); }
.badge.warn { background:rgba(231,184,92,.12); color:var(--warn); }
.badge.muted { background:#202632; color:var(--muted); }
.badge.gateway { background:rgba(93,169,255,.12); color:var(--accent); flex:0 0 auto; }
.flash { border:1px solid var(--border); background:var(--panel); padding:9px 11px; border-radius:9px; margin:8px 0; }
.flash.error { border-color:#66343a; color:#ff9ca3; }
.hidden { display:none; }
.empty { border:1px dashed var(--border); border-radius:11px; color:var(--muted); text-align:center; padding:32px 16px; }
dialog { width:min(620px, calc(100% - 28px)); background:var(--panel); color:var(--text); border:1px solid var(--border); border-radius:16px; padding:20px; }
dialog::backdrop { background:rgba(0,0,0,.65); }
form { display:grid; gap:16px; }
label { display:grid; gap:7px; font-weight:700; }
input,select { width:100%; min-height:44px; border-radius:9px; border:1px solid var(--border); background:#0f131a; color:var(--text); padding:0 12px; font:inherit; font-size:16px; }
.input-action input { min-width:0; }
small,.muted { color:var(--muted); font-weight:400; }
pre { white-space:pre-wrap; overflow-wrap:anywhere; background:#0a0d11; border:1px solid var(--border); padding:16px; border-radius:10px; color:#dce8f7; }
@media (max-width: 800px) {
  .toolbar,.node-head { align-items:stretch; flex-direction:column; }
  .node-actions { justify-content:flex-start; }
  .grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 460px) {
  main { padding:16px 12px 42px; }
  .grid { grid-template-columns:1fr; }
  .input-action { align-items:stretch; flex-direction:column; }
}

/* .item span ist absichtlich allgemein. Badges brauchen deshalb eine
   spezifischere Regel, sonst werden sie zu normalen Block-Spans und der
   Text sitzt optisch oben statt mittig. */
.item > .badge {
  display:flex;
  align-items:center;
  justify-content:flex-start;
  width:100%;
  height:24px;
  margin:0;
  padding:0 8px;
  line-height:24px;
}
.node-title > .badge { width:auto; justify-content:center; }

.ports { margin-top:8px; padding-top:7px; border-top:1px solid var(--border); }
.ports-head { display:flex; align-items:center; gap:8px; margin-bottom:3px; }
.ports-head strong { font-size:13px; }
.ports-table-wrap { width:100%; overflow-x:auto; }
.ports-table { width:auto; min-width:680px; max-width:100%; border-collapse:collapse; border-spacing:0; font-size:14px; }
.ports-table th { padding:1px 10px 3px 0; color:var(--muted); font-size:11px; line-height:1.2; font-weight:650; text-align:left; white-space:nowrap; }
.ports-table td { padding:3px 10px 3px 0; border-top:1px solid var(--border); vertical-align:middle; line-height:1.25; }
.ports-table th:last-child,.ports-table td:last-child { padding-right:0; }
.port-service { width:220px; max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; font-weight:500; }
.port-number { width:105px; white-space:nowrap; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
.port-proto { width:90px; white-space:nowrap; font-size:12px; font-weight:800; letter-spacing:.03em; color:var(--accent); }
.port-action { width:130px; white-space:nowrap; }
.port-action-button { min-height:24px; padding:0 7px; border-radius:6px; font-size:11px; line-height:1; }
.port-action-button + .port-action-button { margin-left:4px; }
.port-empty { color:var(--muted); font-size:13px; padding:1px 0; }
.port-form-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width: 1040px) {
  .grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px 18px; }
}
@media (max-width: 800px) {
  .grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 650px) {
  .port-form-grid { grid-template-columns:1fr; }
  .ports-table { min-width:620px; }
}
@media (max-width: 460px) {
  .grid { grid-template-columns:1fr; }
}

/* Authentication UI */
.topbar-status { display:flex; align-items:center; gap:8px; }
.session-user { color:var(--muted); font-size:13px; }
.logout-button { min-height:32px; }
.login-body { min-height:100vh; display:grid; place-items:center; }
.login-shell { width:min(440px, 100%); padding:20px; }
.login-card { background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:24px; }
.login-card h1 { margin-top:3px; }
.login-intro { margin:4px 0 20px; }
.login-card form { gap:14px; }
.login-card button[type="submit"] { margin-top:3px; }
@media (max-width: 600px) {
  .topbar-status { align-items:flex-end; flex-direction:column; gap:5px; }
  .session-user { display:none; }
}
