/* ============================================================
   隧道合规哨兵 · Tunnel Guard — 设计系统（achromatic ledger）
   白/锌灰底，墨色文字，1px 细边框，8px 面板圆角，黑色胶囊主按钮，
   单一图表色 #1d5fbf，Geist 字体 + 等宽数字。运维安全面板，彩色像素 < 2%。
   ============================================================ */

/* ---------- 字体（本地 woff2，无外链） ---------- */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-latin-wght-normal.20f3xrkj613ah.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-latin-ext-wght-normal.39q78sztp1ci5.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font-sans: 'Geist', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC',
    system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Menlo, Consolas,
    'Liberation Mono', monospace;

  /* 底色与文字（契约 §8.1） */
  --bg: #f8f8f8;
  --surface: #ffffff;
  --raised: #f1f1f2;
  --active: #ededee;
  --border: #e4e4e7;
  --rule: #f0f0f1;
  --control: #d4d4d8;
  --text: #0a0a0a;
  --muted: #6b6b6b;
  --accent: #141414;

  /* 语义色（克制使用，仅状态与数据） */
  --ok: #2e7d32;
  --ok-bg: #dcfae5;
  --ok-line: #b7ebc9;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --danger: #c4242a;
  --danger-bg: #ffedea;
  --danger-line: #f7d4d0;
  --critical: #831c1e;
  --chart: #1d5fbf;
  --chart-soft: #dbe7f8;

  /* 尺寸 */
  --sidebar-w: 232px;
  --pad: 28px;
  --gap: 16px;
  --card-pad: 20px;
  --radius-card: 8px;
  --radius-control: 8px;
  --radius-pill: 999px;
  --control-h: 34px;
  --nav-row: 34px;
  --row-h: 48px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
}

::selection {
  background: #0a0a0a;
  color: #fff;
}

h1,
h2,
h3,
h4,
p,
figure,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

img,
svg {
  display: block;
}

dd {
  margin-left: 0;
}

:focus-visible {
  outline: 2px solid var(--chart);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono {
  font-family: var(--font-mono);
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 应用外壳（Open plane：侧栏与画布同底色，一条发丝线分隔） ---------- */

#app {
  min-height: 100svh;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  border-right: 1px solid var(--border);
  overflow: auto;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  border-radius: 8px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--text);
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.012em;
  white-space: nowrap;
}

.brand-tag {
  display: block;
  margin-top: 1px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

/* 节点范围块 */
.scope {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 12px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  min-width: 0;
}

.scope-main {
  min-width: 0;
  flex: 1;
}

.scope-title {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scope-sub {
  margin-top: 1px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group {
  margin: 14px 8px 5px;
  font-size: 13px;
  color: var(--muted);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--nav-row);
  padding: 0 9px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  stroke-width: 1.6;
}

.nav-item:hover {
  background: var(--raised);
  color: var(--text);
}

.nav-item[aria-current='page'] {
  background: var(--active);
  color: var(--text);
  font-weight: 550;
}

.nav-count {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 550;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
}

.conn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: default;
}

.conn.is-off {
  color: var(--danger);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.conn.is-off .conn-dot {
  background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex: none;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-name small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--raised);
  color: var(--text);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* 手机顶栏与抽屉导航 */
.m-topbar {
  display: none;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(10 10 10 / 0.35);
  animation: fade-in 0.15s var(--ease);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 71;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 14px 16px 20px;
  overflow: auto;
  animation: sheet-in 0.18s var(--ease);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet .nav-item {
  height: 44px;
  font-size: 15px;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------- 画布与页头 ---------- */

.canvas {
  min-width: 0;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
}

.page {
  min-width: 0;
  animation: page-in 0.16s var(--ease);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head-main {
  min-width: 0;
  flex: 1 1 420px;
}

.page-title {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 620;
  letter-spacing: -0.022em;
}

.page-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.stamp {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.004em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease), transform 0.08s var(--ease);
}

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

.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #2a2a2a;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--control);
  background: #fcfcfc;
}

.btn-ghost {
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--raised);
  color: var(--text);
}

/* 危险动作：描边 + 危险色文字，不用大红填充（契约 §8.3） */
.btn-danger {
  background: var(--surface);
  border-color: var(--danger-line);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-sm svg {
  width: 13px;
  height: 13px;
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  opacity: 0.7;
  cursor: progress;
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 面板 ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px var(--card-pad) 0;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.008em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.panel-body {
  padding: 14px var(--card-pad) 18px;
  min-width: 0;
}

.panel-body.flush {
  padding: 6px 0 0;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--card-pad);
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

.c4 {
  grid-column: span 4;
}
.c5 {
  grid-column: span 5;
}
.c6 {
  grid-column: span 6;
}
.c7 {
  grid-column: span 7;
}
.c8 {
  grid-column: span 8;
}
.c12 {
  grid-column: span 12;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.grow {
  flex: 1;
  min-width: 0;
}

.hr {
  height: 1px;
  background: var(--rule);
  border: 0;
  margin: 0;
}

/* ---------- KPI 条（一个容器，发丝线分格） ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.kpi {
  padding: 13px 16px 12px;
  border-left: 1px solid var(--rule);
  min-width: 0;
}

.kpi:first-child {
  border-left: 0;
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-value.is-warn {
  color: var(--warn);
}

.kpi-value.is-danger {
  color: var(--danger);
}

.kpi-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

.kpi-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 主机 / agent 状态条 ---------- */

.agent-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.agent-cell {
  padding: 12px 16px;
  border-left: 1px solid var(--rule);
  min-width: 0;
}

.agent-cell:first-child {
  border-left: 0;
}

.agent-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}

.agent-title small {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.agent-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.agent-value {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-value small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.agent-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  margin-top: 5px;
  height: 3px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 2px;
}

.meter span.is-warn {
  background: var(--warn);
}

.meter span.is-danger {
  background: var(--danger);
}

/* ---------- 判定链（本产品专属元素：来源 → 端口 → 指纹 → 命中 → 处置） ---------- */

.verdict {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 2fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.verdict-main {
  padding: 15px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.verdict-kicker {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.verdict-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.verdict-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.verdict-actions {
  display: flex;
  gap: 7px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.chain {
  border-left: 1px solid var(--rule);
  padding: 15px 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  align-items: start;
  min-width: 0;
}

.chain-step {
  position: relative;
  padding: 0 14px 0 16px;
  min-width: 0;
}

.chain-step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 3px;
  width: 1px;
  background: var(--border);
}

.chain-step:first-child {
  padding-left: 0;
}

.chain-step:first-child::before {
  display: none;
}

.chain-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.chain-value {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 550;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chain-value.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.chain-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- 图表 ---------- */

.chart-wrap {
  position: relative;
  min-width: 0;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.chart-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chart-legend .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: opacity 0.1s var(--ease);
}

.chart-tip.is-on {
  opacity: 1;
}

/* ---------- 风险分布 ---------- */

.risk-split {
  display: flex;
  align-items: center;
  gap: 18px;
}

.risk-ring {
  flex: none;
}

.risk-legend {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.risk-legend-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.risk-legend-row .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.risk-legend-row .cnt {
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}

.risk-legend-row .pct {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}

/* ---------- 实例卡 ---------- */

.inst-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.inst {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inst-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.inst-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.006em;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.inst-ver {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid var(--rule);
  margin-top: auto;
}

.inst-fact {
  min-width: 0;
}

.inst-fact dt {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.inst-fact dd {
  margin-top: 1px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inst-fact dd small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.prot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

.prot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}

.prot.is-warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn);
}

.prot.is-none {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow-x: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  padding: 10px 14px 8px;
  white-space: nowrap;
  border-top: 1px solid var(--rule);
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--card-pad);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--card-pad);
}

.table td {
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  vertical-align: middle;
}

.table tbody tr:first-child td {
  border-top: 0;
}

.table tbody tr.clickable {
  cursor: pointer;
}

.table tbody tr.clickable:hover {
  background: #fafafa;
}

.table th.num,
.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table td.mono-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.cell-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cell-title {
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cell-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-sub.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* 空/加载/错误 */
.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 30px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
}

.empty-desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 46ch;
}

.empty .btn {
  margin-top: 8px;
}

.sk {
  background: var(--raised);
  border-radius: 4px;
  height: 12px;
  display: inline-block;
}

.sk-line {
  height: 12px;
  border-radius: 4px;
  background: var(--raised);
}

.sk-lg {
  height: 22px;
  border-radius: 5px;
  background: var(--raised);
}

.load-error {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}

.load-error strong {
  color: var(--text);
  font-weight: 550;
}

.skeleton-panel {
  padding: 16px var(--card-pad);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 徽标 / 药丸 ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill-neutral {
  background: var(--bg);
  border-color: var(--border);
  color: var(--muted);
}

.pill-ok {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok);
}

.pill-warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn);
}

.pill-danger {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: var(--danger);
}

.pill-critical {
  background: var(--danger-bg);
  border-color: #eec2c0;
  color: var(--critical);
}

.pill-info {
  background: #eef4fd;
  border-color: #d8e5f8;
  color: var(--chart);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.chip.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* 置信度条 */
.conf {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 88px;
}

.conf-track {
  flex: 1;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  min-width: 40px;
}

.conf-track span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 2px;
}

.conf-val {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}

/* ---------- 筛选栏 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .spacer {
  flex: 1;
}

.select,
.input {
  height: var(--control-h);
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
  transition: border-color 0.15s var(--ease);
}

.select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}

.select:hover,
.input:hover {
  border-color: var(--control);
}

.select:focus,
.input:focus {
  outline: none;
  border-color: var(--text);
}

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

.search {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 220px;
  flex: 0 1 280px;
}

.search svg {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.search .input {
  padding-left: 32px;
  width: 100%;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--text);
  cursor: pointer;
  margin: 0;
}

/* 标题页签（底部 1px 规则线 + 2px 指示条） */
.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  padding: 8px 0 9px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected='true'] {
  color: var(--text);
  font-weight: 550;
}

.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 1px;
  background: var(--text);
}

.tab .n {
  margin-left: 4px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 活动流 ---------- */

.feed {
  display: flex;
  flex-direction: column;
}

.feed-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  min-width: 0;
  align-items: flex-start;
}

.feed-item:first-child {
  border-top: 0;
  padding-top: 2px;
}

.feed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
  background: var(--muted);
}

.feed-dot.is-warn {
  background: var(--warn);
}

.feed-dot.is-danger {
  background: var(--danger);
}

.feed-dot.is-ok {
  background: var(--ok);
}

.feed-main {
  min-width: 0;
  flex: 1;
}

.feed-text {
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.feed-text b {
  font-weight: 550;
}

.feed-meta {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.feed-time {
  flex: none;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field + .field {
  margin-top: 16px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.label .req {
  color: var(--danger);
  margin-left: 2px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.textarea {
  width: 100%;
  min-height: 96px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
  font-family: var(--font-mono);
  line-height: 1.6;
  resize: vertical;
}

.textarea:focus {
  outline: none;
  border-color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-row .field + .field {
  margin-top: 0;
}

.field-err {
  font-size: 13px;
  color: var(--danger);
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  width: 34px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--control);
  position: relative;
  transition: background-color 0.15s var(--ease);
  flex: none;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--text);
}

.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}

.switch input:disabled + .switch-track {
  opacity: 0.55;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--chart);
  outline-offset: 2px;
}

.switch-label {
  font-size: 13px;
}

/* 设置页：标签列 + 面板列 */
.set-section {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 32px;
  padding: 26px 0;
  border-top: 1px solid var(--border);
}

.set-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.set-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.006em;
}

.set-head p {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 40ch;
}

.set-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  min-width: 0;
}

.set-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.set-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.set-row:last-child {
  padding-bottom: 0;
}

.set-row-main {
  min-width: 0;
}

.set-row-title {
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.set-row-desc {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.set-row-control {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.set-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.set-fields .field + .field {
  margin-top: 0;
}

.num-input {
  width: 100px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.list-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.list-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.list-name {
  font-size: 13.5px;
  font-weight: 550;
}

.list-meta {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 登录页 ---------- */

.auth {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 26px 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.auth-brand .brand-mark {
  width: 30px;
  height: 30px;
}

.auth-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.auth-name small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.auth-title {
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.auth-desc {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.auth-form {
  margin-top: 20px;
}

.auth-form .field + .field {
  margin-top: 14px;
}

.auth-error {
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
}

.auth-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}

.auth-node b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}

/* ---------- 抽屉（详情） ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgb(10 10 10 / 0.28);
  animation: fade-in 0.15s var(--ease);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.2s var(--ease);
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.drawer-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.drawer-title {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 620;
  letter-spacing: -0.018em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 22px;
  min-height: 0;
}

.drawer-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.drawer-foot .spacer {
  flex: 1;
}

.ev-sec {
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}

.ev-sec:first-child {
  border-top: 0;
  padding-top: 0;
}

.ev-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ev-sec-title {
  font-size: 13px;
  font-weight: 600;
}

.ev-sec-meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.kv {
  display: grid;
  grid-template-columns: minmax(76px, 110px) minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv dd.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tl-item {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  min-width: 0;
}

.tl-time {
  flex: none;
  width: 66px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}

.tl-main {
  min-width: 0;
  flex: 1;
  padding-left: 11px;
  border-left: 1px solid var(--border);
}

.tl-title {
  font-size: 13px;
  line-height: 1.45;
}

.tl-sub {
  margin-top: 1px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.evidence-box {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.code-block {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 220px;
  overflow: auto;
}

.url-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.url-item {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
  display: flex;
  gap: 5px;
  align-items: baseline;
}

.url-item a {
  color: var(--chart);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.obs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  min-width: 0;
}

.obs-row:first-child {
  border-top: 0;
}

.obs-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  flex: none;
  width: 62px;
}

.obs-main {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgb(10 10 10 / 0.32);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 20px 40px;
  overflow: auto;
  animation: fade-in 0.15s var(--ease);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  animation: modal-in 0.16s var(--ease);
}

.modal-wide {
  max-width: 600px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 4px;
}

.modal-title {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.015em;
}

.modal-desc {
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-body {
  padding: 14px 20px 6px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
}

/* ---------- 轻提示 ---------- */

.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  animation: toast-in 0.18s var(--ease);
}

.toast svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.toast.is-success {
  background: #1f4d2c;
}

.toast.is-error {
  background: #7a1a1e;
}

.toast.is-out {
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--card-pad);
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}

.pager-btns {
  display: flex;
  gap: 6px;
}

.pager-range {
  font-variant-numeric: tabular-nums;
}

/* ---------- 断线提示条 ---------- */

.conn-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-card);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
}

.conn-banner svg {
  width: 14px;
  height: 14px;
  flex: none;
}

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

.notice {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.notice strong {
  color: var(--text);
  font-weight: 550;
}

.notice svg {
  width: 15px;
  height: 15px;
  flex: none;
  margin-top: 1px;
  color: var(--muted);
}

.notice-warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn);
}

.notice-warn svg {
  color: var(--warn);
}

/* ---------- 演示模式标记 ---------- */

.demo-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 工具类 ---------- */

.mt0 {
  margin-top: 0 !important;
}
.mt8 {
  margin-top: 8px;
}
.mt12 {
  margin-top: 12px;
}
.mt16 {
  margin-top: 16px;
}
.mt24 {
  margin-top: 24px;
}
.mb8 {
  margin-bottom: 8px;
}
.mb12 {
  margin-bottom: 12px;
}
.mb16 {
  margin-bottom: 16px;
}
.flex-wrap {
  flex-wrap: wrap;
}
.gap6 {
  gap: 6px;
}
.gap10 {
  gap: 10px;
}
.gap16 {
  gap: 16px;
}
.fs12 {
  font-size: 13px;
}
.fs11 {
  font-size: 13px;
}
.b {
  font-weight: 550;
}
.right {
  text-align: right;
}
.clickable-row {
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   响应式：1100 / 980 / 860 / 720 / 520
   ============================================================ */

@media (max-width: 1240px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpi:nth-child(4) {
    border-left: 0;
  }
  .kpi:nth-child(n + 4) {
    border-top: 1px solid var(--rule);
  }
  .agent-strip {
    grid-template-columns: minmax(200px, 1.2fr) repeat(2, minmax(0, 1fr));
  }
  .agent-cell:nth-child(4) {
    border-left: 0;
  }
  .agent-cell:nth-child(n + 4) {
    border-top: 1px solid var(--rule);
  }
  .chain {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  :root {
    --pad: 20px;
  }
  .c4,
  .c5,
  .c6,
  .c7,
  .c8 {
    grid-column: span 12;
  }
  .inst-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .verdict {
    grid-template-columns: 1fr;
  }
  .chain {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .set-section {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 0;
  }
  .set-head p {
    max-width: 60ch;
  }
}

/* 侧栏在 860px 以下折叠为手机顶栏 + 全屏抽屉 */
@media (max-width: 860px) {
  :root {
    --pad: 16px;
  }
  .app {
    display: block;
  }
  .sidebar {
    display: none;
  }
  .m-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 0 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .m-topbar .brand-mark {
    width: 22px;
    height: 22px;
  }
  .m-title {
    font-size: 15px;
    font-weight: 620;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .m-topbar .spacer {
    flex: 1;
  }
  .m-menu {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface);
  }
  .m-menu svg {
    width: 17px;
    height: 17px;
  }
  .canvas {
    padding: 16px 16px 40px;
  }
  .page-title {
    font-size: 22px;
  }
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpi {
    padding: 11px 12px 10px;
  }
  .kpi-value {
    font-size: 21px;
  }
  .agent-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .agent-cell {
    padding: 10px 12px;
  }
  .agent-cell:nth-child(odd) {
    border-left: 0;
  }
  .agent-cell:nth-child(n + 3) {
    border-top: 1px solid var(--rule);
  }
  .chain {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }
  .chain-step:nth-child(odd) {
    padding-left: 0;
  }
  .chain-step:nth-child(odd)::before {
    display: none;
  }
  .chain-step:nth-child(even) {
    padding-left: 14px;
  }
  .drawer {
    width: 100vw;
  }
  .drawer-head,
  .drawer-body,
  .drawer-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 720px) {
  .page-head {
    margin-bottom: 14px;
  }
  .page-actions {
    width: 100%;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi:nth-child(odd) {
    border-left: 0;
  }
  .kpi:nth-child(even) {
    border-left: 1px solid var(--rule);
  }
  .kpi:nth-child(n + 3) {
    border-top: 1px solid var(--rule);
  }
  .inst-grid {
    grid-template-columns: 1fr;
  }
  .field-row,
  .set-fields {
    grid-template-columns: 1fr;
  }
  .toolbar {
    gap: 7px;
  }
  .search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .select {
    flex: 1 1 0;
    min-width: 0;
  }
  /* 表格降级为两行卡片：身份与关键数字在第一行，其余字段在第二行 */
  .table-responsive thead {
    display: none;
  }
  .table-responsive,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }
  .table-responsive tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .table-responsive td {
    border: 0;
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 13px;
    color: var(--muted);
    flex: none;
  }
  .table-responsive td.cell-go {
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--rule);
  }
  .table-responsive td.cell-go::before {
    display: none;
  }
  .table-responsive td[data-label='']::before {
    display: none;
  }
  .table-responsive th:first-child,
  .table-responsive td:first-child {
    padding-left: 0;
  }
  .table-responsive th:last-child,
  .table-responsive td:last-child {
    padding-right: 0;
  }
  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .table-responsive tr.clickable:hover {
    background: var(--surface);
  }
  .pager {
    padding: 10px 0;
  }
  .set-row {
    flex-direction: column;
    gap: 8px;
  }
  .set-row-control {
    width: 100%;
    justify-content: space-between;
  }
  .risk-split {
    gap: 14px;
  }
  .modal {
    max-width: 100%;
  }
  .overlay {
    padding: 4vh 12px 24px;
  }
}

@media (max-width: 520px) {
  .kpi-value {
    font-size: 19px;
  }
  .kpi-label {
    font-size: 13px;
  }
  .page-title {
    font-size: 21px;
  }
  .toasts {
    left: 12px;
    right: 12px;
    max-width: none;
  }
}

/* ============================================================
   补充：视图内使用的细小组件
   ============================================================ */

.dot,
.conn-dot {
  display: inline-block;
  flex: none;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px;
  border-radius: 5px;
  color: var(--muted);
  transition: color 0.15s var(--ease);
}

.link-arrow:hover {
  color: var(--text);
}

.sev-mark {
  display: inline-block;
  flex: none;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--muted);
}

.sev-info {
  background: #a7a7ad;
}
.sev-warn {
  background: var(--warn);
}
.sev-critical {
  background: var(--danger);
}

.set {
  display: block;
}

.set .set-section:last-child {
  border-bottom: 0;
}

/* 手机端隐藏次要表格列（由 data-label 卡片承载） */
@media (max-width: 720px) {
  .table-responsive td.num::before,
  .table-responsive td[data-label='']::before {
    content: none;
  }
  .table-responsive td[data-main] {
    display: block;
  }
  .table-responsive td[data-main] .cell-title {
    font-size: 14px;
  }
  .table-responsive td[data-label] {
    font-size: 13px;
  }
  .table-responsive td .cell-main {
    width: 100%;
  }
  .table-responsive .row-actions {
    width: 100%;
  }
  .table-responsive .pill,
  .table-responsive .chip {
    flex: none;
  }
}

/* ---------- 判定来源 + 置信度（两行，图例与数值对齐） ---------- */

.conf {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  max-width: 156px;
}

.conf-src {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conf-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conf-track {
  width: 52px;
  flex: none;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.conf-track span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 2px;
}

.conf-val {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: right;
}

/* 设置面板里的紧凑数字控件 */
.set-row-control .field {
  align-items: flex-end;
}

.set-row-control .field .row {
  justify-content: flex-end;
}

.set-row-control .hint {
  text-align: right;
}

/* ---------- 排版与布局细节（第二轮） ---------- */

body {
  font-variant-numeric: tabular-nums;
}

.mono,
.mono-cell,
.cell-mono,
.code-block,
.tl-time,
.obs-time,
.obs-main .mono,
.url-item,
.kv dd.mono {
  font-variant-numeric: tabular-nums;
}

.fs13 {
  font-size: 13px;
}

.page-sub {
  gap: 14px;
}

/* 步骤流（设置页合规流程 / 能力边界），不要与图表类名混淆 */
.flow-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.flow-list .tl-item {
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}

.flow-list .tl-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.flow-list .tl-main {
  border-left: 1px solid var(--border);
}

.num .conf {
  margin-left: auto;
  align-items: flex-end;
}

/* 窄屏：agent 状态条首格独占一行，其余 2×2，避免出现孤立半格 */
@media (max-width: 860px) {
  .agent-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .agent-strip .agent-cell:first-child {
    grid-column: 1 / -1;
    border-left: 0;
  }
  .agent-strip .agent-cell:nth-child(2) {
    border-left: 0;
  }
  .agent-strip .agent-cell:nth-child(n + 2) {
    border-top: 1px solid var(--rule);
  }
  .agent-title {
    white-space: normal;
    flex-wrap: wrap;
  }
  .agent-note {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .agent-value {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .agent-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .agent-strip .agent-cell:nth-child(odd) {
    border-left: 0;
  }
  .agent-strip .agent-cell:nth-child(even) {
    border-left: 1px solid var(--rule);
  }
  .agent-strip .agent-cell:nth-child(n + 2) {
    border-top: 1px solid var(--rule);
  }
}

/* ---------- 手机端表格降级：两行卡片（身份行 + 两列字段） ---------- */

@media (max-width: 720px) {
  .table-responsive {
    padding: 0 12px 8px;
  }
  .table-responsive tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 3px 14px;
    padding: 11px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
  }
  .table-responsive td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0;
    border: 0;
    text-align: left;
    min-width: 0;
  }
  .table-responsive td::before {
    content: attr(data-label);
    flex: none;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
  }
  .table-responsive td[data-main] {
    grid-column: 1 / -1;
    display: block;
    padding-bottom: 4px;
  }
  .table-responsive td[data-main]::before {
    display: none;
  }
  .table-responsive td.cell-go {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 4px;
    margin-top: 2px;
    border-top: 1px solid var(--rule);
  }
  .table-responsive td.cell-go::before {
    display: none;
  }
  .table-responsive td:has(> input[type='checkbox']) {
    display: none;
  }
  .table-responsive td[data-label='']::before {
    display: none;
  }
  .table-responsive td .cell-main {
    width: 100%;
  }
  .table-responsive tr.clickable:hover {
    background: var(--surface);
  }
  .table-responsive .row-actions {
    justify-content: flex-end;
  }
}

/* 手机端两行卡片：身份 + 次行摘要（由 labelTables 生成） */
@media (max-width: 720px) {
  .table-responsive tr {
    display: block;
    padding: 11px 12px;
  }
  .table-responsive td {
    display: block;
    padding: 0;
  }
  .table-responsive td.m-extra {
    display: none;
  }
  .table-responsive td[data-main] {
    display: block;
    padding-bottom: 2px;
  }
  .table-responsive td[data-main]::before {
    display: none;
  }
  .table-responsive .m-meta {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .table-responsive td.cell-go {
    display: flex;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--rule);
  }
}

/* 单行置信度（域名表） */
.conf-inline {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.conf-inline .conf-track {
  width: 52px;
}

/* 手机端筛选控件两列换行，避免下拉被挤成三个字 */
@media (max-width: 520px) {
  .toolbar .select {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
  .toolbar .check {
    flex: 1 1 100%;
    height: 30px;
  }
}

/* 手机端两行卡片的次行摘要仅在窄屏显示 */
.m-meta {
  display: none;
}
