/* === Design Tokens === */
:root {
  /* Background layers */
  --bg-base: #0b0e14;
  --bg-surface: #111827;
  --bg-elevated: #1e293b;

  /* Primary accent */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-ghost: rgba(99,102,241,0.12);

  /* Semantic colors */
  --success: #22c55e;
  --success-text: #4ade80;
  --warning: #f59e0b;
  --warning-text: #fbbf24;
  --error: #ef4444;
  --error-text: #fca5a5;

  /* Text hierarchy */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --text-disabled: #334155;

  /* Borders */
  --border: #1e293b;
  --border-subtle: #334155;

  /* Typography */
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 20px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-focus: 0 0 0 3px rgba(99,102,241,0.15);
}

/* === Light theme overrides === */
body.theme-light {
  --bg-base: #f7f7f5;
  --bg-surface: #ffffff;
  --bg-elevated: #eef0f3;

  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --primary-ghost: rgba(79,70,229,0.08);

  --success: #16a34a;
  --success-text: #15803d;
  --warning: #d97706;
  --warning-text: #b45309;
  --error: #dc2626;
  --error-text: #b91c1c;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;

  --border: #e2e8f0;
  --border-subtle: #cbd5e1;

  --shadow-card: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-elevated: 0 8px 24px rgba(15,23,42,0.08);
  --shadow-focus: 0 0 0 3px rgba(79,70,229,0.18);
}

/* === Theme toggle button === */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
  margin-right: 14px;
}

.theme-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

body.theme-light .theme-toggle .icon-sun { display: block; }
body.theme-light .theme-toggle .icon-moon { display: none; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-secondary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* === Top Navigation Bar === */
.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.topnav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  flex-shrink: 0;
}

.topnav-title {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topnav-sep {
  color: var(--text-disabled);
  font-size: 14px;
}

.topnav-page {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav-links a {
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.topnav-links a:hover {
  color: var(--text-secondary);
}

.topnav-links a.is-active {
  color: var(--primary-light);
  font-weight: 600;
}

.topnav-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav-email {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.4;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.btn-ghost {
  background: transparent;
  color: var(--primary-light);
  border: 1px solid rgba(99,102,241,0.3);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-ghost);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-subtle);
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--error-text);
  border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,0.18);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

/* === Input Fields === */
.input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

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

.input-compact {
  padding: 8px 12px;
  font-size: 13px;
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

textarea.input {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

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

/* === Status Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

.badge-running {
  background: rgba(99,102,241,0.1);
  color: var(--primary-light);
  border: 1px solid rgba(99,102,241,0.2);
}

.badge-success {
  background: rgba(34,197,94,0.1);
  color: var(--success-text);
  border: 1px solid rgba(34,197,94,0.2);
}

.badge-error {
  background: rgba(239,68,68,0.1);
  color: var(--error-text);
  border: 1px solid rgba(239,68,68,0.2);
}

.badge-warning {
  background: rgba(245,158,11,0.1);
  color: var(--warning-text);
  border: 1px solid rgba(245,158,11,0.2);
}

.badge-idle {
  background: rgba(148,163,184,0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(148,163,184,0.15);
}

/* === Step Progress Bar === */
.stepper {
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.step {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.step-circle-done {
  background: var(--success);
  color: #fff;
}

.step-circle-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.step-circle-pending {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.step-circle-error {
  background: var(--error);
  color: #fff;
}

.step-label {
  font-size: 12px;
  transition: color 0.2s ease;
}

.step-label-done { color: var(--text-secondary); }
.step-label-active { color: var(--primary-light); font-weight: 600; }
.step-label-pending { color: var(--text-muted); }
.step-label-error { color: var(--error-text); font-weight: 600; }

.step-line {
  flex: 1;
  height: 2px;
  margin: 0 8px;
  transition: background 0.3s ease;
}

.step-line-done { background: var(--success); }
.step-line-active { background: linear-gradient(90deg, var(--success), var(--primary)); }
.step-line-pending { background: var(--border); }
.step-line-error { background: linear-gradient(90deg, var(--success), var(--error)); }

/* === Timeline Log === */
.timeline-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
}

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

.timeline-title {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.timeline-elapsed {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.timeline-content {
  position: relative;
  padding-left: 24px;
  max-height: 320px;
  overflow-y: auto;
}

.timeline-line {
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-entry {
  position: relative;
  margin-bottom: 12px;
  animation: tl-fade-in 0.2s ease;
}

.timeline-entry:last-child {
  margin-bottom: 0;
}

.timeline-node {
  position: absolute;
  left: -21px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  transition: background 0.2s ease;
  transform: scale(0);
  animation: tl-node-in 0.2s ease forwards;
}

.timeline-node-success { background: var(--success); }
.timeline-node-info { background: var(--primary); }
.timeline-node-warning { background: var(--warning); animation: tl-node-in 0.2s ease forwards, pulse 1.5s infinite 0.2s; }
.timeline-node-error { background: var(--error); }
.timeline-node-pending { background: var(--text-disabled); }

.timeline-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.timeline-ts {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-right: 6px;
}

.timeline-highlight {
  color: var(--primary-light);
}

.timeline-success-text {
  color: var(--success-text);
}

.timeline-warning-text {
  color: var(--warning-text);
  font-size: 11px;
}

.timeline-error-text {
  color: var(--error-text);
}

.timeline-entry-deleted-account .timeline-text,
.timeline-entry-deleted-account .timeline-ts {
  color: var(--error-text);
  font-weight: 700;
}

/* === Animations === */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes tl-node-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes tl-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-out-up {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

@keyframes badge-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.anim-fade-in {
  animation: fade-in 0.3s ease forwards;
}

.anim-fade-out-up {
  animation: fade-out-up 0.3s ease forwards;
}

.anim-badge-in {
  animation: badge-in 0.2s ease forwards;
}

/* === Utility === */
.hidden { display: none !important; }

.mono { font-family: var(--font-mono); }

.text-primary { color: var(--text-primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-text); }
.text-error { color: var(--error-text); }

/* === Responsive === */
@media (max-width: 768px) {
  .topnav {
    padding: 12px 16px;
  }

  .topnav-links {
    gap: 10px;
  }

  .step-label {
    display: none;
  }
}
