:root {
  --bg: #050a12;
  --bg-2: #07101c;
  --panel: #0b1523;
  --panel-2: #0e1a2b;
  --panel-3: #111f33;
  --line: rgba(122, 166, 208, .16);
  --line-strong: rgba(122, 166, 208, .3);
  --text: #dbe9f8;
  --muted: #7e94ac;
  --muted-2: #5c7189;
  --accent: #38d9ff;
  --accent-soft: rgba(56, 217, 255, .14);
  --green: #7cf5b8;
  --green-soft: rgba(124, 245, 184, .12);
  --amber: #ffb057;
  --amber-soft: rgba(255, 176, 87, .12);
  --red: #ff5c7a;
  --red-soft: rgba(255, 92, 122, .12);
  --violet: #b39dff;
  --radius: 11px;
  --font: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", "Consolas", "JetBrains Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

button { cursor: pointer; }

::selection { background: rgba(56, 217, 255, .28); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(110, 150, 190, .24);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(110, 150, 190, .4); background-clip: padding-box; }

.hidden { display: none !important; }

.mono { font-family: var(--mono); }
.ok { color: var(--green); }
.danger { color: var(--red); }
.warn { color: var(--amber); }

/* ---------- 布局 ---------- */

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 176px;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(31, 99, 145, .12), transparent 60%),
    var(--bg);
}

.app-shell.logs-collapsed {
  grid-template-rows: 64px minmax(0, 1fr) 42px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 24, 39, .96), rgba(8, 15, 26, .96));
  backdrop-filter: blur(8px);
  z-index: 6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(56, 217, 255, .24);
  background: radial-gradient(circle at 50% 20%, rgba(56, 217, 255, .14), rgba(8, 18, 30, .6));
  box-shadow: inset 0 0 18px rgba(56, 217, 255, .06);
}

.brand-mark svg { width: 26px; height: 26px; }

.brand-copy h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: .17em;
  font-weight: 700;
  color: #eaf5ff;
}

.brand-copy h1 span { color: var(--accent); }

.brand-copy p {
  margin: 3px 0 0;
  font-size: 9.5px;
  letter-spacing: .06em;
  color: var(--muted-2);
  text-transform: uppercase;
}

.brand-copy p em { color: rgba(56, 217, 255, .55); font-style: normal; margin: 0 4px; }

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(12, 22, 36, .7);
  font-size: 9.5px;
  color: var(--muted);
}

.stat i { font-style: normal; }
.stat b { font-family: var(--mono); font-size: 12px; color: #d5e7f8; font-weight: 600; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- 按钮与表单 ---------- */

.btn {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: rgba(20, 35, 54, .55);
  color: #cfe0f0;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }

.btn:hover {
  border-color: rgba(56, 217, 255, .42);
  background: rgba(30, 62, 86, .55);
  color: #eef9ff;
}

.btn:active { transform: translateY(1px); }

.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .device-row:focus-visible {
  outline: 2px solid rgba(56, 217, 255, .55);
  outline-offset: 1px;
}

.btn-primary {
  border-color: rgba(56, 217, 255, .5);
  background: linear-gradient(180deg, rgba(56, 217, 255, .18), rgba(56, 217, 255, .07));
  color: #d8fbff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.btn-primary:hover {
  background: linear-gradient(180deg, rgba(56, 217, 255, .28), rgba(56, 217, 255, .12));
  box-shadow: 0 0 18px rgba(56, 217, 255, .16);
}

.btn-ghost { background: rgba(15, 28, 44, .55); }

.btn-danger {
  border-color: rgba(255, 92, 122, .45);
  background: linear-gradient(180deg, rgba(255, 92, 122, .18), rgba(255, 92, 122, .07));
  color: #ffdbe2;
}

.btn-danger:hover {
  border-color: rgba(255, 92, 122, .7);
  background: rgba(255, 92, 122, .24);
  box-shadow: 0 0 16px rgba(255, 92, 122, .15);
}

.btn-danger-ghost {
  border-color: rgba(255, 92, 122, .28);
  background: rgba(255, 92, 122, .05);
  color: #ffbcc9;
}

.btn-danger-ghost:hover {
  border-color: rgba(255, 92, 122, .55);
  background: rgba(255, 92, 122, .12);
}

#btnConnect.active {
  border-color: rgba(56, 217, 255, .7);
  background: rgba(56, 217, 255, .16);
  color: #e6fbff;
  box-shadow: 0 0 18px rgba(56, 217, 255, .15);
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(15, 28, 44, .55);
  color: var(--muted);
  font-size: 15px;
  transition: .18s;
}

.icon-btn svg { width: 14px; height: 14px; }
.icon-btn.wide { width: auto; padding: 0 9px; font-size: 10px; letter-spacing: .06em; }
.icon-btn:hover { color: #eaf9ff; border-color: rgba(56, 217, 255, .4); }
.icon-btn.collapsed svg { transform: rotate(180deg); }

.zoom-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 19, 31, .5);
}

.zoom-group .icon-btn { border-color: transparent; background: transparent; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.field > span {
  font-size: 9.5px;
  color: var(--muted-2);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.field input, .field select {
  height: 31px;
  width: 100%;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(7, 15, 26, .86);
  color: #dceaf8;
  font-size: 11px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 13px, calc(100% - 8px) 13px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 24px;
}

.field input:focus, .field select:focus {
  border-color: rgba(56, 217, 255, .5);
  box-shadow: 0 0 0 3px rgba(56, 217, 255, .08);
}

.field input::placeholder { color: var(--muted-2); }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.btn-row .btn { width: 100%; padding: 0 6px; }

.microcopy {
  margin: 10px 0 0;
  font-size: 9.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

/* ---------- 主区域 ---------- */

.main-grid {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 322px;
  min-height: 0;
}

.rail {
  min-height: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(9, 17, 28, .92), rgba(7, 13, 22, .96));
}

.rail-left {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 13px;
  border-right: 1px solid var(--line);
}

.rail-right {
  border-left: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 27, 45, .9), rgba(8, 16, 28, .9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 26, 42, .55);
}

.panel-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  color: #d8e8f5;
}

.dot-cyan, .dot-red, .dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.dot-cyan { background: var(--accent); box-shadow: 0 0 7px rgba(56, 217, 255, .7); }
.dot-red { background: var(--red); box-shadow: 0 0 7px rgba(255, 92, 122, .7); }
.dot-green { background: var(--green); box-shadow: 0 0 7px rgba(124, 245, 184, .7); }

.panel-tag {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.panel-tag.danger { color: var(--red); border-color: rgba(255, 92, 122, .3); background: rgba(255, 92, 122, .08); }

.panel-body { padding: 11px; }

.panel-grow {
  flex: 1;
  min-height: 170px;
  display: flex;
  flex-direction: column;
}

.panel-grow .panel-body {
  overflow-y: auto;
  padding: 6px;
}

#testPanel .panel-body { padding-bottom: 10px; }

.trace-result {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 21, .7);
  min-height: 104px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 10.5px;
}

.trace-placeholder {
  padding: 12px;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.7;
}

.trace-card { padding: 10px; }
.trace-card.ok { border-left: 2px solid var(--green); }
.trace-card.fail { border-left: 2px solid var(--red); }

.trace-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trace-status {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  padding: 2px 5px;
  border-radius: 3px;
}

.trace-card.ok .trace-status { color: var(--green); background: var(--green-soft); }
.trace-card.fail .trace-status { color: var(--red); background: var(--red-soft); }
.trace-top b { font-size: 10.5px; font-weight: 600; color: #e6f2fd; }
.trace-latency { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--green); }

.trace-error {
  margin-top: 7px;
  color: #ff9aaf;
  font-size: 9.5px;
  line-height: 1.55;
}

.hop-list { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }

.hop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: #c6d8e9;
}

.hop-index {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-style: normal;
  flex: 0 0 auto;
}

.hop-note { margin-left: auto; color: var(--muted-2); font-size: 8.5px; text-align: right; }
.hop-ip { color: var(--accent); font-size: 8.5px; }

.trace-nats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.nat-chip {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--amber);
  border: 1px solid rgba(255, 176, 87, .25);
  background: rgba(255, 176, 87, .07);
  border-radius: 3px;
  padding: 1px 5px;
}

.trace-foot {
  margin-top: 8px;
  font-size: 8.5px;
  color: var(--muted-2);
  line-height: 1.5;
  border-top: 1px dashed var(--line);
  padding-top: 7px;
}

/* ---------- 设备清单 ---------- */

.device-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 7px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}

.device-row:hover { background: rgba(56, 217, 255, .06); border-color: rgba(56, 217, 255, .16); }
.device-row.selected { background: rgba(56, 217, 255, .09); border-color: rgba(56, 217, 255, .3); }
.device-row.offline { opacity: .62; }

.device-type {
  width: 30px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .04em;
  flex: 0 0 auto;
}

.device-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.device-info strong { font-size: 10.5px; font-weight: 600; color: #dceaf8; }
.device-info small {
  font-size: 8px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-state {
  font-size: 8px;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.device-state.on { color: var(--green); background: rgba(124, 245, 184, .08); }
.device-state.off { color: var(--red); background: rgba(255, 92, 122, .08); }

/* ---------- 拓扑舞台 ---------- */

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 50% 45%, rgba(17, 48, 74, .22), transparent 70%),
    #060c15;
}

.stage-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(90, 140, 185, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 140, 185, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 50%, #000 30%, transparent 82%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 30%, transparent 82%);
  pointer-events: none;
}

#topology {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

.stage.connect-mode #topology { cursor: crosshair; }

.stage-hint, .stage-legend {
  position: absolute;
  z-index: 3;
  font-size: 9.5px;
  color: var(--muted-2);
  background: rgba(7, 14, 24, .72);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.stage-hint { left: 14px; bottom: 12px; }
.stage.connect-mode .stage-hint { color: var(--accent); border-color: rgba(56, 217, 255, .3); }

.stage-legend {
  right: 14px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
}

.stage-legend span { display: inline-flex; align-items: center; gap: 4px; }

.legend-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.fw { background: var(--amber); }
.legend-dot.router { background: var(--accent); }
.legend-dot.switch { background: var(--violet); }
.legend-dot.host { background: var(--green); }
.legend-line {
  width: 14px;
  height: 1px;
  display: inline-block;
  background: linear-gradient(90deg, rgba(56, 217, 255, .2), var(--green));
}

/* SVG 设备卡片 */

.device-card { cursor: grab; }
.device-card:active { cursor: grabbing; }

.device-card .card-bg {
  fill: url(#cardGrad);
  stroke: rgba(122, 166, 208, .28);
  stroke-width: 1;
  transition: stroke .2s, filter .2s;
}

.device-card:hover .card-bg {
  stroke: rgba(56, 217, 255, .5);
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .35));
}

.device-card.selected .card-bg {
  stroke: rgba(56, 217, 255, .9);
  stroke-width: 1.4;
  filter: drop-shadow(0 0 12px rgba(56, 217, 255, .22));
}

.device-card.offline { opacity: .55; }
.device-card.offline .card-bg { stroke: rgba(255, 92, 122, .35); }

.card-accent { opacity: .7; }
.card-name { fill: #e8f3ff; font-size: 11.5px; font-weight: 600; }
.card-sub { fill: rgba(151, 176, 201, .72); font-size: 8.1px; letter-spacing: .02em; }
.card-kind { fill: rgba(146, 172, 198, .5); font-size: 7.2px; letter-spacing: .14em; }

.status-led {
  fill: var(--green);
  filter: drop-shadow(0 0 4px rgba(124, 245, 184, .8));
}

.offline .status-led { fill: var(--red); filter: drop-shadow(0 0 4px rgba(255, 92, 122, .8)); }

.port { cursor: pointer; }
.port-dot {
  fill: #263a50;
  stroke: rgba(130, 172, 210, .45);
  stroke-width: 1;
  transition: fill .16s, stroke .16s;
}

.port.linked .port-dot {
  fill: #34c98a;
  stroke: #8ef8c6;
  filter: drop-shadow(0 0 4px rgba(57, 230, 160, .55));
}

.port.down .port-dot { fill: var(--red); stroke: #ff9cb0; }
.port.free .port-dot { opacity: .85; }
.port:hover .port-dot { fill: var(--accent); stroke: #b9f4ff; }

.stage.connect-mode .port.free .port-dot {
  fill: var(--accent);
  stroke: #d8fbff;
  animation: portPulse 1.6s ease-in-out infinite;
}

.port.armed .port-dot {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2.4;
  filter: drop-shadow(0 0 7px rgba(56, 217, 255, .9));
}

.port-alias { fill: #d2e3f2; font-size: 9px; font-weight: 500; }
.port-ip { fill: rgba(147, 175, 200, .82); font-size: 8.2px; font-family: var(--mono); }
.port.down .port-alias { fill: rgba(255, 156, 176, .85); }

@keyframes portPulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

.link-base { stroke-width: 1.2; opacity: .5; }
.link-flow {
  stroke: var(--green);
  stroke-width: 1.2;
  stroke-dasharray: 4 11;
  opacity: .5;
  animation: flowDash 1.8s linear infinite;
}

.link.down .link-base { stroke: var(--red); opacity: .5; stroke-dasharray: 4 7; }
.link.selected .link-base { stroke: #eaf9ff; opacity: .9; stroke-width: 1.6; }
.link-hit { stroke: transparent; stroke-width: 12; cursor: pointer; }

@keyframes flowDash { to { stroke-dashoffset: -30; } }

.packet-dot { filter: drop-shadow(0 0 8px rgba(57, 230, 160, .65)); }
.alarm-flash .card-bg { animation: alarmFlash .9s ease-in-out 2; }
.ok-flash .card-bg { animation: okFlash .8s ease-in-out; }

@keyframes alarmFlash {
  0%, 100% { stroke: rgba(255, 92, 122, .3); }
  50% { stroke: var(--red); filter: drop-shadow(0 0 16px rgba(255, 92, 122, .5)); }
}

@keyframes okFlash {
  0%, 100% { stroke: rgba(124, 245, 184, .3); }
  50% { stroke: var(--green); filter: drop-shadow(0 0 14px rgba(124, 245, 184, .4)); }
}

/* ---------- 通知 ---------- */

.toast-layer {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9;
  pointer-events: none;
  max-width: 340px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 20, 34, .94);
  color: #d8e8f6;
  font-size: 10px;
  line-height: 1.5;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  animation: toastIn .22s ease-out;
  backdrop-filter: blur(8px);
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--accent);
  flex: 0 0 auto;
}

.toast.success { border-color: rgba(124, 245, 184, .35); }
.toast.success .toast-dot { background: var(--green); box-shadow: 0 0 7px rgba(124, 245, 184, .6); }
.toast.warn { border-color: rgba(255, 176, 87, .35); }
.toast.warn .toast-dot { background: var(--amber); }
.toast.danger { border-color: rgba(255, 92, 122, .45); }
.toast.danger .toast-dot { background: var(--red); box-shadow: 0 0 7px rgba(255, 92, 122, .6); }
.toast.leaving { opacity: 0; transform: translateX(8px); transition: .22s; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- 检查器 ---------- */

.inspector { padding: 16px 15px 26px; }

.insp-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.insp-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--kind-color) 32%, transparent);
  background:
    radial-gradient(circle at 50% 10%, color-mix(in srgb, var(--kind-color) 15%, transparent), transparent 70%),
    rgba(9, 18, 30, .8);
  color: var(--kind-color);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.insp-title { min-width: 0; flex: 1; }
.insp-title h2 { margin: 1px 0 2px; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.insp-title p { margin: 0; font-size: 9.5px; color: var(--muted); }
.insp-title .insp-os { font-family: var(--mono); font-size: 8px; color: var(--muted-2); letter-spacing: .05em; margin-top: 2px; }

.state-badge {
  font-size: 8px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: .05em;
  flex: 0 0 auto;
}

.state-badge.on { color: var(--green); background: rgba(124, 245, 184, .1); border: 1px solid rgba(124, 245, 184, .2); }
.state-badge.off { color: var(--red); background: rgba(255, 92, 122, .1); border: 1px solid rgba(255, 92, 122, .25); }

.insp-actions { display: flex; gap: 8px; margin: 13px 0 0; }
.insp-actions .btn { flex: 1; height: 31px; font-size: 10.5px; }

.cred-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(56, 217, 255, .045);
  border: 1px dashed rgba(56, 217, 255, .18);
  font-size: 8.5px;
  color: var(--muted);
}

.cred-hint b { font-size: 9px; color: #cfeeff; font-weight: 500; }
.cred-hint em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 7.5px; color: var(--muted-2); }

.insp-section { margin-top: 19px; }

.insp-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .08em;
  color: #b8ccdf;
  text-transform: uppercase;
}

.insp-section h3 em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted-2);
  background: rgba(255, 255, 255, .04);
  border-radius: 3px;
  padding: 1px 5px;
}

.iface-list { display: flex; flex-direction: column; }

.iface-row {
  padding: 8px 0;
  border-bottom: 1px dashed rgba(122, 166, 208, .1);
}

.iface-row:last-child { border-bottom: 0; padding-bottom: 2px; }

.iface-top { display: flex; align-items: center; gap: 6px; }

.iface-name {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: .01em;
}

.iface-alias { font-size: 8px; letter-spacing: .06em; color: var(--muted-2); }
.iface-top .toggle-btn { margin-left: auto; }

.iface-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 8.5px;
  color: var(--muted);
}

.iface-meta .mono { color: #c3d6e7; font-size: 8.6px; }

.zone-pill, .mode-pill {
  font-size: 7.5px;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
  letter-spacing: .04em;
}

.zone-untrust { color: var(--amber); border-color: rgba(255, 176, 87, .25); background: rgba(255, 176, 87, .08); }
.zone-trust { color: var(--green); border-color: rgba(124, 245, 184, .25); background: rgba(124, 245, 184, .07); }
.zone-dmz { color: var(--violet); border-color: rgba(179, 157, 255, .25); background: rgba(179, 157, 255, .08); }
.mode-pill { color: var(--violet); }

.peer-link { color: var(--muted-2); font-size: 8.2px; }
.peer-none { color: rgba(126, 148, 172, .55); font-size: 8.2px; }

.toggle-btn {
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(10, 20, 34, .6);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .03em;
  color: var(--muted);
  transition: .16s;
}

.toggle-btn.on { color: var(--green); border-color: rgba(124, 245, 184, .3); background: rgba(124, 245, 184, .08); }
.toggle-btn.off { color: var(--red); border-color: rgba(255, 92, 122, .25); background: rgba(255, 92, 122, .06); }
.toggle-btn:hover { filter: brightness(1.2); border-color: rgba(56, 217, 255, .4); }
.toggle-btn.small { height: 18px; font-size: 7.5px; }
.toggle-btn.tiny { height: 18px; font-size: 7.5px; padding: 0 6px; margin-left: auto; }

.policy-list { display: flex; flex-direction: column; gap: 7px; }

.policy-card {
  padding: 8px 9px;
  border-radius: 6px;
  border: 1px solid rgba(122, 166, 208, .12);
  border-left: 2px solid rgba(124, 245, 184, .5);
  background: rgba(10, 20, 34, .55);
}

.policy-card.disabled { opacity: .5; border-left-color: var(--red); }

.policy-top { display: flex; align-items: center; gap: 6px; }
.policy-top strong { font-size: 9.5px; font-weight: 600; color: #d8e8f7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.action-pill {
  font-size: 7px;
  letter-spacing: .06em;
  padding: 1px 5px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.action-pill.allow { color: var(--green); background: rgba(124, 245, 184, .1); }
.action-pill.deny { color: var(--red); background: rgba(255, 92, 122, .1); }

.policy-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 8.2px;
  color: var(--muted);
}

.policy-meta .mono { color: var(--muted-2); font-size: 7.8px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.policy-foot { margin-top: 3px; font-size: 7.8px; color: var(--muted-2); }

.service-list { display: flex; flex-direction: column; gap: 1px; }

.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(122, 166, 208, .1);
  font-size: 9.5px;
  color: #c8dbee;
}

.service-row:last-child { border-bottom: 0; }

.blacklist-wrap { margin-top: 10px; }
.sub-label { font-size: 8px; color: var(--muted-2); letter-spacing: .05em; margin-bottom: 6px; }
.sub-label em { font-style: normal; color: var(--red); font-family: var(--mono); margin-left: 3px; }
.blacklist { display: flex; flex-wrap: wrap; gap: 5px; }

.black-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 92, 122, .25);
  background: rgba(255, 92, 122, .07);
  color: #ffb6c4;
  font-family: var(--mono);
  font-size: 8px;
  transition: .16s;
}

.black-chip span { color: rgba(255, 182, 196, .6); }
.black-chip:hover { background: rgba(255, 92, 122, .16); border-color: rgba(255, 92, 122, .5); }

.empty-note { margin: 4px 0; font-size: 8.5px; color: var(--muted-2); line-height: 1.6; }

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8px;
  color: var(--muted-2);
  margin-bottom: 5px;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 8.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(122, 166, 208, .3);
}

.text-btn:hover { color: var(--accent); }
.text-btn.danger { color: rgba(255, 92, 122, .8); }

.session-list, .route-list, .vlan-list, .mac-list { display: flex; flex-direction: column; gap: 0; }

.session-row, .route-row, .vlan-row, .mac-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(122, 166, 208, .08);
  font-size: 8.2px;
  color: var(--muted);
}

.session-row .mono { font-size: 8px; color: #bfd4e7; flex: 1; }
.session-meta { color: var(--muted-2); font-size: 7.6px; text-align: right; }

.route-type {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 7.5px;
  flex: 0 0 auto;
}

.route-type.c { color: var(--green); background: rgba(124, 245, 184, .08); }
.route-type.s { color: var(--accent); background: rgba(56, 217, 255, .08); }
.route-row .mono { color: #c4d8ea; font-size: 8px; flex: 1; }
.route-next, .route-iface { font-family: var(--mono); font-size: 7.4px; color: var(--muted-2); }
.route-iface { width: 62px; text-align: right; }
.route-row.inactive { opacity: .45; }

.vlan-id {
  width: 20px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: rgba(179, 157, 255, .1);
  color: var(--violet);
  font-family: var(--mono);
  font-size: 8px;
  flex: 0 0 auto;
}

.vlan-row strong { font-size: 8.5px; font-weight: 500; color: #c8dbec; flex: 1; }
.vlan-ports { font-size: 7.5px; color: var(--muted-2); text-align: right; }
.vlan-ports i { font-style: normal; opacity: .55; }

.mac-row .mono { font-size: 7.5px; color: #c4d8ea; flex: 1; }
.mac-row > span:nth-child(2) { font-family: var(--mono); font-size: 7.2px; color: var(--muted); width: 76px; }
.vlan-tag { font-size: 7px; color: var(--violet); background: rgba(179, 157, 255, .08); padding: 1px 4px; border-radius: 3px; }

.kv-list { display: flex; flex-direction: column; }
.kv-row, .kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(122, 166, 208, .1);
  font-size: 9px;
}

.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-size: 9px; color: #d3e4f4; font-weight: 500; }

.host-note {
  margin: 10px 0 0;
  font-size: 8.5px;
  line-height: 1.65;
  color: var(--muted-2);
  border-left: 2px solid rgba(56, 217, 255, .2);
  padding-left: 8px;
}

.insp-footnote {
  margin: 16px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 8px;
  line-height: 1.65;
  color: var(--muted-2);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.stat-grid > div {
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(9, 18, 30, .6);
  text-align: center;
}

.stat-grid b { display: block; font-family: var(--mono); font-size: 15px; color: #d9edf9; font-weight: 600; }
.stat-grid span { display: block; margin-top: 2px; font-size: 7.5px; color: var(--muted-2); }

.guide-list {
  margin: 0;
  padding-left: 15px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 8.5px;
  line-height: 1.6;
  color: var(--muted);
}

.guide-list b { color: #d0e5f6; font-weight: 500; }
.guide-list .mono { color: var(--accent); font-size: 8px; }

.overview-head { padding-bottom: 12px; }

/* ---------- 日志 ---------- */

.logdock {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 15, 25, .96), rgba(5, 11, 19, .98));
  z-index: 5;
}

.logdock-head {
  height: 40px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
}

.logdock-title { display: flex; align-items: center; gap: 7px; }
.logdock-title h2 { margin: 0; font-size: 10px; font-weight: 600; letter-spacing: .06em; color: #b9cee1; }

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(124, 245, 184, .8);
  animation: livePulse 2s infinite;
}

@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.logcount {
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--accent);
  background: rgba(56, 217, 255, .08);
  border: 1px solid rgba(56, 217, 255, .18);
  border-radius: 8px;
  padding: 1px 6px;
}

.log-filters { display: flex; gap: 3px; }

.chip {
  height: 21px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-2);
  font-size: 8.5px;
  letter-spacing: .03em;
  transition: .16s;
}

.chip:hover { color: var(--text); background: rgba(255, 255, 255, .035); }
.chip.active { color: var(--accent); background: rgba(56, 217, 255, .08); border-color: rgba(56, 217, 255, .22); }

.logdock-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.logdock-actions .icon-btn { width: 25px; height: 25px; }

.log-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 5px 0;
  font-size: 10px;
}

.log-row {
  display: grid;
  grid-template-columns: 54px 46px 86px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 4px 16px;
  border-left: 2px solid transparent;
  transition: background .15s;
}

.log-row:hover { background: rgba(255, 255, 255, .025); }
.log-time { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); }
.log-level { font-family: var(--mono); font-size: 7.5px; letter-spacing: .04em; color: var(--muted); }
.log-dev { font-family: var(--mono); font-size: 8px; color: #9db8d0; letter-spacing: .03em; }
.log-text { font-size: 9px; color: #b9cee0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log-row.level-success .log-level { color: var(--green); }
.log-row.level-warn .log-level { color: var(--amber); }
.log-row.level-alert .log-level { color: var(--red); }
.log-row.level-alert { border-left-color: rgba(255, 92, 122, .55); background: rgba(255, 92, 122, .035); }
.log-row.level-warn { border-left-color: rgba(255, 176, 87, .35); }
.log-row.level-success { border-left-color: rgba(124, 245, 184, .3); }
.log-row.cat-security .log-dev { color: #ff9aae; }

.log-empty {
  padding: 24px;
  text-align: center;
  font-size: 9.5px;
  color: var(--muted-2);
}

.logs-collapsed .log-list { display: none; }
.logs-collapsed .logdock { overflow: hidden; }

/* ---------- 控制台 ---------- */

.console-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 4vw;
  background: rgba(3, 7, 13, .82);
  backdrop-filter: blur(7px);
}

.console-window {
  width: min(1080px, 94vw);
  height: min(760px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(56, 217, 255, .35);
  background: #040a12;
  box-shadow:
    0 35px 90px rgba(0, 0, 0, .65),
    0 0 0 1px rgba(0, 0, 0, .5) inset,
    0 0 50px rgba(56, 217, 255, .06);
}

.console-head {
  height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(56, 217, 255, .16);
  background: linear-gradient(180deg, #0a1724, #07111b);
}

.console-id { display: flex; align-items: center; gap: 10px; }
.console-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(124, 245, 184, .8);
}

.console-led.off { background: var(--red); box-shadow: 0 0 8px rgba(255, 92, 122, .8); }
.console-id strong { display: block; font-family: var(--mono); font-size: 12px; font-weight: 600; color: #e7f6ff; letter-spacing: .04em; }
.console-id small { display: block; font-size: 8.5px; color: var(--muted-2); margin-top: 2px; }

.console-meta { display: flex; align-items: center; gap: 14px; }
.console-conn { font-family: var(--mono); font-size: 7.5px; letter-spacing: .06em; color: var(--muted-2); }
.console-time { font-family: var(--mono); font-size: 8px; color: var(--muted); }
.console-meta .icon-btn { width: 26px; height: 26px; font-size: 12px; border-color: transparent; background: transparent; }

.console-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.62;
  color: #cde6e0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .012) 0, rgba(255, 255, 255, .012) 1px, transparent 1px, transparent 3px),
    radial-gradient(900px 400px at 50% 0%, rgba(36, 100, 110, .07), transparent 70%),
    #040a12;
  outline: none;
}

.term-line { white-space: pre-wrap; word-break: break-word; min-height: 1.62em; }
.t-dim { color: #5f7489; }
.t-ok { color: #7cf5b8; }
.t-warn { color: #ffcf7a; }
.t-err { color: #ff8499; }
.t-accent { color: var(--accent); }
.boot-ok { color: #63cfa8; }
.boot-dim { color: #55697e; }
.term-echo .t-prompt { color: #7cf5b8; }
.term-echo .t-value { color: #e6f4ff; }

.console-inputbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-top: 1px solid rgba(56, 217, 255, .12);
  background: #06101a;
  font-family: var(--mono);
}

.term-prompt { font-size: 12px; color: #7cf5b8; white-space: pre; flex: 0 0 auto; }

#termInput {
  flex: 1;
  min-width: 0;
  height: 22px;
  background: transparent;
  border: 0;
  outline: none;
  color: #dffaf0;
  font-family: var(--mono);
  font-size: 12px;
  caret-color: #7cf5b8;
}

#termInput:disabled { opacity: .4; }

.enter-hint {
  font-family: var(--mono);
  font-size: 7px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  letter-spacing: .06em;
}

.console-foot {
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  background: #050d16;
  font-size: 8.5px;
  color: var(--muted-2);
}

.console-foot b { color: #b9d9e6; font-weight: 500; font-family: var(--mono); }
.console-foot span { color: rgba(122, 166, 208, .3); }

/* ---------- 模态 ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 13, .78);
  backdrop-filter: blur(6px);
}

.modal {
  width: min(420px, 90vw);
  border-radius: 11px;
  border: 1px solid rgba(56, 217, 255, .28);
  background: linear-gradient(180deg, #0d1a2a, #08111c);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.modal-head { padding: 15px 17px 0; }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: #eaf6ff; }
.modal-body { padding: 10px 17px 18px; font-size: 10.5px; line-height: 1.7; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 17px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .015); }

/* ---------- 响应式 ---------- */

@media (max-width: 1500px) {
  .main-grid { grid-template-columns: 250px minmax(0, 1fr) 300px; }
  .topbar { gap: 14px; padding: 0 14px; }
  .stat { padding: 3px 7px; font-size: 8.5px; }
  .stat b { font-size: 10.5px; }
  .brand-copy p { font-size: 8.5px; }
}

@media (max-width: 1300px) {
  .main-grid { grid-template-columns: 234px minmax(0, 1fr) 284px; }
  .topbar-stats .stat:nth-child(4),
  .topbar-stats .stat:nth-child(5) { display: none; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 32px; padding: 0; }
  .inspector { padding: 14px 12px 22px; }
  .rail-left { padding: 10px; gap: 9px; }
}

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 218px minmax(0, 1fr) 0; }
  .rail-right { display: none; }
  .topbar-stats { display: none; }
  .brand-copy p { display: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-rows: 58px minmax(0, 1fr) 154px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-copy h1 { font-size: 13px; }
  .topbar-actions { gap: 5px; }
  .main-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(280px, 1fr) auto;
    overflow-y: auto;
  }
  .stage { order: -1; border-right: 0; min-height: 280px; }
  .rail-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    padding: 9px;
    border-right: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
  #testPanel, #attackPanel { min-width: 0; }
  #devicePanel { grid-column: 1 / -1; min-height: 0; }
  #devicePanel .panel-body { max-height: 150px; }
  .rail-right { display: none; }
  .stage-hint, .stage-legend { display: none; }
  .logdock { display: flex; }
  .logdock-head { gap: 8px; padding: 0 10px; }
  .logdock-title h2 { display: none; }
  .log-row { grid-template-columns: 46px 36px 62px minmax(0, 1fr); gap: 6px; padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
