:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #21262d;
  --line: #30363d;
  --ink: #f0f6fc;
  --ink2: #8b949e;
  --faint: #6e7681;
  --accent: #2f81f7;
  --accent-glow: rgba(47, 129, 247, 0.25);
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --purple: #a371f7;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.ico {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.runner-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--ink2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  transition: background 0.2s;
}
.dot.run { background: var(--ok); animation: pulse 1.2s infinite; }
.dot.err { background: var(--bad); }
.dot.warn { background: var(--warn); }
@keyframes pulse { 50% { opacity: 0.35; } }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink2);
}

/* 布局 */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 310px 1fr;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

/* 环境提示条 */
.env-banner {
  background: rgba(47, 129, 247, 0.08);
  border-bottom: 1px solid rgba(47, 129, 247, 0.2);
  padding: 8px 16px;
  font-size: 12px;
  color: #79c0ff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field label {
  font-size: 12px;
  color: var(--ink2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hint {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink2);
  cursor: pointer;
  margin-top: 5px;
}
.check input {
  accent-color: var(--accent);
}

/* 分段控件 */
.seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  background: none;
  border: 0;
  color: var(--ink2);
  padding: 6px 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  min-width: 0;
  transition: background 0.15s, color 0.15s;
}
.seg button.on {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* 机场码选择 */
.colo-box { position: relative; }
.colo-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 4px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.colo-list.show { display: block; }
.colo-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.colo-item:hover {
  background: var(--accent);
  color: #fff;
}
.colo-item code {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.8;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
}
.chip b {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--accent);
}
.chip span {
  cursor: pointer;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
}
.chip span:hover { color: var(--bad); }

.more summary {
  font-size: 12px;
  color: var(--ink2);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.more[open] summary { margin-bottom: 8px; }
.more .field { margin-bottom: 9px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  padding: 9px;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
  width: 100%;
  padding: 9px;
}
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.actions { margin-top: auto; padding-top: 10px; }
.hidden { display: none !important; }

/* 进度与状态 */
.progress {
  height: 3px;
  background: var(--line);
  flex: 0 0 auto;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s;
}
.progress i.idle { width: 0 !important; }
.progress i.indet {
  width: 35%;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

.statusline {
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
}

.job-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  border: 1px solid var(--line);
}
.job-pill.queued { background: rgba(210, 153, 34, 0.15); color: #e3b341; border-color: rgba(210, 153, 34, 0.4); }
.job-pill.running { background: rgba(63, 185, 80, 0.15); color: #56d364; border-color: rgba(63, 185, 80, 0.4); }
.job-pill.completed { background: rgba(47, 129, 247, 0.15); color: #79c0ff; border-color: rgba(47, 129, 247, 0.4); }
.job-pill.failed { background: rgba(248, 81, 73, 0.15); color: #ff7b72; border-color: rgba(248, 81, 73, 0.4); }

/* 工具条 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.toolbar input { max-width: 220px; }
.spacer { flex: 1; }

/* 表格 */
.table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 5;
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--ink); }
thead th.c-idx, thead th.c-act { cursor: default; }
thead th[data-dir]::after { content: ""; margin-left: 5px; font-size: 10px; }
thead th[data-dir="asc"]::after { content: "▲"; }
thead th[data-dir="desc"]::after { content: "▼"; }

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr:hover { background: var(--panel2); }
.c-idx { width: 44px; color: var(--faint); font-family: var(--mono); font-size: 12px; }
.c-num { text-align: right; }
.c-act { width: 60px; text-align: right; }
td.mono { font-family: var(--mono); font-size: 12.5px; }

.g { color: var(--ok); }
.y { color: var(--warn); }
.r { color: var(--bad); }

.copy-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--faint);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.15s;
}
.copy-btn:hover {
  color: var(--accent);
  background: var(--panel2);
  border-color: var(--line);
}
.empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

em.note {
  font-style: normal;
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* 弹窗 */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}
.modal h3 { font-size: 16px; font-weight: 600; }
.modal hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* 任务历史列表 */
.job-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.job-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.job-item:hover { border-color: var(--accent); }
.job-item-left { display: flex; flex-direction: column; gap: 2px; }
.job-item-id { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.job-item-time { color: var(--faint); font-size: 11px; }

/* 提示 */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 350px;
  animation: in 0.2s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
@keyframes in { from { opacity: 0; transform: translateX(16px); } }

/* 移动端响应式 */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 52vh;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .toolbar input {
    max-width: none;
    width: 100%;
  }
  .actions {
    margin-top: 10px;
  }
  .topbar-right .stat {
    display: none;
  }
}
