/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(15, 23, 42, 0.8);
  --bg-sidebar: rgba(15, 23, 42, 0.95);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-active: rgba(99, 102, 241, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --accent-blue: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-theme="light"] {
  --bg-primary: #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: rgba(234, 236, 240, 0.8);
  --bg-glass: rgba(0, 0, 0, 0.03);
  --bg-input: #ffffff;
  --bg-sidebar: #f6f8fa;

  --border-color: #d0d7de;
  --border-active: #0969da;

  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-muted: #6e7781;

  --accent-gradient: #0969da;
  --accent-blue: #0969da;
  --accent-purple: #8250df;
  --accent-pink: #bf3989;
  --accent-green: #1a7f37;
  --accent-red: #cf222e;
  --accent-amber: #9a6700;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.05);
  --shadow-glow: none;
}

body.force-light-theme {
  background: #f6f8fa !important;
}

body[data-theme="light"]::before,
body.force-light-theme::before {
  display: none !important;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background gradient effect */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow), background-color 0.2s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  font-size: 28px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: var(--accent-blue);
  border-radius: 0 4px 4px 0;
  transition: transform var(--transition-normal);
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-glass);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}

.nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.version-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
}

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

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

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 0.05;
  transform: translate(30%, -30%);
}

.stat-card.blue::after {
  background: var(--accent-blue);
}

.stat-card.purple::after {
  background: var(--accent-purple);
}

.stat-card.green::after {
  background: var(--accent-green);
}

.stat-card.amber::after {
  background: var(--accent-amber);
}

.stat-card.pink::after {
  background: var(--accent-pink);
}

.stat-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  outline: none;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

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

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

.btn-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.2);
}

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

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  justify-content: center;
}

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

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

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

.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 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

.form-help {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== File Upload ===== */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-blue);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone.dragover {
  transform: scale(1.01);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

.upload-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ===== Recipient Mode Toggle ===== */
.recipient-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border-color);
}

.recipient-mode-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.recipient-mode-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.recipient-mode-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.manual-input-section {
  margin-top: 4px;
}

.manual-input-area {
  min-height: 220px;
  font-family: 'Inter', monospace;
  font-size: 0.95rem;
  line-height: 1.8;
  resize: vertical;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--bg-card);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

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

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.badge-sent {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
}

.badge-running {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-blue);
}

.badge-draft {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
}

.badge-completed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
}

.badge-paused {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.badge-cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
}

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ===== Steps / Wizard ===== */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 40px;
  padding: 0 20px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  position: relative;
}

.wizard-step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border-color);
  margin: 0 16px;
}

.wizard-step.active:not(:last-child)::after {
  background: var(--accent-gradient);
}

.wizard-step.completed:not(:last-child)::after {
  background: var(--accent-green);
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--border-color);
  color: var(--text-muted);
  background: var(--bg-secondary);
  flex-shrink: 0;
  transition: all var(--transition-normal);
}

.wizard-step.active .step-number {
  border-color: var(--accent-blue);
  color: white;
  background: var(--accent-gradient);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.wizard-step.completed .step-number {
  border-color: var(--accent-green);
  color: white;
  background: var(--accent-green);
}

.step-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.wizard-step.active .step-label {
  color: var(--text-primary);
}

.wizard-step.completed .step-label {
  color: var(--accent-green);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 300px;
  max-width: 420px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideIn 0.3s ease;
  backdrop-filter: blur(12px);
}

.toast.leaving {
  animation: slideOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-body {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

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

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

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

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

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.25s ease;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Campaign Card ===== */
.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  transition: all var(--transition-normal);
  cursor: pointer;
}

.campaign-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

.campaign-card-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.campaign-card-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 12px;
}

.campaign-card-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ===== SMTP Card ===== */
.smtp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-normal);
  margin-bottom: 12px;
}

.smtp-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.smtp-card-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.smtp-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

.smtp-card-details h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.smtp-card-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.smtp-card-actions {
  display: flex;
  gap: 8px;
}

/* ===== Recipient Preview Table ===== */
.preview-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.preview-info-icon {
  font-size: 1.4rem;
}

.preview-info-text {
  font-size: 0.9rem;
}

.preview-info-text strong {
  color: var(--accent-blue);
}

/* ===== Email Editor ===== */
.email-editor {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.editor-toolbar button {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.editor-toolbar button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.editor-toolbar .separator {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.editor-content {
  min-height: 250px;
  padding: 20px;
  outline: none;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-input);
}

.editor-content:focus {
  box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

/* ===== Placeholder Chips ===== */
.placeholder-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.placeholder-chip {
  padding: 6px 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-purple);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.placeholder-chip:hover {
  background: rgba(139, 92, 246, 0.2);
  transform: translateY(-1px);
}

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

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-secondary);
}

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

.review-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-value {
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.review-html {
  padding: 20px;
  background: white;
  color: #1a1a1a;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  max-height: 300px;
  overflow-y: auto;
}

/* ===== Column Mapping ===== */
.column-mapping {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* ===== Page Transitions ===== */
.page-enter {
  animation: pageEnter 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .nav-label,
  .logo-text,
  .version-info {
    display: none;
  }

  .sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: center;
  }

  .main-content {
    margin-left: var(--sidebar-collapsed);
  }

  .page-container {
    padding: 20px 16px;
  }

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

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

  .wizard-steps {
    flex-wrap: wrap;
    gap: 8px;
  }

  .wizard-step:not(:last-child)::after {
    display: none;
  }

  .column-mapping {
    grid-template-columns: 1fr;
  }
}

/* ===== Utility ===== */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-20 {
  gap: 20px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

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

.text-secondary {
  color: var(--text-secondary);
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Pulse animation for running indicator */
.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

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

.auth-container {
  position: relative;
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  position: relative;
  z-index: 2;
  animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo-icon {
  font-size: 48px;
  width: 80px;
  height: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.25);
  margin-bottom: 16px;
}

.auth-logo-text {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  margin: 0;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid var(--border-color);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-normal);
}

.auth-tab.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.auth-tab:hover:not(.active) {
  color: var(--text-primary);
}

.auth-form .form-group {
  margin-bottom: 18px;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 1rem;
  justify-content: center;
}

.auth-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-size: 0.85rem;
  text-align: center;
}

.auth-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  animation: authGlow 4s ease-in-out infinite alternate;
}

@keyframes authGlow {
  0% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* ===== Sidebar Section ===== */
.sidebar-section-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 4px;
}

.sidebar-section {
  margin-top: 4px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 6px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-section-action {
  font-size: 0.9rem;
  text-decoration: none;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.sidebar-section-action:hover {
  opacity: 1;
}

.sidebar-accounts-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 8px;
}

.sidebar-account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  transition: all var(--transition-fast);
}

.sidebar-account-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.sidebar-account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-empty {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.sidebar-add-account {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 4px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--accent-blue);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  border: 1px dashed rgba(99, 102, 241, 0.3);
}

.sidebar-add-account:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.5);
}

/* ===== Sidebar User / Logout ===== */
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  margin-bottom: 8px;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.15);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

/* ===== Responsive: Auth Page & Sidebar Sections ===== */
@media (max-width: 768px) {

  .sidebar-section,
  .sidebar-section-divider,
  .sidebar-user-info {
    display: none;
  }

  .sidebar-user {
    justify-content: center;
    padding: 4px 0;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

/* ===== Template Selector ===== */
.template-selector {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all var(--transition-normal);
}

.template-selector:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.template-selector option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px;
}

/* ===== Attachment Badge ===== */
.attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-md);
  margin-top: 8px;
  transition: all var(--transition-normal);
}

.attachment-badge:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.35);
}

.attachment-badge-icon {
  font-size: 1.3rem;
}

.attachment-badge-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.attachment-badge-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
  line-height: 1;
}

.attachment-badge-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* ===== Templates Grid ===== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.template-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.template-card:hover {
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.08);
  transform: translateY(-2px);
}

.template-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.template-card-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.1);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.template-card-meta {
  flex: 1;
  min-width: 0;
}

.template-card-name {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.template-card-subject {
  font-size: 0.88rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-label {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  margin-right: 6px;
}

.template-card-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 60px;
  overflow: hidden;
}

.template-card-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.08);
  padding: 4px 10px;
  border-radius: 100px;
  width: fit-content;
}

.template-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease-out;
  padding: 24px;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.08);
  animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-body {
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  min-width: 300px;
  max-width: 420px;
  animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.leaving {
  animation: toastSlideOut 0.25s ease-in forwards;
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

.toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.toast-content,
.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

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

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.toast.success::before {
  background: var(--accent-green);
}

.toast.error::before {
  background: var(--accent-red);
}

.toast.warning::before {
  background: var(--accent-amber);
}

.toast.info::before {
  background: var(--accent-blue);
}

/* ===== SMTP Card ===== */
.smtp-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.smtp-card:last-child {
  border-bottom: none;
}

.smtp-card:hover {
  background: rgba(255, 255, 255, 0.02);
}

.smtp-card-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.smtp-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.smtp-card-details h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.smtp-card-details p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.smtp-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Inbox ===== */

/* Nav Badge */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 100px;
  background: var(--accent-gradient);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: auto;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0);
  }
}

/* Inbox Header */
.inbox-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inbox-account-filter {
  min-width: 200px;
  padding: 10px 36px 10px 14px;
  font-size: 0.88rem;
}

/* Inbox Layout — Split pane */
.inbox-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  min-height: 500px;
}

.inbox-layout .inbox-detail-container[style*="display: block"]~.inbox-list-container,
.inbox-layout:has(.inbox-detail-container[style*="display: block"]) {
  grid-template-columns: 1fr 1fr;
}

@media (min-width: 900px) {

  .inbox-layout:has(.inbox-detail-container[style="display:block;"]),
  .inbox-layout:has(.inbox-detail-container[style="display: block;"]) {
    grid-template-columns: minmax(360px, 1fr) minmax(400px, 1.2fr);
  }
}

/* Inbox List */
.inbox-list-container {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.inbox-list {
  max-height: 650px;
  overflow-y: auto;
}

/* Individual Email Item */
.inbox-email-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.inbox-email-item:last-child {
  border-bottom: none;
}

.inbox-email-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.inbox-email-item.selected {
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--accent-blue);
}

.inbox-email-item.unread {
  background: rgba(99, 102, 241, 0.04);
}

.inbox-email-item.unread::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

/* Avatar */
.inbox-email-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(148, 163, 184, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.inbox-email-avatar.unread-avatar {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

/* Email Content */
.inbox-email-content {
  flex: 1;
  min-width: 0;
}

.inbox-email-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.inbox-email-sender {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-email-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.inbox-email-subject {
  font-size: 0.88rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.inbox-email-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.inbox-email-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.inbox-campaign-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.inbox-account-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent-purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.inbox-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.5);
}

.fw-bold {
  font-weight: 700 !important;
}

/* Pagination */
.inbox-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.inbox-page-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Detail Panel */
.inbox-detail-container {
  position: relative;
}

.inbox-detail-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: detailSlideIn 0.25s ease;
}

@keyframes detailSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inbox-detail-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.inbox-detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
}

.inbox-detail-subject {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-right: 40px;
  line-height: 1.4;
}

.inbox-detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.inbox-detail-from {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inbox-detail-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.inbox-detail-sender {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.inbox-detail-email {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.inbox-detail-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inbox-detail-campaign,
.inbox-detail-account {
  margin-top: 12px;
}

.inbox-detail-body {
  padding: 24px;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

.inbox-detail-html {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.inbox-detail-html a {
  color: var(--accent-blue);
}

.inbox-detail-text {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.inbox-detail-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

/* Responsive — Inbox */
@media (max-width: 900px) {
  .inbox-layout {
    grid-template-columns: 1fr !important;
  }

  .inbox-header-actions {
    flex-wrap: wrap;
  }

  .inbox-account-filter {
    min-width: 160px;
  }
}

/* =======================================================
   ===== ANALYTICS PAGE =====
   ======================================================= */

/* Timezone Badge */
.analytics-timezone-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-blue);
  letter-spacing: 0.3px;
}

/* Filter Bar */
.analytics-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding: 16px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.analytics-filter-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.analytics-filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.analytics-account-select {
  min-width: 200px;
  max-width: 300px;
}

.analytics-filter-right {
  display: flex;
  align-items: center;
}

/* Period Toggle */
.analytics-period-toggle {
  display: flex;
  gap: 0;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border-color);
}

.analytics-period-btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.analytics-period-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.analytics-period-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* Chart Card */
.analytics-chart-card {
  margin-bottom: 24px;
  position: relative;
}

.analytics-chart-container {
  position: relative;
  width: 100%;
  min-height: 280px;
}

.analytics-chart-container canvas {
  display: block;
  width: 100%;
}

/* Chart Legend */
.analytics-chart-legend {
  display: flex;
  gap: 16px;
}

.analytics-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.analytics-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Chart Tooltip */
.analytics-chart-tooltip {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 10;
  min-width: 140px;
  animation: fadeIn 0.15s ease;
}

.analytics-tooltip-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.analytics-tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.analytics-tooltip-row strong {
  color: var(--text-primary);
  margin-left: 2px;
}

.analytics-tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Bottom Grid */
.analytics-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Top Firms List */
.analytics-firms-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-firm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.analytics-firm-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.analytics-firm-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-blue);
  flex-shrink: 0;
}

.analytics-firm-item:nth-child(1) .analytics-firm-rank {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.analytics-firm-item:nth-child(2) .analytics-firm-rank {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
}

.analytics-firm-item:nth-child(3) .analytics-firm-rank {
  background: rgba(180, 120, 80, 0.12);
  color: #c4956a;
}

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

.analytics-firm-domain {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-firm-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 100px;
  overflow: hidden;
}

.analytics-firm-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.analytics-firm-stats {
  text-align: right;
  flex-shrink: 0;
}

.analytics-firm-count {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.analytics-firm-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Account Breakdown */
.analytics-account-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.01);
  transition: all var(--transition-fast);
}

.analytics-account-row:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.analytics-account-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

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

.analytics-account-email {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-account-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-account-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.analytics-account-stat {
  text-align: center;
}

.analytics-account-stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.analytics-account-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.text-green {
  color: var(--accent-green) !important;
}

/* Empty Mini State */
.analytics-empty-mini {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.analytics-empty-mini span {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

.analytics-empty-mini p {
  font-size: 0.88rem;
}

/* Loading */
.analytics-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* Responsive — Analytics */
@media (max-width: 900px) {
  .analytics-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

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

  .analytics-account-select {
    min-width: 100%;
  }

  .analytics-period-toggle {
    overflow-x: auto;
  }

  .analytics-bottom-grid {
    grid-template-columns: 1fr;
  }

  .analytics-account-stats {
    gap: 10px;
  }
}