:root {
  color-scheme: dark;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #171b23;
  --surface-3: #1d222c;
  --line: #282e39;
  --line-strong: #384151;
  --fg: #eef1f6;
  --muted: #929cac;
  --faint: #687384;
  --ok: #46d59a;
  --warn: #efbd5b;
  --bad: #ff686d;
  --unknown: #737e91;
  --accent: #77a7ff;
  --accent-soft: rgba(119, 167, 255, 0.12);
  --edge-dep: #6593c7;
  --edge-flow: #8d7fd1;
  --edge-client: #6e7b8e;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef1f5;
    --line: #dfe4eb;
    --line-strong: #c9d0da;
    --fg: #171b23;
    --muted: #606b7a;
    --faint: #87919f;
    --ok: #178a5d;
    --warn: #a66800;
    --bad: #d43d45;
    --unknown: #7b8492;
    --accent: #346ed1;
    --accent-soft: rgba(52, 110, 209, 0.1);
    --edge-dep: #4779ae;
    --edge-flow: #7664bc;
    --edge-client: #7e8998;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

main { max-width: 1240px; margin: 0 auto; padding: 34px 24px 56px; }

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.brand { min-width: 0; }
.eyebrow, .section-kicker, .gate-kicker, .inspector-kicker {
  color: var(--accent);
  font: 650 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .16em;
}

.title-row { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.2; letter-spacing: -.035em; }
.brand p { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }

.connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--unknown); }
.pulse.live { background: var(--ok); animation: breathe 2.4s ease-in-out infinite; }
.pulse.failed { background: var(--bad); }
@keyframes breathe { 50% { opacity: .45; } }

.top-nav { padding-top: 18px; }
.navlink {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 160ms var(--ease-out);
}
.navlink:active { transform: scale(.97); }

/* ---- 摘要 ---- */
.overview {
  display: grid;
  grid-template-columns: 1.45fr repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.summary {
  min-width: 0;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.summary-health { border-left: 3px solid var(--unknown); }
.summary-health[data-state="ok"] { border-left-color: var(--ok); }
.summary-health[data-state="warn"] { border-left-color: var(--warn); }
.summary-health[data-state="bad"] { border-left-color: var(--bad); }
.summary-label { color: var(--muted); font-size: 11.5px; }
.summary strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.summary-health[data-state="ok"] strong { color: var(--ok); }
.summary-health[data-state="warn"] strong { color: var(--warn); }
.summary-health[data-state="bad"] strong { color: var(--bad); }
#serviceCard[data-state="warn"] strong,
#protectionCard[data-state="warn"] strong { color: var(--warn); }
#serviceCard[data-state="bad"] strong,
#protectionCard[data-state="bad"] strong { color: var(--bad); }
#serviceCard[data-state="ok"] strong,
#protectionCard[data-state="ok"] strong { color: var(--ok); }
.summary-sub { overflow: hidden; margin-top: 4px; color: var(--faint); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
#freshCard[data-state="warn"] strong, #freshCard[data-state="bad"] strong { color: var(--warn); }

/* ---- 通用区块 ---- */
.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.section-heading {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.section-heading.compact { min-height: 0; padding-bottom: 8px; border-bottom: 0; }
.section-heading h2 { margin: 3px 0 0; font-size: 15px; line-height: 1.25; letter-spacing: -.01em; }
.section-help, .filter-result { color: var(--faint); font-size: 11.5px; text-align: right; }

.filter-section { margin-bottom: 12px; padding-bottom: 12px; }
.view-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; padding: 2px 14px 12px; }
.view-tab {
  min-width: 0;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 10px 11px;
  color: inherit;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  appearance: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
.view-tab strong { overflow: hidden; font-size: 12px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.view-tab span { overflow: hidden; color: var(--faint); font-size: 9.5px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.view-tab.active { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.view-tab:active { transform: scale(.98); }
.relation-row { display: flex; align-items: center; gap: 11px; padding: 0 14px; }
.relation-label { flex: 0 0 auto; color: var(--faint); font-size: 10.5px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }
.filter {
  min-height: 30px;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font: 560 11px/1.2 inherit;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
.filter.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.filter:disabled { opacity: .32; cursor: not-allowed; }
.filter:active { transform: scale(.96); }

.topology-content { display: flex; flex-direction: column; gap: 12px; }
.map-section { order: 1; }
.routes-section { order: 2; }

/* ---- 地图 ---- */
.map-wrap {
  overflow-x: auto;
  padding: 18px 16px 20px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
.map-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.map { position: relative; width: 100%; min-width: var(--map-min, 760px); min-height: 340px; }
#wires {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  transition: opacity 220ms var(--ease-out);
}
#wires.in { opacity: 1; }
#cols { position: relative; z-index: 1; display: flex; gap: 42px; align-items: stretch; min-height: 340px; }

.site {
  flex: 1 0 178px;
  min-width: 178px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.site-head { display: flex; align-items: center; gap: 7px; min-height: 24px; margin-bottom: 9px; }
.site-head .site-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--unknown); }
.site-head[data-state="ok"] .site-dot { background: var(--ok); }
.site-head[data-state="warn"] .site-dot { background: var(--warn); }
.site-head[data-state="bad"] .site-dot { background: var(--bad); }
.site h3 { margin: 0; color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .03em; }
.site-count { margin-left: auto; color: var(--faint); font: 10.5px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }

.node {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  position: relative;
  padding: 9px 10px;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  appearance: none;
  cursor: pointer;
  opacity: 0;
  transform: translateY(5px);
  animation: in 220ms var(--ease-out) forwards;
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}
.node::before, .node::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  opacity: 0;
}
.node::before { left: -4px; }
.node::after { right: -4px; }
.node.has-in::before, .node.has-out::after { opacity: 1; }
@keyframes in { to { opacity: 1; transform: none; } }
.node[data-state="bad"] { border-color: var(--bad); }
.node[data-state="warn"] { border-color: var(--warn); }
.node.filtered-out { opacity: .34 !important; }
.node.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.node .dot, .legend .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); }
.node[data-state="ok"] .dot, .legend .dot[data-state="ok"] { background: var(--ok); }
.node[data-state="warn"] .dot, .legend .dot[data-state="warn"] { background: var(--warn); }
.node[data-state="bad"] .dot, .legend .dot[data-state="bad"] { background: var(--bad); }
.nl { display: block; overflow: hidden; font-weight: 620; font-size: 12.5px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.ns { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 10.5px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.nms { color: var(--faint); font: 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.node-protection {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin-top: 2px;
  padding-top: 7px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.node-protection .shield { color: var(--unknown); font-size: 15px; line-height: 1; }
.node-protection[data-state="ok"] .shield { color: var(--ok); }
.node-protection[data-state="warn"] .shield { color: var(--warn); }
.node-protection[data-state="bad"] .shield { color: var(--bad); }
.node-protection b, .node-protection small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-protection b { color: var(--fg); font-size: 10.5px; font-weight: 620; }
.node-protection small { margin-top: 1px; color: var(--faint); font-size: 9.5px; }

#wires path.edge { opacity: .68; transition: opacity 160ms var(--ease-out), stroke-width 160ms var(--ease-out); }
#wires path.edge[data-type="flow"] { opacity: .72; }
#wires path.edge[data-type="client"] { opacity: .46; }
#wires path.edge.dim { opacity: .09; }
#wires path.edge.hot { stroke-width: 3.5; opacity: 1; }
#wires path.edge.selected { stroke-width: 4; opacity: 1; }

/* ---- 链路清单 ---- */
.routes-section > summary { list-style: none; cursor: pointer; user-select: none; }
.routes-section > summary::-webkit-details-marker { display: none; }
.routes-section > summary::after { content: "+"; color: var(--faint); font-size: 18px; line-height: 1; }
.routes-section[open] > summary::after { content: "−"; }
.routes-section[open] > summary { border-bottom: 1px solid var(--line); }
.summary-title { display: block; margin-top: 3px; font-size: 15px; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
.routes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
.route {
  min-width: 0;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  color: inherit;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  appearance: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
.route:active { transform: scale(.99); }
.route.selected { border-color: var(--accent); outline: 1px solid var(--accent); }
.route-state { width: 7px; height: 7px; border-radius: 50%; background: var(--unknown); }
.route[data-state="ok"] .route-state { background: var(--ok); }
.route[data-state="warn"] .route-state { background: var(--warn); }
.route[data-state="bad"] .route-state { background: var(--bad); }
.route-main { min-width: 0; }
.route-path { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; font-weight: 620; }
.route-path span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-arrow { flex: 0 0 auto; color: var(--faint); font-weight: 400; }
.route-label { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.route-kind {
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 6px;
  font: 9.5px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: nowrap;
}
.empty-routes { grid-column: 1 / -1; padding: 28px; color: var(--muted); text-align: center; }

/* ---- 图例 / 页脚 ---- */
.legend { display: flex; flex-wrap: wrap; gap: 13px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 11.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sep { width: 1px; height: 13px; background: var(--line); }
.legend .line { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--edge-dep); }
.legend .line.dashed { border-color: var(--edge-flow); border-top-style: dashed; }
.legend .line.faint { border-color: var(--edge-client); opacity: .65; border-top-width: 1px; }

footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.muted { color: var(--faint); }

/* ---- 详情 ---- */
.inspector {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(470px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 36px));
  overflow-y: auto;
  display: grid;
  gap: 3px;
  padding: 16px 46px 16px 17px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, .32);
  animation: inspect-in 180ms var(--ease-out);
}
@keyframes inspect-in { from { opacity: 0; transform: translateY(5px); } }
.inspector-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font: 23px/1 inherit;
  cursor: pointer;
}
.inspector strong { margin-top: 4px; font-size: 15px; }
.inspector-sub { color: var(--muted); font-size: 11.5px; }
.inspector-state { width: fit-content; margin-top: 7px; font-size: 11.5px; font-weight: 650; }
.inspector-state[data-state="ok"] { color: var(--ok); }
.inspector-state[data-state="warn"] { color: var(--warn); }
.inspector-state[data-state="bad"] { color: var(--bad); }
.inspector p { margin: 5px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.inspector-extra:empty { display: none; }
.inspector-extra { display: grid; gap: 10px; margin-top: 10px; }
.inspector-meta { display: grid; gap: 5px; padding-top: 10px; border-top: 1px solid var(--line); }
.meta-row { display: flex; gap: 10px; font-size: 11px; line-height: 1.5; }
.meta-row small { flex: 0 0 52px; padding-top: .5px; color: var(--faint); font-size: 9.5px; font-weight: 650; }
.meta-row span { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.hist h4 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
}
.hist h4 small { color: var(--faint); font-size: 9.5px; font-weight: 450; }
.hist-strip { display: flex; gap: 1px; height: 18px; }
.hist-strip i { flex: 1; min-width: 2px; border-radius: 1.5px; background: var(--unknown); opacity: .55; }
.hist-strip i[data-state="ok"] { background: var(--ok); opacity: 1; }
.hist-strip i[data-state="warn"] { background: var(--warn); opacity: 1; }
.hist-strip i[data-state="bad"] { background: var(--bad); opacity: 1; }
.hist-strip i[data-state="gap"] { background: var(--line); opacity: 1; }
.hist-sum { margin: 5px 0 0; color: var(--faint); font-size: 10.5px; }
.evidence-summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}
.evidence-summary > span { min-width: 0; }
.evidence-summary > span:last-child { text-align: right; }
.evidence-summary b, .evidence-summary strong, .evidence-summary small { display: block; }
.evidence-summary b { margin-top: 2px; font-size: 13px; }
.evidence-summary strong { color: var(--fg); font-size: 13px; }
.evidence-summary small { color: var(--faint); font-size: 9.5px; font-weight: 450; }
.evidence-summary[data-state="warn"] strong { color: var(--warn); }
.evidence-summary[data-state="bad"] strong { color: var(--bad); }
.related-evidence h4 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
}
.related-evidence h4 small { color: var(--faint); font-size: 9.5px; font-weight: 450; }
.copy-list { display: grid; gap: 7px; margin-top: 8px; }
.copy-card {
  padding: 10px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.copy-head { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 7px; align-items: center; }
.copy-head > i { width: 7px; height: 7px; background: var(--unknown); border-radius: 50%; }
.copy-card[data-state="ok"] .copy-head > i { background: var(--ok); }
.copy-card[data-state="warn"] .copy-head > i { background: var(--warn); }
.copy-card[data-state="bad"] .copy-head > i { background: var(--bad); }
.copy-head span b, .copy-head span small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-head span b { color: var(--fg); font-size: 11px; }
.copy-head span small { color: var(--faint); font-size: 9px; font-weight: 450; }
.copy-head em { color: var(--faint); font-size: 8.5px; font-style: normal; }
.copy-age { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 7px 0 0 14px; }
.copy-age strong { color: var(--fg); font-size: 12.5px; }
.copy-card[data-state="warn"] .copy-age strong { color: var(--warn); }
.copy-card[data-state="bad"] .copy-age strong { color: var(--bad); }
.copy-age span { color: var(--faint); font-size: 9px; }
.copy-card > p { margin: 3px 0 0 14px; font-size: 9.5px; }
.copy-fail { margin: 7px 0 0 14px; color: var(--bad); font-size: 9.5px; }
.copy-files { display: grid; gap: 3px; max-height: 150px; overflow-y: auto; margin: 8px 0 0 14px; padding-top: 7px; border-top: 1px dashed var(--line); }
.copy-files span { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font: 9.5px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.copy-files b { font-weight: 500; }
.copy-files small { color: var(--faint); font-size: inherit; }
.evidence-log { border-top: 1px solid var(--line); padding-top: 8px; }
.evidence-log summary { color: var(--muted); font-size: 10.5px; cursor: pointer; }
.evidence-log pre { max-height: 190px; overflow: auto; margin: 8px 0 0; padding: 9px; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; font: 9.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }

/* ---- 鼠标提示 ---- */
.tip {
  position: fixed;
  z-index: 30;
  max-width: 320px;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: 0 7px 26px rgba(0, 0, 0, .3);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 125ms var(--ease-out), transform 125ms var(--ease-out);
}
.tip.show { opacity: 1; transform: none; }
.tip b { font-weight: 650; }
.tip .t2 { margin-top: 2px; color: var(--muted); }
.tip .st { font-weight: 650; }
.tip .st[data-state="ok"] { color: var(--ok); }
.tip .st[data-state="warn"] { color: var(--warn); }
.tip .st[data-state="bad"] { color: var(--bad); }

/* ---- 门禁 ---- */
.gate {
  max-width: 680px;
  margin: 9vh auto 0;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--warn);
  border-radius: 14px;
}
.gate-main { margin-top: 6px; font-size: 22px; font-weight: 680; letter-spacing: -.02em; }
.gate-sub { max-width: 520px; margin: 7px auto 0; color: var(--muted); font-size: 13px; }
.gate-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.gate button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 17px;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 8px;
  font: 590 13px/1 inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
#retryBtn { color: var(--fg); background: transparent; border-color: var(--line-strong); }
.gate button:active { transform: scale(.97); }
.gate-err { margin-top: 12px; color: var(--bad); font-size: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .navlink:hover { color: var(--fg); border-color: var(--line-strong); }
  .view-tab:hover:not(.active), .filter:hover:not(.active):not(:disabled), .route:hover { border-color: var(--line-strong); }
  .node:hover { transform: translateY(-1px); border-color: var(--line-strong); }
  .node[data-state="bad"]:hover { border-color: var(--bad); }
  .node[data-state="warn"]:hover { border-color: var(--warn); }
  .inspector-close:hover { color: var(--fg); background: var(--surface-2); }
}

@media (max-width: 820px) {
  main { padding: 24px 16px 42px; }
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-health { grid-column: 1 / -1; }
  .overview .summary:last-child { grid-column: 1 / -1; }
  .view-tabs { display: flex; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .view-tab { flex: 0 0 180px; scroll-snap-align: start; }
  .routes { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .top { gap: 12px; }
  .title-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .brand p { font-size: 12.5px; }
  .top-nav { padding-top: 14px; }
  .navlink { min-height: 32px; padding: 5px 9px; font-size: 11.5px; }
  .overview { gap: 8px; }
  .summary { min-height: 96px; padding: 13px 14px; }
  .summary strong { font-size: 19px; }
  .section-heading { align-items: flex-start; min-height: 62px; }
  .section-help { max-width: 140px; }
  .view-tabs { padding-inline: 12px; }
  .relation-row { align-items: flex-start; flex-direction: column; gap: 7px; padding-inline: 12px; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .filter { width: 100%; }
  .map-wrap { padding-inline: 12px; }
  #cols { gap: 34px; }
  .site { min-height: 300px; }
  .routes { padding: 9px; }
  .route { padding: 10px; }
  .legend .sep { display: none; }
  .gate { margin-top: 5vh; padding: 25px 18px; }
  .inspector { right: 14px; bottom: 14px; }
}

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