:root {
  --bg: #0b0e12;
  --surface: #12161d;
  --surface-2: #0e1218;
  --border: #222933;
  --text: #e6eaf0;
  --muted: #8b95a5;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --ok: #22c55e;
  --warn: #eab308;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
}

.auth-header h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.auth-header p {
  margin: 0 0 18px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

input, select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

.btn {
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: #181e27;
}

.error-banner {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #fca5a5;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13px;
  margin-top: 8px;
}

/* Main App */
.topbar {
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sep {
  color: var(--border);
}

.workspace {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.title-row, .actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.seg-btn.active {
  background: #1d2430;
  color: var(--text);
}

.run-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.grow {
  flex: 1;
  min-width: 0;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .split-grid {
    grid-template-columns: 1fr;
  }
  .run-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-right .small {
    display: none;
  }
}

.subpanel {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.subpanel-head {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.history-row {
  cursor: pointer;
}

.history-row:hover {
  background: #161b24;
}

.empty-cell {
  text-align: center;
  padding: 20px 12px;
}

.log-box {
  margin: 0;
  padding: 10px 12px;
  height: 360px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line-warn {
  color: var(--warn);
}

.log-line-error {
  color: #f87171;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: lowercase;
  border: 1px solid var(--border);
}

.pill-connecting, .pill-running {
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.1);
}

.pill-completed {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}

.pill-failed {
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.45);
  background: rgba(220, 38, 38, 0.1);
}

.pill-stopped, .pill-pending, .pill-unsupported {
  color: var(--muted);
  background: rgba(139, 149, 165, 0.08);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}
