:root {
  color-scheme: dark;
  --bg: #09111f;
  --bg-soft: #101a31;
  --sidebar: #0d1529;
  --panel: rgba(13, 21, 41, 0.96);
  --panel-alt: rgba(18, 28, 52, 0.96);
  --border: rgba(148, 163, 184, 0.15);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.18);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.18);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.18);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.18);
  --running: #38bdf8;
  --running-soft: rgba(56, 189, 248, 0.18);
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background:
    radial-gradient(circle at left top, rgba(96, 165, 250, 0.12), transparent 30%),
    radial-gradient(circle at right top, rgba(56, 189, 248, 0.08), transparent 22%),
    var(--bg);
  color: var(--text);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, rgba(13, 21, 41, 0.98), rgba(10, 17, 33, 0.96));
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: var(--accent-soft);
  border-color: rgba(96, 165, 250, 0.28);
  transform: translateX(2px);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0 0 10px;
  font-size: 30px;
  font-weight: 800;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--panel-alt));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: var(--shadow);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
}

.metric-card.total::before {
  background: linear-gradient(90deg, #60a5fa, #38bdf8);
}

.metric-card.running::before {
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
}

.metric-card.success::before {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.metric-card.error::before {
  background: linear-gradient(90deg, #ef4444, #fb7185);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.metric-value {
  font-size: 34px;
  font-weight: 800;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-alt));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.loading-panel,
.empty-panel {
  padding: 28px 22px;
  color: var(--muted);
}

.empty-panel {
  text-align: center;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: rgba(15, 23, 42, 0.7);
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr {
  transition: background 0.18s ease;
}

tbody tr:hover {
  background: rgba(96, 165, 250, 0.08);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: #93c5fd;
}

.task-link {
  color: #dbeafe;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-running {
  background: var(--running-soft);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.24);
}

.status-paused {
  background: var(--warning-soft);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.24);
}

.status-stopped {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.2);
}

.status-success {
  background: var(--success-soft);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.24);
}

.status-error,
.status-failed {
  background: var(--error-soft);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.24);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.button.primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
}

.button.primary:hover {
  filter: brightness(1.08);
}

.button.ghost {
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  border-color: var(--border);
}

.button.ghost:hover {
  background: rgba(96, 165, 250, 0.12);
}

.button.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.25);
}

.button.danger:hover {
  background: rgba(239, 68, 68, 0.24);
}

.button.small {
  padding: 8px 10px;
  font-size: 12px;
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.settings-form,
.task-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.settings-form label,
.task-form label {
  display: grid;
  gap: 8px;
}

.settings-form span,
.task-form span {
  font-size: 13px;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.58);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.14);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 20px;
}

.summary-item,
.step-item {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.52);
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.summary-value {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.steps-list {
  display: grid;
  gap: 12px;
  padding: 20px;
}

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

.step-id {
  font-weight: 700;
  color: #dbeafe;
}

.step-meta {
  color: var(--muted);
  font-size: 13px;
}

.step-error {
  color: #fca5a5;
  font-size: 13px;
  line-height: 1.6;
}

.logs-panel {
  max-height: 640px;
  overflow: auto;
  padding: 20px;
}

.log-entry {
  padding: 12px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.log-entry:last-child {
  border-bottom: 0;
}

.log-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.log-message {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.modal.hidden,
.toast.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 6vh auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-alt));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  min-width: 260px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: white;
}

.toast.success {
  background: rgba(22, 163, 74, 0.95);
}

.toast.error {
  background: rgba(220, 38, 38, 0.95);
}

.empty-note {
  color: var(--muted);
  padding: 20px;
}

@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }
  th,
  td {
    padding: 12px 14px;
  }
  .modal-dialog {
    margin: 3vh 12px;
  }
}
