/* ═══════════════════════════════════════════════════════════════
   EmailDB Admin — Design System
   Font: Inter via Google Fonts
   Base: Tailwind CDN + custom component layer
   ═══════════════════════════════════════════════════════════════ */

*,*::before,*::after{box-sizing:border-box;}
:root{
  --brand:#6366f1; --brand-dark:#4f46e5; --brand-light:#e0e7ff;
  --sidebar-bg:#0f172a;
  --danger:#ef4444; --warn:#f59e0b; --success:#10b981; --info:#3b82f6;
  --surface:#fff; --surface-muted:#f8fafc;
  --border:#e2e8f0; --border-focus:#6366f1;
  --text-primary:#0f172a; --text-secondary:#475569; --text-muted:#94a3b8;
  --radius:0.625rem;
  --shadow-sm:0 1px 2px 0 rgba(0,0,0,.05);
  --shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);
  --shadow-md:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);
}
body{font-family:'Inter',system-ui,-apple-system,sans-serif;}

/* HTMX */
.htmx-indicator{opacity:0;transition:opacity 200ms ease;}
.htmx-request .htmx-indicator{opacity:1;}

/* ── SIDEBAR ──────────────────────────────────────────────────────────────── */
.sidebar{
  background:linear-gradient(180deg,#0f172a 0%,#1a1040 100%);
  border-right:1px solid rgba(255,255,255,.04);
  box-shadow:4px 0 24px rgba(0,0,0,.25);
  position:relative;z-index:20;
}
.sidebar-brand{background:rgba(255,255,255,.02);}
.brand-icon{
  width:2rem;height:2rem;flex-shrink:0;
  background:linear-gradient(135deg,var(--brand) 0%,#8b5cf6 100%);
  border-radius:.5rem;display:flex;align-items:center;justify-content:center;
  box-shadow:0 4px 12px rgba(99,102,241,.4);
}
.nav-section-label{
  font-size:.65rem;font-weight:600;letter-spacing:.08em;
  text-transform:uppercase;color:#3f4f6b;
  padding:0 .75rem;margin-bottom:.25rem;
}
.nav-item{
  display:flex;align-items:center;gap:.625rem;
  padding:.5rem .75rem;border-radius:.5rem;
  font-size:.8125rem;font-weight:500;color:#7c8db5;
  transition:background 150ms ease,color 150ms ease;
  text-decoration:none;border-left:2px solid transparent;
}
.nav-item:hover{background:rgba(255,255,255,.06);color:#c7d2fe;}
.nav-item.active{
  background:rgba(99,102,241,.2);color:#c7d2fe;
  border-left-color:#6366f1;font-weight:600;
}
.avatar-sm{
  width:2rem;height:2rem;border-radius:50%;flex-shrink:0;
  background:linear-gradient(135deg,var(--brand) 0%,#8b5cf6 100%);
  display:flex;align-items:center;justify-content:center;
  font-size:.75rem;font-weight:700;color:#fff;text-transform:uppercase;
}

/* ── TOPBAR ─────────────────────────────────────────────────────────────────*/
.topbar{background:var(--surface);border-bottom:1px solid var(--border);box-shadow:var(--shadow-sm);}

/* ── AUTH ───────────────────────────────────────────────────────────────────*/
.auth-bg{background:linear-gradient(135deg,#0f172a 0%,#1e1b4b 50%,#0f172a 100%);}

/* ── CARDS ──────────────────────────────────────────────────────────────────*/
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-sm);}
.card-header{display:flex;align-items:center;gap:.75rem;padding:.875rem 1.25rem;border-bottom:1px solid var(--border);}
.card-title{font-size:.875rem;font-weight:600;color:var(--text-primary);}

/* ── STAT CARDS ─────────────────────────────────────────────────────────────*/
.stat-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:1.25rem 1.5rem;
  display:flex;flex-direction:column;gap:.375rem;
  box-shadow:var(--shadow-sm);
  transition:box-shadow 150ms ease,transform 150ms ease;
  position:relative;overflow:visible;
}
.stat-card:hover{box-shadow:var(--shadow-md);transform:translateY(-1px);z-index:60;}
.stat-label{font-size:.7rem;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.05em;}
.stat-value{font-size:2rem;font-weight:700;color:var(--text-primary);letter-spacing:-.025em;line-height:1;cursor:default;}
/* Info icon tooltip for stat cards */
.stat-info-btn{
  display:inline-flex;align-items:center;justify-content:center;
  width:1.1rem;height:1.1rem;border-radius:50%;
  background:#cbd5e1;color:#475569;font-size:.6rem;font-weight:700;
  cursor:pointer;border:none;line-height:1;
  transition:background 120ms ease;flex-shrink:0;
  position:relative;
}
.stat-info-btn:hover{background:#94a3b8;color:#1e293b;}
.stat-info-popup{
  position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);
  background:#1e293b;color:#f1f5f9;font-size:.72rem;line-height:1.5;
  border-radius:.5rem;padding:.5rem .75rem;width:13rem;text-align:left;
  z-index:9999;box-shadow:0 8px 24px rgba(0,0,0,.3);pointer-events:none;
  display:none;
}
.stat-info-popup::before{
  content:'';position:absolute;bottom:100%;left:50%;transform:translateX(-50%);
  border:5px solid transparent;border-bottom-color:#1e293b;
}
.stat-info-btn:hover .stat-info-popup,
.stat-info-btn:focus .stat-info-popup{display:block;}
.stat-info-btn{position:relative;}

/* ── ICON ACTION BUTTONS ─────────────────────────────────────────────────────*/
.icon-action-btn{
  display:inline-flex;align-items:center;justify-content:center;
  width:1.875rem;height:1.875rem;border-radius:.4rem;
  border:1.5px solid currentColor;cursor:pointer;
  transition:all 120ms ease;background:transparent;
  position:relative;opacity:.85;
}
.icon-action-btn:hover{opacity:1;transform:scale(1.08);}
.icon-action-btn:active{transform:scale(0.95);}
/* action-cell centered below the Actions table head */
.action-cell{text-align:center !important;padding-right:1.25rem !important;white-space:nowrap;vertical-align:middle;}
.th-actions{text-align:center !important;padding-right:1.25rem !important;}

/* ── TABLES ─────────────────────────────────────────────────────────────────*/
.data-table{width:100%;font-size:.8125rem;border-collapse:collapse;}
.data-table thead tr{background:#f8fafc;border-bottom:1px solid var(--border);}
.data-table th{
  text-align:left;padding:.6875rem 1.25rem;
  font-size:.68rem;font-weight:600;color:var(--text-muted);
  text-transform:uppercase;letter-spacing:.06em;white-space:nowrap;
}
.data-table tbody tr{border-bottom:1px solid #f1f5f9;transition:background 100ms ease;}
.data-table tbody tr:last-child{border-bottom:none;}
.data-table tbody tr:hover{background:#fafbfe;}
.data-table td{padding:.6875rem 1.25rem;color:var(--text-secondary);vertical-align:middle;}
.mono-cell{font-family:'Fira Code','Cascadia Code',monospace;font-size:.72rem;color:var(--text-muted);}
.muted-cell{color:var(--text-muted);font-size:.775rem;}

/* ── BUTTONS ─────────────────────────────────────────────────────────────────*/
.btn-primary{
  display:inline-flex;align-items:center;gap:.375rem;
  background:var(--brand);color:#fff;
  padding:.5rem 1rem;border-radius:.5rem;
  font-size:.8125rem;font-weight:600;border:none;cursor:pointer;
  transition:background 150ms ease,box-shadow 150ms ease,transform 100ms ease;
  text-decoration:none;white-space:nowrap;
}
.btn-primary:hover{background:var(--brand-dark);box-shadow:0 4px 12px rgba(99,102,241,.35);transform:translateY(-1px);}
.btn-primary:active{transform:translateY(0);}

.btn-ghost{
  display:inline-flex;align-items:center;gap:.375rem;
  background:transparent;color:var(--text-secondary);
  padding:.5rem 1rem;border-radius:.5rem;
  font-size:.8125rem;font-weight:500;border:1px solid var(--border);
  cursor:pointer;transition:background 150ms ease,color 150ms ease;
  text-decoration:none;white-space:nowrap;
}
.btn-ghost:hover{background:#f1f5f9;color:var(--text-primary);border-color:#cbd5e1;}

.btn-download{
  display:inline-flex;align-items:center;gap:.375rem;
  background:#ecfdf5;color:#059669;
  padding:.5rem 1rem;border-radius:.5rem;
  font-size:.8125rem;font-weight:600;border:1px solid #a7f3d0;
  cursor:pointer;transition:background 150ms ease;
  text-decoration:none;white-space:nowrap;
}
.btn-download:hover{background:#d1fae5;}

/* ── ACTION BUTTONS (table rows) ─────────────────────────────────────────────*/
.action-btn{
  display:inline-flex;align-items:center;gap:.25rem;
  padding:.2rem .5rem;border-radius:.375rem;
  font-size:.7rem;font-weight:600;border:1px solid;
  cursor:pointer;transition:all 120ms ease;white-space:nowrap;background:none;
}
.action-btn-view{background:#eef2ff;color:var(--brand);border-color:#c7d2fe;}
.action-btn-view:hover{background:#e0e7ff;border-color:var(--brand);}
.action-btn-warn{background:#fffbeb;color:#b45309;border-color:#fde68a;}
.action-btn-warn:hover{background:#fef3c7;}
.action-btn-danger{background:#fef2f2;color:var(--danger);border-color:#fecaca;}
.action-btn-danger:hover{background:#fee2e2;}
.link-action{color:var(--brand);font-weight:600;font-size:.8rem;text-decoration:none;}
.link-action:hover{color:var(--brand-dark);text-decoration:underline;}

/* ── FORM FIELDS ─────────────────────────────────────────────────────────────*/
.field-label{display:block;font-size:.72rem;font-weight:600;color:var(--text-secondary);margin-bottom:.3rem;letter-spacing:.01em;}
.field-input{
  display:block;width:100%;
  padding:.5rem .75rem;background:var(--surface);
  border:1px solid var(--border);border-radius:.5rem;
  font-size:.8125rem;color:var(--text-primary);
  transition:border-color 150ms ease,box-shadow 150ms ease;
  outline:none;font-family:inherit;
}
.field-input:focus{border-color:var(--border-focus);box-shadow:0 0 0 3px rgba(99,102,241,.1);}
.field-input::placeholder{color:var(--text-muted);}
.field-input[readonly]{background:#f8fafc;cursor:not-allowed;color:var(--text-muted);}
.info-field{
  display:flex;flex-direction:column;gap:.25rem;
  background:#f8fafc;border:1px solid var(--border);
  border-radius:.5rem;padding:.625rem .75rem;
}
.field-value{font-size:.8125rem;color:var(--text-primary);font-weight:500;}

/* ── BADGES ──────────────────────────────────────────────────────────────────*/
.badge{display:inline-flex;align-items:center;padding:.15rem .55rem;border-radius:9999px;font-size:.7rem;font-weight:600;white-space:nowrap;}
.badge-verified{display:inline-flex;align-items:center;background:#ecfdf5;color:#059669;border:1px solid #a7f3d0;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.badge-valid{display:inline-flex;align-items:center;background:#eff6ff;color:#2563eb;border:1px solid #bfdbfe;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.badge-neutral{display:inline-flex;align-items:center;background:#f8fafc;color:#64748b;border:1px solid #e2e8f0;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:600;}
.badge-success{display:inline-flex;align-items:center;background:#ecfdf5;color:#059669;border:1px solid #a7f3d0;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.badge-info{display:inline-flex;align-items:center;background:#eff6ff;color:#2563eb;border:1px solid #bfdbfe;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.badge-purple{display:inline-flex;align-items:center;background:#f5f3ff;color:#7c3aed;border:1px solid #ddd6fe;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.badge-danger{display:inline-flex;align-items:center;background:#fef2f2;color:#dc2626;border:1px solid #fecaca;padding:.2rem .6rem;border-radius:9999px;font-size:.7rem;font-weight:700;}
.count-pill{display:inline-flex;align-items:center;justify-content:center;min-width:2rem;background:linear-gradient(135deg,#eef2ff 0%,#f5f3ff 100%);color:var(--brand-dark);border:1px solid #c7d2fe;padding:.2rem .65rem;border-radius:9999px;font-size:.75rem;font-weight:800;box-shadow:0 2px 8px rgba(99,102,241,.14);}
.count-badge{display:inline-block;background:#f1f5f9;color:var(--text-secondary);padding:.1rem .5rem;border-radius:.375rem;font-size:.75rem;font-weight:600;font-family:monospace;}
.tag-location{display:inline-flex;align-items:center;background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe;padding:.15rem .5rem;border-radius:.375rem;font-size:.7rem;font-weight:600;}
.tag-industry{display:inline-flex;align-items:center;background:#fdf4ff;color:#9333ea;border:1px solid #e9d5ff;padding:.15rem .5rem;border-radius:.375rem;font-size:.7rem;font-weight:600;}

/* ── TABS ────────────────────────────────────────────────────────────────────*/
.tab-bar{display:flex;gap:.25rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:.25rem;width:fit-content;box-shadow:var(--shadow-sm);}
.tab-item{display:inline-flex;align-items:center;gap:.5rem;padding:.5rem 1rem;border-radius:.375rem;font-size:.8125rem;font-weight:500;color:var(--text-secondary);text-decoration:none;transition:all 150ms ease;white-space:nowrap;}
.tab-item:hover{background:#f1f5f9;color:var(--text-primary);}
.tab-item.active{background:var(--brand);color:#fff;font-weight:600;box-shadow:0 2px 8px rgba(99,102,241,.3);}
.tab-item.active .tab-count{background:rgba(255,255,255,.25);color:#fff;}
.tab-count{background:#f1f5f9;color:var(--text-muted);padding:.1rem .45rem;border-radius:9999px;font-size:.65rem;font-weight:700;}

/* ── MODAL ───────────────────────────────────────────────────────────────────*/
.modal-backdrop{
  position:fixed;inset:0;
  background:rgba(15,23,42,.5);
  z-index:50;display:flex;align-items:center;justify-content:center;
  padding:1rem;animation:mFadeIn 150ms ease;
}
.modal-backdrop.hidden{display:none!important;}
.modal-box{
  background:var(--surface);border-radius:.875rem;
  box-shadow:var(--shadow-lg),0 0 0 1px rgba(0,0,0,.05);
  width:100%;max-width:28rem;max-height:90vh;overflow-y:auto;
  animation:mSlideUp 200ms ease;
}
.modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:1.125rem 1.5rem;border-bottom:1px solid var(--border);
  position:sticky;top:0;background:var(--surface);
  border-radius:.875rem .875rem 0 0;z-index:1;
}
.modal-close-btn{
  width:1.75rem;height:1.75rem;display:flex;align-items:center;justify-content:center;
  border-radius:.375rem;background:transparent;border:1px solid transparent;
  color:var(--text-muted);cursor:pointer;transition:all 120ms ease;
}
.modal-close-btn:hover{background:#f1f5f9;color:var(--text-primary);border-color:var(--border);}
@keyframes mFadeIn{from{opacity:0;}to{opacity:1;}}
@keyframes mSlideUp{from{opacity:0;transform:translateY(12px);}to{opacity:1;transform:translateY(0);}}

/* ── LOGIN ───────────────────────────────────────────────────────────────────*/
.login-card{background:#fff;border-radius:1rem;box-shadow:0 25px 50px -12px rgba(0,0,0,.4);padding:2.5rem;width:100%;max-width:24rem;}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────*/
@media(max-width:768px){
  main{padding:1rem!important;}
}
@media(max-width:640px){
  .data-table th,.data-table td{padding:.5rem .75rem;}
  .stat-value{font-size:1.5rem;}
}

/* ── QUICK ACTION ICONS ───────────────────────────────────────────────────────*/
.quick-icon{
  width:2.5rem;height:2.5rem;border-radius:.625rem;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  transition:transform 150ms ease;
}
.group:hover .quick-icon{transform:scale(1.05);}
.quick-icon-indigo{background:#eef2ff;color:#6366f1;}
.quick-icon-purple{background:#f5f3ff;color:#7c3aed;}
.quick-icon-teal{background:#f0fdfa;color:#0d9488;}
.quick-icon-blue{background:#eff6ff;color:#2563eb;}


/* Colored table action buttons */
.icon-action-btn.action-edit{color:#4f46e5;background:#eef2ff;border-color:#c7d2fe;}
.icon-action-btn.action-edit:hover{color:#3730a3;background:#e0e7ff;border-color:#818cf8;}
.icon-action-btn.action-block{color:#d97706;background:#fffbeb;border-color:#fde68a;}
.icon-action-btn.action-block:hover{color:#92400e;background:#fef3c7;border-color:#f59e0b;}
.icon-action-btn.action-delete{color:#dc2626;background:#fef2f2;border-color:#fecaca;}
.icon-action-btn.action-delete:hover{color:#991b1b;background:#fee2e2;border-color:#f87171;}
