*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

/* Design tokens — mirror Tailwind theme in index.html */
:root {
  --admin-surface-0: #09090b;
  --admin-surface-1: #0f0f12;
  --admin-surface-2: #17171c;
  --admin-surface-3: #1e1e24;
  --admin-surface-4: #27272e;
  --admin-border: rgba(255, 255, 255, 0.06);
  --admin-border-strong: rgba(255, 255, 255, 0.08);
  --admin-text: #e2e8f0;
  --admin-text-muted: #94a3b8;
  --admin-text-dim: #64748b;
  --admin-accent: #4170f5;
  --admin-success: #22c55e;
  --admin-success-bright: #4ade80;
  --admin-danger: #ef4444;
  --admin-danger-bright: #f87171;
  --admin-warn: #eab308;
  --admin-warn-bright: #facc15;
}

.fade-in { animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.spinner {
  border: 2.5px solid rgba(255,255,255,0.08);
  border-top-color: var(--admin-accent, #4170f5);
  border-radius: 50%;
  width: 24px; height: 24px;
  animation: spin 0.65s linear infinite;
}
.spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
  line-height: 18px; white-space: nowrap;
}
.pill-green  { background: rgba(34,197,94,0.12); color: #4ade80; }
.pill-red    { background: rgba(239,68,68,0.12); color: #f87171; }
.pill-yellow { background: rgba(234,179,8,0.12); color: #facc15; }
.pill-blue   { background: rgba(65,112,245,0.12); color: #6090fa; }
.pill-orange { background: rgba(249,115,22,0.12); color: #fb923c; }
.pill-gray   { background: rgba(148,163,184,0.10); color: #64748b; }

.table-row { transition: background 0.1s ease; }
.table-row:hover { background: rgba(255,255,255,0.02); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: #64748b; cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 38px;
}
.nav-item:hover { color: #cbd5e1; background: rgba(255,255,255,0.04); }
.nav-item.active { color: #e2e8f0; background: rgba(65,112,245,0.10); }
.nav-item.active svg { color: #6090fa; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 9px 12px;
  color: #e2e8f0; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, select:focus {
  border-color: rgba(65,112,245,0.5);
  box-shadow: 0 0 0 3px rgba(65,112,245,0.1);
}
input::placeholder { color: #475569; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  border: none; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary { background: #4170f5; color: #fff; }
.btn-primary:hover { background: #3354ea; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-ghost {
  background: transparent; color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-ghost:hover { color: #e2e8f0; border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.03); }
.btn-secondary {
  background: rgba(255,255,255,0.06); color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-secondary:hover { color: #e2e8f0; background: rgba(255,255,255,0.1); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  background: rgba(255,255,255,0.06); color: #94a3b8;
}
.badge--provider {
  background: rgba(255, 255, 255, 0.06);
  color: var(--admin-text-muted, #94a3b8);
  font-size: 11px;
}

.card {
  background: #0f0f12;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 20px;
}

.kpi-value {
  font-size: 28px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 11px; font-weight: 500; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 8px;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; color: #475569;
}
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }

.divider { height: 1px; background: rgba(255,255,255,0.06); margin: 0; }

/* ── Environment Toggle (Stripe-style) ── */
.env-toggle {
  display: flex; border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 2px; gap: 2px;
}
.env-toggle__btn {
  flex: 1; padding: 5px 0; border: none; border-radius: 6px;
  font-size: 11px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s ease;
  background: transparent; color: #64748b;
}
.env-toggle__btn:hover { color: #94a3b8; }
.env-toggle__btn--active-prod {
  background: rgba(34,197,94,0.12); color: #4ade80;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.env-toggle__btn--active-staging {
  background: rgba(234,179,8,0.12); color: #facc15;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.env-banner {
  text-align: center; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; padding: 4px 8px;
  border-radius: 6px;
}
.env-banner--production {
  background: rgba(34,197,94,0.08); color: #4ade80;
  border: 1px solid rgba(34,197,94,0.15);
}
.env-banner--staging {
  background: rgba(234,179,8,0.10); color: #facc15;
  border: 1px solid rgba(234,179,8,0.20);
  animation: stagingPulse 2s ease-in-out infinite;
}
@keyframes stagingPulse {
  0%, 100% { border-color: rgba(234,179,8,0.20); }
  50% { border-color: rgba(234,179,8,0.45); }
}

.copy-btn {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 2px; border-radius: 4px; opacity: 0.4;
  transition: opacity 0.15s;
  background: none; border: none; color: currentColor;
  vertical-align: middle; margin-left: 4px;
}
.copy-btn:hover { opacity: 1; }

.sidebar { transition: transform 0.25s cubic-bezier(0.16,1,0.3,1); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 40; display: none;
}
.mobile-header { display: none; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 50; transform: translateX(-100%);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }

  .mobile-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: #0f0f12;
    position: sticky; top: 0; z-index: 30;
  }
  .hamburger {
    background: none; border: none; color: #94a3b8;
    cursor: pointer; padding: 4px; display: flex;
  }
  .hamburger:hover { color: #e2e8f0; }

  .card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 10px; }

  .main-content { padding: 16px !important; }
}

/* ── Command bar (env context) ── */
.command-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(15,15,18,0.96);
  font-size: 11px;
  color: #94a3b8;
  flex-shrink: 0;
}
.command-bar__dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.command-bar__dot--prod { background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,0.35); }
.command-bar__dot--staging { background: #facc15; box-shadow: 0 0 8px rgba(250,204,21,0.25); }
.command-bar__sep { opacity: 0.45; padding: 0 2px; }
.command-bar__env { font-weight: 600; color: #e2e8f0; }
.command-bar__host { color: #64748b; }

.nav-section-label {
  padding: 10px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.mc-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.mc-chip:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.mc-chip--warn { border-color: rgba(234,179,8,0.4); background: rgba(234,179,8,0.07); }
.mc-chip__val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: #e2e8f0; line-height: 1.2; }
.mc-chip__lbl { font-size: 9px; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }

.mission-control--ok { border-left: 3px solid rgba(34,197,94,0.45); }
.mission-control--alert { border-left: 3px solid rgba(234,179,8,0.55); }

.mc-fail-row {
  display: grid;
  grid-template-columns: 8px 52px 80px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.mc-fail-row:last-child { border-bottom: none; }
.mc-fail-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f87171;
}

/* ── Page hierarchy (dashboard product chrome) ── */
.page-header-block {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}
.page-header-block .page-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 6px;
}
.page-header-block h1.page-title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #f1f5f9;
  line-height: 1.25;
}
.page-header-block .page-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: #64748b;
  line-height: 1.5;
  max-width: 42rem;
  margin-top: 6px;
}

.callout {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.55;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  color: #94a3b8;
}
.callout--info {
  border-color: rgba(65, 112, 245, 0.22);
  background: linear-gradient(135deg, rgba(65, 112, 245, 0.06) 0%, rgba(15, 15, 18, 0.4) 100%);
}
.callout--warn {
  border-color: rgba(234, 179, 8, 0.35);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.08) 0%, rgba(15, 15, 18, 0.5) 100%);
  color: var(--admin-text-muted, #94a3b8);
}
.callout--warn strong,
.callout--warn .callout__title {
  color: var(--admin-warn-bright, #facc15);
  font-weight: 600;
}
.callout strong {
  color: #cbd5e1;
  font-weight: 600;
}

.card--subtle {
  background: rgba(15, 15, 18, 0.65);
  border-color: rgba(255, 255, 255, 0.05);
}

.card.infra-card {
  background: linear-gradient(165deg, rgba(30, 30, 36, 0.65) 0%, #0f0f12 48%);
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card.infra-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(65, 112, 245, 0.08);
}

.http-chip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.http-chip {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(65, 112, 245, 0.14);
  color: #93b4fd;
  border: 1px solid rgba(65, 112, 245, 0.25);
}
.http-chip-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.panel-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.panel-section-desc {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.45;
}

.data-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
}

.stat-banner {
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.stat-banner--ok {
  border-left: 3px solid rgba(74, 222, 128, 0.75);
  background: rgba(34, 197, 94, 0.04);
}
.stat-banner--warn {
  border-left: 3px solid rgba(250, 204, 21, 0.75);
  background: rgba(234, 179, 8, 0.05);
}
.stat-banner__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.stat-banner__meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.checklist-ordered {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.6;
}
.checklist-ordered li::marker {
  color: #64748b;
}
.checklist-ordered code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: #94a3b8;
}

/* ── Data tables & toolbars (unified admin UI) ── */
.infra-service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.admin-stat-tile {
  padding: 14px;
}
.admin-stat-tile__label {
  font-size: 11px;
  color: var(--admin-text-muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-stat-tile__value {
  font-size: 24px;
  font-weight: 600;
  color: var(--admin-text, #f1f5f9);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.admin-toolbar .admin-select--inline,
.admin-toolbar select {
  width: auto;
  min-width: 140px;
  font-size: 12px;
  padding: 6px 10px;
}

.admin-table-wrap {
  overflow-x: auto;
}
.card > .admin-table-wrap:first-child,
.card.p-0 > .admin-table-wrap {
  border-radius: inherit;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.admin-table thead tr {
  border-bottom: 1px solid var(--admin-surface-3, #1e1e24);
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--admin-text-dim, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.admin-table th.text-right {
  text-align: right;
}
.admin-table td {
  padding: 10px 12px;
  font-size: 12px;
  color: #cbd5e1;
  vertical-align: top;
}
.admin-table--compact th {
  padding: 8px 10px;
  font-size: 10px;
}
.admin-table--compact td {
  padding: 8px 10px;
  font-size: 11px;
}
.admin-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.admin-table tbody tr:last-child {
  border-bottom: none;
}

.admin-table--min-500 { min-width: 500px; }
.admin-table--min-560 { min-width: 560px; }
.admin-table--min-600 { min-width: 600px; }
.admin-table--min-680 { min-width: 680px; }
.admin-table--min-700 { min-width: 700px; }
.admin-table--min-900 { min-width: 900px; }

.admin-table .admin-cell-time {
  white-space: nowrap;
  color: var(--admin-text-muted, #94a3b8);
  font-variant-numeric: tabular-nums;
}
.admin-table .admin-cell-ellipsis {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-table .admin-cell-ellipsis--sm {
  max-width: 200px;
}

.text-ok {
  color: var(--admin-success-bright, #4ade80);
  font-weight: 500;
}
.text-fail {
  color: var(--admin-danger-bright, #f87171);
  font-weight: 500;
}

/* Onboarding funnel step bar — --bar-pct set inline, width driven by CSS */
.funnel-bar__fill {
  height: 100%;
  border-radius: 9999px;
  width: var(--bar-pct, 0%);
  transition: width 0.3s ease;
}

/* App version distribution bar — only dynamic axis via --bar-pct (see app.js) */
.version-bar__track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9999px;
  overflow: hidden;
}
.version-bar__fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--admin-accent, #4170f5);
  width: var(--bar-pct, 0%);
}
