/* Homelab Diagram editor UI.
   Spacing: 4/8 px grid. Type scale: 12 caption · 14 secondary · 16 body · 20 subhead · 32 title.
   Colour: 60 % slate background, 30 % surfaces, 10 % accent. Text contrast ≥ 4.5:1. */

@font-face { font-family: 'Fira Sans'; font-weight: 400; font-display: swap; src: url('../fonts/FiraSans-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-weight: 500; font-display: swap; src: url('../fonts/FiraSans-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-weight: 600; font-display: swap; src: url('../fonts/FiraSans-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-weight: 700; font-display: swap; src: url('../fonts/FiraSans-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Fira Code'; font-weight: 400; font-display: swap; src: url('../fonts/FiraCode-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Fira Code'; font-weight: 500; font-display: swap; src: url('../fonts/FiraCode-Medium.woff2') format('woff2'); }

:root {
    --bg: #0f172a;            /* 60 %: app background (deep slate) */
    --surface: #1e293b;       /* 30 %: panels, cards */
    --surface-2: #273449;     /* raised: inputs, list items */
    --surface-3: #334155;     /* hover */
    --border: #334155;
    --border-subtle: #263246;
    --text: #e2e8f0;          /* 13.9:1 on --bg */
    --text-muted: #94a3b8;    /* 6.9:1 on --bg, 5.7:1 on --surface */
    --accent: #3b82f6;        /* 10 %: primary action, focus, selection */
    --accent-strong: #2563eb; /* primary button fill: white text 5.2:1 */
    --accent-text: #93c5fd;
    --danger: #f87171;
    --danger-bg: #7f1d1d40;
    --ok: #4ade80;
    --warn: #fbbf24;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s8: 64px;
    --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
    --fs-caption: 12px; --fs-small: 14px; --fs-body: 16px; --fs-sub: 20px; --fs-title: 32px;
    --shadow: 0 8px 24px rgb(2 6 23 / 0.35), 0 2px 6px rgb(2 6 23 / 0.25);
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
    --font: 'Fira Sans', system-ui, sans-serif;
    --mono: 'Fira Code', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 400 var(--fs-small)/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- layout */
.editor {
    display: grid;
    --left-w: 232px;
    --right-w: 360px;
    /* the column widths are separate from the panel widths: the remembered widths are set inline (--left-w, --right-w),
       which would win over a collapsed state set on the widths themselves */
    --left-col: var(--left-w);
    --right-col: var(--right-w);
    grid-template-columns: var(--left-col) minmax(0, 1fr) var(--right-col);
    grid-template-rows: 56px minmax(0, 1fr) 40px;
    grid-template-areas: "tool tool tool" "left canvas right" "status status status";
    height: 100vh;
}
.toolbar {
    grid-area: tool;
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding: 0 var(--s4);
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
}
.brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: none; }
.brand svg { width: 24px; height: 24px; color: var(--accent-text); flex: none; }
.brand-name { font-weight: 600; font-size: var(--fs-body); white-space: nowrap; }
/* fixed width, so a longer name or the unsaved dot never moves the toolbar buttons */
.file-name { color: var(--text-muted); width: 184px; flex: none; display: flex; align-items: baseline; min-width: 0; white-space: nowrap; }
.file-name .file-text { overflow: hidden; text-overflow: ellipsis; }
.file-name .dirty { flex: none; margin-left: var(--s1); }
/* the preview of the next version (next/): a pill next to the name; clicked, what that means */
.preview-pill {
    height: 24px; padding: 0 var(--s2); border-radius: 999px; border: 1px solid rgb(251 191 36 / .45); flex: none;
    background: rgb(251 191 36 / .12); color: var(--warn); font-size: var(--fs-caption); font-weight: 600; cursor: pointer;
    transition: background-color .12s;
}
.preview-pill:hover { background: rgb(251 191 36 / .22); }
.preview-pill:active { background: rgb(251 191 36 / .3); }
.preview-pill:focus-visible { outline: none; box-shadow: var(--focus); }
.popover {
    position: absolute; top: calc(100% + var(--s2)); left: 0; z-index: 41; width: 320px; padding: var(--s4); display: grid; gap: var(--s2);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); white-space: normal;
}
.popover h3 { font-size: var(--fs-body); }
.popover p { color: var(--text-muted); }
.popover .button-row { margin-top: var(--s1); }
a.btn { text-decoration: none; }
.btn .btn-icon { display: none; width: 20px; height: 20px; flex: none; }
.tool-group { display: flex; align-items: center; gap: var(--s1); padding-left: var(--s4); border-left: 1px solid var(--border-subtle); }
.spacer { flex: 1; }
.zoom-label { min-width: 64px; font-variant-numeric: tabular-nums; }

.sidebar {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar.left { grid-area: left; border-right: 1px solid var(--border-subtle); position: relative; }
.sidebar.right { grid-area: right; border-left: 1px solid var(--border-subtle); position: relative; }
.editor.left-collapsed { --left-col: 56px; }
.editor.right-collapsed, .editor.right-overlay { --right-col: 0px; }
.editor.right-collapsed .sidebar.right { display: none; }
/* narrow windows: the properties panel floats over the canvas while something is selected */
.editor.right-overlay .sidebar.right {
    position: fixed; top: 56px; bottom: 40px; right: 0; z-index: 20;
    width: min(var(--right-w), calc(100vw - 56px - var(--s6)));
    box-shadow: var(--shadow);
}

/* panel resize handles: an 8 px grab area on the inner edge */
.resizer { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 5; cursor: col-resize; touch-action: none; }
.sidebar.left .resizer { right: -4px; }
.sidebar.right .resizer { left: -4px; }
.resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background-color .12s; }
.resizer:hover::after, .resizer.dragging::after { background: var(--accent); }
.resizer:focus-visible { outline: none; }
.resizer:focus-visible::after { background: var(--accent); }
.editor.left-collapsed .sidebar.left .resizer { display: none; }
body.resizing { cursor: col-resize; user-select: none; }

/* left sidebar: Add / Outline tabs; collapsed it shows the palette as icons */
.side-tabs { align-items: center; }
.side-tabs .collapse-btn { flex: none; margin-bottom: var(--s1); }
.side-hint { padding: var(--s3) var(--s4) 0; }
.editor.left-collapsed .side-tabs { justify-content: center; padding: var(--s2) var(--s2) var(--s1); border-bottom: none; }
.editor.left-collapsed .side-tabs .collapse-btn { margin: 0; }
.collapsed-tools { display: grid; justify-items: center; padding: 0 var(--s2) var(--s2); border-bottom: 1px solid var(--border-subtle); }
.collapsed-tools svg { width: 20px; height: 20px; }
.editor.left-collapsed .side-hint,
.editor.left-collapsed .palette-group h3, .editor.left-collapsed .palette-item span { display: none; }
.editor.left-collapsed .palette-group { padding: var(--s1) var(--s2); }
.editor.left-collapsed .palette-group + .palette-group { border-top: 1px solid var(--border-subtle); }
.editor.left-collapsed .palette-item { justify-content: center; padding: 0; }
.collapse-btn svg { width: 18px; height: 18px; }
.panel-scroll { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: var(--s6); scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

.canvas-wrap { grid-area: canvas; position: relative; min-width: 0; min-height: 0; }
.statusbar {
    grid-area: status;
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding: 0 var(--s4);
    background: var(--surface);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--fs-small);
}
.status-error { color: var(--danger); display: flex; gap: var(--s2); align-items: center; font-weight: 500; }
.status-warn { color: var(--warn); font-weight: 500; }
.status-ok { color: var(--ok); display: flex; gap: var(--s2); align-items: center; font-weight: 500; }

/* ---------------------------------------------------------------- canvas */
.canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; cursor: default; user-select: none; }
body.kbd .canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.canvas.panning, .canvas.space { cursor: grab; }
.canvas.panning { cursor: grabbing; }
.canvas.grabbing { cursor: grabbing; }
.canvas.connecting, .canvas.port-hover { cursor: crosshair; }
.canvas.row-resize { cursor: row-resize; }
.canvas [data-node] { cursor: move; }
.canvas.port-hover [data-node] { cursor: crosshair; }   /* a free port: drag from here to draw a cable */
.canvas.port-used, .canvas.port-used [data-node] { cursor: pointer; }   /* a port with a cable: click opens it in the port table */
.canvas.connecting [data-node] { cursor: crosshair; }
.canvas.grabbing [data-node] { cursor: grabbing; }
.canvas.space [data-node] { cursor: grab; }
.canvas.panning [data-node] { cursor: grabbing; }
.canvas .cable-hit { pointer-events: stroke; cursor: pointer; }
.canvas .cables, .canvas .cable-labels, .canvas .overlay { pointer-events: none; }
.canvas .cables .cable-hit { pointer-events: stroke; }
/* a link's label (a bond's ring and label) is dragged along its line */
.canvas [data-handle="label"] { pointer-events: all; cursor: move; }
.canvas.moving, .canvas.moving [data-node] { cursor: move; }
/* a locked object: a press on its body passes through to what is behind it; its name, content and ports stay live */
.canvas [data-locked] .locked-body { pointer-events: none; }
.canvas [data-locked] .lock-live { pointer-events: all; }
.canvas [data-locked] .lock-name { pointer-events: all; cursor: pointer; }
.canvas-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: end center;   /* below the new diagram's title and network table, which sit top-left */
    padding: var(--s5);
    pointer-events: none;
}
.canvas-empty .empty-state { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s6); max-width: 440px; }
/* the preview's first start: a copy of the release's diagram (its button doesn't wrap, so the box is wider) */
.canvas-empty .empty-state:has(.release-copy) { max-width: 480px; }
.release-copy { display: grid; justify-items: center; gap: var(--s2); padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.empty-state .release-copy p { color: var(--text); }
.empty-state .release-copy .btn { margin-top: 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    height: 36px;
    padding: 0 var(--s4);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 500;
    font-size: var(--fs-small);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--surface-3); }
.btn:active { transform: translateY(1px); background: var(--surface-3); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .palette-item:focus-visible,
.chip-toggle:focus-visible, .icon-cell:focus-visible, .segmented button:focus-visible, .link-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; background: transparent; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn.primary:active { background: #1e40af; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.small { height: 32px; padding: 0 var(--s3); }
.btn.icon-only { width: 36px; padding: 0; font-size: var(--fs-sub); }
.btn.icon-only svg { width: 20px; height: 20px; }
.btn.danger-ghost { border-color: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.icon-btn {
    width: 32px; height: 32px; border-radius: var(--r-sm); border: none; background: transparent; color: var(--text-muted);
    font-size: var(--fs-sub); line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { background: var(--border); }
.link-btn { border: none; background: none; color: var(--accent-text); cursor: pointer; padding: 0; font-weight: 500; text-decoration: underline; }
.link-btn:hover { color: #bfdbfe; }
.button-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; justify-content: center; }

/* toggle switch */
.toggle { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 36px; height: 20px; border-radius: 10px; background: var(--surface-3); position: relative; transition: background-color .15s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.toggle input:checked + .toggle-track { background: var(--accent-strong); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--focus); }
.toggle:hover { color: var(--text); }
.toggle-icon { display: none; width: 20px; height: 20px; flex: none; }

/* why a palette item or a drop could not be added: a short bubble next to it */
.hint-layer { position: absolute; top: 0; left: 0; width: 0; height: 0; }
.hint-pop {
    position: absolute; z-index: 30; width: max-content; max-width: 280px; padding: var(--s2) var(--s3); transform: translateY(-50%);
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md);
    box-shadow: var(--shadow); color: var(--text); font-size: var(--fs-small); line-height: 1.4; pointer-events: none;
    animation: hint-in .12s ease-out;
}
.hint-pop.fixed { position: fixed; }
.hint-pop.below { transform: translate(-50%, var(--s4)); }
@keyframes hint-in { from { opacity: 0; } }

/* ---------------------------------------------------------------- palette */
.palette-group { padding: var(--s2) var(--s3) var(--s3); display: grid; gap: var(--s1); }
.palette-group h3, .subhead {
    font-size: var(--fs-caption);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: var(--s2) var(--s1) var(--s1);
}
.palette-item {
    display: flex;
    align-items: center;
    gap: var(--s3);
    height: 40px;
    padding: 0 var(--s2);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    cursor: grab;
    text-align: left;
    font-weight: 500;
}
.palette-item img { width: 24px; height: 24px; flex: none; }
.palette-item:hover { background: var(--surface-2); border-color: var(--border-subtle); }
.palette-item:active { cursor: grabbing; background: var(--surface-3); }

/* ---------------------------------------------------------------- outline (left sidebar) */
.outline { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ol-search { display: grid; gap: var(--s1); padding: var(--s3) var(--s3) var(--s2); border-bottom: 1px solid var(--border-subtle); }
.ol-search-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.ol-search-label label { font-size: var(--fs-small); font-weight: 500; }
.ol-search-label kbd { font: 500 var(--fs-caption) var(--mono); color: var(--text-muted); }
.ol-search-box { position: relative; }
.ol-search-box input {
    width: 100%; height: 36px; padding: 0 var(--s6) 0 var(--s6); background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--r-md); font-size: var(--fs-small); transition: border-color .12s, box-shadow .12s;
}
.ol-search-box input:hover { border-color: #475569; }
.ol-search-box input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f640; }
.ol-search-box input::placeholder { color: #73829a; }
.ol-search-box input::-webkit-search-cancel-button { display: none; }
.ol-search-icon { position: absolute; left: var(--s2); top: var(--s2); width: 20px; height: 20px; color: var(--text-muted); pointer-events: none; }
.ol-clear { position: absolute; right: var(--s1); top: 6px; }
.outline-tree { padding: var(--s1) var(--s2) var(--s6); }
.outline-tree .empty-state.compact { padding: var(--s6) var(--s3); }
.ol-group + .ol-group { margin-top: var(--s2); }
.ol-group-head {
    font-size: var(--fs-caption); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
    padding: var(--s2) var(--s2) var(--s1);
}
.ol-row {
    --depth: 0;
    /* wraps, but only the first line shows: the IP / match moves out of view when the name needs the room */
    display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: var(--s2); height: 32px; overflow: hidden;
    padding: 0 var(--s2) 0 calc(var(--s1) + var(--depth) * 12px);
    border-radius: var(--r-sm); cursor: pointer; user-select: none; outline: none;
}
.ol-row:hover { background: var(--surface-2); }
.ol-row:active { background: var(--surface-3); }
.ol-row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.ol-row.selected { background: #1d4ed840; }
.ol-row.selected .ol-name { font-weight: 600; }
.ol-row.context .ol-name { color: var(--text-muted); }
.ol-row.dragging { opacity: .45; }
.ol-row.drop-into { background: #3b82f626; box-shadow: inset 0 0 0 2px var(--accent); }
.ol-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.ol-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.ol-twisty, .ol-twisty-space { width: 16px; height: 16px; flex: none; display: grid; place-items: center; color: var(--text-muted); border-radius: var(--s1); }
.ol-twisty:hover { color: var(--text); background: var(--surface-3); }
.ol-twisty svg { width: 14px; height: 14px; transition: transform .12s; }
.ol-row[aria-expanded=true] .ol-twisty svg { transform: rotate(90deg); }
.ol-icon { width: 16px; height: 16px; flex: none; }
/* twisty, icon and name never wrap: they are the first item, so they always hold the first line */
.ol-main { flex: 1 1 auto; min-width: 0; height: 32px; display: flex; align-items: center; gap: var(--s2); }
.ol-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ol-sub { flex: 0 1 auto; max-width: 50%; min-width: 0; line-height: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-caption); color: var(--text-muted); }
.outline mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--text); border-radius: 2px; }
/* lock toggle at the end of a row: its room is always kept (no shift on hover); shown on hover and while locked */
.ol-row.has-lock { position: relative; padding-right: calc(var(--s2) + 28px); }
.ol-lock {
    position: absolute; right: var(--s1); top: 4px; width: 24px; height: 24px; display: grid; place-items: center;
    border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-muted); cursor: pointer; opacity: 0;
}
.ol-lock svg { width: 16px; height: 16px; }
/* an offer on hover stays faint; a lock that is on is drawn in full text colour, so the two never look alike */
.ol-row:hover .ol-lock { opacity: .55; }
.ol-lock.on { opacity: 1; color: var(--text); }
.ol-lock:hover, .ol-lock:focus-visible { opacity: 1; color: var(--text); background: var(--surface-3); }
.ol-lock:active { background: var(--border); }
.ol-lock:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------------------------------------------------------------- property panel */
.tabs { display: flex; gap: var(--s1); padding: var(--s2) var(--s3) 0; border-bottom: 1px solid var(--border-subtle); }
.tab {
    flex: 1;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s4) var(--s4) 0; }
.kind-pill { flex: none; white-space: nowrap; font-size: var(--fs-caption); font-weight: 600; padding: 2px var(--s2); border-radius: 999px; background: #1d4ed833; color: var(--accent-text); }
.head-actions { display: flex; flex: none; margin-left: auto; gap: var(--s1); }
.panel-section { padding: var(--s4); display: grid; gap: var(--s4); border-bottom: 1px solid var(--border-subtle); }
.panel-section:last-child { border-bottom: none; }
.panel-section h3 { font-size: var(--fs-small); font-weight: 600; display: flex; align-items: center; gap: var(--s2); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.count { font-size: var(--fs-caption); font-weight: 600; color: var(--text-muted); background: var(--surface-2); padding: 0 var(--s2); border-radius: 999px; }
.empty-inline { color: var(--text-muted); }
.callout { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md); background: var(--surface-2); }
/* the lock toggle keeps its width, so Lock ↔ Unlock never moves the buttons beside it */
.lock-toggle { min-width: 96px; }
.lock-toggle svg, .chip-toggle svg { width: 16px; height: 16px; flex: none; }
.lock-note { display: flex; align-items: flex-start; gap: var(--s2); margin: var(--s3) var(--s4) 0; padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-small); line-height: 1.4; }
.lock-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--text-muted); }
.lock-note strong { font-weight: 600; }
.lock-note span { color: var(--text-muted); }
/* port table: a row's network cell is the untagged network's list plus, on a trunk, a badge with the count of tagged VLANs
   that opens the port's details ("+3"; "+3 tagged" where the cell has room). The cell keeps its column's width: the badge
   takes its room from the list, never from "Connected to". */
.port-row .port-net { display: flex; align-items: center; gap: var(--s1); min-width: 0; container-type: inline-size; }
.port-row .port-net select { flex: 1 1 0; width: auto; min-width: 0; }
.tag-badge {
    flex: none; min-width: 24px; height: 24px; padding: 0 var(--s1); border: 1px solid transparent; border-radius: 999px;
    background: var(--surface-3); color: var(--text); font-size: var(--fs-caption); font-weight: 600; white-space: nowrap; cursor: pointer;
    font-variant-numeric: tabular-nums; transition: background-color .12s, border-color .12s;
}
.tag-badge:hover { border-color: #64748b; }
.tag-badge:active { background: var(--border-subtle); }
.tag-badge:focus-visible { outline: none; box-shadow: var(--focus); }
.tag-badge[aria-expanded=true] { border-color: var(--accent); }
.tag-badge .long { display: none; }
@container (min-width: 168px) { .tag-badge .short { display: none; } .tag-badge .long { display: inline; } }
/* a narrow panel: the label column gives the network room for its list and badge ("SFP+1" still fits) */
.port-table { container: ports / inline-size; }
@container ports (max-width: 299px) {
    .port-table .port-row { grid-template-columns: 56px minmax(0, 1.25fr) minmax(0, 1fr) 24px; }
    .port-table .port-row input { padding: 0 var(--s1); }
}
/* no networks yet: one offer above the table, not one per port */
.port-no-networks { display: grid; gap: var(--s2); justify-items: start; }
/* IP address from the network (IpField): the network part, sized to its text and set off like a prefix, joined to the host
   part; the renumber question under it */
.ip-split { display: flex; min-width: 0; }
.field .ip-split .ip-net {
    flex: none; width: calc(var(--chars) * 1ch + 2 * var(--s3) + 4px);
    border-radius: var(--r-md) 0 0 var(--r-md); background: var(--surface-2); color: var(--text-muted);
}
.field .ip-split .ip-net:focus-visible { color: var(--text); }
.field .ip-split .ip-host { flex: 1; min-width: 0; margin-left: -1px; border-radius: 0 var(--r-md) var(--r-md) 0; }
.field .ip-split input:hover, .field .ip-split input:focus-visible { position: relative; z-index: 1; }
.ip-renumber-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
/* Type (a device's or a place's template): looks like the inputs below it, opens Change type */
.type-field {
    display: flex; align-items: center; gap: var(--s2); width: 100%; height: 36px; padding: 0 var(--s3);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); text-align: left; cursor: pointer;
    transition: border-color .12s, box-shadow .12s, background-color .12s;
}
.type-field img { width: 20px; height: 20px; flex: none; }
.type-field-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-field-action { flex: none; font-size: var(--fs-caption); font-weight: 600; color: var(--accent-text); }
.type-field:hover { border-color: #475569; }
.type-field:active { background: var(--surface-2); }
.type-field:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f640; }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: var(--s1); border: none; padding: 0; margin: 0; min-width: 0; }
.field.layers { gap: var(--s2); }
.link-end { display: grid; gap: var(--s3); }
.link-end + .link-end { margin-top: var(--s2); }
.bond-member { display: grid; gap: var(--s2); padding: var(--s2) 0; }
.bond-member + .bond-member { border-top: 1px solid var(--border); }
.bond-ports { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.field > label, .field .label, .vlan-picker legend { font-size: var(--fs-small); font-weight: 500; color: var(--text); padding: 0; }
.field input[type=text], .field input[type=number], .field input[type=search], .field select, .field textarea {
    width: 100%;
    height: 36px;
    padding: 0 var(--s3);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: var(--fs-small);
    transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: auto; padding: var(--s2) var(--s3); resize: vertical; line-height: 1.5; }
.field input.mono { font-family: var(--mono); font-size: var(--fs-small); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #475569; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f640; }
.field input[aria-invalid=true] { border-color: var(--danger); }
/* examples, not values: clearly fainter than typed text (13.9:1) but still 4.6:1 on the input background */
.field input::placeholder, .field textarea::placeholder, .port-row input::placeholder, .inline-row input::placeholder { color: #73829a; }
.field-hint { font-size: var(--fs-caption); color: var(--text-muted); line-height: 1.4; }
.field-error { font-size: var(--fs-caption); color: var(--danger); font-weight: 500; }
.field-ok { font-size: var(--fs-small); color: var(--ok); font-weight: 500; }
.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; cursor: pointer; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check > span { display: grid; gap: 2px; }
.check-label { font-weight: 500; }
.color-row { display: flex; align-items: center; gap: var(--s3); }
.color-row input[type=color] { width: 48px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm); background: none; cursor: pointer; }
.color-row input[type=color]:focus-visible { outline: none; box-shadow: var(--focus); }
.vlan-picker { border: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.vlan-picker legend { font-weight: 600; margin-bottom: var(--s3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip-toggle {
    display: inline-flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 var(--s3);
    border-radius: 999px; border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: var(--fs-small); font-weight: 500;
    color: var(--text-muted);
}
.chip-toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--vlan); opacity: .5; }
.chip-toggle:hover { background: var(--surface-2); color: var(--text); }
.chip-toggle.on { border-color: var(--vlan); color: var(--text); background: color-mix(in srgb, var(--vlan) 16%, transparent); }
.chip-toggle.on .dot { opacity: 1; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; width: fit-content; }
.segmented button { height: 36px; padding: 0 var(--s4); border: none; background: transparent; cursor: pointer; font-weight: 500; color: var(--text-muted); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--surface-2); color: var(--text); }
.segmented button.on { background: #1d4ed833; color: var(--text); }

/* list items (ports, hardware, apps…) */
.item { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--r-md); }
.item summary {
    display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s3); cursor: pointer; list-style: none;
    border-radius: var(--r-md);
}
.item summary::-webkit-details-marker { display: none; }
.item summary::before { content: '›'; color: var(--text-muted); width: 12px; transition: transform .12s; font-size: var(--fs-body); }
.item[open] summary::before { transform: rotate(90deg); }
.item summary:hover { background: var(--surface-3); }
.item summary:focus-visible { outline: none; box-shadow: var(--focus); }
.item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--text-muted); font-size: var(--fs-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }
.item-body { padding: var(--s2) var(--s3) var(--s4); display: grid; gap: var(--s4); }
.item-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.item-actions .muted { font-size: var(--fs-caption); }
.node-id { font-size: var(--fs-caption); color: var(--text-muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.swatch.dot { width: 10px; height: 10px; border-radius: 50%; margin: 1px; }
.check .swatch.dot { margin-top: 5px; }

/* icons */
.icon-list { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.icon-tile { display: flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s1) 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.icon-tile img { width: 20px; height: 20px; }
.icon-name { font-size: var(--fs-caption); color: var(--text-muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-missing { width: 20px; height: 20px; border: 1px dashed var(--text-muted); border-radius: 4px; display: grid; place-items: center; font-size: var(--fs-caption); color: var(--text-muted); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.icon-cell {
    display: grid; justify-items: center; gap: var(--s2); padding: var(--s3) var(--s2); border-radius: var(--r-md); border: 1px solid var(--border-subtle);
    background: var(--surface-2); cursor: pointer; font-size: var(--fs-caption); color: var(--text-muted); min-width: 0;
}
.icon-cell img { width: 32px; height: 32px; }
.icon-cell span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-cell:hover { border-color: var(--accent); color: var(--text); background: var(--surface-3); }
.icon-cell:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; background: rgb(2 6 23 / .6); display: grid; place-items: center; z-index: 50; padding: var(--s5); }
/* max-height from the window, not 100 %: a percentage of the backdrop's auto grid row grew with the content (a long icon list),
   which pushed the dialog's top below the middle of the window */
.modal {
    width: min(760px, 100%); max-height: min(720px, calc(100vh - 2 * var(--s5))); display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.modal.narrow { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s4) var(--s4) var(--s5); border-bottom: 1px solid var(--border-subtle); }
.modal-head h2 { font-size: var(--fs-sub); }
.modal-body { padding: var(--s5); overflow-y: auto; display: grid; gap: var(--s5); align-content: start; }
/* stays above the scrolling list (icon picker) */
.modal-search { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border-subtle); flex: none; }
.import-notes { margin: 0; padding-left: var(--s5); display: grid; gap: var(--s2); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--border-subtle); }

/* choice lists: Change type…, Move to… */
.choice-body { gap: var(--s4); }
.choice-group { display: grid; gap: var(--s1); }
.choice {
    --depth: 0;
    display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px;
    padding: var(--s1) var(--s3) var(--s1) calc(var(--s3) + var(--depth) * var(--s4));
    border: 1px solid transparent; border-radius: var(--r-md); background: transparent; text-align: left; cursor: pointer;
    transition: background-color .12s, border-color .12s;
}
.choice img { width: 24px; height: 24px; flex: none; }
.choice:hover { background: var(--surface-2); border-color: var(--border-subtle); }
.choice:active { background: var(--surface-3); }
.choice:focus-visible { outline: none; box-shadow: var(--focus); }
.choice.current { border-color: var(--accent); background: #1d4ed826; }
.choice:disabled { cursor: default; background: transparent; border-color: var(--border-subtle); }
.choice-text { display: grid; flex: 1; min-width: 0; }
.choice-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-sub { font-size: var(--fs-caption); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-tag { flex: none; font-size: var(--fs-caption); font-weight: 600; color: var(--accent-text); }

/* ---------------------------------------------------------------- empty states, loading */
.empty-state { display: grid; justify-items: center; text-align: center; gap: var(--s3); }
.empty-state.compact { padding: var(--s6) var(--s5); }
.empty-state h2 { font-size: var(--fs-sub); }
.empty-state h4 { font-size: var(--fs-body); font-weight: 600; }
.empty-state p { color: var(--text-muted); max-width: 60ch; }
.empty-state .btn { margin-top: var(--s2); }
.empty-icon { width: 40px; height: 40px; color: var(--accent-text); }
.loading { display: flex; align-items: center; gap: var(--s2); color: var(--text-muted); }
.spinner {
    width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
    display: inline-block; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot { height: 100vh; display: flex; align-items: center; justify-content: center; gap: var(--s3); color: var(--text-muted); font-size: var(--fs-body); }

#blazor-error-ui {
    display: none; position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%); z-index: 100;
    background: #450a0a; border: 1px solid var(--danger); color: var(--text); padding: var(--s3) var(--s4); border-radius: var(--r-md);
    box-shadow: var(--shadow); align-items: center; gap: var(--s4);
}
#blazor-error-ui .reload { color: #fecaca; font-weight: 600; }
#blazor-error-ui .dismiss { background: none; border: none; color: var(--text); cursor: pointer; font-size: var(--fs-sub); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } }

.legend-row { display: grid; gap: var(--s2); padding-bottom: var(--s3); border-bottom: 1px solid var(--border-subtle); }
.legend-row:last-child { border-bottom: none; padding-bottom: 0; }
.icon-tile[draggable=true] { cursor: grab; }
.icon-tile.dragging { opacity: .4; }
.icon-tile.drop-before { box-shadow: -3px 0 0 var(--accent); }
.icon-btn.small { width: 24px; height: 24px; font-size: var(--fs-body); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: none; }
.color-group { display: grid; gap: var(--s2); }
.color-group .subhead { padding: var(--s2) 0 0; }
.color-item { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 40px; }
.color-item label { font-weight: 500; }
.color-item .color-row .mono { font-size: var(--fs-caption); min-width: 64px; }
.inline-row { display: flex; gap: var(--s2); align-items: center; }
.inline-row input { flex: 1; }
.field .custom-input {
    width: 100%; height: 36px; padding: 0 var(--s3); background: var(--bg); border: 1px solid var(--accent);
    border-radius: var(--r-md); font-size: var(--fs-small);
}
.field .custom-input:focus-visible { outline: none; box-shadow: 0 0 0 3px #3b82f640; }
.field .custom-input::placeholder { color: #73829a; }

/* port table */
.port-table { display: grid; gap: var(--s1); }
.port-row { display: grid; grid-template-columns: 72px minmax(0, 1.25fr) minmax(0, 1fr) 28px; gap: var(--s2); align-items: center; border-radius: var(--r-sm); }
.port-row.head { font-size: var(--fs-caption); font-weight: 600; color: var(--text-muted); padding-bottom: var(--s1); }
.port-row input, .port-row select {
    width: 100%; height: 32px; padding: 0 var(--s2); background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--r-sm); font-size: var(--fs-small);
}
.port-row input:hover, .port-row select:hover { border-color: #475569; }
.port-row input:focus-visible, .port-row select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f640; }
.port-row .peer { font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.port-row .peer.free { color: var(--text-muted); }
.port-row.open, .port-row.focused { background: var(--surface-2); box-shadow: 0 0 0 4px var(--surface-2); }
/* a selected port (clicked here or on the canvas; Delete deletes it): tinted in the selection colour */
.port-row:not(.head) { cursor: pointer; }
.port-row:not(.head):not(.open):not(.focused):hover { background: var(--surface-2); box-shadow: 0 0 0 4px var(--surface-2); }
.port-row.focused { --sel-bg: color-mix(in srgb, var(--accent) 18%, var(--surface)); background: var(--sel-bg); box-shadow: 0 0 0 4px var(--sel-bg), inset 3px 0 0 var(--accent); }
.port-detail { display: grid; gap: var(--s4); padding: var(--s3); margin: 0 0 var(--s2); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.bulk-add { display: grid; gap: var(--s4); padding: var(--s4); background: var(--surface-2); border-radius: var(--r-md); }
.connection-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.connection { display: flex; gap: var(--s2); align-items: baseline; width: 100%; text-align: left; padding: var(--s2); border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; font-size: var(--fs-small); cursor: pointer; }
.connection .muted { margin-left: auto; }
.connection:hover { background: var(--surface-2); }
.connection:focus-visible { outline: none; box-shadow: var(--focus); }
.connection:active { border-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* canvas editing */
.box-select { position: absolute; display: none; border: 1px solid var(--accent); background: #3b82f61f; border-radius: 2px; pointer-events: none; z-index: 4; }
.canvas .overlay .handle { pointer-events: all; }
.canvas .overlay .handle:hover rect:last-child { fill: var(--accent); }
.rename-input {
    position: absolute; z-index: 6; height: 36px; padding: 0 var(--s3); font: 600 var(--fs-body) var(--font); color: var(--text);
    background: var(--bg); border: 2px solid var(--accent); border-radius: var(--r-md); box-shadow: var(--shadow); outline: none;
}
textarea.rename-input { height: auto; padding: var(--s2) var(--s3); resize: both; line-height: 1.5; font-weight: 500; }
.menu-backdrop { position: absolute; inset: 0; z-index: 7; }
.context-menu {
    position: absolute; z-index: 8; min-width: 220px; padding: var(--s1); display: grid; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); outline: none;
}
.menu-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s4); height: 32px; padding: 0 var(--s3);
    border: none; border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: var(--fs-small); font-weight: 500;
    cursor: pointer; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item:active { background: var(--border); }
.menu-item.danger { color: var(--danger); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
.menu-item kbd { font: 500 var(--fs-caption) var(--mono); color: var(--text-muted); }
.menu-sep { height: 1px; margin: var(--s1) var(--s2); background: var(--border-subtle); }

/* toolbar dropdown */
.menu-anchor { position: relative; }
.menu-backdrop.fixed { position: fixed; z-index: 40; }
.context-menu.dropdown { top: calc(100% + 4px); left: 0; z-index: 41; min-width: 320px; }
.menu-item span { white-space: nowrap; }
.menu-head { padding: var(--s2) var(--s3) var(--s1); font-size: var(--fs-caption); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.menu-head.plain { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: var(--fs-small); color: var(--text); max-width: 320px; white-space: normal; }
.menu-note { font-size: var(--fs-caption); color: var(--text-muted); font-weight: 500; }
.menu-empty { margin: 0; padding: var(--s1) var(--s3) var(--s2); max-width: 300px; color: var(--text-muted); font-size: var(--fs-caption); line-height: 1.5; }
.menu-item.default span:first-child { font-weight: 600; }
a.menu-item { text-decoration: none; }
.menu-icon { width: 16px; height: 16px; flex: none; color: var(--text-muted); }
/* the build's version, at the foot of the More menu */
.menu-version { margin: 0; padding: var(--s1) var(--s3) var(--s2); color: var(--text-muted); font-size: var(--fs-caption); }
/* a menu item that switches something on and off (Layers) */
.menu-item.toggle-item { justify-content: flex-start; gap: var(--s3); }
.menu-item.toggle-item .menu-note { margin-left: auto; }
.menu-check { width: 16px; height: 16px; flex: none; border: 1.5px solid var(--border); border-radius: 4px; display: grid; place-items: center; color: transparent; }
.menu-item[aria-checked="true"] .menu-check { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.menu-check svg { width: 12px; height: 12px; }
.layer-sample { width: 28px; height: 0; flex: none; border-top: 3px solid currentColor; }
.layer-sample.dotted { border-top-style: dotted; }
.layer-sample.dashed { border-top-style: dashed; border-top-width: 2px; }
.layer-sample.thin { border-top-width: 2px; }
.keys dl { display: grid; grid-template-columns: 200px 1fr; gap: var(--s2) var(--s4); margin: var(--s2) 0 0; }
.keys dt { margin: 0; }
.keys dd { margin: 0; color: var(--text-muted); }
.keys kbd, .menu-item kbd { font: 500 var(--fs-caption) var(--mono); }
.keys kbd { padding: 2px var(--s2); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); }

/* ---------------------------------------------------------------- narrow windows: the toolbar gives up text, never overlaps */
@media (max-width: 1770px) {
    .brand-name { display: none; }
}
@media (max-width: 1630px) {
    .toggle .toggle-text { display: none; }
    .toggle .toggle-icon { display: block; }
    .file-name { width: 144px; }
}
@media (max-width: 1510px) {
    .toolbar { gap: var(--s2); }
    .tool-group { padding-left: var(--s2); }
    .btn.collapsible { width: 36px; padding: 0; }
    .btn.collapsible .btn-label { display: none; }
    .btn.collapsible .btn-icon { display: block; }
    .btn.collapsible { position: relative; }
    .btn.collapsible .count { position: absolute; top: -2px; right: -6px; }
}
@media (max-width: 1370px) {
    .file-name { width: 112px; }
}
/* tablets: the name gives way (it stays in the tooltip), the unsaved dot stays */
@media (max-width: 1110px) {
    .file-name { width: auto; }
    .file-name .file-text { display: none; }
}
@media (max-width: 990px) {
    .toolbar .view-switch button { padding: 0 var(--s2); }
    .zoom-label { min-width: 48px; padding: 0 var(--s2); }
    .toolbar .btn.primary { padding: 0 var(--s3); }
}

/* notes and details: a closed row on every node's panel */
.panel-section.info-section { padding: var(--s2) var(--s4); gap: 0; }
.disclosure {
    display: flex; align-items: center; gap: var(--s2); width: calc(100% + var(--s4)); min-height: 40px; margin: 0 calc(-1 * var(--s2));
    padding: 0 var(--s2); border: none; border-radius: var(--r-md); background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.disclosure:hover { background: var(--surface-2); }
.disclosure:active { background: var(--surface-3); }
.disclosure:focus-visible { outline: none; box-shadow: var(--focus); }
.disclosure-chevron { width: 16px; height: 16px; flex: none; color: var(--text-muted); transition: transform .12s; }
.disclosure[aria-expanded=true] .disclosure-chevron { transform: rotate(90deg); }
.disclosure-title { font-size: var(--fs-small); font-weight: 600; white-space: nowrap; }
.disclosure-sub { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-caption); color: var(--text-muted); }
.info-body { display: grid; gap: var(--s4); padding: var(--s2) 0 var(--s3); }
.inline-row .btn { flex: none; }
a.btn { text-decoration: none; }
.tag-list { list-style: none; margin: 0 0 var(--s1); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.tag-chip {
    display: inline-flex; align-items: center; gap: var(--s1); height: 28px; padding: 0 var(--s1) 0 var(--s3);
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: var(--fs-small); font-weight: 500;
}
.tag-chip .icon-btn.small { width: 20px; height: 20px; border-radius: 999px; font-size: var(--fs-small); }
/* fields: a table where there is room; in a narrow panel each field takes two lines (name with On card and ×, then the
   value), so long names such as "Warranty until" stay readable */
.field-table { display: grid; gap: var(--s1); container: fields / inline-size; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 24px; gap: var(--s2); align-items: center; }
.field-table.with-show .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 56px 24px; }
.field-row.head { font-size: var(--fs-caption); font-weight: 600; color: var(--text-muted); }
.field-table.with-show .field-row.head span:nth-child(3) { text-align: center; }
.field .field-row input[type=text] { height: 32px; padding: 0 var(--s2); border-radius: var(--r-sm); }
.f-show { display: flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 32px; cursor: pointer; }
.f-show-text { display: none; font-size: var(--fs-caption); font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.f-show:hover .f-show-text { color: var(--text); }
.field-row input[type=checkbox] { justify-self: center; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.field-row input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@container fields (max-width: 399px) {
    .field-table.with-show .field-row { grid-template-columns: minmax(0, 1fr) auto 24px; grid-template-areas: "name show remove" "value value value"; row-gap: var(--s1); }
    .field-table.with-show .field-row.head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .field-table.with-show .field-row:not(.head) ~ .field-row { margin-top: var(--s3); }
    .field-table.with-show .f-name { grid-area: name; font-weight: 600; }
    .field-table.with-show .f-value { grid-area: value; }
    .field-table.with-show .f-show { grid-area: show; padding: 0 var(--s1); }
    .field-table.with-show .f-show-text { display: inline; }
    .field-table.with-show .f-remove { grid-area: remove; }
}
@container fields (max-width: 299px) {
    .field-table:not(.with-show) .field-row { grid-template-columns: minmax(0, 1fr) 24px; grid-template-areas: "name remove" "value value"; row-gap: var(--s1); }
    .field-table:not(.with-show) .field-row.head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .field-table:not(.with-show) .field-row:not(.head) ~ .field-row { margin-top: var(--s3); }
    .field-table:not(.with-show) .f-name { grid-area: name; font-weight: 600; }
    .field-table:not(.with-show) .f-value { grid-area: value; }
    .field-table:not(.with-show) .f-remove { grid-area: remove; }
}

/* ---------------------------------------------------------------- Diagram / Inventory */
.view-switch { flex: none; }
.view-switch button { height: 36px; display: inline-flex; align-items: center; gap: var(--s2); }
.problem-badge {
    min-width: 20px; height: 20px; padding: 0 var(--s1); border-radius: 999px; display: inline-grid; place-items: center;
    font-size: var(--fs-caption); font-weight: 700; color: #1c1300; background: var(--warn);
}
.editor.inventory-view { --left-col: 0px; }
.editor.inventory-view .sidebar.left { display: none; }
.canvas-wrap[hidden], .inventory-wrap[hidden] { display: none; }
.inventory-wrap { grid-area: canvas; min-width: 0; min-height: 0; background: var(--bg); }
.inventory { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.inv-bar { display: flex; align-items: flex-end; gap: var(--s4); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border-subtle); background: var(--surface); }
.inv-filter { display: grid; gap: var(--s1); width: min(360px, 40vw); }
.inv-count { padding-bottom: var(--s2); white-space: nowrap; }
.inv-bar .btn { flex: none; }
.inv-bar .btn-icon.shown { display: block; }
.inv-columns { min-width: 240px; max-height: min(480px, 70vh); overflow-y: auto; right: 0; left: auto; }

/* the strip under the filter: a hint, the editing mark or the ticked rows' actions on the left, the problem count on the right;
   its height never changes, so the table doesn't move when the mode or the ticks change */
.inv-strip {
    display: flex; align-items: center; gap: var(--s2); height: 44px; flex: none; padding: 0 var(--s4);
    border-bottom: 1px solid var(--border-subtle); font-size: var(--fs-small); white-space: nowrap; position: relative; z-index: 2;
}
.inv-strip.editing { background: #1d4ed814; }
.inv-strip.bulk { background: #1d4ed826; }
.inv-strip-main { display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1; }
.inv-strip-main > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.inv-pill {
    display: inline-flex; align-items: center; gap: var(--s1); height: 24px; padding: 0 var(--s2); flex: none; border-radius: 999px;
    background: #1d4ed833; color: var(--accent-text); font-size: var(--fs-caption); font-weight: 600;
}
.inv-pill svg { width: 14px; height: 14px; }
.inv-problems-anchor { flex: none; margin-left: auto; }
.inv-problems-btn { gap: var(--s2); color: var(--text); }
.inv-warn-icon { width: 20px; height: 20px; color: var(--warn); flex: none; }
.inv-chevron { width: 16px; height: 16px; flex: none; color: var(--text-muted); }
.inv-problem-menu { left: auto; right: 0; width: min(560px, 70vw); max-height: min(360px, 60vh); overflow-y: auto; }
.inv-problem-menu .menu-item { height: auto; min-height: 32px; padding: var(--s1) var(--s3); }
.inv-problem-menu .menu-item span { white-space: normal; line-height: 1.4; }
.inv-selcount { font-weight: 600; margin-right: var(--s2); }
.inv-net-menu { min-width: 240px; max-height: min(360px, 60vh); overflow-y: auto; }
.inv-tag-pop { width: 288px; }
.inv-menu-right { left: auto; right: 0; min-width: 240px; }
.inv-mode { min-width: 88px; justify-content: center; }
.inv-group-now { font-weight: 600; }
.menu-radio { width: 16px; height: 16px; flex: none; border: 1.5px solid var(--border); border-radius: 50%; }
.menu-item[aria-checked="true"] .menu-radio { border-color: var(--accent-strong); background: radial-gradient(circle, var(--accent-strong) 0 4px, transparent 4.5px); }
.swatch.dot.none { background: transparent; border: 1.5px dashed var(--text-muted); }

.inv-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.inv-scroll > .empty-state { padding: var(--s8) var(--s5); }
.inv-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: var(--fs-small); }
.inv-table th {
    position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 600;
    border-bottom: 1px solid var(--border); padding: 0; white-space: nowrap;
}
.inv-sort {
    display: inline-flex; align-items: center; gap: var(--s1); width: 100%; height: 40px; padding: 0 var(--s3);
    border: none; background: transparent; color: var(--text-muted); font-weight: 600; cursor: pointer;
}
.inv-sort:hover { color: var(--text); background: var(--surface-2); }
.inv-sort:active { background: var(--surface-3); }
.inv-sort:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.inv-sort.on { color: var(--text); }
.inv-sort-icon { width: 16px; height: 16px; opacity: 0; flex: none; }
.inv-sort:hover .inv-sort-icon { opacity: .5; }
.inv-sort.on .inv-sort-icon { opacity: 1; }
.inv-table td {
    padding: 0 var(--s3); height: 40px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap;
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.inv-table tbody tr:hover td { background: var(--surface); }
.inv-table tbody tr.selected td { background: #1d4ed833; }
/* no longer matches the filter after an edit: dimmed, with a mark at its start; same size, so nothing moves */
.inv-table tbody tr.kept td { color: var(--text-muted); }
.inv-table tbody tr.kept td:not(.editing) > * { opacity: .6; }
.inv-table tbody tr.kept td:first-child { box-shadow: inset 3px 0 0 var(--text-muted); }
.inv-table td:focus { outline: none; }
.inv-table td:focus-visible, body.kbd .inv-table td:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.inv-table td.editable { cursor: text; }
.inv-table td.editing { position: relative; overflow: visible; }
.inv-cell-ghost { visibility: hidden; }
.inv-cell-editor { position: absolute; z-index: 3; left: var(--s1); top: 50%; transform: translateY(-50%); width: max(calc(100% - var(--s2)), 200px); }
.inv-checkcell { width: 40px; padding: 0 var(--s3) !important; text-align: center; }
.inv-box {
    display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; vertical-align: middle; cursor: pointer;
    border: 1.5px solid #64748b; border-radius: 4px; background: var(--bg); color: transparent;
}
.inv-box:hover { border-color: var(--accent); }
.inv-box[aria-checked="true"], .inv-box[aria-checked="mixed"] { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.inv-box svg { width: 12px; height: 12px; }
button.inv-box:focus-visible { outline: none; box-shadow: var(--focus); }
button.inv-box:active { transform: scale(.94); }
.inv-showcell { width: 44px; padding: 0 var(--s1) !important; }
.inv-show { opacity: 0; }
.inv-table tr:hover .inv-show, .inv-table tr.selected .inv-show, .inv-table tr.current .inv-show, .inv-showcell:focus .inv-show, .inv-show:focus-visible { opacity: 1; }
.inv-show svg { width: 16px; height: 16px; }
.inv-name { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 500; }
.inv-name.nested { padding-left: var(--s5); }
.inv-col-ip, .inv-col-hostname, .inv-col-ref { font-variant-numeric: tabular-nums; }
.inv-net { display: inline-flex; align-items: center; gap: var(--s1); margin-right: var(--s2); }
.inv-net.inherited { color: var(--text-muted); }
.inv-net.overlay { color: var(--text-muted); font-size: var(--fs-caption); }
.inv-tag {
    display: inline-block; padding: 0 var(--s2); margin-right: var(--s1); border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-2); font-size: var(--fs-caption); font-weight: 500; line-height: 20px;
}
.inv-editor {
    width: 100%; height: 32px; padding: 0 var(--s2); background: var(--bg); color: var(--text);
    border: 1px solid var(--accent); border-radius: var(--r-sm); font-size: var(--fs-small);
}
.inv-editor.mono { font-family: var(--mono); }
.inv-editor:focus-visible { outline: none; box-shadow: 0 0 0 3px #3b82f640; }

/* reading: a row is one thing to click; the one whose details show is marked at its start */
.inv-table[data-mode="view"] tbody tr[data-id] { cursor: pointer; }
.inv-table tbody tr.current td { background: #1d4ed81f; }
.inv-table tbody tr.current td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.inv-table tbody tr:focus { outline: none; }
.inv-table tbody tr:focus-visible, body.kbd .inv-table tbody tr:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.inv-table[data-mode="edit"] td.editable:hover { background: var(--surface-2); }
.inv-table tbody tr.selected:hover td { background: #1d4ed840; }
.inv-col-ip .mono, .inv-col-hostname .mono { font-size: var(--fs-caption); }
/* a group's heading: a row of its own, not sticky (the column headers are) */
.inv-table tr.inv-group th { position: static; padding: var(--s4) var(--s3) var(--s2); background: var(--bg); border-bottom: 1px solid var(--border-subtle); }
.inv-group-title { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-small); font-weight: 600; color: var(--text); }
/* a row just added lights up once */
@keyframes inv-flash { from { background: #3b82f64d; } to { background: transparent; } }
.inv-table tbody tr.flash td { animation: inv-flash 1.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .inv-table tbody tr.flash td { animation: none; } }

/* a list to pick from while typing (the list cells, the add row) */
.combo { position: relative; width: 100%; min-width: 0; }
.combo-list {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 100%; width: max-content; max-width: 360px; max-height: 288px;
    overflow-y: auto; margin: 0; padding: var(--s1); list-style: none; display: grid; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow);
    scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.combo-list.up { top: auto; bottom: calc(100% + 4px); }
.combo-option {
    display: flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 var(--s2); border-radius: var(--r-sm);
    color: var(--text); font-size: var(--fs-small); white-space: nowrap; cursor: pointer;
}
.combo-option:hover { background: var(--surface-2); }
.combo-option.active { background: var(--surface-3); box-shadow: inset 2px 0 0 var(--accent); }
.combo-option.current .combo-text { font-weight: 600; }
.combo-option.new { color: var(--accent-text); }
.combo-icon { width: 16px; height: 16px; flex: none; }
.combo-plus { width: 16px; flex: none; text-align: center; font-weight: 700; }
.combo-hint { margin-left: auto; padding-left: var(--s4); color: var(--text-muted); font-size: var(--fs-caption); }
.combo-empty { padding: var(--s2); color: var(--text-muted); font-size: var(--fs-caption); }


/* the add row at the foot of the list (edit mode) */
.inv-add { flex: none; display: grid; gap: var(--s2); padding: var(--s3) var(--s4) var(--s1); border-top: 1px solid var(--border); background: var(--surface); }
.inv-add-head { display: flex; align-items: baseline; gap: var(--s3); min-width: 0; }
.inv-add-head h3 { display: inline-flex; align-items: center; gap: var(--s1); flex: none; font-size: var(--fs-small); font-weight: 600; }
.inv-add-head h3 svg { width: 16px; height: 16px; color: var(--accent-text); }
.inv-add-head .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-caption); }
.inv-add-fields {
    display: grid; gap: var(--s3); align-items: end;
    grid-template-columns: minmax(144px, 1.3fr) minmax(144px, 1.2fr) minmax(120px, 1fr) minmax(128px, 1fr) minmax(144px, 1.2fr) auto;
}
.inv-add .field > label .muted { font-size: var(--fs-caption); font-weight: 400; }
.inv-add-note { height: 20px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: var(--fs-caption); line-height: 20px; }
.inv-add-note.error { color: var(--danger); font-weight: 500; }

/* the details pane (the inventory's view mode, in the properties panel) */
.details-head { gap: var(--s3); }
.details-head .btn-icon.shown { display: block; width: 16px; height: 16px; }
.details-title { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.details-icon { width: 32px; height: 32px; flex: none; }
.details-name { display: grid; min-width: 0; }
.panel-section .details-name h3 { display: block; font-size: var(--fs-body); overflow-wrap: anywhere; }
.details-name p { font-size: var(--fs-caption); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s2) var(--s4); margin: 0; font-size: var(--fs-small); }
.facts dt { margin: 0; color: var(--text-muted); }
.facts dd { margin: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); overflow-wrap: anywhere; }
.facts .inv-net { margin-right: 0; }
.details-link { color: var(--accent-text); overflow-wrap: anywhere; }
.details-link:hover { color: #bfdbfe; }
.details-ref { padding: 0; border: none; background: none; color: var(--accent-text); font: inherit; text-align: left; cursor: pointer; }
.details-ref:hover { text-decoration: underline; }
.details-ref:focus-visible { outline: none; border-radius: 2px; box-shadow: var(--focus); }
.details-notes { display: grid; gap: var(--s1); }
.details-notes .label { color: var(--text-muted); font-size: var(--fs-caption); }
.details-notes p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.details-table { width: 100%; border-collapse: collapse; font-size: var(--fs-caption); }
.details-table th { padding: 0 var(--s2) var(--s1) 0; color: var(--text-muted); font-weight: 600; text-align: left; }
.details-table td { padding: var(--s1) var(--s2) var(--s1) 0; border-top: 1px solid var(--border-subtle); vertical-align: middle; }
.details-table .inv-net { margin-right: var(--s1); }
.details-port { margin-left: var(--s1); }
.details-list { display: grid; gap: 2px; margin: 0 calc(var(--s2) * -1); padding: 0; list-style: none; }
.details-row {
    display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 32px; padding: var(--s1) var(--s2); border: none;
    border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit; font-size: var(--fs-small); text-align: left; cursor: pointer;
}
.details-row:hover { background: var(--surface-2); }
.details-row:active { background: var(--surface-3); }
.details-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.details-row > .muted { flex: none; font-size: var(--fs-caption); }
.details-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.details-row-end { margin-left: auto; padding-left: var(--s2); }
.details-kind { min-width: 52px; flex: none; color: var(--text-muted); font-size: var(--fs-caption); }

/* Edit selected… in the panel */
.chip-toggle.some { color: var(--text); border-style: dashed; border-color: var(--vlan); }
.chip-toggle.some .dot { opacity: .8; }
.bulk-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
.devlist-group { display: grid; gap: var(--s2); }
.devlist-lines { margin: 0; padding-left: var(--s5); display: grid; gap: var(--s1); font-size: var(--fs-small); }

/* ---------------------------------------------------------------- a cluster's nodes (panel) */
.member-list { display: grid; gap: var(--s1); max-height: 296px; overflow-y: auto; margin: 0 calc(var(--s2) * -1); padding: 0 var(--s2); }
.member-row { align-items: center; gap: var(--s2); min-height: 40px; padding: var(--s1) var(--s2); border-radius: var(--r-sm); }
.member-row:hover { background: var(--surface-2); }
.member-row.on { background: #1d4ed81f; }
.member-row input { margin: 0; }
.member-row > span { min-width: 0; }
.member-row .check-label, .member-row .field-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-inside { margin: 0; overflow-wrap: anywhere; }
.field .ol-search-box input[type=search] { padding-left: var(--s6); padding-right: var(--s6); }
.field .ol-search-box .ol-search-icon { top: 50%; transform: translateY(-50%); }
.field .ol-search-box .ol-clear { top: 50%; transform: translateY(-50%); }
