/* ==========================================================================
   MailHost - Ultra-Modern Enterprise SaaS Design System
   Sleek Dark Navigation & Contrast Crisp Light Canvas
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Typography */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace;

  /* Color Palette - Modern Enterprise SaaS */
  --bg-app: #f8fafc;
  --bg-body-radial: radial-gradient(at 0% 0%, rgba(241, 245, 249, 0.8) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(238, 242, 255, 0.6) 0px, transparent 50%);
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --border-light: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #3b82f6;

  /* Sidebar Dark Theme (Stripe/Supabase/Vercel Style) */
  --sidebar-bg: #090d16;
  --sidebar-bg-elevated: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f8fafc;
  --sidebar-text-active: #ffffff;
  --sidebar-nav-hover: rgba(255, 255, 255, 0.05);
  --sidebar-nav-active: rgba(59, 130, 246, 0.15);
  --sidebar-accent: #3b82f6;

  /* Typography Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Brand Accents */
  --brand-blue: #2563eb;
  --brand-blue-hover: #1d4ed8;
  --brand-blue-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
  --brand-blue-light: #eff6ff;
  --brand-blue-border: #bfdbfe;
  --brand-indigo: #6366f1;

  /* Status Tokens */
  --status-delivered-bg: #ecfdf5;
  --status-delivered-text: #059669;
  --status-delivered-border: #a7f3d0;
  --status-delivered-dot: #10b981;

  --status-queued-bg: #eff6ff;
  --status-queued-text: #2563eb;
  --status-queued-border: #bfdbfe;
  --status-queued-dot: #3b82f6;

  --status-deferred-bg: #fffbeb;
  --status-deferred-text: #d97706;
  --status-deferred-border: #fde68a;
  --status-deferred-dot: #f59e0b;

  --status-failed-bg: #fff1f2;
  --status-failed-text: #e11d48;
  --status-failed-border: #fecdd3;
  --status-failed-dot: #f43f5e;

  /* Shadows - Layered & Subtle */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 6px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 25px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  --shadow-brand: 0 8px 20px -4px rgba(37, 99, 235, 0.35);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  background-image: var(--bg-body-radial);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================================================
   Application Layout
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ==========================================================================
   Sleek Enterprise Sidebar
   ========================================================================== */
.app-sidebar {
  width: 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  padding: 24px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--brand-blue-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.brand-wrapper:hover .brand-icon {
  transform: scale(1.04);
}

.brand-text {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  display: block;
  line-height: 1.2;
}

.brand-subtext {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  display: inline-block;
  margin-top: 2px;
}

/* Sidebar Cluster Status Pill */
.sidebar-cluster-status {
  padding: 10px 14px;
  margin: 16px 16px 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cluster-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cluster-pulse {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #34d399;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseDot 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.8);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748b;
  padding: 14px 12px 6px;
  letter-spacing: 0.08em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  position: relative;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  background-color: var(--sidebar-nav-hover);
  color: var(--sidebar-text-hover);
  transform: translateX(2px);
}

.nav-link.active {
  background: var(--sidebar-nav-active);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.15);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3.5px;
  background: #3b82f6;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px #3b82f6;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity var(--transition-fast);
}

.nav-link.active svg,
.nav-link:hover svg {
  opacity: 1;
}

/* Sidebar Footer & User Profile Badge */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg-elevated);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--sidebar-border);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.user-profile-badge:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.avatar-circle {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #38bdf8;
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.73rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.app-main {
  margin-left: 270px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Modern Topbar */
.app-topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
}

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

.page-title {
  font-size: 1.42rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cluster-badge-topbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

.cluster-badge-topbar .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  position: relative;
}

.cluster-badge-topbar .live-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: pulseDot 2s infinite;
}

.content-body {
  padding: 32px 36px 60px;
  max-width: 1440px;
  width: 100%;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background-color: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.alert svg {
  flex-shrink: 0;
}

/* ==========================================================================
   Cards & Panels
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
  overflow: hidden;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  border-color: #cbd5e1;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body {
  padding: 24px;
}

/* ==========================================================================
   KPI Stats Grid & Stat Cards
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
}

.stat-icon.blue {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
.stat-icon.green {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}
.stat-icon.amber {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.stat-icon.purple {
  background: #faf5ff;
  color: #9333ea;
  border: 1px solid #e9d5ff;
}
.stat-icon.rose, .stat-icon.red {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}
.stat-icon.emerald {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* Metric class aliases for analytics & settings cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.metric-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.metric-card:hover .metric-icon-badge {
  transform: scale(1.08);
}

.metric-icon-badge.blue {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
.metric-icon-badge.green, .metric-icon-badge.emerald {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}
.metric-icon-badge.amber {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.metric-icon-badge.purple {
  background: #faf5ff;
  color: #9333ea;
  border: 1px solid #e9d5ff;
}
.metric-icon-badge.rose, .metric-icon-badge.red {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.metric-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-trend {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-trend.success {
  color: #059669;
  font-weight: 600;
}

/* ==========================================================================
   Modern Interactive Toggle Switches
   ========================================================================== */
.toggle-switch, .switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input, .switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-slider, .slider {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  background-color: #cbd5e1;
  border-radius: 26px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-slider::before, .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider,
.switch input:checked + .slider {
  background-color: #2563eb !important;
}

.toggle-switch input:checked + .toggle-slider::before,
.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.toggle-switch:hover .toggle-slider,
.switch:hover .slider {
  filter: brightness(0.96);
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Progress Bars */
.progress-container {
  margin-top: 12px;
  background: #e2e8f0;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Modern Data Tables
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.data-table td {
  padding: 15px 18px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
  vertical-align: middle;
  background: #ffffff;
  transition: background-color var(--transition-fast);
}

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

.data-table tbody tr:hover td {
  background-color: #f8fafc;
}

/* ==========================================================================
   Status Badges & Pills
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-delivered {
  background: var(--status-delivered-bg);
  color: var(--status-delivered-text);
  border: 1px solid var(--status-delivered-border);
}
.badge-delivered .badge-dot { background: var(--status-delivered-dot); }

.badge-accepted, .badge-queued {
  background: var(--status-queued-bg);
  color: var(--status-queued-text);
  border: 1px solid var(--status-queued-border);
}
.badge-accepted .badge-dot, .badge-queued .badge-dot { background: var(--status-queued-dot); }

.badge-deferred {
  background: var(--status-deferred-bg);
  color: var(--status-deferred-text);
  border: 1px solid var(--status-deferred-border);
}
.badge-deferred .badge-dot { background: var(--status-deferred-dot); }

.badge-failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-text);
  border: 1px solid var(--status-failed-border);
}
.badge-failed .badge-dot { background: var(--status-failed-dot); }

.badge-active {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.badge-active .badge-dot { background: #10b981; }

.badge-inactive {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}
.badge-inactive .badge-dot { background: #94a3b8; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.25;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand-blue-gradient);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3), 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.4), 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background-color: #f8fafc;
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: #ffffff;
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.btn-danger {
  background-color: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.btn-danger:hover {
  background-color: #e11d48;
  color: #ffffff;
  border-color: #e11d48;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Forms & Controls
   ========================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-primary);
  background-color: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.16);
}

.form-control::placeholder {
  color: #94a3b8;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ==========================================================================
   Credential Boxes (SaaS Copy Cards)
   ========================================================================== */
.cred-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}

.cred-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-hover);
}

.cred-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cred-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cred-copy-btn {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.cred-copy-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #cbd5e1;
}

.cred-copy-btn:active {
  transform: scale(0.97);
}

.cred-val-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Code Snippet Box & macOS Dots
   ========================================================================== */
.code-box {
  background: #090d16;
  color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 20px 22px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
  position: relative;
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.code-copy-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 92%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.8);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.modal-body {
  padding: 26px;
}

.modal-footer {
  padding: 18px 26px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--brand-blue);
}

.tab-btn.active {
  color: var(--brand-blue);
  border-bottom-color: var(--brand-blue);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Terminal Log Window (Inspector / Testing)
   ========================================================================== */
.terminal-window {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  margin-top: 16px;
}

.terminal-header {
  background: #0f172a;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #10b981; }

.terminal-title {
  font-size: 0.74rem;
  color: #64748b;
  font-family: var(--font-mono);
  font-weight: 500;
}

.terminal-log {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.6;
  color: #38bdf8;
  background: #090d16;
}

.terminal-line {
  margin-bottom: 5px;
  word-break: break-all;
}

.terminal-line.success { color: #4ade80; }
.terminal-line.error { color: #f87171; }
.terminal-line.info { color: #94a3b8; }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.15fr);
  gap: 24px;
  align-items: start;
}

.analytics-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .content-body {
    padding: 24px 20px;
  }
  .app-topbar {
    padding: 14px 20px;
  }
  .settings-grid,
  .analytics-two-col {
    grid-template-columns: 1fr;
  }
}
