:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg-dark: #0f172a;
  --bg-lighter: #1e293b;
  --bg-darkest: #0b1121;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-hover: #475569;
  --accent-generic: #ef4444;
  --accent-personal: #10b981;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(148, 163, 184, 0.1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --font-main: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.background-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% -20%, #1d4ed8 0%, transparent 50%),
              radial-gradient(circle at 0% 100%, #1e1b4b 0%, transparent 30%),
              radial-gradient(circle at 100% 100%, #1e293b 0%, transparent 30%);
  z-index: -1;
  opacity: 0.6;
}

.container {
  max-width: 1000px;
  width: 95%;
  margin: 2rem auto;
  padding: 2rem;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeInDown 0.8s ease-out;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.icon-primary {
  width: 40px;
  height: 40px;
  color: var(--primary);
}

header h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header h1 span {
  color: var(--primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Upload Section */
.upload-section {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1.5rem;
  padding: 1rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.8s ease-out;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.drop-zone:hover, .drop-zone.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  transition: transform 0.3s ease;
}

.drop-zone:hover .upload-icon {
  transform: translateY(-5px);
  color: var(--primary);
}

.drop-zone h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-primary);
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Results Section */
.results-section {
  animation: fadeInUp 0.6s ease-out;
}

.stats-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 1.25rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 120px;
  flex: 1 1 calc(33.333% - 1rem); /* 3 cards per row */
  min-width: 180px;
  max-width: calc(33.333% - 1rem);
}

/* On mobile, stack them more naturally */
@media (max-width: 900px) {
  .stat-card {
    flex: 1 1 calc(45% - 1rem);
    max-width: none;
  }
}

@media (max-width: 600px) {
  .stat-card {
    flex: 1 1 100%;
  }
}

.stat-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: auto;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  line-height: 1.2;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  width: fit-content;
  text-transform: uppercase;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
  margin-top: 0.5rem;
  line-height: 1;
}

.stat-card:first-child {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.highlight-generic .stat-value { color: var(--accent-generic); }
.highlight-generic .badge { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.highlight-personal .stat-value { color: var(--accent-personal); }
.highlight-personal .badge { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.highlight-nomx .stat-value { color: #f59e0b; }
.highlight-nomx .badge { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.highlight-disposable .stat-value { color: #8b5cf6; }
.highlight-disposable .badge { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }

/* Upload Actions & Toggle */
.upload-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.mx-check-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  border: 1px solid var(--glass-border);
}

/* Switch Slider */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

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

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--bg-lighter);
  padding: 0.4rem;
  border-radius: 0.75rem;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.tab-btn i { width: 18px; height: 18px; }

.tab-btn.active {
  background: var(--bg-dark);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* Tab Content */
.tab-content {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  min-height: 400px;
}

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

.content-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
}

.actions { display: flex; gap: 0.75rem; }

.mail-list {
  list-style: none;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.mail-list::-webkit-scrollbar { width: 6px; }
.mail-list::-webkit-scrollbar-track { background: var(--bg-darkest); border-radius: 10px; }
.mail-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.mail-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.05);
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: background 0.2s ease;
}

.mail-item:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

/* Buttons */
.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

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

.btn-outline:hover {
  background: var(--bg-lighter);
  color: var(--text-primary);
  border-color: var(--primary);
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Progress Bar */
.progress-container {
  margin-top: 1.5rem;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.progress-bar-wrapper {
  height: 14px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
  background-size: 200% 100%;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  animation: gradientFlow 3s linear infinite;
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Moving highlights for progress bar */
.progress-bar::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: shine 2s infinite;
}

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

.progress-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-family: monospace;
}

/* Locked/Disabled States */
.locked {
  pointer-events: none;
  opacity: 0.5;
  filter: grayscale(0.5);
  cursor: not-allowed !important;
}

.btn-disabled {
  background: var(--bg-lighter) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  opacity: 0.6;
}

.mail-item {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
}

.mail-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

.copy-entry-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.copy-entry-btn:hover {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.load-more-wrapper {
  margin-top: 1rem;
  text-align: center;
}

.btn-load-more {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-load-more:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

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

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

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

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-lighter);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  z-index: 1000;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

footer {
  margin-top: 4rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .actions { flex-direction: column; }
}
