/* Switchboard — dark operations theme.
   Deliberately dark-only: this is meant to sit on a wall display or a second
   monitor, where a light theme is the wrong answer. */

:root {
  --bg:          #0a0d13;
  --bg-raised:   #11161f;
  --panel:       #141a24;
  --panel-hi:    #1b2331;
  --chassis:     #0c1017;
  --border:      #232c3b;
  --border-hi:   #33405480;

  --text:        #e6edf3;
  --muted:       #8b97a8;
  --faint:       #5c6879;

  --rx:          #38bdf8;
  --tx:          #a78bfa;
  --up:          #3fb950;
  --down:        #3a4453;
  --warn:        #e3b341;
  --hot:         #f0883e;
  --crit:        #f85149;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 15px; letter-spacing: .02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 10px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--rx), var(--tx));
  box-shadow: 0 0 14px color-mix(in srgb, var(--rx) 50%, transparent);
}

.totals { display: flex; gap: 26px; margin-left: auto; flex-wrap: wrap; }
.total { display: flex; flex-direction: column; line-height: 1.25; }
.total-label { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.total-value { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.total-value.rx { color: var(--rx); }
.total-value.tx { color: var(--tx); }

.link-state {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; flex-shrink: 0;
}
.link-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.link-state[data-state="live"] .dot { background: var(--up); box-shadow: 0 0 8px var(--up); animation: pulse 2.4s ease-in-out infinite; }
.link-state[data-state="lost"] .dot { background: var(--crit); box-shadow: 0 0 8px var(--crit); }
.link-state[data-state="connecting"] .dot { background: var(--warn); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- layout ---------- */
main { padding: 20px; display: flex; flex-direction: column; gap: 20px; max-width: 1800px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 16px;
}
.panel-head.compact { padding: 16px 0 8px; }

/* ---------- range picker ---------- */
.range-picker { display: flex; gap: 2px; background: var(--chassis); padding: 3px; border-radius: var(--radius-sm); }
.range-picker button {
  border: 0; background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  padding: 5px 11px; border-radius: 4px; cursor: pointer; transition: .12s;
}
.range-picker button:hover { color: var(--text); background: var(--panel-hi); }
.range-picker button.active { background: var(--panel-hi); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-hi); }
.range-picker.small button { padding: 4px 9px; font-size: 10px; }

/* ---------- charts ---------- */
.chart-host { position: relative; height: 260px; padding: 0 8px 8px; }
.chart-host.short { height: 180px; padding: 0; }
.chart-host canvas { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--faint); font-size: 12px; pointer-events: none;
}
.chart-empty[hidden] { display: none; }

.legend { display: flex; gap: 18px; padding: 0 16px 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.rx { background: var(--rx); }
.swatch.tx { background: var(--tx); }

/* ---------- switch cards ---------- */
.switch-grid { display: flex; flex-direction: column; gap: 20px; }

.switch-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.switch-card.offline { border-color: color-mix(in srgb, var(--crit) 45%, var(--border)); }

.switch-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.switch-id { display: flex; flex-direction: column; min-width: 220px; }
.switch-name { font-size: 14px; font-weight: 600; }
.switch-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px; font-weight: 600;
}
.badge.online { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.badge.offline { background: color-mix(in srgb, var(--crit) 16%, transparent); color: var(--crit); }
.badge.vendor { background: var(--panel-hi); color: var(--muted); }
.badge.pending {
  background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn);
  animation: pulse 1.6s ease-in-out infinite;
}

.switch-metrics { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.metric { display: flex; flex-direction: column; line-height: 1.25; }
.metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.metric-value { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.metric-value.rx { color: var(--rx); }
.metric-value.tx { color: var(--tx); }

.switch-error {
  margin: 0; padding: 10px 16px;
  background: color-mix(in srgb, var(--crit) 10%, transparent);
  color: var(--crit); font-family: var(--mono); font-size: 11px;
  border-bottom: 1px solid var(--border);
}

/* ---------- faceplate ---------- */
.faceplate {
  display: flex; align-items: flex-start; gap: 26px;
  padding: 18px 16px; background: var(--chassis); flex-wrap: wrap;
}
.port-group { display: flex; flex-direction: column; gap: 7px; }
.port-group-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); padding-left: 2px;
}
/* Two staggered rows, the way ports are physically laid out on a 1U switch. */
.port-rows { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); gap: 5px; }
.port-rows.single { grid-template-rows: auto; }

.port {
  position: relative;
  width: 42px; height: 34px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  cursor: pointer;
  padding: 3px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .1s, border-color .12s, box-shadow .12s;
}
.port:hover { transform: translateY(-2px); border-color: var(--border-hi); box-shadow: 0 4px 12px rgba(0,0,0,.5); }
.port:focus-visible { outline: 2px solid var(--rx); outline-offset: 2px; }
.port.sfp { width: 50px; border-radius: 3px; border-style: dashed; }
.port.lag { border-color: var(--tx); }

.port.down { opacity: .45; }
.port.up { border-color: color-mix(in srgb, var(--up) 55%, var(--border)); }
.port.up.warm { border-color: color-mix(in srgb, var(--warn) 65%, var(--border)); }
.port.up.hot  { border-color: color-mix(in srgb, var(--hot) 70%, var(--border)); }
.port.up.crit { border-color: var(--crit); box-shadow: 0 0 10px color-mix(in srgb, var(--crit) 35%, transparent); }
.port.has-errors::after {
  content: ""; position: absolute; top: -3px; right: -3px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--crit); border: 1px solid var(--chassis);
}

.port-num {
  font-family: var(--mono); font-size: 10px; line-height: 1;
  color: var(--muted); text-align: center; font-variant-numeric: tabular-nums;
}
.port.up .port-num { color: var(--text); }

.port-bars { display: flex; flex-direction: column; gap: 2px; }
.port-bar { height: 3px; border-radius: 2px; background: #ffffff10; overflow: hidden; }
.port-bar > i { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .45s ease-out; }
.port-bar.rx > i { background: var(--rx); }
.port-bar.tx > i { background: var(--tx); }

.faceplate-empty { color: var(--faint); font-size: 12px; padding: 6px 2px; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(480px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0,0,0,.5);
  padding: 18px 20px; overflow-y: auto;
  animation: slide-in .18s ease-out;
}
.drawer[hidden] { display: none; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
#drawer-title { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); }
#drawer-subtitle { margin: 2px 0 0; font-family: var(--mono); font-size: 11px; }

.icon-button {
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--muted);
  width: 28px; height: 28px; border-radius: var(--radius-sm); cursor: pointer; flex-shrink: 0;
}
.icon-button:hover { color: var(--text); border-color: var(--border-hi); }

/* The faceplate prints a number; the vendor's own naming lives here. */
.drawer-names {
  display: flex; flex-direction: column; gap: 4px; margin-top: 14px;
  padding: 10px 12px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.drawer-names:empty { display: none; }
.drawer-name-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.drawer-name-label { color: var(--muted); }
.drawer-name-value { font-family: var(--mono); color: var(--text); text-align: right; }

.drawer-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.stat {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.stat-value { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-value.rx { color: var(--rx); }
.stat-value.tx { color: var(--tx); }
.stat-value.up { color: var(--up); }
.stat-value.down { color: var(--faint); }

.counter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin-top: 18px; }
.counter-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.counter-row span:first-child { color: var(--muted); }
.counter-row span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.counter-row.alert span:last-child { color: var(--crit); }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); }
.scrim[hidden] { display: none; }

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--panel-hi); border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 11px; box-shadow: var(--shadow); max-width: 260px;
}
.tooltip[hidden] { display: none; }
.tooltip-title { font-weight: 600; margin-bottom: 4px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); }
.tooltip-row .k { color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; background: var(--chassis); padding: 3px; border-radius: var(--radius-sm); }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 6px 14px; border-radius: 4px; cursor: pointer; transition: .12s;
}
.tabs button:hover { color: var(--text); background: var(--panel-hi); }
.tabs button.active { background: var(--panel-hi); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-hi); }

.view { display: flex; flex-direction: column; gap: 20px; }
.view[hidden] { display: none; }
.pad { padding: 16px; }
.small { font-size: 11px; }
.mono { font-family: var(--mono); }
.head-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.button {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--rx); color: #06121c;
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  padding: 7px 14px; cursor: pointer; transition: .12s; white-space: nowrap;
}
.button:hover { filter: brightness(1.12); }
.button.subtle { background: var(--panel-hi); color: var(--text); border-color: var(--border); }
.button.subtle:hover { border-color: var(--border-hi); filter: none; background: var(--panel); }
.button.danger { background: color-mix(in srgb, var(--crit) 20%, transparent); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.button.danger:hover { background: color-mix(in srgb, var(--crit) 30%, transparent); filter: none; }
.button.tiny { padding: 4px 9px; font-size: 11px; }

.select, .inline-form input {
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; font-family: var(--sans); font-size: 12px;
}
.select:focus, input:focus, textarea:focus { outline: 2px solid var(--rx); outline-offset: -1px; }

.inline-form { display: flex; gap: 8px; margin-top: 12px; max-width: 460px; }
.inline-form input { flex: 1; }
.link { color: var(--rx); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- tables ---------- */
.table-host { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
  text-align: left; padding: 10px 16px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-raised); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- topology ---------- */
.topo-host { position: relative; padding: 8px 16px 16px; overflow-x: auto; }
#topo-svg { width: 100%; display: block; }

/* Sits under the diagram rather than centred over it: with nodes drawn but no
   edges yet, an overlay would land on top of a switch box. */
#topo-empty {
  position: static; inset: auto; display: block;
  padding: 10px 0 0; text-align: center;
}
#topo-empty[hidden] { display: none; }

.topo-node-box {
  fill: var(--bg-raised); stroke: var(--border); stroke-width: 1;
  transition: stroke .12s;
}
.topo-node { cursor: pointer; }
.topo-node:hover .topo-node-box { stroke: var(--border-hi); }
.topo-node:focus-visible .topo-node-box { stroke: var(--rx); stroke-width: 2; }
.topo-node.online .topo-node-accent { fill: var(--up); }
.topo-node.offline .topo-node-accent { fill: var(--crit); }
.topo-node.offline .topo-node-box { stroke: color-mix(in srgb, var(--crit) 45%, var(--border)); }

.topo-node-title { fill: var(--text); font: 600 12px var(--sans); }
.topo-node-sub { fill: var(--faint); font: 10px var(--mono); }
.topo-node-stats { fill: var(--muted); font: 10px var(--mono); }

.topo-edge { cursor: pointer; }
.topo-edge-line { fill: none; stroke: var(--down); stroke-linecap: round; transition: stroke .15s; }
.topo-edge.up .topo-edge-line { stroke: var(--rx); }
.topo-edge-hit { fill: none; stroke: transparent; }
.topo-edge:hover .topo-edge-line { stroke: var(--tx); }
.topo-edge:focus-visible .topo-edge-line { stroke: var(--tx); }
.topo-edge-label {
  fill: var(--muted); font: 9px var(--mono); pointer-events: none;
  /* Outline in the panel colour so the text stays readable where it crosses
     an edge, without needing a background rectangle behind every label. */
  paint-order: stroke; stroke: var(--panel); stroke-width: 3.5px;
  stroke-linejoin: round;
}
.topo-edge:hover .topo-edge-label { fill: var(--text); }

.swatch.up { background: var(--rx); }
.swatch.down { background: var(--down); }

/* Devices are leaves: smaller, quieter, so the switch fabric reads first. */
.topo-device { cursor: pointer; }
.topo-device-box {
  fill: var(--chassis); stroke: var(--border); stroke-width: 1; transition: stroke .12s;
}
.topo-device.up .topo-device-box { stroke: color-mix(in srgb, var(--up) 40%, var(--border)); }
.topo-device:hover .topo-device-box { stroke: var(--border-hi); }
.topo-device:focus-visible .topo-device-box { stroke: var(--rx); stroke-width: 2; }
.topo-device.down { opacity: .6; }
/* The drawings carry their own colours — a PlayStation is white whatever the
   page is doing. Only two things are conditional: an offline device is
   desaturated, and its status light goes out. */
.device-art { display: block; }
.topo-device.down .device-art { filter: saturate(0.25) brightness(0.72); }
.topo-device.down .device-art .art-led { fill: var(--down); }

.kind-preview { align-items: flex-start; }
.kind-preview-art {
  width: 76px; height: 76px; margin-top: 2px;
  background: var(--chassis); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px;
  display: grid; place-items: center;
}
.topo-device-label { fill: var(--text); font: 500 12px var(--sans); }
.topo-device-sub { fill: var(--faint); font: 10px var(--mono); }
.topo-device-line { fill: none; stroke: var(--down); stroke-width: 1.5; stroke-linecap: round; }
.topo-device-line.up { stroke: color-mix(in srgb, var(--up) 55%, transparent); }
.topo-device-line.down { stroke-dasharray: 3 4; }
.topo-section-label {
  fill: var(--faint); font: 9px var(--sans);
  text-transform: uppercase; letter-spacing: .1em;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 24px 60px rgba(0,0,0,.6);
  width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { transform: translateY(10px) scale(.99); opacity: 0; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--border);
}

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.subgrid {
  grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr);
  padding: 14px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.form-grid.subgrid[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field-inline { flex-direction: row; align-items: center; gap: 9px; }
.field-inline .field-label { order: 2; }
.field-label { font-size: 11px; color: var(--muted); font-weight: 500; }
.field-hint { font-size: 10px; color: var(--faint); }
.field input, .field select {
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; font-family: var(--sans); font-size: 12px; width: 100%;
}
.field input[type="checkbox"] { width: auto; accent-color: var(--rx); }
.field input[readonly] { color: var(--muted); background: var(--chassis); }

.form-result {
  grid-column: 1 / -1; margin: 0; padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: 11px; font-family: var(--mono);
  background: var(--bg-raised); color: var(--muted); word-break: break-word;
}
.form-result.ok { background: color-mix(in srgb, var(--up) 12%, transparent); color: var(--up); }
.form-result.error { background: color-mix(in srgb, var(--crit) 12%, transparent); color: var(--crit); }
.form-result[hidden] { display: none; }
.form-error { color: var(--crit); font-size: 11px; margin: 8px 0 0; }
.form-error[hidden] { display: none; }

/* ---------- suggestions ---------- */
.suggestion {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.suggestion:last-child { border-bottom: 0; }

.notice { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.notice p { margin: 0; }
.warn-notice {
  padding: 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ---------- VLAN editor ---------- */
.vlan-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; flex-wrap: wrap;
}

.port-membership { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.port-membership-row { display: flex; align-items: center; gap: 12px; }
.port-membership-label {
  font-family: var(--mono); font-size: 12px; min-width: 62px; color: var(--text);
}
.port-membership-hint { font-size: 10px; color: var(--faint); font-family: var(--mono); }

/* Three mutually exclusive states: a port cannot be tagged and untagged at
   once, so a segmented control says that better than two checkboxes. */
.segmented { display: flex; gap: 2px; background: var(--chassis); padding: 3px; border-radius: var(--radius-sm); }
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 11px; padding: 5px 12px;
  border-radius: 4px; cursor: pointer; transition: .12s;
}
.segmented button:hover { color: var(--text); background: var(--panel-hi); }
.segmented button.active { background: var(--panel-hi); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-hi); }
.segmented button.active:nth-child(2) { color: var(--up); }
.segmented button.active:nth-child(3) { color: var(--tx); }

/* ---------- VLAN chips ---------- */
.drawer-section { margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--muted);
}
.chip strong { color: var(--text); font-family: var(--mono); }
.chip.untagged { border-color: color-mix(in srgb, var(--up) 40%, var(--border)); }
.chip.tagged { border-color: color-mix(in srgb, var(--tx) 40%, var(--border)); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 70; padding: 11px 18px; border-radius: var(--radius);
  background: var(--panel-hi); border: 1px solid var(--border-hi);
  color: var(--text); font-size: 12px; box-shadow: var(--shadow);
  max-width: min(560px, 92vw); animation: toast-in .18s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } }
.toast.ok { border-color: color-mix(in srgb, var(--up) 50%, transparent); }
.toast.error { border-color: color-mix(in srgb, var(--crit) 55%, transparent); }
.toast.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; }
  .tabs { order: 2; }
  .totals { order: 4; width: 100%; margin-left: 0; }
  .link-state { order: 3; margin-left: auto; }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 14px; }
  .totals { gap: 18px; margin-left: 0; order: 4; width: 100%; }
  main { padding: 14px; }
  .drawer-stats { grid-template-columns: 1fr; }
  .counter-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid.subgrid { grid-template-columns: 1fr; }
}
