:root {
  --bg: #0b0f17;
  --surface: #131926;
  --surface-2: #1a2234;
  --border: #263147;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.6rem; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 20px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}
.logo-title { font-weight: 700; font-size: 1.1rem; display: block; }
.logo-sub { font-size: 0.78rem; color: var(--muted); display: block; }
.topbar-actions { display: flex; gap: 10px; }

.container { max-width: 1240px; margin: 24px auto; padding: 0 20px; }

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.kpi-label { font-size: 0.85rem; color: var(--muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; margin-top: 6px; }
.accent-blue { color: var(--primary); }
.accent-green { color: var(--green); }
.accent-amber { color: var(--amber); }

/* Panel & Jobs */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-header { margin-bottom: 16px; }
.panel-header h2 { margin: 0 0 4px; font-size: 1.2rem; }
.panel-header p { margin: 0; font-size: 0.9rem; }

.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.job-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.job-main { min-width: 260px; flex: 1; }
.job-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-name { font-weight: 600; font-size: 1.05rem; }
.job-route { font-size: 0.88rem; color: var(--muted); margin-top: 4px; }
.job-meta { font-size: 0.8rem; color: var(--muted); margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge-idle { background: rgba(139, 155, 180, 0.14); color: var(--muted); }
.badge-queued { background: rgba(245, 158, 11, 0.16); color: var(--amber); }
.badge-running { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border-color: rgba(59, 130, 246, 0.4); }
.badge-completed { background: rgba(34, 197, 94, 0.16); color: var(--green); }
.badge-error { background: rgba(239, 68, 68, 0.16); color: var(--red); }
.badge-cancelled { background: rgba(139, 155, 180, 0.16); color: var(--muted); }
.badge-mode { background: rgba(255, 255, 255, 0.06); color: var(--text); border-color: var(--border); }

/* Forms & Buttons */
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 4px; }
input, select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; margin-top: 16px; padding: 11px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: rgba(239, 68, 68, 0.16); color: var(--red); border-color: rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.28); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 900px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.btn-close {
  background: none; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 768px) {
  .two-cols, .row-3 { grid-template-columns: 1fr; }
}

.server-box, .options-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.options-box { margin-top: 14px; }
.server-box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.server-box-head h4, .options-box h4 { margin: 0; font-size: 0.96rem; }

.checkbox-wrap { display: flex; align-items: flex-end; padding-bottom: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; color: var(--text); }
.checkbox-label input { width: auto; }

.inspect-box {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.inspect-box.err {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.error-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.88rem;
}

.live-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.live-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.86rem;
}
.live-pill.green strong { color: var(--green); }
.live-pill.amber strong { color: var(--amber); }
.live-pill.red strong { color: var(--red); }

.console-pre {
  background: #06090f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  height: 380px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.86rem;
}

