/*
 * EasyProxy 控制台
 * 布局：左侧导航栏 + 顶部操作条 + 内容区（最大 1480px）；
 * 概览 = 汇总条 → 趋势/延迟 → 国家/协议；手机端导航变底部标签栏。
 * 字体只用系统栈：控制台常在国内网络访问，Google Fonts 加载不到会静默回退。
 */
:root {
  /* 中性色带一点蓝调，与强调色同源 */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --border: rgba(16, 24, 40, 0.09);
  --border-strong: rgba(16, 24, 40, 0.18);
  --text: #0f1726;
  --text-2: #475266;
  --muted: #7a8599;
  --grid: #e7eaf0;
  --baseline: #c9ced8;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-soft: rgba(42, 120, 214, 0.1);
  --on-accent: #ffffff;
  --focus: rgba(42, 120, 214, 0.45);
  /* 状态色（固定）+ 文字用的深一档 */
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --good-text: #006300;
  --warn-text: #8a5a00;
  --bad-text: #b42323;
  --good-soft: rgba(12, 163, 12, 0.1);
  --warn-soft: rgba(250, 178, 25, 0.16);
  --bad-soft: rgba(208, 59, 59, 0.1);
  /* 分类色前三槽（dataviz 校验通过：浅色 / 深色各一套） */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.18);
  --scrim: rgba(15, 23, 38, 0.32);
  --tip-bg: #0f1726;
  --tip-text: #f3f5f8;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-kpi: 28px;
  --fs-hero: 52px;

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 224px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #161b24;
    --surface-2: #1b212c;
    --surface-3: #222a37;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #e8ecf3;
    --text-2: #b3bccb;
    --muted: #8590a3;
    --grid: #252c3a;
    --baseline: #3a4254;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --on-accent: #ffffff;
    --focus: rgba(85, 152, 231, 0.55);
    --good-text: #3fcf3f;
    --warn-text: #fab219;
    --bad-text: #f07272;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warn-soft: rgba(250, 178, 25, 0.14);
    --bad-soft: rgba(208, 59, 59, 0.18);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
    --scrim: rgba(0, 0, 0, 0.5);
    --tip-bg: #e8ecf3;
    --tip-text: #0f1726;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b24;
  --surface-2: #1b212c;
  --surface-3: #222a37;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf3;
  --text-2: #b3bccb;
  --muted: #8590a3;
  --grid: #252c3a;
  --baseline: #3a4254;
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --on-accent: #ffffff;
  --focus: rgba(85, 152, 231, 0.55);
  --good-text: #3fcf3f;
  --warn-text: #fab219;
  --bad-text: #f07272;
  --good-soft: rgba(12, 163, 12, 0.16);
  --warn-soft: rgba(250, 178, 25, 0.14);
  --bad-soft: rgba(208, 59, 59, 0.18);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --scrim: rgba(0, 0, 0, 0.5);
  --tip-bg: #e8ecf3;
  --tip-text: #0f1726;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  min-width: 18px;
  text-align: center;
  display: inline-block;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text-2);
}
h1, h2, h3 { text-wrap: balance; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.mono { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mt { margin-top: 20px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.eyebrow { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; letter-spacing: 0.02em; }
.ico { width: 16px; height: 16px; flex-shrink: 0; }

.layout { display: flex; min-height: 100vh; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px 20px; }
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  background: var(--accent);
  flex-shrink: 0;
}
.brand-logo.sm { width: 30px; height: 30px; font-size: 12px; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: var(--fs-xs); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-count { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.nav-item.active .nav-count { color: var(--accent); }
.nav-kbd { display: none; }
.nav-item:hover .nav-kbd { display: inline-block; margin-left: auto; }
.nav-item:hover .nav-count + .nav-kbd { margin-left: 6px; }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn);
  margin-left: auto;
  animation: pulse 1.4s ease-in-out infinite;
}

.sidebar-footer { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.svc-card { display: grid; gap: 4px; padding: 0 6px; }
.sidebar-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  width: fit-content;
}
.status-pill .dot, .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
  flex-shrink: 0;
}
.status-pill.ok .dot, .status-dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-pill.bad .dot, .status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; font-size: var(--fs-xl); font-weight: 700; line-height: 1.25; }
.page-desc { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.mobile-brand { display: none; align-items: center; gap: 8px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.content { padding: 20px 28px 48px; max-width: 1480px; }

.view { display: none; }
.view.active { display: block; }
.grid { display: grid; gap: 16px; }

/* ---------- 按钮 / 分段 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: var(--fs-sm); }
.btn.icon-only { width: 34px; padding: 0; }
.btn.icon-only.sm { width: 28px; }
.btn.done { color: var(--good-text); }
.btn.running { opacity: 0.9; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btn.loading .ico { animation: spin 0.8s linear infinite; }

.spinner {
  display: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
.spinner.on, .btn.running .spinner, .btn.loading .spinner { display: inline-block; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  flex-shrink: 0;
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 4px 10px;
  min-height: 28px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.seg button b { font-weight: 500; color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.seg button b:empty { display: none; }
.seg-icons button { padding: 4px 7px; }

/* ---------- 横幅 ---------- */
.banner {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--surface);
}
.banner.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-soft); }
.banner-text { display: grid; gap: 2px; font-size: var(--fs-sm); min-width: 220px; flex: 1; }
.banner-form { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 460px; }
.banner-form input { flex: 1; min-width: 0; }
.banner.job {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  align-items: stretch;
  gap: 8px;
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
}
.banner.job .spinner { color: var(--accent); }
.banner.flash { animation: flash 0.9s ease 2; }
.job-banner-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: var(--fs-md); }
.job-banner-head .mono { margin-left: auto; font-size: var(--fs-sm); }
.stepper { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); }
.stepper li { padding: 2px 8px; border-radius: 999px; color: var(--muted); background: transparent; }
.stepper li.done { color: var(--text-2); }
.stepper li.done::before { content: "✓ "; }
.stepper li.now { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.progress { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.5s ease; }
.progress.indeterminate .progress-fill { width: 35% !important; animation: indeterminate 1.3s ease-in-out infinite; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
figure.card { margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-sub { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.card-head.mt { margin-top: 22px; }

/* 汇总条：一张卡四个格，用竖线分隔而不是四张卡 */
.summary { display: grid; grid-template-columns: 1.15fr 1.4fr 1fr 1fr; padding: 0; margin-bottom: 16px; }
.summary-cell { padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.summary-cell + .summary-cell { border-left: 1px solid var(--border); }
.hero-figure { font-size: var(--fs-hero); font-weight: 650; line-height: 1; letter-spacing: -0.02em; }
.kpi { display: flex; align-items: baseline; gap: 6px; }
.kpi-value { font-size: var(--fs-kpi); font-weight: 650; line-height: 1.1; letter-spacing: -0.01em; }
.kpi-unit { font-size: var(--fs-sm); color: var(--muted); }

.dash-row { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); margin-bottom: 16px; }
.stack-col { display: grid; gap: 16px; align-content: start; min-width: 0; }

/* 堆叠条：段间 2px 表面色间隙，不画描边 */
.stackbar { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stackbar span { display: block; height: 100%; min-width: 2px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: var(--fs-sm); }
.legend li { display: grid; grid-template-columns: 16px 1fr auto auto; gap: 8px; align-items: center; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .ico { width: 14px; height: 14px; }
.legend .lv { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.legend .lp { font-variant-numeric: tabular-nums; color: var(--muted); width: 44px; text-align: right; }
.summary .legend { gap: 4px; }

/* SVG 图表 */
.chart { position: relative; min-height: 200px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 650; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--s1); opacity: 0.1; }
.chart .dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--s1); transition: opacity 0.12s ease; }
.chart .bar.dim { opacity: 0.45; }
.chart .crosshair { stroke: var(--baseline); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit-col { fill: transparent; cursor: default; }
.chart:focus-visible { outline: 2px solid var(--focus); border-radius: 6px; }
.chart-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.chart-table th, .chart-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.chart-table td.num, .chart-table th.num { text-align: right; }

.tooltip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  background: var(--tip-bg);
  color: var(--tip-text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  max-width: 260px;
}
.tooltip .tv { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.tooltip .tl { opacity: 0.75; }

/* 国家横条：单一系列单一颜色，数值在条末 */
.hbars { display: grid; gap: 1px; }
.hbar-row {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.hbar-row:hover { background: var(--surface-2); }
.hbar-name { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); min-width: 0; }
.hbar-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-name .cc { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); width: 22px; flex-shrink: 0; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 3px; }
.hbar-val { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

.job-list { display: grid; gap: 2px; }
.job-item { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 6px; font-size: var(--fs-sm); }
.job-item:hover { background: var(--surface-2); }
.job-item .ico { width: 16px; height: 16px; }
.job-item .when { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.job-item .sum { color: var(--muted); font-size: var(--fs-xs); }

/* ---------- 状态徽标：图标 + 文字，不只靠颜色 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px;
  padding: 1px 9px 1px 7px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 20px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge .ico { width: 13px; height: 13px; }
.badge.alive, .badge.idle, .badge.ok { background: var(--good-soft); color: var(--good-text); }
.badge.dead, .badge.bad { background: var(--bad-soft); color: var(--bad-text); }
.badge.unknown, .badge.busy { background: var(--warn-soft); color: var(--warn-text); }
.badge.plain { padding: 1px 8px; font-weight: 500; font-family: var(--mono); }

/* ---------- 代理列表 ---------- */
.list-card { padding: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 240px;
  max-width: 340px;
  min-height: 34px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); padding: 6px 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.more-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.field input, .field select, .banner-form input, .input-group input, .page-size select {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.field input { width: 92px; }
.field input:focus, .field select:focus, .banner-form input:focus, .input-group input:focus, .page-size select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field.full { flex-direction: column; align-items: stretch; gap: 6px; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; }
.filter-toggle { display: none; }

.list-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.list-meta-left, .list-meta-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.list-meta-left { font-size: var(--fs-sm); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 4px 1px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 0;
  cursor: pointer;
}
.chip .ico { width: 13px; height: 13px; }
.chip:hover { filter: brightness(0.95); }
.page-size { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); margin-left: 4px; }
.page-size select { min-height: 28px; padding: 2px 6px; }

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.list-card .table-wrap { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); max-height: calc(100vh - 290px); min-height: 240px; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: var(--fs-xs); }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
#proxyTable tbody tr { cursor: pointer; }
#proxyTable td:first-child, #proxyTable th:first-child { padding-left: 16px; }
.th-actions { width: 1%; }
.sortable button { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sortable button:hover { color: var(--text); }
.sort-ind::after { content: "↕"; opacity: 0.35; font-style: normal; }
.sortable[aria-sort="ascending"] .sort-ind::after { content: "↑"; opacity: 1; color: var(--accent); }
.sortable[aria-sort="descending"] .sort-ind::after { content: "↓"; opacity: 1; color: var(--accent); }
.table td.actions { display: flex; gap: 2px; }
.addr { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.addr .scheme { color: var(--muted); }
.cc-code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); margin-left: 4px; }
.lat { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.lat-bar { display: inline-block; width: 44px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.lat-bar i { display: block; height: 100%; border-radius: 2px; }
.lat-good i { background: var(--good); }
.lat-mid i { background: var(--warn); }
.lat-bad i { background: var(--bad); }
.pager-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.kbd-hint kbd { margin: 0 1px; }

.empty { color: var(--muted); padding: 36px 16px; text-align: center; font-size: var(--fs-sm); white-space: normal !important; }
.empty strong { display: block; color: var(--text); font-size: var(--fs-md); margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
tbody.refetching { opacity: 0.55; transition: opacity 0.15s ease; }

/* ---------- 任务页 ---------- */
.jobs-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.job-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.job-action { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.job-action p { margin: 0; flex: 1; }
.job-action-head { display: flex; align-items: center; gap: 8px; }
.job-action .btn { align-self: flex-start; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 8px 14px; font-size: var(--fs-sm); }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; font-variant-numeric: tabular-nums; }
.kv .v.mono { font-size: var(--fs-xs); }
.job-row-detail td { background: var(--surface-2); white-space: normal !important; }
.job-row-detail pre { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--text-2); white-space: pre-wrap; word-break: break-all; }

/* ---------- API 页 ---------- */
.api-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; }
.endpoint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.endpoint-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 4px 10px;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.endpoint-list button:hover { background: var(--surface-2); }
.endpoint-list button.on { background: var(--accent-soft); }
.endpoint-list .path { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text); overflow-wrap: anywhere; }
.endpoint-list .desc { grid-column: 2; font-size: var(--fs-xs); color: var(--muted); }
.method { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 1px 0; border-radius: 4px; text-align: center; }
.method.get { color: var(--good-text); background: var(--good-soft); }
.method.post { color: var(--accent); background: var(--accent-soft); }
.code-card { position: sticky; top: 86px; }
.code-block { margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.code-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; font-size: var(--fs-xs); color: var(--muted); border-bottom: 1px solid var(--border); }
.code-block pre { margin: 0; padding: 14px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-all; }

.settings-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }

/* ---------- 抽屉 / 弹窗 ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--scrim); }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 51;
  width: min(460px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.18s ease;
  outline: none;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 4px 0 0; font-size: var(--fs-lg); font-weight: 650; word-break: break-all; }
.drawer-body { padding: 16px 20px 24px; overflow: auto; display: grid; gap: 18px; align-content: start; }
.drawer-section h4 { margin: 0 0 8px; font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; letter-spacing: 0.02em; }
.copy-list { display: grid; gap: 6px; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 6px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.copy-row code { background: transparent; padding: 0; font-size: 12px; word-break: break-all; white-space: pre-wrap; }
.copy-row .lbl { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; font-family: var(--font); }
.test-result { padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--fs-sm); background: var(--surface-2); border: 1px solid var(--border); }
.test-result.ok { background: var(--good-soft); border-color: transparent; color: var(--good-text); }
.test-result.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad-text); }

.modal {
  position: fixed;
  z-index: 51;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 18px 20px;
}
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: var(--fs-sm); }
.shortcuts dt { white-space: nowrap; }
.shortcuts dd { margin: 0; color: var(--text-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  background: var(--tip-bg);
  color: var(--tip-text);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-width: min(440px, calc(100vw - 32px));
  font-size: var(--fs-sm);
  border-left: 3px solid var(--good);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.error { border-left-color: var(--bad); }
.toast.hidden { display: block !important; opacity: 0; pointer-events: none; transform: translateY(8px); }

.skeleton {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--focus); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .summary { grid-template-columns: 1fr 1.4fr 1fr; }
  .summary-cell:nth-child(4) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); flex-direction: row; align-items: baseline; gap: 16px; }
}
@media (max-width: 1100px) {
  .dash-row, .jobs-grid, .api-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .code-card { position: static; }
  .search { max-width: none; }
}

/* 平板 / 手机：侧栏变底部标签栏 */
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 4px 6px var(--safe-b);
    flex-direction: row;
    border-right: 0;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 40;
  }
  .brand, .sidebar-footer, .nav-kbd, .nav-count, .kbd-hint { display: none !important; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; font-size: 11px; min-height: 52px; }
  .nav-item.active { background: transparent; }
  .nav-icon { width: 21px; height: 21px; }
  .nav-dot { position: absolute; top: 8px; left: calc(50% + 8px); margin: 0; }

  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; }
  .mobile-brand { display: flex; }
  .topbar h1 { font-size: 18px; }
  .page-desc { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { min-height: 36px; padding: 6px 11px; }
  .topbar-actions .btn.icon-only { width: 36px; padding: 0; }
  .content { padding: 12px 14px calc(var(--tabbar-h) + var(--safe-b) + 20px); }

  .card { padding: 14px; }
  .summary { grid-template-columns: 1fr 1fr; padding: 0; }
  .summary-cell { padding: 14px; }
  .summary-cell:nth-child(2) { grid-column: 1 / -1; order: 3; border-left: 0; border-top: 1px solid var(--border); }
  .summary-cell:nth-child(3) { border-left: 1px solid var(--border); }
  .summary-cell:nth-child(4) { grid-column: 1 / -1; order: 4; border-left: 0; border-top: 1px solid var(--border); flex-direction: column; align-items: flex-start; gap: 8px; }
  .hero-figure { font-size: 40px; }
  .kpi-value { font-size: 24px; }
  .job-actions { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 100px 1fr; }

  /* iOS 输入框字号 < 16px 会在聚焦时自动放大页面 */
  input, select { font-size: 16px !important; }

  .toolbar { padding: 12px; }
  .search { flex-basis: 100%; }
  .seg { max-width: 100%; overflow-x: auto; }
  .filter-toggle { display: inline-flex; }
  .filter-toggle .small { margin-left: 6px; }
  .more-filters { display: none; width: 100%; }
  .more-filters.open { display: grid; grid-template-columns: 1fr 1fr; }
  .more-filters .field { flex-direction: column; align-items: stretch; }
  .field input { width: auto; }
  .list-meta, .pager-row { padding: 10px 12px; }
  .list-card .table-wrap { max-height: none; border: 0; }

  .drawer { width: 100vw; }
  .toast { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); max-width: none; }
}

/* 手机：表格行渲染成卡片（DOM 与列顺序不变） */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; }
  .table.cards-on-mobile thead { display: none; }
  .table.cards-on-mobile, .table.cards-on-mobile tbody { display: block; }
  .table.cards-on-mobile tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    padding: 12px;
    margin: 0 12px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  #jobTable.cards-on-mobile tr { margin: 0 0 10px; }
  .table.cards-on-mobile tr.job-row-detail { display: block; margin-top: -6px; }
  .table.cards-on-mobile td { display: flex; flex-direction: column; gap: 2px; padding: 0 !important; border: 0; white-space: normal; min-width: 0; word-break: break-all; text-align: left !important; }
  .table.cards-on-mobile td::before { content: attr(data-label); font-size: 11px; color: var(--muted); }
  .table.cards-on-mobile td.span-2, .table.cards-on-mobile td.empty { grid-column: 1 / -1; }
  .table.cards-on-mobile td.empty::before, .table.cards-on-mobile td.actions::before, .table.cards-on-mobile td.title::before { display: none; }
  .table.cards-on-mobile td.title .addr { font-size: 14px; }
  .table.cards-on-mobile td.actions { flex-direction: row; gap: 8px; margin-top: 4px; }
  .table.cards-on-mobile td.actions .btn { flex: 1; min-height: 38px; border-color: var(--border-strong); }
  .list-meta { flex-direction: column; align-items: stretch; }
  .list-meta-right .page-size { display: none; }
}

@media (max-width: 420px) {
  .topbar-actions #btnRecheck { display: none; }
  .more-filters.open { grid-template-columns: 1fr; }
}
