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

:root {
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --purple-dark: #5b21b6;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg: #f9fafb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.05);
}

body { font-family: 'Inter', -apple-system, sans-serif; color: var(--text-primary); background: var(--bg); font-size: 15px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ============ AUTH ============ */
.auth-body { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #ddd6fe 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 420px; padding: 1rem; }
.auth-card { background: white; border-radius: 16px; padding: 2.5rem; box-shadow: 0 20px 60px rgba(124,58,237,0.15); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.auth-logo .brand-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; color: var(--purple); }
.auth-card h1 { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 1.5rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 14px; color: var(--text-secondary); }
.auth-footer a { color: var(--purple); font-weight: 500; }

/* ============ FORMS ============ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border-strong); border-radius: 8px;
  font-size: 14px; background: white; color: var(--text-primary); transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.field input::placeholder { color: var(--text-muted); }
.input-disabled { background: var(--bg) !important; color: var(--text-secondary) !important; cursor: not-allowed; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.inline-select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: white; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s;
  border: 1.5px solid var(--border-strong); background: white; color: var(--text-primary);
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--purple); color: white; border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }
.btn-green { background: var(--green-bg); color: var(--green); border-color: #86efac; }
.btn-red { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-red-ghost { background: transparent; color: var(--red); border-color: transparent; font-size: 13px; }
.btn-red-ghost:hover { background: var(--red-bg); }
.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============ APP LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: white; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 1.25rem 1rem; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 17px; color: var(--purple); border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: all 0.15s; }
.nav-item:hover { background: var(--purple-bg); color: var(--purple); }
.nav-item.active { background: var(--purple-bg); color: var(--purple); }

.sidebar-user { padding: 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--purple); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { color: var(--text-muted); padding: 4px; border-radius: 6px; display: flex; }
.logout-btn:hover { color: var(--red); background: var(--red-bg); }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 2rem; max-width: 1100px; }

/* ============ PAGE ELEMENTS ============ */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { font-family: 'Syne', sans-serif; font-size: 24px; font-weight: 700; margin-bottom: 2px; }
.back-link { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.back-link:hover { color: var(--purple); }
.section-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ============ CARDS ============ */
.card { background: white; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 1.5rem; overflow: hidden; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 15px; font-weight: 600; }

/* ============ STATS ============ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.stats-grid.four { grid-template-columns: repeat(4, 1fr); }
.stat-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-value { font-size: 26px; font-weight: 700; font-family: 'Syne', sans-serif; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-pct { font-size: 12px; color: var(--text-muted); }

/* ============ TABLE ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { background: var(--bg); }
.data-table th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.data-table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.data-table tr:hover td { background: var(--purple-bg); }

/* ============ BADGES ============ */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-valid, .badge-completed, .badge-active { background: var(--green-bg); color: var(--green); }
.badge-invalid, .badge-failed { background: var(--red-bg); color: var(--red); }
.badge-risky, .badge-invited, .badge-pending, .badge-running { background: var(--amber-bg); color: var(--amber); }
.badge-catch-all, .badge-unknown { background: #f3f4f6; color: var(--text-secondary); }
.badge-role { background: var(--purple-bg); color: var(--purple); }

/* ============ ALERTS ============ */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 1rem; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #86efac; }

/* ============ MODAL ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal form { padding: 1.25rem 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1.25rem; }

/* ============ FILE DROP ============ */
.file-drop {
  border: 2px dashed var(--purple-border); border-radius: 10px; padding: 2rem;
  text-align: center; cursor: pointer; transition: all 0.15s; background: var(--purple-bg);
}
.file-drop.drag-over { border-color: var(--purple); background: #ede9fe; }
.file-drop p { font-size: 14px; color: var(--text-secondary); margin-top: 8px; }
.file-link { color: var(--purple); cursor: pointer; text-decoration: underline; }

/* ============ PROGRESS ============ */
.progress-header { display: flex; justify-content: space-between; font-size: 14px; font-weight: 500; padding: 1.25rem 1.25rem 0; }
.progress-bar { height: 8px; background: var(--purple-border); border-radius: 4px; margin: 10px 1.25rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--purple); border-radius: 4px; transition: width 0.5s ease; }

/* ============ SCORE ============ */
.score-bar { display: flex; align-items: center; gap: 8px; }
.score-fill { height: 6px; border-radius: 3px; }
.score-bar span { font-size: 12px; color: var(--text-secondary); min-width: 28px; }

/* ============ RISK ============ */
.risk { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.risk-low { background: var(--green-bg); color: var(--green); }
.risk-medium { background: var(--amber-bg); color: var(--amber); }
.risk-high { background: var(--red-bg); color: var(--red); }

/* ============ TEAMS ============ */
.team-grid { display: flex; flex-direction: column; gap: 8px; }
.team-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: white; border: 1px solid var(--border); border-radius: 10px; transition: all 0.15s; }
.team-card:hover { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,0.08); }
.team-avatar { width: 40px; height: 40px; border-radius: 10px; background: var(--purple); color: white; display: flex; align-items: center; justify-content: center; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.team-info { flex: 1; }
.team-name { font-weight: 600; font-size: 15px; }
.team-meta { font-size: 13px; color: var(--text-secondary); }
.member-row { display: flex; align-items: center; gap: 10px; }
.member-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--purple-bg); color: var(--purple); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }

/* ============ SETTINGS ============ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.settings-grid .card { margin-bottom: 0; padding: 1.25rem; }
.settings-grid .card .card-header { padding: 0 0 1rem; border: none; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.info-grid { display: flex; flex-direction: column; }
.info-item { display: flex; justify-content: space-between; padding: 10px 1.25rem; border-top: 1px solid var(--border); font-size: 14px; }
.info-label { color: var(--text-secondary); }

/* ============ EMPTY STATE ============ */
.empty-state { padding: 3rem; text-align: center; color: var(--text-secondary); }
.empty-state p { margin: 1rem 0; }

/* ============ UTILS ============ */
.link { color: var(--purple); font-weight: 500; }
.link:hover { text-decoration: underline; }
.text-muted { color: var(--text-secondary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
