/* ── Dashboard ──────────────────────────────────────────────── */

.dashboard {
  padding: calc(var(--nav-height) + 3rem) 0 4rem;
  min-height: 100vh;
}

.dashboard__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.dashboard__header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dashboard__title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.dashboard__subtitle {
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* At-a-glance counts above the runner grid. */
.dashboard__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 96px;
  padding: 0.7rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-chip__num {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.stat-chip__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-chip--running .stat-chip__num { color: var(--success); }
.stat-chip--busy .stat-chip__num { color: #fbbf24; }

.dashboard__loading,
.dashboard__empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.dashboard__empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.dashboard__empty h3 {
  color: var(--text);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* ── Instance cards ─────────────────────────────────────────── */

.instances-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.instance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.instance-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.instance-card__name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.instance-card__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.instance-card__actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* ── Status badge ───────────────────────────────────────────── */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge--running { color: var(--success); background: rgba(52, 211, 153, 0.1); }
.status-badge--provisioning { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.status-badge--stopped { color: var(--text-muted); background: rgba(99, 99, 102, 0.12); }
.status-badge--failed { color: #f87171; background: rgba(248, 113, 113, 0.12); }

/* Busy badges show a spinner instead of the static dot. */
.status-badge:has(.spinner)::before { display: none; }

.spinner {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: td-spin 0.7s linear infinite;
}

@keyframes td-spin { to { transform: rotate(360deg); } }

/* ── Failure reason ─────────────────────────────────────────── */

.instance-card__fail {
  font-size: 0.85rem;
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  line-height: 1.4;
}

/* ── Activity feed ──────────────────────────────────────────── */

.activity {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  min-height: 2.2rem;
}

.activity__idle { color: var(--text-muted); }

.activity__row + .activity__row { margin-top: 0.5rem; }

.activity__ticket {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.5rem;
}

.activity__stage {
  text-transform: capitalize;
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

.activity__time { color: var(--text-muted); font-size: 0.78rem; }

.activity__line {
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Pending activation ─────────────────────────────────────── */

.pending-activation {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.pending-activation__icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.pending-activation h3 { color: var(--text); font-size: 1.25rem; margin-bottom: 0.5rem; }
.pending-activation p { max-width: 32rem; margin: 0 auto; }

.btn--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto;
}

/* ── Destructive action ─────────────────────────────────────────
 * The "Stop" button is a bare <button class="btn">, which would fall back to
 * the browser's white default and read as the loudest control on the card.
 * Style it muted-by-default, red-on-hover — matching the runner task
 * dashboard's "Cancel", so destructive actions look the same on both surfaces. */
.btn[data-stop] {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn[data-stop]:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.08);
}

/* ── Advanced settings (onboarding) ──────────────────────────── */
.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
}
.advanced > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 0.85rem 0;
  list-style: revert;
}
.advanced[open] > summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.advanced .form-group {
  margin-bottom: 1rem;
}

/* Checkbox row: label + box on one line, override the column flex default. */
.form-group--check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row;
  cursor: pointer;
}
.form-group--check input {
  width: auto;
  padding: 0;
}

/* ── Settings modal ──────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal__head h3 {
  font-size: 1.15rem;
  font-weight: 700;
}
.modal__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}
.modal__close:hover { color: var(--text); }
.modal__body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.modal__section {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
