/* ============================================================
   Sift Web UI — 深度设计系统（工业实用风 / 双主题）
   零依赖、零构建。设计令牌 → 组件。
   结构：①令牌 ②基础 ③布局/导航 ④面板 ⑤卡片 ⑥任务/日志
        ⑦调度 ⑧路径 ⑨配置 ⑩监控(组件化) ⑪帮助 ⑫浮层/空态/模态/Toast
        ⑬响应式 ⑭无障碍/动效
   ============================================================ */

/* ============ ① 设计令牌 ============ */
:root, [data-theme="light"] {
  /* 表面（层级：bg < surface < surface-2 < surface-3） */
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eef1f5;
  /* 文字（常规 / 强调 / 次级 / 极弱） */
  --text: #1f2329;
  --text-strong: #11151b;
  --muted: #5f6b7a;
  --muted-2: #8a93a0;
  /* 描边（弱 / 常规 / 强） */
  --border: #e3e6ea;
  --border-strong: #cbd2da;
  --border-weak: #eef1f5;
  /* 品牌主色（已校色：白字对比 ≥4.5:1 AA） */
  --primary: #2563d9;
  --primary-hover: #1d54c4;
  --primary-active: #1948ad;
  --primary-text: #ffffff;
  --primary-weak: #e9f1ff;
  --primary-ring: color-mix(in srgb, var(--primary) 38%, transparent);
  /* 语义状态（文字色已加深，保证在浅底/weak 底上可读） */
  --running: #1f5fd0;        --running-weak: #e8f1ff;        --running-dot: #2f6fed;
  --waiting: #b45309;         --waiting-weak: #fff4e6;        --waiting-dot: #d97706;
  --done: #1f7a36;            --done-weak: #e8f6ea;           --done-dot: #2e9d4b;
  --danger: #c0392b;          --danger-weak: #fdecea;         --danger-dot: #e0483b;
  /* 交互态底色（hover / active / disabled 等） */
  --state-hover: color-mix(in srgb, var(--text) 6%, transparent);
  --state-active: color-mix(in srgb, var(--text) 12%, transparent);
  --state-disabled-bg: var(--surface-3);
  --state-disabled-fg: var(--muted-2);
  --state-loading-fg: var(--muted);
  --focus-ring: 0 0 0 3px var(--primary-ring);
  /* 层级阴影（三级 elevation） */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-md: 0 6px 18px rgba(16,24,40,.12);
  --shadow-lg: 0 18px 48px rgba(16,24,40,.22);
  /* 圆角 */
  --r: 10px; --r-sm: 6px; --r-lg: 14px; --r-pill: 999px;
  /* 间距标尺（模块化节奏，2 倍数） */
  --sp-0: 2px; --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  /* 字号标尺（模块化，1.5 行高基准） */
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px;
  --fs-md: 15px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px;
  --lh-tight: 1.3; --lh-base: 1.5; --lh-relaxed: 1.65;
  /* 字体 */
  --sans: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: Consolas, "Cascadia Code", "SFMono-Regular", Menlo, monospace;
  /* 日志终端（双主题均深色等宽） */
  --term-bg: #0f1115; --term-fg: #c8e1ff; --term-err: #ff9b8a;
}
[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2128; --surface-2: #232a33; --surface-3: #2a313b;
  --text: #e6e9ee; --text-strong: #f3f5f8; --muted: #9aa3af; --muted-2: #6f7884;
  --border: #2c333d; --border-strong: #3a424e; --border-weak: #222932;
  --primary: #2f6fe0; --primary-hover: #528cf5; --primary-active: #2456c4;
  --primary-text: #ffffff; --primary-weak: #16233c; --primary-ring: color-mix(in srgb, var(--primary) 45%, transparent);
  --running: #6da8ff;        --running-weak: #16233c; --running-dot: #4d8bff;
  --waiting: #f0a93a;        --waiting-weak: #332712; --waiting-dot: #f0a93a;
  --done: #6fce82;           --done-weak: #142a1b;   --done-dot: #56c46a;
  --danger: #f0786e;         --danger-weak: #361a18; --danger-dot: #f0786e;
  --state-hover: color-mix(in srgb, var(--text) 9%, transparent);
  --state-active: color-mix(in srgb, var(--text) 16%, transparent);
  --state-disabled-bg: #20262e; --state-disabled-fg: #5d656f;
  --state-loading-fg: var(--muted);
  --focus-ring: 0 0 0 3px var(--primary-ring);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.45); --shadow-md: 0 8px 22px rgba(0,0,0,.55); --shadow-lg: 0 22px 56px rgba(0,0,0,.62);
  --term-bg: #0c0e12; --term-fg: #b9d4ff; --term-err: #ff8f7d;
}

/* ============ ② 基础 ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: var(--fs-base); line-height: var(--lh-base); -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* 统一过渡：仅颜色/阴影，杜绝布局位移（守 UI 铁律：禁止抖动） */
body, .panel, .card, .task, .badge, .btn, .modal-box, .toast,
input, select, textarea, .sidebar, .nav-item, .sched-item, .file, .cfg-group {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
h1,h2,h3,h4 { margin: 0; font-weight: 650; color: var(--text-strong); }
a { color: var(--primary); cursor: pointer; }
/* 焦点环：所有可聚焦元素统一可见（D4 无障碍） */
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.btn:focus-visible, .link-btn:focus-visible, .nav-item:focus-visible,
select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus-ring);
}

/* ============ ③ 布局 / 导航 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5);
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.brand { font-size: var(--fs-xl); font-weight: 750; letter-spacing: .3px; color: var(--text-strong); }
.brand-sub { font-size: var(--fs-xs); font-weight: 450; color: var(--muted); margin-left: var(--sp-2); }
.topbar-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.layout { display: flex; gap: var(--sp-5); max-width: 1320px; margin: 0 auto; padding: var(--sp-5); align-items: flex-start; }
.sidebar { position: sticky; top: 72px; flex: 0 0 170px; display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-item {
  text-align: left; display: flex; align-items: center; gap: var(--sp-3); padding: 10px 14px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
  color: var(--muted); font-size: var(--fs-base); font-family: inherit; cursor: pointer;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item:active { background: var(--state-active); }
.nav-item.active {
  background: var(--primary-weak); color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent); font-weight: 600;
}
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
.view.hidden { display: none; }

/* ============ ④ 面板 ============ */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: var(--sp-4) var(--sp-5) var(--sp-5);
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: var(--fs-lg); }
.panel-sub { font-size: var(--fs-xs); color: var(--muted); }

/* ============ ⑤ 卡片 ============ */
.card-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2);
  position: relative;
}
.card::before {
  content: ""; position: absolute; left: 0; top: var(--sp-3); bottom: var(--sp-3);
  width: 3px; border-radius: 3px; background: transparent;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card.is-running { border-color: var(--running); }
.card.is-running::before { background: var(--running-dot); }
.card h3 { font-size: var(--fs-md); color: var(--text-strong); }
.card .meta { font-size: var(--fs-xs); color: var(--muted); word-break: break-all; }
.card .fields { font-size: var(--fs-xs); color: var(--muted); }
.card .fields b { color: var(--text); font-weight: 600; }
.card .btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-1); }
.card .btns .btn { padding: 5px 10px; font-size: var(--fs-xs); }
.card input.url {
  width: 100%; padding: 6px 9px; font-size: var(--fs-xs); font-family: var(--mono);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text);
}
.card input.url:focus { border-color: var(--primary); }
.card .progress { height: 3px; border-radius: 3px; overflow: hidden; background: var(--surface-3); margin-top: 2px; }
.card .progress > i { display: block; height: 100%; width: 40%; background: var(--running-dot); animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ============ ⑥ 任务 / 日志 ============ */
.task-list { display: grid; gap: var(--sp-3); }
.task {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: var(--sp-3); position: relative;
}
.task::before {
  content: ""; position: absolute; left: 0; top: var(--sp-2); bottom: var(--sp-2);
  width: 3px; border-radius: 3px; background: transparent;
}
.task.is-waiting { border-color: var(--waiting); background: var(--waiting-weak); }
.task.is-waiting::before { background: var(--waiting-dot); }
.task .th { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.task .th .tid { font-family: var(--mono); color: var(--muted); font-size: var(--fs-xs); }
.badge {
  font-size: var(--fs-2xs); padding: 3px 9px; border-radius: var(--r-pill); font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 5px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.running { background: var(--running-weak); color: var(--running); border-color: color-mix(in srgb, var(--running) 30%, transparent); }
.badge.waiting_human { background: var(--waiting-weak); color: var(--waiting); border-color: color-mix(in srgb, var(--waiting) 40%, transparent); animation: pulse-wait 1.6s ease-out infinite; }
.badge.done { background: var(--done-weak); color: var(--done); border-color: color-mix(in srgb, var(--done) 30%, transparent); }
.badge.danger { background: var(--danger-weak); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
/* 状态不仅靠颜色：badge 已有文字标签；等待态用脉冲描边提示（reduced-motion 下关闭） */
@keyframes pulse-wait { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--waiting) 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.logs {
  background: var(--term-bg); color: var(--term-fg); font-family: var(--mono);
  font-size: var(--fs-xs); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  max-height: 210px; overflow: auto; white-space: pre-wrap; word-break: break-all; line-height: var(--lh-relaxed);
}
.logs .err { color: var(--term-err); }

/* ============ ⑦ 调度 ============ */
.sched-top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.sched-list { display: grid; gap: var(--sp-2); }
.sched-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); font-size: var(--fs-sm); flex-wrap: wrap;
}
.sched-item .period { font-family: var(--mono); color: var(--muted); }
.sched-item .ops { display: flex; align-items: center; gap: var(--sp-3); }
.sched-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sched-top2 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.sched-meta { font-size: var(--fs-xs); color: var(--muted); font-family: var(--mono); line-height: var(--lh-relaxed); }
.sched-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted-2); }
.sched-dot.ok { background: var(--done-dot); }
.sched-dot.fail { background: var(--danger-dot); }
.sched-dot.active { background: var(--running-dot); animation: hud-pulse 1.8s ease-out infinite; }
.danger-t { color: var(--danger); }
.modal-textarea { width: 100%; height: 30vh; font-family: var(--mono); font-size: var(--fs-sm); border: 1px solid var(--border-strong); border-radius: var(--r); padding: var(--sp-3); background: var(--surface); color: var(--text); resize: vertical; line-height: var(--lh-relaxed); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: var(--fs-xs); color: var(--muted); }
.switch input { width: 15px; height: 15px; accent-color: var(--primary); }
.switch input:focus-visible { box-shadow: var(--focus-ring); border-radius: 3px; }

/* ============ ⑧ 路径 ============ */
.path-form { display: grid; gap: var(--sp-3); }
.path-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: var(--sp-3); }
.path-row label { font-size: var(--fs-sm); color: var(--muted); }
.path-row input {
  width: 100%; padding: 7px 10px; font-size: var(--fs-sm); font-family: var(--mono);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text);
}
.path-row input:focus { border-color: var(--primary); }
.path-resolved { margin-top: var(--sp-3); padding: var(--sp-3); background: var(--surface-2); border-radius: var(--r-sm); font-size: var(--fs-xs); }
.path-resolved div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 3px 0; border-bottom: 1px dashed var(--border); }
.path-resolved div:last-child { border-bottom: none; }
.path-resolved .k { color: var(--muted); }
.path-resolved .v { font-family: var(--mono); word-break: break-all; text-align: right; }

/* ============ ⑨ 配置表单（替代裸 JSON） ============ */
.cfg-form { display: grid; gap: var(--sp-5); }
.cfg-group { border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3) var(--sp-4); background: var(--surface-2); }
.cfg-group > h3 { font-size: var(--fs-sm); color: var(--primary); margin-bottom: var(--sp-3); }
.cfg-field { display: grid; grid-template-columns: 220px 1fr; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.cfg-field:last-child { margin-bottom: 0; }
.cfg-field label { font-size: var(--fs-sm); color: var(--muted); }
.cfg-field input[type="text"], .cfg-field input[type="number"], .cfg-field input[type="password"] {
  width: 100%; padding: 7px 10px; font-size: var(--fs-sm); font-family: var(--mono);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
}
.cfg-field input:focus { border-color: var(--primary); }
.cfg-field .chk { width: 18px; height: 18px; accent-color: var(--primary); }
/* 结果视图模式切换（分段控件） */
.view-modes { display: flex; gap: 4px; margin-bottom: var(--sp-4); background: var(--surface-2); padding: 4px; border-radius: var(--r); width: fit-content; }
.view-modes .seg { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: calc(var(--r) - 2px); font-size: var(--fs-sm); cursor: pointer; transition: background .15s, color .15s; }
.view-modes .seg:hover { color: var(--text); }
.view-modes .seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
/* 通用分段控件（调度周期模式切换等） */
.seg-group { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r); }
.seg-group .seg { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: calc(var(--r) - 2px); font-size: var(--fs-sm); cursor: pointer; transition: background .15s, color .15s; }
.seg-group .seg:hover { color: var(--text); }
.seg-group .seg.active { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-sm); font-weight: 600; }
/* 可视化 cron 构造器（替代裸 cron 文本输入） */
.cron-builder { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.cron-builder label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.cron-builder select { padding: 6px 8px; font-size: var(--fs-sm); font-family: var(--mono); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.cron-builder select:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.cron-builder #cronPreview { width: 100%; }
/* MHTML 预览 */
.mhtml-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-3); max-height: 30vh; overflow: auto; }
.mhtml-frame { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: var(--r); background: #fff; }
.mhtml-frame-box { position: relative; }
.mhtml-loading {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  color: var(--muted); font-size: var(--fs-sm);
}
.mhtml-loading .spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-right-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.cfg-select { min-width: 220px; }
.adv { margin-top: var(--sp-4); }
.adv summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); padding: 4px 0; }
.adv #cfgText {
  width: 100%; height: 40vh; font-family: var(--mono); font-size: var(--fs-sm);
  border: 1px solid var(--border-strong); border-radius: var(--r); padding: var(--sp-3);
  background: var(--surface); color: var(--text); margin-top: var(--sp-2); resize: vertical;
}

/* ============ ⑩ 实时监控（网格 + 工业风组件） ============ */
/* 自定义下拉（替代原生 select，修"下拉键变形"） */
.dd { position: relative; display: inline-block; min-width: 160px; font-size: var(--fs-sm); vertical-align: middle; }
.dd.res-site { min-width: 190px; }
.dd.site-sel { min-width: 180px; }
.dd-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-family: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, background .15s; }
.dd-btn:hover { border-color: var(--primary); }
.dd-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: var(--focus-ring); }
.dd-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.dd-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chev { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); transition: transform .18s; display: inline-flex; }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); color: var(--primary); }
.dd-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-md); padding: 6px; max-height: 280px; overflow: auto; display: none; }
.dd-pop.open { display: block; animation: pop .12s ease-out; }
.dd-opt { padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dd-opt:hover { background: var(--surface-2); }
.dd-opt:focus { outline: none; box-shadow: var(--focus-ring); background: var(--surface-2); }
.dd-opt[aria-selected="true"] { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.dd-opt .tick { opacity: 0; color: var(--primary); }
.dd-opt[aria-selected="true"] .tick { opacity: 1; }

/* 统一输入框令牌（修"文字把"） */
.inp { width: 100%; padding: 8px 12px; font-size: var(--fs-sm); font-family: var(--mono); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s; }
.inp:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: var(--focus-ring); }

/* 监控网格 */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--sp-4); }
.monitor-empty-grid { grid-column: 1 / -1; text-align: center; padding: var(--sp-6); color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2); }
.monitor-empty-grid .ico { font-size: 26px; opacity: .5; }
.monitor-empty-grid .msg { margin-top: var(--sp-2); font-size: var(--fs-sm); line-height: var(--lh-relaxed); }

/* 监控卡 */
.mcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; transition: border-color .18s, box-shadow .18s, opacity .2s, transform .2s; }
.mcard.run { border-color: var(--running); }
.mcard.run::before, .mcard.wait::before { content: ""; display: block; height: 3px; background: var(--running-dot); }
.mcard.wait { border-color: var(--waiting); }
.mcard.wait::before { background: var(--waiting-dot); }
.mcard.fade-out { opacity: 0; transform: translateY(6px); }
.mhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mtitle { font-weight: 650; font-size: var(--fs-sm); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mstatus { font-size: var(--fs-2xs); padding: 2px 9px; border-radius: var(--r-pill); font-weight: 600; white-space: nowrap; }
.mstatus.run { background: var(--running-weak); color: var(--running); }
.mstatus.wait { background: var(--waiting-weak); color: var(--waiting); }
.mstatus.idle { background: var(--surface-3); color: var(--muted); }
.mops { display: flex; gap: 4px; flex: 0 0 auto; }
.mop { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.mop:hover { border-color: var(--primary); color: var(--primary); background: var(--state-hover); }
.mop:active { transform: translateY(1px); }
.mop:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.stage { position: relative; background: var(--term-bg); aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage.verify { cursor: grab; }
.stage.verify:active { cursor: grabbing; }
.stage .ph { color: #7e93ad; font-size: var(--fs-sm); text-align: center; padding: 16px; line-height: var(--lh-relaxed); }
.stage .ov { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--term-bg) 82%, transparent); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); padding: var(--sp-4); }
.ovcard { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; background: var(--surface); border: 1px solid var(--waiting); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-lg); max-width: 360px; }
.ovcard .ic { font-size: 26px; color: var(--waiting); line-height: 1; }
.ovcard .t { font-weight: 700; font-size: var(--fs-lg); color: var(--waiting); }
.ovcard .tip { font-size: var(--fs-sm); color: var(--text); line-height: var(--lh-relaxed); }
.mfoot { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: var(--fs-2xs); font-family: var(--mono); color: #8aa0bd; background: var(--term-bg); }
.mfoot .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7686; flex: 0 0 auto; }
.mfoot .dot.live { background: var(--done-dot); animation: hud-pulse 1.8s ease-out infinite; }
.mfoot .dot.wait { background: var(--waiting-dot); }
.mfoot .dot.err { background: var(--danger-dot); }
/* 窗口状态：最小化 / 全屏 */
.mcard.min .stage, .mcard.min .mfoot { display: none; }
.mcard.full { position: fixed; inset: 16px; z-index: 80; background: var(--bg); box-shadow: var(--shadow-lg); }
.mcard.full .stage { aspect-ratio: auto; flex: 1; }

/* ============ ⑪ 帮助 ============ */
.help { font-size: var(--fs-base); }
.help ol { padding-left: 20px; margin: 0; }
.help li { margin-bottom: var(--sp-3); line-height: var(--lh-relaxed); }
.help b { color: var(--primary); }
.help code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: var(--fs-xs); }

/* ============ ⑫ 浮层 / 空态 / 模态 / Toast ============ */
.inline-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); align-items: center; position: relative; }
.inline-form input, .inline-form select {
  padding: 7px 10px; font-size: var(--fs-sm); font-family: inherit; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text);
}
.inline-form input:focus, .inline-form select:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.inline-form input.url-wide { flex: 2; min-width: 200px; }
.inline-form .err { color: var(--danger); font-size: var(--fs-xs); width: 100%; }
.inline-form .hint { font-size: var(--fs-2xs); color: var(--muted); width: 100%; line-height: var(--lh-relaxed); }
.empty {
  text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2);
}
.empty .ico { font-size: 26px; opacity: .5; }
.empty .msg { margin: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-sm); line-height: var(--lh-relaxed); }
.empty .act { display: inline-block; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,12,16,.5); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal.hidden, .toast.hidden, .hidden { display: none; }
.modal-box {
  background: var(--surface); color: var(--text); border-radius: var(--r-lg); width: 680px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .14s ease-out;
}
.modal-box.wide { width: 820px; }
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; justify-content: space-between; align-items: center; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); font-weight: 650; font-size: var(--fs-md);
}
.modal-head .x { cursor: pointer; border: none; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: var(--r-sm); }
.modal-head .x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: var(--sp-4); overflow: auto; }
#archiveBody pre { white-space: pre-wrap; word-break: break-all; font-size: var(--fs-sm); font-family: var(--mono); line-height: var(--lh-relaxed); }
.file { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.file:last-child { border-bottom: none; }
.file .name { font-family: var(--mono); word-break: break-all; }

/* 结果表格视图 */
.res-site { min-width: 190px; }
.tbl-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; padding: 10px 12px; background: var(--surface-2);
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none;
}
.tbl thead th:hover { color: var(--text); }
.tbl thead th.num { text-align: right; }
.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody td.num { text-align: right; font-family: var(--mono); }
.tbl tbody td.mono { font-family: var(--mono); word-break: break-all; }
.tbl tbody td.sum { color: var(--muted); max-width: 360px; }
.badge.ok { color: var(--done-text); background: var(--done-weak); }
.badge.muted { color: var(--muted); background: var(--surface-2); }
.badge.err { color: var(--danger); background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge.warn { color: var(--waiting, #d29922); background: var(--waiting-weak); border-color: color-mix(in srgb, var(--waiting) 30%, transparent); }
.tbl tbody td.small { font-size: var(--fs-xs); color: var(--muted); max-width: 420px; }
/* K8 三态单元格：待人工=琥珀（值存疑已隔离）/ 缺失=灰（页面未披露）。
   只改颜色与底色，不动尺寸（守 UI 铁律：禁止布局位移）；且均带文字标签，不只靠颜色。 */
.tbl tbody td.fcell { white-space: pre-wrap; word-break: break-word; }
.tbl tbody td.st-pending {
  color: var(--waiting); background: var(--waiting-weak); font-weight: 600;
  border-left: 2px solid var(--waiting);
}
.tbl tbody td.st-missing { color: var(--muted-2, var(--muted)); background: var(--state-hover); }
.stage { display: inline-flex; align-items: center; gap: 6px; }
.stage .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.stage .dot.idle { background: var(--muted); }
.stage .dot.wait { background: var(--waiting-dot, #d29922); }
.stage .dot.live { background: var(--done-dot, #3fb950); }
.stage .dot.run { background: var(--running, #58a6ff); }
.stage .dot.err { background: var(--danger-dot, #f85149); }
.stage .dot.ok { background: var(--done-dot, #3fb950); }
/* 列显隐浮层（替代原生单选，符合"列配置"铁律） */
.col-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); padding: 8px 10px; min-width: 156px;
  display: flex; flex-direction: column; gap: 2px; animation: pop .12s ease-out;
}
.col-pop .col-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); transition: background .15s; }
.col-pop .col-opt:hover { background: var(--surface-2); }
.col-pop .col-opt input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.col-pop .col-opt:focus-within { box-shadow: var(--focus-ring); }
/* 被隐藏的列（th/td 共用） */
.col-hidden { display: none !important; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: var(--r-sm); font-size: var(--fs-sm); box-shadow: var(--shadow-md);
  z-index: 60; animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* 按钮（组件化，含 hover/active/focus/disabled/loading 全态） */
.btn {
  cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); padding: 7px 14px; font-size: var(--fs-sm); font-family: inherit; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--primary); background: var(--state-hover); }
.btn:active { transform: translateY(1px); background: var(--state-active); }
.btn:disabled, .btn.is-disabled { cursor: not-allowed; background: var(--state-disabled-bg); color: var(--state-disabled-fg); border-color: var(--border); }
.btn:disabled:active, .btn.is-disabled:active { transform: none; }
.btn.is-loading { color: var(--state-loading-fg); pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn-ghost { background: var(--surface-2); }
.btn-lg { padding: 9px 18px; font-size: var(--fs-base); }
.btn-icon { padding: 5px 11px; }
/* 链接型按钮（替代 <a onclick>，可键盘聚焦，D4 无障碍） */
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer; font: inherit;
  padding: 2px 4px; border-radius: var(--r-sm);
}
.link-btn:hover { text-decoration: underline; background: var(--state-hover); }
.link-btn.danger-link { color: var(--danger); }
.link-btn.danger-link:hover { background: var(--danger-weak); }
/* 系统日志（可观测性）：终端风 + 级别着色 */
.log-box { background: var(--term-bg); color: var(--term-fg); font-family: var(--mono); font-size: var(--fs-xs); padding: var(--sp-3); border-radius: var(--r); max-height: 260px; overflow: auto; line-height: var(--lh-relaxed); }
.log-box .ll { padding: 1px 0; white-space: pre-wrap; word-break: break-all; }
.log-box .ll.error { color: var(--term-err); }
.log-box .ll.warn { color: #f0c14b; }

/* ============ ⑬ 响应式 ============ */
@media (max-width: 920px) {
  .layout { flex-direction: column; padding: var(--sp-4); }
  .sidebar { position: static; flex-direction: row; flex: none; width: 100%; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; }
  .path-row { grid-template-columns: 1fr; gap: 4px; }
  .cfg-field { grid-template-columns: 1fr; gap: 4px; align-items: stretch; }
  .topbar { padding: var(--sp-3) var(--sp-4); }
}

/* ============ ⑭ 无障碍 / 动效 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
/* 仅供屏幕阅读器 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============ ⑮ 添加站点向导 / 操作指引抽屉 ============ */
.modal-foot { display:flex; gap:var(--sp-2); justify-content:flex-end; padding:var(--sp-3) var(--sp-4); border-top:1px solid var(--border); background:var(--surface-2); }
.wizard-box { max-width: 560px; }
.wiz-steps { display:flex; gap:var(--sp-2); margin-bottom:var(--sp-4); flex-wrap:wrap; }
.wiz-step { font-size:12px; padding:4px 10px; border-radius:999px; background:var(--surface-2); color:var(--text-weak); border:1px solid var(--border); }
.wiz-step.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.wiz-pane { display:block; }
.wz-field { display:flex; gap:var(--sp-2); align-items:center; margin-bottom:var(--sp-2); }
.wz-field .wz-fname { flex:1; min-width:0; }
.wz-field .wz-ftype { width:96px; flex:0 0 auto; }
.wz-field .x { flex:0 0 auto; }
pre.hint { white-space:pre-wrap; max-height:180px; overflow:auto; margin-top:var(--sp-2); }
/* 操作指引常驻抽屉（非模态，不引布局抖动） */
.drawer { position:fixed; top:0; right:0; height:100vh; width:360px; max-width:90vw; background:var(--surface); border-left:1px solid var(--border); box-shadow:-8px 0 24px rgba(0,0,0,.12); transform:translateX(100%); transition:transform .2s ease; z-index:60; display:flex; flex-direction:column; }
.drawer.open { transform:translateX(0); }
.drawer-head { display:flex; align-items:center; justify-content:space-between; padding:var(--sp-3) var(--sp-4); border-bottom:1px solid var(--border); font-weight:600; }
.drawer-body { padding:var(--sp-4); overflow:auto; }
.guide-steps { margin:0; padding-left:1.2em; line-height:1.7; }
.guide-steps li { margin-bottom:var(--sp-3); }
.drawer .x { position:static; }

/* ============ ⑯ 运行自检（站点可达性 / 失败分类 / 登录态 / 残留进程） ============ */
.health-box { margin-top:var(--sp-3); display:flex; flex-direction:column; gap:var(--sp-2); }
.health-box .hint { font-size:var(--fs-2xs); color:var(--muted); line-height:var(--lh-relaxed); }
.health-box .err { font-size:var(--fs-xs); color:var(--danger); line-height:var(--lh-relaxed); }
.health-box .tbl-wrap { margin-top:var(--sp-2); }

/* ============ ⑰ 采集目标（定向采集：维度 → URL 预览 → 勾选运行） ============ */
.target-box { max-width: 980px; width: 96vw; }
.tgt-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:var(--sp-4); }
@media (max-width: 900px) { .tgt-grid { grid-template-columns:1fr; } }
.tgt-col h4 { margin:0 0 var(--sp-2); font-size:var(--fs-sm); color:var(--text); }
#tgtDims .path-row { margin-bottom:var(--sp-2); }
#tgtDims select { min-width:0; flex:1; }
.tgt-list { display:flex; flex-direction:column; gap:var(--sp-2); max-height:330px; overflow:auto; }
.tgt-item { border:1px solid var(--border); border-radius:var(--r); padding:var(--sp-2) var(--sp-3); background:var(--surface-2); }
.tgt-item .tgt-chk { display:flex; align-items:center; gap:6px; cursor:pointer; }
.tgt-item .tgt-url { font-size:var(--fs-2xs); color:var(--muted); word-break:break-all; margin:3px 0; }
.tgt-item .tgt-ops { display:flex; gap:var(--sp-2); }

/* ============ ⑰ 标准列归口（兼容归一：未归口字段 / 冲突 / 标准列清单） ============ */
.ingest-box { margin: var(--sp-2) 0 var(--sp-3); padding: var(--sp-3); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--bg-soft); display: flex; flex-direction: column; gap: var(--sp-2); }
.ingest-box .hint { font-size: var(--fs-2xs); color: var(--muted); line-height: var(--lh-relaxed); }
.ingest-sec { font-size: var(--fs-2xs); color: var(--fg); line-height: var(--lh-relaxed); }
.ingest-sec b.err { color: var(--danger); }
.ingest-sec .chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
.ingest-list { margin: var(--sp-2) 0 0; padding-left: var(--sp-4); }
.ingest-list li { margin-bottom: var(--sp-1); }
