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

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

.logo {
  color: #6366f1;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid #1a1a1a;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.username {
  color: #888;
  font-size: 0.875rem;
}

/* SSE Connection Indicator */
.sse-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: #111;
  border: 1px solid #222;
}

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

.sse-dot-connected {
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e;
}

.sse-dot-connecting {
  background: #f59e0b;
  box-shadow: 0 0 4px #f59e0b;
  animation: sse-pulse 1.2s ease-in-out infinite;
}

@keyframes sse-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sse-dot-disconnected {
  background: #ef4444;
  box-shadow: 0 0 4px #ef4444;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: center;
}

.btn:hover { background: #252525; text-decoration: none; }

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }

.btn-danger { border-color: #dc2626; color: #dc2626; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success { border-color: #22c55e; color: #22c55e; }
.btn-success:hover { background: #22c55e; color: #000; }

.btn-warning { border-color: #f59e0b; color: #f59e0b; }
.btn-warning:hover { background: #f59e0b; color: #000; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover { background: #1a1a1a; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-external {
  background: #1a1a2e;
  border: 1px solid #6366f1;
  color: #818cf8;
}

.badge-error {
  background: #1a0505;
  border: 1px solid #dc2626;
  color: #f87171;
}

/* Cards */
.card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 1.5rem;
}

/* Login */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.breadcrumb-back {
  color: #6366f1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: color 0.15s;
}

.breadcrumb-back:hover {
  color: #818cf8;
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #555;
}

.breadcrumb-current {
  color: #888;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card .logo {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 2rem;
}

.login-card h2 {
  margin-bottom: 1rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.875rem;
  color: #888;
  margin-top: 0.5rem;
}

input[type="text"],
input[type="password"] {
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  color: #e0e0e0;
  font-size: 1rem;
}

input:focus {
  outline: none;
  border-color: #6366f1;
}

input:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.btn:focus-visible,
button:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.login-card button[type="submit"]:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.login-card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-card button[type="submit"] {
  margin-top: 1rem;
  padding: 0.6rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button[type="submit"]:hover {
  background: #4f46e5;
}

.error {
  background: #1a0505;
  border: 1px solid #dc2626;
  color: #f87171;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.success {
  background: #051a05;
  border: 1px solid #16a34a;
  color: #4ade80;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

/* Field validation hints */
.field-hint {
  font-size: 0.75rem;
  min-height: 1rem;
  line-height: 1rem;
}

.field-hint-error {
  color: #f87171;
}

.field-hint-ok {
  color: #4ade80;
}

/* Dashboard grid */
main {
  padding: 2rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 0.75rem; }
}

.status-card:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.status-card .card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.status-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-up { background: #22c55e; }
.dot-slow { background: #f59e0b; }
.dot-down { background: #ef4444; }

.card-body p {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 0.25rem;
}

.card-body strong, .card-body span {
  color: #e0e0e0;
}

/* Response time color coding */
.rt-fast { color: #22c55e !important; font-weight: 600; }
.rt-medium { color: #f59e0b !important; font-weight: 600; }
.rt-slow { color: #ef4444 !important; font-weight: 600; }

.last-checked {
  font-size: 0.8rem !important;
  color: #666 !important;
}

.card-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #222;
}

/* Service Unavailable Banner */
.service-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  color: #f59e0b;
  font-size: 0.9rem;
}

.service-banner-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* KPI Section */
.kpi-section {
  margin-top: 2rem;
}

.kpi-section h2 {
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

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

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 1.25rem;
}

.kpi-card:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: #6366f1;
  margin-bottom: 0.25rem;
}

.kpi-label {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-funnel .kpi-value {
  color: #10b981;
}

.kpi-revenue .kpi-value {
  color: #8b5cf6;
}

.kpi-selfservice .kpi-value {
  color: #14b8a6;
}

.kpi-deliverability .kpi-value {
  color: #f59e0b;
}

/* Warmup progress bar */
.warmup-bar {
  margin-top: 0.5rem;
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
}

.warmup-bar-fill {
  height: 100%;
  background: #f59e0b;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Trend indicators */
.trend-up { color: #22c55e; font-size: 0.8em; margin-left: 0.25rem; }
.trend-down { color: #ef4444; font-size: 0.8em; margin-left: 0.25rem; }
.trend-stable { color: #666; font-size: 0.8em; margin-left: 0.25rem; }

/* Alert badges */
.alert-list {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.alert-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.alert-badge.warning {
  background: #1a1505;
  border: 1px solid #f59e0b;
  color: #fbbf24;
}

.alert-badge.critical {
  background: #1a0505;
  border: 1px solid #dc2626;
  color: #f87171;
}

/* Pipeline */
.pipeline-section {
  margin-top: 2rem;
}

.pipeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.pipeline-header h2 {
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-pipeline {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border: 1px solid #8b5cf6;
  border-radius: 6px;
  background: transparent;
  color: #8b5cf6;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-pipeline:hover {
  background: #8b5cf6;
  color: #fff;
}

.pipeline-leads-list {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.pipeline-empty-help {
  padding: 1.25rem;
  color: #999;
}

.pipeline-empty-title {
  color: #ccc;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.pipeline-empty-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 0.75rem 0;
}

.pipeline-empty-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.8;
}

.pipeline-empty-steps strong {
  color: #a78bfa;
}

.pipeline-lead-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
}

.pipeline-lead-item:hover {
  background: #1a1a1a;
}

.pipeline-lead-item input[type="checkbox"] {
  accent-color: #8b5cf6;
}

#pipeline-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pipeline-progress-bar {
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.pipeline-progress-fill {
  height: 100%;
  background: #8b5cf6;
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.pipeline-track-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1a1a1a;
  font-size: 0.85rem;
}

.pipeline-lead-name {
  flex: 1;
  color: #e0e0e0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-indicator {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.step-indicator.pending {
  background: #1a1a1a;
  color: #666;
  border: 1px solid #333;
}

.step-indicator.running {
  background: #1a1a2e;
  color: #818cf8;
  border: 1px solid #6366f1;
  animation: pulse 1.5s infinite;
}

.step-indicator.success {
  background: #051a05;
  color: #4ade80;
  border: 1px solid #22c55e;
}

.step-indicator.error {
  background: #1a0505;
  color: #f87171;
  border: 1px solid #dc2626;
}

.step-indicator.skipped {
  background: #1a1a1a;
  color: #555;
  border: 1px solid #333;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.pipeline-result {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.pipeline-result.success {
  background: #051a05;
  border: 1px solid #22c55e;
  color: #4ade80;
}

.pipeline-result.partial {
  background: #1a1505;
  border: 1px solid #f59e0b;
  color: #fbbf24;
}

.pipeline-result.error {
  background: #1a0505;
  border: 1px solid #dc2626;
  color: #f87171;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #e0e0e0;
  background: #1a1a2e;
  border: 1px solid #6366f1;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 3.7s forwards;
  max-width: 400px;
}

/* Keyboard shortcuts help */
.shortcuts-help {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcuts-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.shortcuts-panel {
  position: relative;
  background: #111;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.shortcuts-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
}

.shortcuts-list {
  margin: 0;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1a1a1a;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-row dt {
  flex-shrink: 0;
}

.shortcut-row dd {
  margin: 0;
  color: #aaa;
  font-size: 0.875rem;
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  color: #e0e0e0;
  min-width: 1.5rem;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Light mode */
@media (prefers-color-scheme: light) {
  body {
    background: #f8f8f8;
    color: #1a1a1a;
  }

  a { color: #4f46e5; }

  .logo { color: #4f46e5; }

  .topbar { border-bottom-color: #e0e0e0; }

  .username { color: #666; }

  .sse-indicator {
    background: #f0f0f0;
    border-color: #d4d4d4;
  }

  .btn {
    border-color: #d4d4d4;
    background: #f0f0f0;
    color: #1a1a1a;
  }

  .btn:hover { background: #e5e5e5; }
  .btn:disabled:hover { background: #f0f0f0; }

  .badge-external {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4f46e5;
  }

  .badge-error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
  }

  .card {
    background: #fff;
    border-color: #e0e0e0;
  }

  label { color: #666; }

  input[type="text"],
  input[type="password"] {
    background: #fff;
    border-color: #d4d4d4;
    color: #1a1a1a;
  }

  input:focus { border-color: #4f46e5; }
  input:focus-visible { outline-color: #4f46e5; }
  .btn:focus-visible,
  button:focus-visible { outline-color: #4f46e5; }

  .login-card button[type="submit"] {
    background: #4f46e5;
  }

  .login-card button[type="submit"]:hover {
    background: #4338ca;
  }

  .login-card button[type="submit"]:focus-visible {
    outline-color: #1a1a1a;
  }

  .error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
  }

  .success {
    background: #f0fdf4;
    border-color: #16a34a;
    color: #16a34a;
  }

  .field-hint-error { color: #dc2626; }
  .field-hint-ok { color: #16a34a; }

  .card-body p { color: #666; }
  .card-body strong, .card-body span { color: #1a1a1a; }

  .last-checked { color: #999 !important; }

  .card-footer { border-top-color: #e0e0e0; }

  .service-banner {
    background: rgba(245, 158, 11, 0.08);
  }

  .kpi-section h2 { color: #888; }

  .kpi-card {
    background: #fff;
    border-color: #e0e0e0;
  }

  .kpi-value { color: #4f46e5; }
  .kpi-label { color: #888; }
  .kpi-funnel .kpi-value { color: #059669; }
  .kpi-revenue .kpi-value { color: #7c3aed; }
  .kpi-selfservice .kpi-value { color: #0d9488; }
  .kpi-deliverability .kpi-value { color: #d97706; }

  .warmup-bar { background: #e0e0e0; }

  .trend-stable { color: #999; }

  .alert-badge.warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #b45309;
  }

  .alert-badge.critical {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
  }

  .btn-pipeline {
    border-color: #7c3aed;
    color: #7c3aed;
  }

  .btn-pipeline:hover {
    background: #7c3aed;
    color: #fff;
  }

  .pipeline-leads-list {
    background: #fff;
    border-color: #e0e0e0;
  }

  .pipeline-empty-help { color: #666; }
  .pipeline-empty-title { color: #333; }
  .pipeline-empty-steps strong { color: #7c3aed; }

  .pipeline-lead-item { color: #1a1a1a; }
  .pipeline-lead-item:hover { background: #f5f5f5; }

  .pipeline-progress-bar { background: #e0e0e0; }

  .pipeline-track-row { border-bottom-color: #e0e0e0; }
  .pipeline-lead-name { color: #1a1a1a; }

  .step-indicator.pending {
    background: #f5f5f5;
    color: #888;
    border-color: #d4d4d4;
  }

  .step-indicator.running {
    background: #eef2ff;
    color: #4f46e5;
    border-color: #6366f1;
  }

  .step-indicator.success {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #22c55e;
  }

  .step-indicator.error {
    background: #fef2f2;
    color: #dc2626;
    border-color: #dc2626;
  }

  .step-indicator.skipped {
    background: #f5f5f5;
    color: #999;
    border-color: #d4d4d4;
  }

  .pipeline-result.success {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #16a34a;
  }

  .pipeline-result.partial {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #b45309;
  }

  .pipeline-result.error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
  }

  .toast {
    color: #1a1a1a;
    background: #eef2ff;
    border-color: #6366f1;
  }

  .shortcuts-overlay {
    background: rgba(0, 0, 0, 0.3);
  }

  .shortcuts-panel {
    background: #fff;
    border-color: #d4d4d4;
  }

  .shortcuts-header h3 { color: #1a1a1a; }

  .shortcut-row { border-bottom-color: #e0e0e0; }
  .shortcut-row dd { color: #666; }

  kbd {
    background: #f0f0f0;
    border-color: #d4d4d4;
    color: #1a1a1a;
  }

  .breadcrumb-back { color: #4f46e5; }
  .breadcrumb-back:hover { color: #4338ca; }
  .breadcrumb-separator { color: #aaa; }
  .breadcrumb-current { color: #666; }

  .status-card:focus-visible { outline-color: #4f46e5; }
  .kpi-card:focus-visible { outline-color: #4f46e5; }
}
