/* ==========================================================================
   Vianova preview dashboard — design tokens + theming
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Spacing (4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radii */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco,
               Consolas, "Roboto Mono", monospace;

  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-base: 13px;
  --fs-md:  14px;
  --fs-lg:  16px;
  --fs-xl:  20px;
  --fs-2xl: 24px;

  /* Shadows — softer for modern feel */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow:    0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.12), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 12px 24px -6px rgb(0 0 0 / 0.18), 0 4px 8px -4px rgb(0 0 0 / 0.08);

  /* Durations */
  --dur-fast: 120ms;
  --dur:      180ms;

  /* Layout — fixed widths for the three panes */
  --nav-rail-width:      232px;
  --secondary-width:     340px;
}

/* --- Dark theme (default) -------------------------------------------------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg:         #0a0a0c;
  --surface:    #121216;
  --surface-2:  #17171d;
  --surface-3:  #1f1f27;
  --surface-hover: #1c1c24;

  --fg:         #f4f4f5;
  --fg-muted:   #a1a1aa;
  --fg-subtle:  #71717a;

  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --accent:       #818cf8;
  --accent-hover: #6366f1;
  --accent-fg:    #0a0a0c;
  --accent-tint:  rgba(129, 140, 248, 0.14);

  --success:      #4ade80;
  --success-tint: rgba(74, 222, 128, 0.14);
  --warning:      #fbbf24;
  --warning-tint: rgba(251, 191, 36, 0.14);
  --danger:       #f87171;
  --danger-tint:  rgba(248, 113, 113, 0.14);
  --info:         #60a5fa;
  --info-tint:    rgba(96, 165, 250, 0.14);

  --overlay: rgba(0, 0, 0, 0.72);
}

/* --- Light theme ---------------------------------------------------------- */
[data-theme="light"] {
  color-scheme: light;

  --bg:         #fafafa;
  --surface:    #ffffff;
  --surface-2:  #f4f4f5;
  --surface-3:  #e4e4e7;
  --surface-hover: #f4f4f5;

  --fg:         #09090b;
  --fg-muted:   #52525b;
  --fg-subtle:  #71717a;

  --border:        rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-fg:    #ffffff;
  --accent-tint:  rgba(79, 70, 229, 0.10);

  --success:      #16a34a;
  --success-tint: rgba(22, 163, 74, 0.10);
  --warning:      #d97706;
  --warning-tint: rgba(217, 119, 6, 0.10);
  --danger:       #dc2626;
  --danger-tint:  rgba(220, 38, 38, 0.10);
  --info:         #2563eb;
  --info-tint:    rgba(37, 99, 235, 0.10);

  --overlay: rgba(0, 0, 0, 0.32);
}

/* ==========================================================================
   Reset + base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre, .mono {
  font-family: var(--font-mono);
}
code {
  font-size: 0.92em;
  padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent-tint); color: var(--fg); }

/* Scrollbars — subtle, match theme */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); background-clip: padding-box; border: 2px solid transparent; }

/* ==========================================================================
   App shell — nav-rail + workspace
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--nav-rail-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* --- Nav rail (always-on dark side nav) ----------------------------------- */
/* Stays dark even in light theme — matches the mockup and keeps the accent
   punchy against a workspace that can flip between light and dark. */
.nav-rail {
  display: flex;
  flex-direction: column;
  background: #0a0c12;
  color: #e4e4e7;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: var(--space-5) var(--space-3);
  overflow: hidden;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-6);
}
.nav-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.nav-brand-text {
  font-weight: 600;
  font-size: var(--fs-md);
  color: #fafafa;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: #a1a1aa;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fafafa;
}
.nav-item.active {
  background: rgba(129, 140, 248, 0.14);
  color: #c7d2fe;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
}
.nav-item-count {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: #a1a1aa;
  padding: 0 6px;
  min-width: 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
}

.nav-user {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.nav-user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  min-width: 0;
}
.nav-user-card .user-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.nav-user-info {
  min-width: 0;
  flex: 1;
}
.nav-user-name {
  font-weight: 600;
  color: #fafafa;
  font-size: var(--fs-sm);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user-email {
  font-size: var(--fs-xs);
  color: #a1a1aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-signout {
  width: 100%;
  padding: 8px var(--space-3);
  background: rgba(255, 255, 255, 0.05);
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.nav-signout:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

/* --- Workspace (everything to the right of the nav rail) ------------------ */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.workspace-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--secondary-width) 1fr;
  overflow: hidden;
}
.workspace-body.single-pane {
  grid-template-columns: 1fr;
}

/* No-permission fallback shown when the user has no view perms at all. */
.no-perm-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
}
.no-perm-card {
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
}
.no-perm-card h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-lg);
  color: var(--fg);
}
.no-perm-card p {
  margin: var(--space-2) 0;
  color: var(--fg-muted);
}

/* Secondary column — scrolls, used for env / directory list */
.secondary {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}

/* Primary column — main detail area */
.primary {
  overflow-y: auto;
  background: var(--bg);
  padding: var(--space-8) var(--space-10);
}

/* ==========================================================================
   Build / live indicators in the workspace header
   ========================================================================== */

.build-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px 10px;
  background: var(--warning-tint);
  color: var(--warning);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.build-indicator .pulse {
  width: 7px;
  height: 7px;
  background: var(--warning);
  border-radius: var(--radius-full);
  animation: pulse 1.2s ease-in-out infinite;
}

/* Theme toggle button */
.theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--fg);
  border-color: var(--border-strong);
}
.theme-toggle svg { width: 16px; height: 16px; }

/* Live / paused indicator in workspace header */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  font-size: var(--fs-sm);
  border-radius: var(--radius);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.live-indicator:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-tint);
  animation: pulse-soft 2s ease-in-out infinite;
}
.live-dot.stale { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-tint); animation: none; }
.live-dot.paused { background: var(--fg-subtle); box-shadow: none; animation: none; }
.live-dot.state-healthy { /* default green pulse */ }
.live-dot.state-stale { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-tint); animation: none; }
.live-dot.state-unhealthy { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-tint); animation: none; }
.live-dot.state-unknown { background: var(--fg-subtle); box-shadow: none; animation: none; }

/* Heartbeat pill for the auto-sync timer + reaper CronJob. Same shape as
   .live-indicator but non-clickable and with a label/age/next layout. */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  user-select: none;
  font-weight: 500;
  font-size: var(--fs-sm);
  border-radius: var(--radius);
  white-space: nowrap;
}
.sync-indicator .sync-label { color: var(--fg); }
.sync-indicator .sync-next { color: var(--fg-subtle); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ==========================================================================
   Avatar
   ========================================================================== */

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--fs-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.user-avatar-md { width: 40px; height: 40px; font-size: var(--fs-md); }
.user-avatar-lg { width: 56px; height: 56px; font-size: var(--fs-xl); }

/* Nav rail avatar — keeps its dark-rail look regardless of workspace theme */
.nav-user-card .user-avatar {
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
  border-color: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Secondary column — section headings, lists
   ========================================================================== */

.secondary h2 {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.secondary .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  background: var(--surface-3);
  color: var(--fg-muted);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.secondary section + section { margin-top: var(--space-6); }

/* ==========================================================================
   Env list (secondary column, envs view)
   ========================================================================== */

.env-list, .build-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.env-list li {
  padding: var(--space-3);
  cursor: pointer;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.env-list li:hover { background: var(--surface-hover); }
.env-list li.active {
  background: var(--surface-hover);
  border-left-color: var(--accent);
}
.env-list .slug {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--fg);
}
.env-list .meta {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}
.env-list .empty {
  color: var(--fg-subtle);
  padding: var(--space-3) 0;
  font-size: var(--fs-sm);
}

.build-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast);
}
.build-item { cursor: pointer; }
.build-item:hover { background: var(--surface-hover); }

.build-slug { flex: 1; font-family: var(--font-mono); color: var(--fg); }
.build-status { color: var(--fg-muted); font-size: var(--fs-xs); text-transform: lowercase; }

/* Dots — running, success, building, failed */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.status-success { background: var(--success); box-shadow: 0 0 0 2px var(--success-tint); }
.status-building { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-tint); }
.status-failed { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-tint); }
.status-unknown { background: var(--fg-subtle); }

/* ==========================================================================
   Chips — shared everywhere
   ========================================================================== */

.chip,
.client-chip,
.client-default,
.client-prefix,
.shared-chip,
.stale-chip,
.warmup-chip,
.seed-ok,
.seed-missing,
.seed-version {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  white-space: nowrap;
}

.client-chip    { background: var(--accent-tint);  color: var(--accent); }
.client-default { background: var(--surface-3);    color: var(--fg-muted); }
.client-prefix  { background: var(--accent-tint);  color: var(--accent); font-family: var(--font-mono); }
.shared-chip    { background: var(--info-tint);    color: var(--info); }
.stale-chip     { background: var(--warning-tint); color: var(--warning); }

.seed-ok      { background: var(--success-tint); color: var(--success); }
.seed-missing { background: var(--danger-tint);  color: var(--danger); text-transform: none; padding: 2px 8px; font-weight: 500; }
.seed-version { background: transparent; color: var(--fg-subtle); padding: 0; text-transform: none; letter-spacing: 0; font-weight: 400; font-family: var(--font-mono); }

.mode-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: var(--info-tint);
  color: var(--info);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}
.warn-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: var(--warning-tint);
  color: var(--warning);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

.warmup-chip-pending { background: var(--info-tint);    color: var(--info); }
.warmup-chip-ready   { background: var(--success-tint); color: var(--success); }
.warmup-chip-failed  { background: var(--danger-tint);  color: var(--danger); }
.warmup-chip.warmup-pending { background: var(--info-tint);    color: var(--info); }
.warmup-chip.warmup-ready   { background: var(--success-tint); color: var(--success); }
.warmup-chip.warmup-failed  { background: var(--danger-tint);  color: var(--danger); }

/* Admin / role chip on directory rows */
.role-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}
.role-chip-admin { background: var(--accent-tint); color: var(--accent); }
.role-chip-user  { background: var(--surface-3); color: var(--fg-muted); }

/* ==========================================================================
   Data sources view — stat strip + per-client cards
   ========================================================================== */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.stat-tile {
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-tile-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
}
.stat-tile-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stat-tile-value small {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-muted);
  letter-spacing: 0;
}
.stat-tile-value .status-pill {
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0;
}
.status-pill.status-online  { background: var(--success-tint); color: var(--success); }
.status-pill.status-offline { background: var(--danger-tint);  color: var(--danger); }
.status-pill.status-warn    { background: var(--warning-tint); color: var(--warning); }

.stat-tile-sub {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}

/* Shared-MySQL health card */
.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.health-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.health-card-head h3 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
}
.health-card-head .hint { margin: 0; }

.health-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4) var(--space-6);
  margin-bottom: var(--space-4);
}
.health-stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  margin-bottom: 4px;
}
.health-stat-value {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.health-stat-value small {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  font-weight: 500;
  letter-spacing: 0;
}

.health-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-sm);
}
.health-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 120px;
}
.health-bar-fill {
  height: 100%;
  background: var(--success);
  transition: width var(--dur);
}
.health-bar-fill.fill-warn { background: var(--warning); }
.health-bar-fill.fill-danger { background: var(--danger); }

.health-offline {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  padding: var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ==========================================================================
   Activity view
   ========================================================================== */

.activity-controls {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.activity-item {
  display: grid;
  grid-template-columns: 110px 32px 1fr;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-hover); }
.activity-time {
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
  white-space: nowrap;
  padding-top: 4px;
}
.activity-avatar {
  margin-top: 2px;
}
.activity-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.activity-actor {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}
.activity-subject {
  font-size: var(--fs-xs);
  color: var(--fg);
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.activity-summary {
  color: var(--fg);
  font-size: var(--fs-sm);
  line-height: 1.45;
  word-break: break-word;
}
.activity-type-chip {
  display: inline-flex;
  padding: 1px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}
.activity-type-chip.activity-tone-success { background: var(--success-tint); color: var(--success); }
.activity-type-chip.activity-tone-info    { background: var(--info-tint);    color: var(--info); }
.activity-type-chip.activity-tone-warn    { background: var(--warning-tint); color: var(--warning); }
.activity-type-chip.activity-tone-danger  { background: var(--danger-tint);  color: var(--danger); }
.activity-type-chip.activity-tone-muted   { background: var(--surface-3);    color: var(--fg-muted); }

/* ==========================================================================
   Toast notifications
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  max-width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--fg-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur) ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
  margin-bottom: 2px;
  word-break: break-word;
}
.toast-message {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  line-height: 1.45;
  word-break: break-word;
}
.toast-close {
  background: transparent;
  border: none;
  color: var(--fg-subtle);
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  height: 20px;
  flex-shrink: 0;
  transition: color var(--dur-fast);
}
.toast-close:hover { color: var(--fg); }

.toast-info    { border-left-color: var(--info); }
.toast-info    .toast-icon { color: var(--info); }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-warn    { border-left-color: var(--warning); }
.toast-warn    .toast-icon { color: var(--warning); }
.toast-error   { border-left-color: var(--danger); }
.toast-error   .toast-icon { color: var(--danger); }

.client-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast);
}
.client-card:hover { border-color: var(--border-strong); }

.client-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.client-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg);
}
.client-card-head .spacer { flex: 1; }

.client-card-rows {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 6px var(--space-4);
  font-size: var(--fs-sm);
  align-items: baseline;
}
.client-card-rows .row-label {
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.client-card-rows .row-value {
  color: var(--fg);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.client-card-rows .row-value .mono { color: var(--fg); }
.client-card-rows .row-aside {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}

.pr-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  transition: color var(--dur-fast), border-color var(--dur-fast);
  text-decoration: none;
}
.pr-chip:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.pr-chip-empty { color: var(--fg-subtle); font-style: italic; }

/* ==========================================================================
   Directory (secondary column, users view)
   ========================================================================== */

.directory {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  min-height: 0;
}
.directory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.directory-head h2 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fg);
  text-transform: none;
  letter-spacing: -0.01em;
  margin: 0;
}
.directory-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.directory-filter {
  width: 100%;
  padding: 9px var(--space-3);
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.directory-filter::placeholder { color: var(--fg-subtle); }
.directory-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.directory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.directory-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  min-width: 0;
}
.directory-item:hover { background: var(--surface-hover); }
.directory-item.active {
  background: var(--accent-tint);
  border-color: var(--accent-tint);
}
.directory-item-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.directory-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg);
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.directory-item-name .role-chip { flex-shrink: 0; }
.directory-item-email {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.directory-item-chevron {
  color: var(--fg-subtle);
  flex-shrink: 0;
  transition: color var(--dur-fast);
}
.directory-item:hover .directory-item-chevron,
.directory-item.active .directory-item-chevron { color: var(--accent); }

.directory-empty {
  padding: var(--space-6) var(--space-4);
  color: var(--fg-subtle);
  font-size: var(--fs-sm);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ==========================================================================
   Primary column — env detail + user detail
   ========================================================================== */

.primary.detail-empty {
  color: var(--fg-muted);
  padding: var(--space-10);
  text-align: center;
  font-size: var(--fs-md);
}

.primary h3 {
  margin: var(--space-8) 0 var(--space-3);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.primary h3 .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  background: var(--surface-3);
  color: var(--fg-muted);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.detail-header h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
}
.detail-header h1.mono {
  font-family: var(--font-mono);
}

.detail-urls {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
.detail-urls a {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-muted);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.detail-urls a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* Meta strip on env detail */
.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3) var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-6);
}
.detail-meta > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  color: var(--fg-muted);
}
.detail-meta b {
  color: var(--fg-subtle);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
  display: block;
  width: 100%;
}
.detail-meta .mono { color: var(--fg); }
.detail-meta .hint { font-size: var(--fs-xs); }

/* ==========================================================================
   User detail (primary column, users view)
   ========================================================================== */

.user-detail-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.user-detail-identity {
  min-width: 0;
}
.user-detail-identity h1 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  margin: 0;
}
.user-detail-identity .mono {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.user-detail-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5) var(--space-8);
  padding: var(--space-5) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}
.user-field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  margin-bottom: 6px;
}
.user-field-value {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--fg);
  word-break: break-word;
}
.user-field-value.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.user-field-value .hint { font-weight: 400; color: var(--fg-muted); }

.user-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--success-tint);
  color: var(--success);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.user-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--success);
}

/* Admin-access card */
.user-admin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}
.user-admin-card-text { min-width: 0; }
.user-admin-card-text h4 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 2px;
}
.user-admin-card-text p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}
.user-admin-card .btn { flex-shrink: 0; }

/* Permission grid card — sits below the admin/role card on user detail. */
.user-permissions-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
}
.user-permissions-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.user-permissions-head h4 {
  margin: 0;
  font-size: var(--fs-md);
  color: var(--fg);
}
.user-permissions-head p.hint { flex: 1 1 240px; margin: 0; }
.user-permissions-group { margin-top: var(--space-4); }
.user-permissions-group:first-of-type { margin-top: 0; }
.user-permissions-group-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}
.user-permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (max-width: 720px) {
  .user-permissions-grid { grid-template-columns: 1fr; }
}
.user-perm-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.user-perm-row:hover { background: var(--bg); border-color: var(--accent-soft); }
.user-perm-row input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.user-perm-row.saving { opacity: 0.6; pointer-events: none; }
.user-perm-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-perm-title { font-weight: 600; color: var(--fg); font-size: var(--fs-sm); }
.user-perm-desc  { font-size: var(--fs-xs); color: var(--fg-muted); }
.user-perm-key   { font-size: 11px; color: var(--fg-muted); opacity: 0.7; }

/* Role + remove actions row at bottom of user detail */
.user-detail-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

/* ==========================================================================
   Tabs (used inside env detail)
   ========================================================================== */

.detail-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 var(--space-6);
  border-bottom: 1px solid var(--border);
}
.detail-tabs .tab {
  background: transparent;
  color: var(--fg-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  margin-bottom: -1px;
}
.detail-tabs .tab:hover { color: var(--fg); }
.detail-tabs .tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* ==========================================================================
   Pods table
   ========================================================================== */

.pods {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--fs-sm);
}
.pods thead { background: var(--surface-2); }
.pods th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.pods td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.pods tbody tr:last-child td { border-bottom: none; }
.pods tbody tr:hover { background: var(--surface-hover); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled,
.btn.btn-disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-fg);
}

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); }

.btn-warn {
  background: transparent;
  border-color: var(--border);
  color: var(--warning);
}
.btn-warn:hover { background: var(--warning-tint); border-color: var(--warning); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--fg); border-color: transparent; }

.btn-small { padding: 3px 10px; font-size: var(--fs-xs); }

.actions-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-5) 0 var(--space-3);
}

/* ==========================================================================
   Config editor — kv rows
   ========================================================================== */

.config-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.frontend-config { max-width: 900px; }

.kv-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
}
.kv-row input {
  padding: 6px 10px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.kv-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.kv-row input.key { flex: 0 0 260px; color: var(--accent); }
.kv-row input.value { flex: 1; }
.kv-row input[readonly] {
  opacity: 0.85;
  cursor: default;
  background: var(--surface-2);
}
.kv-row input[readonly]:focus { border-color: var(--border); box-shadow: none; }

.kv-new {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border);
}

.hint {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  margin: var(--space-1) 0 var(--space-3);
  max-width: 720px;
  line-height: 1.5;
}
.hint code.mono { font-size: var(--fs-xs); }

.secret-filter {
  width: 100%;
  max-width: 640px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-2);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.secret-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.secret-empty {
  color: var(--fg-subtle);
  padding: var(--space-2) var(--space-3);
  font-style: italic;
}

/* Flash animation when new secret key lands */
.kv-row.flash-new { animation: flash-new-row 2.5s ease-out; }
@keyframes flash-new-row {
  0%   { background: var(--success-tint); box-shadow: 0 0 0 4px var(--success-tint); }
  60%  { background: var(--success-tint); box-shadow: 0 0 0 4px var(--success-tint); }
  100% { background: transparent; box-shadow: 0 0 0 0 transparent; }
}

/* ==========================================================================
   Modals (logs, add-process, new-command)
   ========================================================================== */

.log-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-6);
  animation: fade-in var(--dur) ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.log-box {
  width: 100%;
  max-width: 960px;
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up var(--dur) ease-out;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: var(--space-3);
  font-size: var(--fs-sm);
}
.log-header .btn { padding: 2px 10px; }
.log-header .btn-ghost {
  padding: 0 10px;
  font-size: var(--fs-lg);
  line-height: 1;
  height: 28px;
  width: 28px;
}
.log-status { color: var(--fg-muted); text-transform: lowercase; margin-left: var(--space-2); font-size: var(--fs-xs); }
.log-live {
  margin-left: var(--space-2);
  padding: 1px 8px;
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  animation: pulse 1.4s ease-in-out infinite;
}

.log-pre {
  margin: 0;
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--fg);
  background: var(--surface);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}

/* ==========================================================================
   Commands tab — cards, history list, chips
   ========================================================================== */

.cmd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  max-width: 1040px;
  box-shadow: var(--shadow-sm);
}
.cmd-card-title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg);
}
.cmd-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.exec-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-3) 0;
}
.exec-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}
.exec-component, .exec-input {
  padding: 8px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.exec-component { flex: 0 0 110px; font-family: inherit; }
.exec-input { flex: 1; }
.exec-component:focus, .exec-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.cmd-empty {
  padding: var(--space-6);
  color: var(--fg-subtle);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
}

.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cmd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.cmd-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.cmd-item-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cmd-text {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--fs-sm);
  font-weight: 500;
}
.cmd-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}
.cmd-comp { color: var(--accent); font-weight: 500; }
.cmd-item-status { flex-shrink: 0; }

.cmd-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}
.cmd-chip-running { background: var(--info-tint);    color: var(--info);    animation: pulse 1.6s infinite; }
.cmd-chip-success { background: var(--success-tint); color: var(--success); }
.cmd-chip-failed  { background: var(--danger-tint);  color: var(--danger); }
.cmd-chip-unknown { background: var(--surface-3);    color: var(--fg-muted); }

/* ==========================================================================
   Processes tab
   ========================================================================== */

.proc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-4);
}
.proc-item {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur-fast);
}
.proc-item:hover { border-color: var(--border-strong); }
.proc-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.proc-item-head {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.proc-item-head b {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
}

.proc-kind {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  border-radius: var(--radius-full);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}
.proc-kind-system { background: var(--accent-tint); color: var(--accent); }
.proc-kind-custom { background: var(--info-tint);   color: var(--info); }

.cmd-chip-proc-running { background: var(--success-tint); color: var(--success); }
.cmd-chip-proc-partial { background: var(--warning-tint); color: var(--warning); }
.cmd-chip-proc-stopped { background: var(--surface-3);    color: var(--fg-muted); }
.cmd-chip-proc-pending { background: var(--info-tint);    color: var(--info); animation: pulse 1.6s infinite; }

.proc-cmd {
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proc-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Add-process example card */
.proc-example {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}
.proc-example-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.proc-example-head b { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.proc-example-body { font-size: var(--fs-sm); color: var(--fg-muted); }
.proc-example-body b { color: var(--fg); font-weight: 500; }
.proc-example-cmd {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  word-break: break-all;
  color: var(--fg);
}

textarea.exec-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.45;
}

/* Form labels in modals */
.log-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}
.log-box label b { color: var(--fg); font-weight: 500; }
.log-box label .hint { margin: 0; display: inline; font-size: var(--fs-xs); }

/* ==========================================================================
   Accessibility + reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline-offset: 0;
}

/* Template-switch row on the Overview tab — dropdown + two buttons inline. */
.template-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.template-select {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  min-width: 220px;
}

/* Logs tab — toolbar + tail viewer */
.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.logs-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}
.logs-control select {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}
.logs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}
.logs-pod {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}
.logs-pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin: 0;
  max-height: 600px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--fg-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Shell tab — interactive PTY host. xterm.js mounts inside .shell-host and
   sizes itself via xterm-addon-fit. Flex column + min-height:0 on the child
   lets the xterm element fill the remaining space cleanly; border-box keeps
   padding from inflating the box past the declared height (otherwise xterm's
   row math drifts and the last rows fall outside the scrollbar's reach). */
.shell-host {
  background: #0b0d10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  margin-top: var(--space-3);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: clamp(320px, calc(100vh - 320px), 760px);
  min-height: 320px;
  overflow: hidden;
}
.shell-host .xterm {
  flex: 1 1 auto;
  min-height: 0;
}
