* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-sans); background: var(--bg); color: var(--fg); font-size: 14px; }
header { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
header .brand { font-weight: 800; letter-spacing: .08em; font-size: 13px; color: var(--muted); }
header h1 { font-size: 17px; margin: 0; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--warn); color: var(--warn); }
.spacer { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.group { display: flex; gap: 6px; align-items: end; }
select, button { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: calc(100vh - 120px); }
#diagram { overflow: auto; padding: 16px; }
#diagram svg { width: 100%; height: auto; max-height: calc(100vh - 160px); border: 1px solid var(--border); border-radius: var(--radius); }
aside { border-left: 1px solid var(--border); background: var(--surface); overflow: auto; padding: 12px 14px; }
aside h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.sw { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 6px; }
.sw .name { font-weight: 700; }
.sw .meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.sw .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sw .row select { font-size: 12px; padding: 3px 6px; flex: 1 1 140px; min-width: 0; max-width: 100%; }
.flag { color: var(--warn); font-size: 11px; margin-top: 4px; }
.ovr { font-size: 10px; color: var(--accent); }
#status { padding: 6px 20px; font-size: 12px; color: var(--muted); }
#status.err { color: var(--node-core); }
.warnings { font-size: 12px; color: var(--warn); }
.conn { font-size: 12px; color: var(--muted); }
.conn.live { color: var(--node-access); font-weight: 600; }
.creds { padding: 14px 20px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.creds h2 { font-size: 14px; margin: 0 0 4px; }
.creds .note { margin: 0 0 12px; font-size: 12px; color: var(--muted); max-width: 820px; }
.creds .fields { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.creds label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.creds label[hidden] { display: none; }
.creds label.check, .creds .method label { flex-direction: row; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--fg); }
.creds .method { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px 6px; margin: 0; }
.creds .method legend { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px; }
.creds input[type=text], .creds input[type=password] { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); min-width: 240px; }
.creds .actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
#cMsg { font-size: 12px; color: var(--muted); }
#cMsg.err { color: var(--node-core); }

/* Narrow screens: one column (diagram above the switch list), wrapped header. */
@media (max-width: 760px) {
  header { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .toolbar { padding: 10px 12px; }
  .toolbar label, .toolbar select { max-width: 100%; }
  main { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  #diagram { padding: 8px; }
  #diagram svg { max-height: none; }
  aside { border-left: 0; border-top: 1px solid var(--border); }
  .creds { padding: 12px; }
  .creds label { flex: 1 1 100%; }
  .creds input[type=text], .creds input[type=password] { min-width: 0; width: 100%; }
}
