:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --orange: #db6d28;
  --purple: #bc8cff;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Login ─── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
}

.login-logo {
  color: var(--accent);
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  padding: 10px 14px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-card button:hover { opacity: 0.9; }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ─── Topbar ─── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon { color: var(--accent); }

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.refresh-indicator {
  font-size: 12px;
  color: var(--text-dim);
}

.refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-logout {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ─── Dashboard ─── */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.cpu-icon { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.mem-icon { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.disk-icon { background: rgba(210, 153, 34, 0.15); color: var(--yellow); }
.uptime-icon { background: rgba(63, 185, 80, 0.15); color: var(--green); }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-bar-container {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.stat-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.stat-detail {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Runners Grid ─── */
.runners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.runner-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.2s;
}

.runner-card:hover {
  border-color: var(--text-muted);
}

.runner-card.offline {
  opacity: 0.6;
}

.runner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.runner-name {
  font-size: 15px;
  font-weight: 600;
}

.runner-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot.busy { background: var(--yellow); animation: pulse 1.5s infinite; }

.runner-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.runner-label {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.runner-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
}

.runner-meta-item {
  display: flex;
  flex-direction: column;
}

.runner-meta-key {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.runner-meta-val {
  color: var(--text);
  font-weight: 500;
}

.runner-meta-val.active { color: var(--green); }
.runner-meta-val.inactive { color: var(--red); }

/* ─── Runs Table ─── */
.runs-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.runs-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.runs-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.runs-table tbody tr:hover {
  background: var(--bg-hover);
}

.runs-table tbody tr:last-child td {
  border-bottom: none;
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.run-status .status-dot {
  width: 7px;
  height: 7px;
}

.conclusion-success { color: var(--green); }
.conclusion-failure { color: var(--red); }
.conclusion-cancelled { color: var(--text-muted); }
.conclusion-in_progress { color: var(--yellow); }
.conclusion-queued { color: var(--accent); }
.conclusion-neutral { color: var(--text-muted); }

.run-repo {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.run-repo:hover { text-decoration: underline; }

.run-branch {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--purple);
}

.run-commit {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-runner {
  font-size: 12px;
  color: var(--text-dim);
}

.run-duration {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.run-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Loading ─── */
.loading-placeholder {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .topbar h1 { font-size: 15px; }
  .dashboard { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .runners-grid { grid-template-columns: 1fr; }
}
