:root {
  color-scheme: dark;
  --bg: #08101a;
  --bg-panel: rgba(16, 26, 42, 0.92);
  --bg-panel-strong: rgba(21, 35, 58, 0.98);
  --bg-accent: #0e223e;
  --border: rgba(122, 162, 247, 0.2);
  --border-strong: rgba(122, 162, 247, 0.38);
  --text: #edf3ff;
  --text-muted: #98acc8;
  --accent: #7aa2f7;
  --accent-strong: #4f88ff;
  --success: #65d6a4;
  --warning: #f5c46b;
  --danger: #ff8f8f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 136, 255, 0.18), transparent 24rem),
    linear-gradient(180deg, #0b1421 0%, var(--bg) 100%);
}

.dashboard-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

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

.dashboard-header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.subtle,
.panel-meta {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.refresh-button {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.refresh-button:hover {
  background: var(--bg-accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.stat-card,
.panel {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  border-radius: 18px;
}

.stat-card {
  padding: 16px;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-footnote {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

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

.admin-strip {
  margin-bottom: 16px;
}

.panel {
  grid-column: span 4;
  overflow: hidden;
}

.panel-wide {
  grid-column: span 8;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 16px 18px 8px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.admin-tools {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 18px 18px;
}

.admin-auth-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.worker-secret-form {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr 1.2fr 0.9fr auto;
  gap: 12px;
  align-items: end;
}

.worker-secret-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.worker-secret-form span {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.worker-secret-form input,
.worker-secret-form select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.worker-secret-form input:focus,
.worker-secret-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.18);
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
}

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

th,
td {
  text-align: left;
  padding: 11px 18px;
  border-top: 1px solid rgba(122, 162, 247, 0.12);
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  background: var(--bg-panel-strong);
  z-index: 1;
}

.worker-title,
.job-title {
  font-weight: 600;
}

.worker-subtitle,
.job-subtitle,
.pool-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.mono {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.84rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
}

.status-busy::before,
.status-running::before,
.status-leased::before,
.status-completed::before {
  background: var(--success);
}

.status-idle::before,
.status-queued::before,
.status-provisioning::before {
  background: var(--warning);
}

.status-failed::before,
.status-error::before,
.status-draining::before,
.status-offline::before {
  background: var(--danger);
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 14px;
  max-height: 420px;
  overflow: auto;
}

.event-item {
  padding: 12px 14px;
  border: 1px solid rgba(122, 162, 247, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.event-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.event-body {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.empty-state {
  padding: 20px 18px 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 1180px) {
  .panel,
  .panel-wide {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    padding: 20px 14px 24px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-header h1 {
    font-size: 1.55rem;
  }

  .worker-secret-form {
    grid-template-columns: 1fr;
  }
}
