:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --bg-card: #1c2028;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --text-dim: #9aa4b2;
  --accent: #4f8cff;
  --accent-strong: #2f6fef;
  --green: #34c98a;
  --red: #f26d6d;
  --amber: #e8b563;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.nav { display: flex; gap: 4px; }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.nav-btn:hover { background: var(--bg-card); color: var(--text); }
.nav-btn.active { background: var(--bg-card); color: var(--text); }

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card.wide { max-width: 780px; margin: 0 auto; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card h3 { margin: 22px 0 10px; font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.hint { color: var(--text-dim); font-size: 13px; margin: 4px 0; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin: 12px 0;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(79,140,255,0.06); }
.dz-icon { font-size: 26px; opacity: 0.7; }
.dz-inner p { margin: 4px 0; }

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 14px;
}
.chip-x { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.field > span { font-size: 13px; color: var(--text-dim); }
.field.grow { flex: 1; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
@media (max-width: 640px) { .field-row { flex-direction: column; } }

input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }

.checks { display: flex; gap: 18px; margin: 10px 0; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.primary:disabled { background: #3a5f9e; border-color: #3a5f9e; color: rgba(255,255,255,0.6); cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 14px; padding: 12px; }

.error {
  background: rgba(242,109,109,0.12);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: capitalize;
}
.status-chip.running { color: var(--accent); border-color: rgba(79,140,255,0.4); }
.status-chip.queued { color: var(--amber); border-color: rgba(232,181,99,0.4); }
.status-chip.done { color: var(--green); border-color: rgba(52,201,138,0.4); }
.status-chip.failed { color: var(--red); border-color: rgba(242,109,109,0.4); }
.status-chip.cancelled { color: var(--text-dim); }

.job-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.job-list .empty { color: var(--text-dim); font-size: 13px; padding: 10px 0; }

.job-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
}
.job-card:hover { border-color: var(--accent); }
.job-name { font-weight: 600; }
.job-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.job-progress { height: 5px; background: var(--bg-card); border-radius: 3px; margin-top: 9px; overflow: hidden; }

.progress-bar { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 16px 0 6px; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); transition: width 0.4s ease; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .k { color: var(--text-dim); font-size: 12px; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

.block-list { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.block-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.block-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex: none; }
.block-row.done .dot { background: var(--green); }
.block-row.failed .dot { background: var(--red); }
.block-row.running .dot { background: var(--accent); animation: pulse 1s infinite; }
.block-row .seq { color: var(--text-dim); font-family: var(--mono); font-size: 12px; width: 42px; flex: none; }
.block-row .btext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

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

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
