/* ==========================================================================
   Lifeboat Control Plane — Stylesheet
   ========================================================================== */

/* ---------- Custom Properties ---------- */
:root {
  --color-bg: #ffffff;
  --color-sidebar: #0a0a0a;
  --color-sidebar-hover: #1a1a1a;
  --color-sidebar-active: #2563eb;
  --color-btn-primary: #000000;
  --color-accent: #2563eb;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-text-light: #9ca3af;
  /* Card / input / divider stroke. Bumped from #e5e7eb (gray-200,
     too faint against the white card background — operators reported
     the Playground sidebar cards "blending in") to #cbd5e1 (slate-300)
     so card edges read clearly. --color-border-light stays one step
     lighter for muted internal dividers (e.g. table separators). */
  --color-border: #cbd5e1;
  --color-border-light: #e5e7eb;
  --color-card-bg: #ffffff;
  --color-input-bg: #f9fafb;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.15);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  overflow-x: hidden;
}

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

a:hover {
  color: #1d4ed8;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
  /* `color` is inherited by the wordmark's currentColor strokes —
     keeps the "L" + text in sidebar-light cream on the dark
     sidebar background without needing per-page overrides. */
  color: #ffffff;
}

.sidebar-logo:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-logo-img {
  display: block;
  /* iterate.ai wordmark from UI Experience team. 382:98 aspect.
     Slightly taller than my placeholder because the wordmark has
     a stacked "By Iterate.ai" tagline that gets cramped under 36px. */
  height: 44px;
  width: auto;
  max-width: 100%;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: var(--color-sidebar-hover);
}

.nav-item.active {
  color: #ffffff;
  background: rgba(37, 99, 235, 0.12);
  border-left-color: var(--color-accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-version {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  font-family: var(--font-mono);
}

/* ---------- Hamburger (mobile) ---------- */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--color-btn-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 8px;
  color: #ffffff;
}

.hamburger svg {
  width: 100%;
  height: 100%;
}

/* ---------- Top Bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  /* Tighter overall gap; the divider provides the real visual
     separation between the "system" group (branding + bell) and the
     "account" group (user pill). Without a tight base gap the
     branding/bell pair looked unrelated to each other. */
  gap: 10px;
}

.topbar-branding {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-light);
  letter-spacing: 0.5px;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--color-border);
  /* Extra breathing room around the divider so it reads as a real
     group separator rather than just another element in the row. */
  margin: 0 6px;
}

.topbar-user {
  font-size: 11px;
  color: var(--color-text-muted);
  display: block;
  line-height: 1.2;
}

/* ===== User menu (avatar pill + dropdown) ===== */
/* The whole element is the click target; the dropdown is absolutely
   positioned relative to the wrapper so it pops directly under the
   pill instead of pushing topbar siblings around. */
.topbar-user-menu {
  position: relative;
  display: inline-block;
}

.topbar-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  background: transparent;
  /* No oval border — the avatar + role label read as a single
     unit without a chrome ring around them. Hover still gives
     a subtle wash so it's discoverable as a click target. */
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--color-text);
  transition: background var(--transition-fast);
}
.topbar-user-pill:hover {
  background: var(--color-input-bg);
}
.topbar-user-pill:focus-visible {
  outline: 2px solid var(--color-accent, #2563eb);
  outline-offset: 2px;
}

.topbar-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fee2e2;            /* light-red wash, matches mockup */
  color: #b91c1c;                 /* darker red icon stroke */
}
.topbar-user-avatar svg {
  width: 16px;
  height: 16px;
}

.topbar-user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.15;
}
.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-caret {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.topbar-user-menu.open .topbar-user-caret {
  transform: rotate(180deg);
}

.topbar-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  padding: 4px 0;
  z-index: 200;
  /* Hidden until the wrapper gets `.open`. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast),
              transform var(--transition-fast),
              visibility 0s linear var(--transition-fast, 150ms);
}
.topbar-user-menu.open .topbar-user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity var(--transition-fast),
              transform var(--transition-fast),
              visibility 0s;
}

.topbar-user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: none;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.topbar-user-dropdown-item:hover {
  background: var(--color-input-bg);
}
.topbar-user-dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.topbar-user-dropdown-item:last-child {
  color: #b91c1c;                 /* logout-style red */
}
.topbar-user-dropdown-item:last-child svg {
  color: #b91c1c;
}

.topbar-user-dropdown-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--color-border);
}

/* Alerts bell in the topbar — a clickable icon with a count badge. */
.topbar-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--color-text-muted);
  border-radius: 6px;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-bell:hover {
  background: var(--color-input-bg);
  color: var(--color-text);
}
.topbar-bell svg {
  width: 18px;
  height: 18px;
}
.topbar-bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #ffffff;
  border-radius: 8px;
  /* color overridden by JS based on max severity */
  background: var(--color-error, #ef4444);
}

/* Small inline count pill on sidebar nav entries (matches the bell). */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  background: var(--color-error, #ef4444);
  border-radius: 9px;
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--color-btn-primary);
  color: #ffffff;
  border-color: var(--color-btn-primary);
}

.btn-primary:hover:not(:disabled) {
  background: #1a1a1a;
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-input-bg);
  border-color: #d1d5db;
}

.btn-danger {
  background: var(--color-error);
  color: #ffffff;
  border-color: var(--color-error);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  padding: 6px 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-input-bg);
  color: var(--color-text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-sm .btn-icon {
  width: 13px;
  height: 13px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-icon-only {
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-only:hover {
  background: var(--color-input-bg);
  color: var(--color-text);
}

.btn-icon-only svg {
  width: 16px;
  height: 16px;
}

.btn-group {
  display: flex;
  gap: 8px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Stat Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-sub {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 4px;
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  background: var(--color-input-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--color-input-bg);
}

.table-actions {
  display: flex;
  gap: 4px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 8px;
}

.pagination-info {
  font-size: 13px;
  color: var(--color-text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-input-bg);
  border-color: #d1d5db;
}

.pagination-btn.active {
  background: var(--color-btn-primary);
  color: #ffffff;
  border-color: var(--color-btn-primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn svg {
  width: 14px;
  height: 14px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-running {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.badge-stopped {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.badge-info {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-running .badge-dot { background: #22c55e; }
.badge-stopped .badge-dot { background: #9ca3af; }
.badge-error .badge-dot { background: #ef4444; }
.badge-warning .badge-dot { background: #f59e0b; }

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--color-bg);
}

.form-input::placeholder {
  color: var(--color-text-light);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.form-range {
  width: 100%;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.form-range-value {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  font-family: var(--font-mono);
  margin-left: 8px;
}

.form-error {
  color: var(--color-error);
  font-size: 12px;
  margin-top: 4px;
}

/* ---------- Login Page ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

/* iterate.ai wordmark from UI Experience team. 382:98 aspect ratio,
   so we lock height + auto width so it never stretches. max-width
   keeps it inside the login card on narrow viewports. */
.login-logo-img {
  display: block;
  margin: 0 auto 18px;
  height: 60px;
  width: auto;
  max-width: 100%;
}

.login-logo-text {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 4px;
  display: block;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
}

.login-subtitle-brand {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 4px;
}

.login-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible {
  display: block;
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
  font-size: 14px;
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.page-header-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Section ---------- */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

/* ---------- Grid Layouts ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ---------- Node Cards ---------- */
.node-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  padding-bottom: 44px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast);
  position: relative;
}

.node-card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* Selected state for clickable picker cards (e.g. the HuggingFace model
   search results). Makes the chosen card unambiguous — previously only a
   transient toast signalled the selection. */
.node-card.selected {
  border-color: var(--color-accent, #2563eb);
  box-shadow: 0 0 0 1px var(--color-accent, #2563eb) inset;
  background: rgba(37, 99, 235, 0.04);
}

.node-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.node-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.node-card-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.node-card-actions {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  gap: 4px;
}

.node-card-action-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast);
}

.node-card-action-btn svg {
  width: 14px;
  height: 14px;
}

.node-card-action-btn:hover {
  background: var(--color-bg-hover, rgba(0, 0, 0, 0.04));
  color: var(--color-text);
}

.node-card-action-btn-danger:hover {
  color: var(--color-danger, #dc2626);
  border-color: var(--color-danger, #dc2626);
}

/* ---------- Server Mini Cards ---------- */
.server-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.server-mini-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast);
}

.server-mini-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.server-mini-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.server-mini-model {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-mini-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- YAML Editor ---------- */
.yaml-editor {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.yaml-editor textarea {
  width: 100%;
  min-height: 400px;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-input-bg);
  border: none;
  resize: vertical;
  tab-size: 2;
}

.yaml-editor textarea:focus {
  outline: none;
  background: var(--color-bg);
}

/* ---------- Feature Cards ---------- */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.feature-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--color-input-bg);
}

.feature-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.feature-card-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.feature-card-enabled {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.04);
}

/* ---------- Routing Mode Picker ---------- */
.routing-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.routing-mode-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  background: var(--color-input-bg);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  text-align: left;
  font: inherit;
  color: inherit;
}

.routing-mode-card:hover {
  border-color: var(--color-text-muted);
}

.routing-mode-card-active {
  border-color: var(--color-accent, #2563eb);
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 0 1px var(--color-accent, #2563eb) inset;
}

.routing-mode-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.routing-mode-card-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--color-accent, #2563eb);
  color: #fff;
}

.routing-mode-card-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.routing-mode-card[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.routing-mode-card-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--color-border);
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.routing-mode-card-live {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ---------- Filter Bar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--color-text-light);
  pointer-events: none;
}

.search-input-wrapper .form-input {
  padding-left: 32px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 150ms ease;
}

.modal {
  background: var(--color-card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 200ms ease;
}

.modal-lg {
  max-width: 720px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-input-bg);
  color: var(--color-text);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 250ms ease;
  pointer-events: auto;
}

.toast-success {
  border-left: 3px solid var(--color-success);
}

.toast-error {
  border-left: 3px solid var(--color-error);
}

.toast-warning {
  border-left: 3px solid var(--color-warning);
}

.toast-info {
  border-left: 3px solid var(--color-accent);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-error); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-accent); }

.toast-message {
  flex: 1;
  color: var(--color-text);
}

.toast-close {
  background: none;
  border: none;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 2px;
  line-height: 0;
}

.toast-close:hover {
  color: var(--color-text);
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

.toast-exit {
  animation: toastOut 200ms ease forwards;
}

/* ---------- Loading Spinner ---------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex-direction: column;
  gap: 12px;
}

.loading-text {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-light);
  margin: 0 auto 16px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

/* ---------- Utility ---------- */
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

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

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    left: 0;
    padding-left: 60px;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-input,
  .filter-bar .form-select {
    width: 100%;
    min-width: unset;
  }

  .modal {
    max-width: 100%;
    margin: 0 12px;
  }

  .topbar-branding {
    display: none;
  }

  .topbar-divider {
    display: none;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 20px;
  }
}

/* ---------- Print ---------- */
@media print {
  .sidebar,
  .topbar,
  .hamburger,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
}

@keyframes pgblink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
