:root {
  --bg: #0e0e10;
  --bg-elevated: #16161a;
  --card: #1a1b1f;
  --card-border: rgba(255, 255, 255, 0.06);
  --accent: #00e676;
  --accent-dim: rgba(0, 230, 118, 0.15);
  --accent-glow: rgba(0, 230, 118, 0.35);
  --text: #f2f2f2;
  --muted: #8b8f98;
  --danger: #ff5252;
  --warn: #ffc107;
  --pass: #ffc107;
  --miss: #6b7280;
  --fail: #ff5252;
  --pending: #f5f5f5;
  --select-blue: #2563eb;
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a22 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #1a1f2e 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
}

#app {
  min-height: 100%;
  height: 100%;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Auth gate ===== */
.auth-gate {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 26px 22px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.auth-brand h1 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.auth-brand p {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.auth-field input {
  appearance: none;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.auth-field input:focus {
  border-color: rgba(0, 230, 118, 0.45);
}

.auth-error {
  font-size: 12px;
  color: var(--danger);
  margin: 0;
}

.auth-error.ok {
  color: var(--accent);
}

.auth-submit {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #04140a;
  background: var(--accent);
  margin-top: 4px;
}

.auth-submit:hover:not(:disabled) {
  filter: brightness(1.06);
}

.auth-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-switch {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.auth-switch button {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  padding: 0 2px;
}

.auth-switch button:hover {
  text-decoration: underline;
}

.auth-hint {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.auth-hint code {
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
}

.auth-user {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

/* ===== Header ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.server-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: 0.15s ease;
  flex-shrink: 0;
}

.server-status-btn:hover {
  border-color: rgba(245, 166, 35, 0.45);
  background: rgba(245, 166, 35, 0.08);
}

.server-status-btn.loading {
  opacity: 0.75;
}

.server-status-btn.error {
  border-color: rgba(255, 82, 82, 0.45);
}

.ss-busy { color: #f5a623; font-weight: 650; }
.ss-online { color: #7ed321; font-weight: 650; }
.ss-sep { color: #8b8f98; margin: 0 2px; }
.ss-caret { color: #8b8f98; font-size: 10px; margin-left: 4px; }

/* 服务器状态弹窗 —— 对齐 Spray3D SkinDark + ServerMonitorPopupView */
.server-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
}

.server-modal {
  --sm-region: #1c1c1c;
  --sm-secondary: #262e2f;
  --sm-border: #3f4647;
  --sm-text: #e8e8e8;
  --sm-muted: #9aa0a6;
  --sm-online: #7cfc00;
  --sm-offline: #ff4500;
  --sm-accent: #1ba1e2;

  width: min(920px, 100%);
  height: min(900px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--sm-region);
  color: var(--sm-text);
  border: 1px solid var(--sm-border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  padding: 0;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

.sm-head {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--sm-border);
  background: var(--sm-region);
}
.sm-head-left { display: flex; align-items: center; flex-wrap: wrap; }
.sm-head h2 { font-size: 16px; font-weight: 600; color: var(--sm-text); margin: 0; }
.sm-sub { margin: 2px 0 0 12px; font-size: 12px; color: var(--sm-muted); opacity: 0.92; }
.sm-btn {
  height: 28px; min-width: 72px; margin-left: 12px; padding: 0 10px;
  border: 1px solid var(--sm-border); background: var(--sm-secondary); color: var(--sm-text);
  border-radius: 4px; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.sm-btn:hover { border-color: var(--sm-accent); color: #fff; }

.sm-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 12px 16px 20px;
  scrollbar-gutter: stable;
}
.sm-body::-webkit-scrollbar,
.sm-node-list::-webkit-scrollbar,
.sm-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.sm-body::-webkit-scrollbar-thumb,
.sm-node-list::-webkit-scrollbar-thumb,
.sm-table-wrap::-webkit-scrollbar-thumb {
  background: #5a6366;
  border-radius: 5px;
  border: 2px solid var(--sm-region);
}
.sm-body::-webkit-scrollbar-track,
.sm-node-list::-webkit-scrollbar-track,
.sm-table-wrap::-webkit-scrollbar-track {
  background: #151515;
}

.sm-sep { border: none; border-bottom: 1px solid var(--sm-border); opacity: 0.65; margin: 0 0 12px; }

.sm-broker {
  margin: 0 0 12px; padding: 10px 12px; background: var(--sm-secondary);
  border: 1px solid var(--sm-border); border-radius: 6px;
}
.sm-broker-title { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.sm-broker-title .muted-label { font-size: 12px; font-weight: 600; color: var(--sm-muted); }
.sm-broker-title .broker-name { margin-left: 4px; font-size: 12px; font-weight: 600; color: var(--sm-text); }
.sm-broker-title .sm-status-dot { margin-left: 10px; font-size: 13px; }
.sm-broker-title strong { margin-left: 4px; font-size: 12.5px; font-weight: 600; }
.sm-broker-chips { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; }
.sm-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: var(--sm-secondary); border: 1px solid var(--sm-border); border-radius: 4px; margin-bottom: 4px;
}
.sm-chip em { font-style: normal; font-size: 11.5px; color: var(--sm-muted); }
.sm-chip b { font-size: 12px; font-weight: 600; color: var(--sm-text); }
.sm-broker-err { margin-top: 4px; font-size: 12.5px; color: var(--sm-offline); line-height: 20px; }

.sm-queue-card {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--sm-secondary);
  border: 1px solid var(--sm-border);
  border-radius: 8px;
}
.sm-queue-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.sm-queue-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--sm-text);
}
.sm-queue-head .sm-status-dot { font-size: 13px; margin-left: 4px; }
.sm-queue-idle {
  margin-left: 4px;
  font-size: 12.5px;
  color: var(--sm-muted);
}
.sm-queue-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px 28px;
}
.sm-queue-pending em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--sm-muted);
  margin-bottom: 4px;
}
.sm-queue-pending b {
  font-size: 28px;
  font-weight: 700;
  color: var(--sm-online);
  line-height: 1;
}
.sm-queue-bytype em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--sm-muted);
  margin-bottom: 6px;
}
.sm-queue-card .sm-chip {
  background: transparent;
  color: var(--sm-muted);
  font-size: 12px;
}

.sm-consumer-head { display: flex; align-items: center; margin-bottom: 8px; }
.sm-section-title { font-size: 12.5px; font-weight: 600; color: var(--sm-text); }
.sm-filter-select {
  width: 76px; height: 26px; margin-left: 12px; font-size: 12px;
  border: 1px solid var(--sm-border); border-radius: 4px;
  background: var(--sm-secondary); color: var(--sm-text);
}

.sm-type-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sm-type {
  background: var(--sm-secondary); border: 1px solid var(--sm-border); border-radius: 5px;
  padding: 6px 10px; min-width: 96px;
}
.sm-type em { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: var(--sm-muted); }
.sm-type b {
  display: block; margin-top: 2px; font-family: Consolas, monospace;
  font-size: 12px; font-weight: 500; color: var(--sm-text);
}

.sm-table-wrap.sm-grid-h {
  max-height: 360px;
  min-height: 140px;
  overflow: auto;
  margin-bottom: 12px;
  border: 1px solid var(--sm-border);
  border-radius: 4px;
  background: var(--sm-region);
  scrollbar-gutter: stable;
}
.sm-table.sm-grid { width: 100%; border-collapse: collapse; table-layout: auto; font-size: 12.5px; color: var(--sm-text); }
.sm-table.sm-grid th {
  position: sticky; top: 0; z-index: 1; height: 36px; padding: 8px 10px;
  text-align: left; font-size: 11px; font-weight: 600; background: var(--sm-secondary);
  color: var(--sm-text); border-bottom: 1px solid var(--sm-border);
}
.sm-table.sm-grid td {
  height: 32px; padding: 4px 8px; border-bottom: 1px solid var(--sm-border);
  vertical-align: middle; color: var(--sm-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sm-table.sm-grid .sm-empty {
  text-align: center;
  color: var(--sm-muted);
  padding: 16px 8px;
  white-space: normal;
}
.sm-table.sm-grid .col-dot { width: 30px; text-align: center; }
.sm-table.sm-grid .col-host { width: 215px; min-width: 80px; }
.sm-table.sm-grid .col-status { width: 88px; font-weight: 600; }
.sm-table.sm-grid .col-prog { width: 82px; text-align: right; color: var(--sm-muted); }
.sm-table.sm-grid .col-beat { width: 156px; color: var(--sm-muted); }
.sm-table.sm-grid .col-star { width: 40px; text-align: center; color: #3fa85f; font-weight: 600; }
.sm-table.sm-grid .col-ep { width: 160px; min-width: 100px; }
.sm-table.sm-grid .col-role { width: 100px; }
.sm-table.sm-grid .col-queue { width: 100px; color: var(--sm-muted); }
.sm-table.sm-grid .col-task { width: 220px; min-width: 120px; }
.sm-table.sm-grid .col-ggroup { width: 220px; min-width: 120px; }
.sm-table.sm-grid .col-gnet { width: 80px; color: var(--sm-muted); }
.sm-table.sm-grid .col-gstatus { width: 76px; font-weight: 600; }
.sm-table.sm-grid .col-glat { width: 80px; text-align: right; color: var(--sm-muted); }
.sm-table.sm-grid .col-gtime { width: 100px; color: var(--sm-muted); }
.sm-table.sm-grid .mono { font-family: Consolas, monospace; font-size: 11.5px; }
.sm-table.sm-grid tr.primary td { background: rgba(126, 211, 33, 0.14); }
.sm-table.sm-grid tr.offline td { background: rgba(255, 69, 0, 0.08); }

.sm-plan-primary {
  display: flex; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; font-size: 11.5px;
}
.sm-plan-primary .std { color: #4682b4; margin-right: 6px; }
.sm-plan-primary .re { margin-left: 14px; margin-right: 6px; font-weight: 600; color: #ff4500; }
.sm-plan-primary .plan-info {
  font-style: normal; font-size: 12px; color: var(--sm-muted); max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sm-role {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 11px; font-weight: 600; border: 1px solid;
}
.sm-role.standard { color: #4682b4; border-color: #4682b4; background: transparent; }
.sm-role.replan { color: #ff4500; border-color: #ff4500; background: rgba(255, 140, 0, 0.16); }
.sm-role.dispatch { color: #daa520; border-color: #daa520; background: rgba(218, 165, 32, 0.12); }
.sm-role.grpc { color: #7eb8da; border-color: #4682b4; background: transparent; }
.sm-ep-name { font-size: 12.5px; color: var(--sm-text); }
.sm-ep-sub { font-family: Consolas, monospace; font-size: 10.5px; color: var(--sm-muted); }
.sm-grpc-hint { margin: 4px 0 8px; font-size: 11.5px; color: var(--sm-muted); line-height: 1.45; }

.sm-node-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 180px;
  max-height: 360px;
  overflow-x: hidden;
  overflow-y: scroll;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--sm-border);
  border-radius: 6px;
  background: #171717;
  scrollbar-gutter: stable;
}
.sm-empty-block {
  padding: 18px 12px;
  text-align: center;
  color: var(--sm-muted);
  font-size: 12.5px;
  border: 1px dashed var(--sm-border);
  border-radius: 6px;
  background: var(--sm-region);
}
.sm-node-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--sm-border);
  border-radius: 6px;
  background: var(--sm-region);
  min-height: 48px;
}
.sm-node-card.primary { background: rgba(126, 211, 33, 0.12); border-color: rgba(126, 211, 33, 0.35); }
.sm-node-card.offline { background: rgba(255, 69, 0, 0.08); }
.sm-node-dot { font-size: 12px; flex-shrink: 0; }
.sm-node-main { flex: 1; min-width: 0; }
.sm-node-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--sm-text);
}
.sm-node-title b { font-weight: 600; }
.sm-star { color: #3fa85f; font-weight: 700; }
.sm-node-sub {
  margin-top: 2px;
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--sm-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sm-node-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
}
.sm-node-meta .mono { font-family: Consolas, monospace; font-size: 11px; font-weight: 500; color: var(--sm-muted); }
.sm-node-meta .muted { opacity: 0.75; }

/* ── 任务调度（Sched） ── */
.sm-sched { margin-bottom: 8px; }
.sm-sched-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.sm-sched-today {
  font-size: 12px;
  color: var(--sm-muted);
  margin: 2px 0;
}
.sm-sched-live {
  font-size: 12.5px;
  color: #7cfc00;
  font-weight: 600;
  margin: 2px 0;
}
.sm-sched-backend {
  font-size: 11.5px;
  color: var(--sm-muted);
  margin: 2px 0 8px;
}
.sm-sched-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.sm-sched-domain {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--sm-border);
  border-radius: 999px;
  background: var(--sm-secondary);
  font-size: 12px;
  color: var(--sm-text);
}
.sm-sched-domain b { font-weight: 650; }
.sm-sched-domain .sep { color: var(--sm-muted); font-size: 11px; }
.sm-sched-domain em { font-style: normal; font-weight: 700; }
.sm-sched-high {
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: #ffa500;
  border: 1px solid #ffa500;
}
.sm-sched-list-title {
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sm-text);
}
.sm-sched-list {
  max-height: 280px;
  min-height: 72px;
  overflow-x: hidden;
  overflow-y: scroll;
  border: 1px solid var(--sm-border);
  border-radius: 6px;
  background: #171717;
  padding: 4px 6px;
  margin-bottom: 8px;
  scrollbar-gutter: stable;
}
.sm-sched-row {
  display: grid;
  grid-template-columns: 22px 42px minmax(0, 1fr) 120px 72px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 3px 4px;
  border-bottom: 1px solid rgba(63, 70, 71, 0.45);
  font-size: 12px;
}
.sm-sched-row:last-child { border-bottom: none; }
.sm-sched-row.high { background: rgba(255, 165, 0, 0.08); }
.sm-sched-idx {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
}
.sm-sched-badge {
  display: inline-block;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 4px;
  border: 1px solid;
  border-radius: 3px;
  line-height: 1.3;
}
.sm-sched-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sm-text);
}
.sm-sched-node {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--sm-muted);
  text-align: right;
}
.sm-sched-time {
  text-align: right;
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #00e676, #00c853);
  box-shadow: 0 0 24px var(--accent-glow);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #041208;
  font-size: 14px;
}

.brand-block h1 {
  font-size: 18px;
  font-weight: 650;
}

.brand-block p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.legend-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-bar .lg {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
}

.legend-bar .lg.pass { color: var(--pass); border-color: rgba(255, 193, 7, 0.35); }
.legend-bar .lg.miss { color: #9ca3af; }
.legend-bar .lg.fail { color: var(--fail); border-color: rgba(255, 82, 82, 0.35); }
.legend-bar .lg.pending { color: #e5e7eb; }

.kpi-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
}

.kpi-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

.kpi-chip {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-chip strong {
  color: var(--accent);
  font-weight: 650;
  margin-left: 4px;
}

.kpi-chip.danger strong { color: var(--danger); }
.kpi-chip.car-id strong {
  color: #93c5fd;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
}

/* ===== Four-column browser ===== */
.browser {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns:
    minmax(140px, 0.65fr)
    minmax(200px, 0.9fr)
    minmax(180px, 0.85fr)
    minmax(420px, 2fr);
  gap: 12px;
}

@media (max-width: 1280px) {
  .browser {
    grid-template-columns: 1fr 1fr;
    overflow: auto;
  }
  .panel { min-height: 280px; }
}

@media (max-width: 800px) {
  .browser { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, #1e1f24 0%, #17181c 100%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.panel-ico {
  color: var(--accent);
  font-size: 14px;
}

.panel-head .sep {
  opacity: 0.4;
}

.panel-search {
  margin-left: auto;
  width: 110px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.panel-search:focus {
  border-color: rgba(0, 230, 118, 0.45);
}

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
}

.panel-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
}

.refresh-strip {
  display: grid;
  /* 与下方 .browser 四栏同宽，第 3 列对准「部件名称」 */
  grid-template-columns:
    minmax(140px, 0.65fr)
    minmax(200px, 0.9fr)
    minmax(180px, 0.85fr)
    minmax(420px, 2fr);
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
}

.refresh-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.refresh-msgs {
  justify-content: flex-start;
}

.refresh-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 0;
}

.panel-refresh {
  appearance: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.panel-refresh:hover:not(:disabled) {
  border-color: rgba(0, 230, 118, 0.45);
  color: #fff;
  background: rgba(0, 230, 118, 0.1);
}

.panel-refresh:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gen-flow-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 40;
  margin-left: 0;
}

.refresh-tools {
  gap: 6px;
  flex-wrap: wrap;
}

.gen-step-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 41;
}

.gen-step-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  padding: 10px;
  background: #2a2d33;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.gen-step-menu-copy {
  width: 140px;
}

.gen-step-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: start;
}

.gen-step-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.gen-step-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
}

.gen-step-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
}

.gen-step-select {
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #1e1e1e;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  padding: 0 6px;
}

.gen-step-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  padding-top: 0;
}

.gen-step-actions .gen-flow-btn {
  min-width: 88px;
  border-radius: 3px;
}

.gen-flow-trigger {
  appearance: none;
  width: auto;
  height: 32px;
  padding: 0 14px;
  border: 1px solid rgba(70, 130, 180, 0.55);
  background: steelblue;
  color: #fff;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.gen-flow-trigger:hover,
.gen-flow-trigger.open {
  filter: brightness(1.1);
}

.gen-flow-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  width: 320px;
  min-width: 280px;
  padding: 8px 10px 10px;
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.gen-flow-title {
  font-size: 13px;
  color: #f3f4f6;
  margin: 2px 0 10px;
  white-space: nowrap;
}

.gen-flow-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid rgba(160, 160, 160, 0.55);
  margin-left: 6px;
  padding-left: 0;
}

.gen-flow-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  align-items: stretch;
  min-height: 30px;
  border-top: 1px solid rgba(120, 120, 120, 0.35);
}

.gen-flow-row:first-child {
  border-top: none;
}

.gen-flow-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px 0 4px;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  border-right: 1px solid rgba(120, 120, 120, 0.35);
  position: relative;
}

.gen-flow-label::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  width: 6px;
  border-top: 1px solid rgba(160, 160, 160, 0.55);
}

.gen-flow-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  min-height: 30px;
}

.gen-flow-btn {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 0;
  background: steelblue;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 0 4px;
  min-height: 30px;
  line-height: 1.1;
}

.gen-flow-btn:hover {
  filter: brightness(1.12);
}

.gen-flow-btn.wide {
  grid-column: 1 / span 2;
}

.panel-action {
  appearance: none;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.panel-action:hover:not(:disabled) {
  border-color: rgba(0, 230, 118, 0.45);
  color: #fff;
}

.panel-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel-action.danger:hover:not(:disabled) {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.panel-action.accent:hover:not(:disabled) {
  border-color: rgba(34, 197, 94, 0.55);
  color: #86efac;
}

.panel-action-msg {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-toolbar {
  flex-wrap: wrap;
  flex-shrink: 0;
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.part-filters {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.part-filters.bar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.part-filters label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.part-filters input { accent-color: var(--accent); }

.head-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.detail-tabs-head {
  gap: 0;
  padding: 0;
  align-items: stretch;
  min-height: 40px;
}

.detail-tabs {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 100%;
}

.detail-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: #e8e8e8;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px 8px;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  line-height: 1.2;
  flex: 1 1 50%;
  width: 50%;
  text-align: center;
}

.detail-tab:hover {
  color: #fff;
}

.detail-tab.active {
  color: #1ba1e2;
  font-weight: 650;
}

.detail-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: #1ba1e2;
  border-radius: 0;
}

.detail-tab.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #2a2d34;
  border: 1px solid var(--card-border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle.on {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #888;
  transition: 0.15s ease;
}

.toggle.on::after {
  left: 21px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.list {
  list-style: none;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.12s ease;
}

.list li:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Brand / Year / Part — 有数据黄，无数据灰 */
.brand-list li .name {
  color: var(--pass);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-list li .idx,
.brand-list li .meta {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.brand-list li.nodata .name,
.brand-list li.nodata .idx,
.brand-list li.nodata .meta {
  color: #9ca3af;
}

.brand-list li.active {
  background: rgba(255, 255, 255, 0.08);
}

.brand-list li.active .name {
  color: #ffd54f;
  font-weight: 650;
}

.brand-list li.active.nodata .name {
  color: #c4c9d1;
}

/* Year table */
.table-head {
  display: grid;
  grid-template-columns: 40px 1fr 120px 28px;
  gap: 8px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.year-list li {
  display: grid;
  grid-template-columns: 40px 1fr 120px 28px;
  gap: 8px;
  color: var(--pass);
}

.year-list li .c-idx { color: var(--muted); font-variant-numeric: tabular-nums; }
.year-list li .c-model {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.year-list li .c-year { font-variant-numeric: tabular-nums; }
.year-list li .c-more {
  text-align: center;
  color: var(--pass);
  font-size: 10px;
}

.year-list li.nodata,
.year-list li.nodata .c-idx,
.year-list li.nodata .c-model,
.year-list li.nodata .c-year,
.year-list li.nodata .c-more {
  color: #9ca3af;
}

.year-list li.active {
  background: var(--select-blue);
  color: #fff;
}

.year-list li.active .c-idx,
.year-list li.active .c-more {
  color: rgba(255, 255, 255, 0.85);
}

.year-list li.active.nodata,
.year-list li.active.nodata .c-idx,
.year-list li.active.nodata .c-model,
.year-list li.active.nodata .c-year,
.year-list li.active.nodata .c-more {
  color: rgba(255, 255, 255, 0.75);
}

.empty-row {
  padding: 24px 14px !important;
  color: var(--muted) !important;
  cursor: default !important;
  display: block !important;
}

.empty-row.pad { padding: 28px 16px !important; }

/* Col3: part catalog pick */
.part-list { padding-bottom: 8px; }

.part-pick {
  color: var(--pass);
  padding-left: 16px !important;
}

.part-pick .name {
  flex: 1;
  color: var(--pass);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-pick.active {
  background: rgba(255, 255, 255, 0.1);
}

.part-pick.active .name {
  color: #ffd54f;
  font-weight: 650;
}

/* Col4: detail + step table */
.detail-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.detail-head,
.detail-row {
  display: grid;
  grid-template-columns: 36px 0.9fr 1fr 0.85fr 1.1fr 1.15fr 44px;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.sel-count {
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
}

.list.drag-select,
.detail-list.drag-select {
  user-select: none;
}

.brand-list li,
.year-list li,
.part-pick {
  cursor: pointer;
}

.detail-head {
  padding: 8px 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.detail-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-body.steps-only {
  flex: 1;
  min-height: 0;
}

.detail-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.detail-item {
  display: block !important;
  padding: 0 !important;
  cursor: default !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-item:hover { background: transparent !important; }

.detail-row {
  padding: 8px 10px;
  cursor: default;
  color: #e5e7eb;
  min-height: 36px;
}

.detail-row.selectable {
  cursor: pointer;
}

.detail-row.tone-nostep,
.detail-item.active > .detail-row.tone-nostep {
  color: #9ca3af;
}

.detail-row.tone-pass,
.detail-item.active > .detail-row.tone-pass {
  color: #22c55e;
}

.detail-row.tone-fail,
.detail-item.active > .detail-row.tone-fail {
  color: #ff5252;
}

.detail-item.active > .detail-row,
.detail-row.selectable:hover {
  background: rgba(37, 99, 235, 0.35);
}

.detail-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-row .d-idx {
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-row .d-idx em {
  font-style: normal;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.detail-row .d-steps {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Step table */
.step-table-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: rgba(0, 0, 0, 0.12);
}

.step-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-title {
  font-size: 12px;
  color: var(--muted);
}

.status-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.status-filters .sf {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.55;
}

.status-filters .sf.on {
  font-weight: 700;
  opacity: 1;
  border-width: 2px;
}
.status-filters .sf.pass.on { color: var(--pass); border-color: var(--pass); background: rgba(255, 193, 7, 0.15); }
.status-filters .sf.miss.on { color: #9ca3af; border-color: #9ca3af; background: rgba(156, 163, 175, 0.15); }
.status-filters .sf.fail.on { color: var(--fail); border-color: var(--fail); background: rgba(255, 82, 82, 0.15); }
.status-filters .sf.pending.on { color: #e5e7eb; border-color: #e5e7eb; background: rgba(255, 255, 255, 0.08); }
.status-filters .sf.on:not(.pass):not(.miss):not(.fail):not(.pending) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.step-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  /* 方便拖动横向查看完整内容 */
  overscroll-behavior: contain;
}

/* 车型列宽稳定；年款/部件较窄可截断；其余列收紧；横向滚动看全 */
.step-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.step-table th,
.step-table td {
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 1 车型：保持可读宽度 */
.step-table th:nth-child(1),
.step-table td:nth-child(1) { width: 120px; min-width: 120px; max-width: 120px; }
/* 2 年款、3 部件：窄一些，初始可只显示一部分 */
.step-table th:nth-child(2),
.step-table td:nth-child(2) { width: 72px; min-width: 72px; max-width: 72px; }
.step-table th:nth-child(3),
.step-table td:nth-child(3) { width: 78px; min-width: 78px; max-width: 78px; }
/* 4 流程名、5 步骤名 */
.step-table th:nth-child(4),
.step-table td:nth-child(4) { width: 100px; min-width: 100px; max-width: 100px; }
.step-table th:nth-child(5),
.step-table td:nth-child(5) { width: 64px; min-width: 64px; max-width: 64px; }
/* 6 轨迹生成时间、7 修改人：再窄 */
.step-table th:nth-child(6),
.step-table td:nth-child(6) { width: 96px; min-width: 96px; max-width: 96px; }
.step-table th:nth-child(7),
.step-table td:nth-child(7) { width: 56px; min-width: 56px; max-width: 56px; }

.step-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1a1b1f;
  color: #e5e7eb;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--card-border);
}

.step-table thead th:hover { color: var(--accent); }
.step-table thead th.active { color: var(--accent); }

.step-table tbody tr.pass { color: var(--pass); }
.step-table tbody tr.miss { color: var(--miss); }
.step-table tbody tr.fail { color: var(--fail); }
.step-table tbody tr.pending { color: var(--pending); }

.step-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

.step-table .empty-td {
  color: var(--muted);
  text-align: center;
  padding: 24px 10px;
}

.year-head {
  display: grid;
  grid-template-columns: 40px 1fr 120px 28px;
  gap: 8px;
  padding: 8px 14px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
