:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070b14;
  color: #e5eefc;
  --background: #070b14;
  --panel: rgba(14, 21, 36, 0.88);
  --panel-border: rgba(148, 163, 184, 0.14);
  --muted: #8ea0ba;
  --muted-strong: #b8c5d8;
  --primary: #4f8cff;
  --primary-strong: #6aa0ff;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(37, 99, 235, 0.16), transparent 26rem),
    radial-gradient(circle at 90% 18%, rgba(16, 185, 129, 0.08), transparent 24rem),
    var(--background);
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.topbar,
.section-heading,
.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar {
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 4vw, 3.35rem);
  letter-spacing: -0.045em;
}

h2 {
  margin-top: 3px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.eyebrow {
  color: #6f91c7;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.subtitle {
  margin-top: 10px;
  color: var(--muted);
  max-width: 680px;
}

.panel {
  background: linear-gradient(145deg, rgba(17, 25, 42, 0.96), var(--panel));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-badge[data-status="running"] {
  color: var(--success);
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.2);
}

.status-badge[data-status="stopping"] {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.09);
  border-color: rgba(251, 191, 36, 0.2);
}

.status-badge[data-status="completed"] {
  color: var(--primary-strong);
  background: rgba(79, 140, 255, 0.1);
  border-color: rgba(79, 140, 255, 0.2);
}

.status-badge[data-status="error"] {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
}

.control-panel {
  padding: 18px;
  border-radius: 18px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 1;
  gap: 10px;
}

.config-item {
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(148, 163, 184, 0.08);
}

.config-item span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.config-item strong {
  display: block;
  margin-top: 6px;
  color: #dfe9f8;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button {
  flex: 0 0 160px;
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #4f8cff);
  color: #fff;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.34);
}

.action-button.is-stop {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 10px 30px rgba(220, 38, 38, 0.22);
}

.action-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.message {
  margin: 12px 2px 0;
  color: var(--muted-strong);
  font-size: 0.82rem;
}

.message.is-error {
  color: var(--danger);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: 16px;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 70px;
  height: 70px;
  border-radius: 0 0 0 100%;
  background: rgba(79, 140, 255, 0.05);
}

.metric-card-success::after {
  background: rgba(52, 211, 153, 0.06);
}

.metric-card-danger::after {
  background: rgba(248, 113, 113, 0.06);
}

.metric-card strong {
  display: block;
  margin-top: 9px;
  color: #f7fbff;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  letter-spacing: -0.04em;
}

.metric-card-success strong {
  color: var(--success);
}

.metric-card-danger strong {
  color: var(--danger);
}

.chart-panel,
.workers-panel {
  margin-top: 16px;
  border-radius: 18px;
  padding: 20px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.legend-dot.completed {
  background: #60a5fa;
}

.legend-dot.accepted {
  background: #34d399;
}

.legend-dot.rejected {
  background: #f87171;
}

.chart-container {
  height: 310px;
  margin-top: 16px;
}

#metrics-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-variant-numeric: tabular-nums;
}

th {
  color: #657892;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: #c9d5e6;
  font-size: 0.82rem;
}

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

.worker-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.1);
  color: #8ab4ff;
  font-weight: 900;
}

.progress-track {
  width: 100%;
  min-width: 120px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 220ms linear;
}

@media (max-width: 1050px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .action-button {
    flex-basis: auto;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 22px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .config-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .legend {
    flex-wrap: wrap;
  }

  .chart-container {
    height: 260px;
  }
}

.diagnostics-panel {
  margin-top: 16px;
  border-radius: 18px;
  padding: 20px;
}

.failure-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.failure-item,
.failure-empty {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.08);
  background: rgba(255, 255, 255, 0.025);
}

.failure-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted-strong);
  font-size: 0.8rem;
}

.failure-item strong {
  color: var(--danger);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.failure-empty {
  color: var(--muted);
  font-size: 0.8rem;
}

.diagnostic-message,
.compatibility-message {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 0.78rem;
  line-height: 1.5;
}

.diagnostic-message {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.12);
}

.compatibility-message {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.12);
}
