:root {
  --brand: #0F62FE;
  --brand-dark: #0043CE;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --success: #16A34A;
  --danger: #DC2626;
  --warn: #F59E0B;
  --bg: #F1F5F9;
  --sidebar-bg: #0F172A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

.shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 26px; }
.brand-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 20px;
}
.brand-title { color: #fff; font-weight: bold; font-size: 15px; }
.brand-sub { color: #94A3B8; font-size: 10.5px; }

.nav { flex: 1; display: flex; flex-direction: column; }
.nav-btn {
  display: block;
  margin: 2px 8px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #CBD5E1;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}
.nav-btn:hover { background: #1E293B; }
.nav-btn.active {
  background: #1E293B;
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-footer { padding: 16px; }
.sandbox-label { color: var(--warn); font-size: 10px; font-weight: bold; letter-spacing: .04em; }
.config-path { color: #64748B; font-size: 9.5px; margin-top: 4px; word-break: break-all; }

/* ---------------- Content ---------------- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.h1 { font-size: 20px; font-weight: bold; margin: 0; }
.muted { color: var(--text-muted); font-size: 11.5px; margin: 2px 0 0; }

.status-pill {
  background: var(--surface-alt);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-muted);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-pill.success { background: rgba(22,163,74,.12); color: var(--success); }
.status-pill.success .status-dot { background: var(--success); }
.status-pill.danger { background: rgba(220,38,38,.12); color: var(--danger); }
.status-pill.danger .status-dot { background: var(--danger); }
.status-pill.warn { background: rgba(245,158,11,.12); color: var(--warn); }
.status-pill.warn .status-dot { background: var(--warn); }

.page { padding: 24px; flex: 1; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 14px rgba(15,23,42,.07);
}
.card + .card { margin-top: 16px; }
.h2 { font-size: 14px; font-weight: 600; margin: 0; }

.run-grid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .run-grid { grid-template-columns: 1fr; } }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-top: 14px; }
.field-label { color: var(--text-muted); font-size: 10.5px; font-weight: 600; margin-bottom: 4px; letter-spacing: .02em; }
.field-value { font-weight: 600; }
.field-value.big { font-size: 18px; font-weight: bold; color: var(--brand); }

hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: 8px;
  font-weight: 600; font-size: 12.5px;
  padding: 10px 20px;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #94A3B8; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: #F1F5F9; }

.run-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.run-actions-left { display: flex; align-items: center; gap: 10px; }
.run-actions-right { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 11.5px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
  display: none;
}
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track { height: 3px; border-radius: 2px; background: var(--border); margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--brand); border-radius: 2px; transition: width .25s ease-out; }

/* ---------------- Log ---------------- */
.log-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.log-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.log-line { margin: 1px 0; }
.log-line.success { color: var(--success); }
.log-line.warn { color: var(--warn); }
.log-line.error { color: var(--danger); }
.log-line.muted { color: #94A3B8; }
.log-section { color: var(--brand); font-weight: 600; margin: 6px 0 2px; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-field { margin-top: 8px; }
.form-field.span-2 { grid-column: span 2; }
.form-field.span-3 { grid-column: span 3; }

label.field-label { display: block; }
input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%;
  padding: 10px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.save-bar { display: flex; align-items: center; justify-content: space-between; }
.save-actions { display: flex; gap: 10px; }
.save-status { color: var(--text-muted); }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; }
.alert.success { background: rgba(22,163,74,.1); color: var(--success); }
.alert.error { background: rgba(220,38,38,.1); color: var(--danger); }
