:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #EEF2FF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --sidebar-bg: #0F172A;
  --sidebar-hover: #1E293B;
  --sidebar-active: #4F46E5;
  --bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 240px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.sidebar-logo span { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-logo small { color: #64748B; font-size: 11px; display: block; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-label { color: #475569; font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; padding: 8px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #94A3B8; font-weight: 500; font-size: 13.5px; cursor: pointer; transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #CBD5E1; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto; background: rgba(255,255,255,.15); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}

.sidebar-user {
  padding: 12px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .name { color: #F1F5F9; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: #64748B; font-size: 11px; text-transform: capitalize; }
.btn-logout {
  background: none; border: none; color: #475569; font-size: 16px; padding: 4px;
  border-radius: 6px; transition: .15s;
}
.btn-logout:hover { color: #EF4444; background: rgba(239,68,68,.1); }

#main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
#topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

#content { padding: 24px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────── */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card .stat-icon {
  position: absolute; right: 14px; top: 14px; font-size: 28px; opacity: .12;
}
.stat-card.green .stat-value { color: var(--success); }
.stat-card.green .stat-icon { opacity: .18; }
.stat-card.orange .stat-value { color: var(--warning); }
.stat-card.blue .stat-value { color: var(--info); }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.purple .stat-value { color: #8B5CF6; }

/* ── Tabla ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: #F8FAFC; color: var(--text-muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }
td { padding: 11px 14px; color: var(--text); vertical-align: middle; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-HUMANO      { background: #D1FAE5; color: #065F46; }
.badge-BUZON       { background: #FEF3C7; color: #92400E; }
.badge-TIMBRADO    { background: #DBEAFE; color: #1E40AF; }
.badge-APAGADO     { background: #F1F5F9; color: #475569; }
.badge-NO_EXISTE   { background: #FEE2E2; color: #991B1B; }
.badge-SIN_SERVICIO{ background: #FEE2E2; color: #991B1B; }
.badge-SUSPENDIDO  { background: #EDE9FE; color: #5B21B6; }
.badge-OCUPADO     { background: #FEF9C3; color: #854D0E; }
.badge-NO_DISPONIBLE { background: #F1F5F9; color: #475569; }
.badge-NUMERO_INCORRECTO { background: #FEE2E2; color: #991B1B; }
.badge-SILENCIO    { background: #E2E8F0; color: #475569; }
.badge-CONGESTION  { background: #FFEDD5; color: #9A3412; }
.badge-PENDIENTE   { background: #F1F5F9; color: #475569; }
.badge-activa      { background: #D1FAE5; color: #065F46; }
.badge-pausada     { background: #FEF3C7; color: #92400E; }
.badge-finalizada  { background: #F1F5F9; color: #475569; }
.badge-pendiente   { background: #DBEAFE; color: #1E40AF; }
.badge-validador   { background: #EDE9FE; color: #5B21B6; }
.badge-bot         { background: #D1FAE5; color: #065F46; }
.badge-superadmin  { background: #FEE2E2; color: #991B1B; }
.badge-admin       { background: #FEF3C7; color: #92400E; }
.badge-supervisor  { background: #DBEAFE; color: #1E40AF; }
.badge-agente      { background: #F1F5F9; color: #475569; }

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 7px; font-size: 13px; font-weight: 600; border: none; transition: all .15s; line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #DC2626; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Formularios ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff; transition: border .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-control select, select.form-control { appearance: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(2px); animation: fadeIn .15s ease;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.25); animation: slideUp .2s ease;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-lg { max-width: 760px; }
.modal-header {
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px 22px; overflow-y: auto; min-height: 60px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }

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

/* ── Progress bar ────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }

/* ── Login ───────────────────────────────────────────────── */
#login-page {
  flex: 1; min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 15% 10%, #312E81 0%, transparent 55%),
              radial-gradient(1000px 700px at 90% 90%, #1E40AF 0%, transparent 50%),
              linear-gradient(135deg, #0B1120 0%, #111827 50%, #0B1120 100%);
}
/* Halo decorativo */
#login-page::before {
  content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.35) 0%, transparent 70%);
  top: -160px; right: -120px; filter: blur(20px); pointer-events: none;
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.98); border-radius: 20px; padding: 44px 40px; width: 400px;
  max-width: 100%;
  box-shadow: 0 30px 60px -15px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06);
  animation: loginIn .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .icon { font-size: 38px; background: linear-gradient(135deg, #6366F1, #4F46E5);
  width: 68px; height: 68px; border-radius: 18px; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 16px; box-shadow: 0 10px 24px rgba(79,70,229,.45); }
.login-logo h1 { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-error { background: #FEE2E2; color: #991B1B; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 16px; display: none; border: 1px solid #FECACA; }
#login-page .form-label { font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: #64748B; }
#login-page .form-control { padding: 12px 14px; border-radius: 11px; font-size: 14px;
  border: 1.5px solid #E2E8F0; background: #F8FAFC; transition: all .18s; }
#login-page .form-control:focus { background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
/* Neutraliza el fondo azul del autofill del navegador */
#login-page .form-control:-webkit-autofill,
#login-page .form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #F8FAFC inset;
  transition: background-color 9999s ease-in-out 0s;
}
.btn-login { width: 100%; padding: 13px; font-size: 15px; font-weight: 700; margin-top: 8px;
  border-radius: 11px; box-shadow: 0 8px 20px rgba(79,70,229,.3); }
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(79,70,229,.4); }

/* ── Filters bar ─────────────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .form-control { width: auto; flex: 1; min-width: 140px; }

/* ── Paginación ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding-top: 14px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); font-size: 12px; cursor: pointer; }
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-info { color: var(--text-muted); font-size: 12px; }

/* ── Chart donut ─────────────────────────────────────────── */
.chart-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.chart-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Upload zone ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 36px 24px;
  text-align: center; color: var(--text-muted); cursor: pointer; transition: .2s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 160px; gap: 4px;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.upload-zone input { display: none; }
.upload-zone .upload-icon { font-size: 40px; margin-bottom: 8px; line-height: 1; }
.upload-zone strong { font-size: 14px; }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.upload-zone .upload-filename { margin-top: 10px; font-weight: 700; color: var(--primary); font-size: 13px; }

/* ── Alert ───────────────────────────────────────────────── */
.alert { padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error   { background: #FEE2E2; color: #991B1B; }
.alert-info    { background: #DBEAFE; color: #1E40AF; }

/* ── Misc ────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono  { font-family: monospace; font-size: 12px; }
.mt-16 { margin-top: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-header h2 { font-size: 18px; font-weight: 800; }
.section-header p  { font-size: 13px; color: var(--text-muted); margin-top: 1px; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ── Reproductor de audio ────────────────────────────────── */
.player-modal {
  background: #0F1B2D; border-radius: 16px; width: 100%; max-width: 600px;
  box-shadow: 0 25px 60px rgba(0,0,0,.6); animation: slideUp .2s ease;
  overflow: hidden;
}
.player-header {
  padding: 16px 20px 12px; display: flex; align-items: flex-start; justify-content: space-between;
}
.player-title { color: #E2E8F0; font-size: 14px; font-weight: 700; }
.player-meta  { color: #64748B; font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.player-close {
  background: rgba(255,255,255,.08); border: none; color: #94A3B8;
  width: 28px; height: 28px; border-radius: 50%; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.player-close:hover { background: rgba(255,255,255,.15); color: #fff; }

.waveform-wrap {
  margin: 0 20px 12px; background: rgba(255,255,255,.04); border-radius: 10px;
  position: relative; height: 80px; overflow: hidden; cursor: pointer;
}
.waveform-wrap canvas { display: block; width: 100%; height: 100%; }
.waveform-progress {
  position: absolute; top: 0; left: 0; height: 100%;
  background: rgba(16,185,129,.12); pointer-events: none; transition: width .1s linear;
}
.waveform-cursor {
  position: absolute; top: 0; width: 2px; height: 100%;
  background: #10B981; pointer-events: none; transition: left .1s linear;
}

.player-timeline {
  padding: 0 20px 8px; display: flex; align-items: center; gap: 10px;
}
.player-time { color: #64748B; font-size: 11px; font-family: monospace; white-space: nowrap; }
.timeline-bar {
  flex: 1; height: 4px; background: rgba(255,255,255,.1); border-radius: 2px;
  cursor: pointer; position: relative;
}
.timeline-fill {
  height: 100%; background: linear-gradient(90deg, #10B981, #06B6D4);
  border-radius: 2px; transition: width .1s linear; pointer-events: none;
}
.timeline-bar:hover .timeline-fill { background: linear-gradient(90deg, #34D399, #22D3EE); }

.player-controls {
  padding: 10px 20px 14px; display: flex; align-items: center; gap: 8px;
}
.ctrl-btn {
  background: rgba(255,255,255,.07); border: none; color: #94A3B8;
  width: 36px; height: 36px; border-radius: 50%; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.ctrl-btn:hover { background: rgba(255,255,255,.14); color: #E2E8F0; }
.ctrl-btn.play-btn {
  background: #10B981; color: #fff; width: 42px; height: 42px; font-size: 16px;
}
.ctrl-btn.play-btn:hover { background: #059669; }
.ctrl-btn.play-btn.loading { background: #374151; }
.speed-select {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  color: #94A3B8; border-radius: 6px; padding: 4px 8px; font-size: 12px;
  cursor: pointer; font-family: inherit;
}
.speed-select:focus { outline: none; }
.speed-select option { background: #1E293B; }
.vol-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.vol-icon { color: #64748B; font-size: 14px; }
.vol-slider {
  -webkit-appearance: none; width: 70px; height: 4px;
  background: rgba(255,255,255,.15); border-radius: 2px; outline: none; cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  background: #10B981; border-radius: 50%;
}

.player-transcripcion {
  margin: 0 20px 20px; background: rgba(255,255,255,.04);
  border-radius: 10px; padding: 12px 14px;
}
.player-transcripcion .trans-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.player-transcripcion .trans-label {
  color: #475569; font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase;
}
.player-transcripcion .trans-btn {
  background: rgba(99,102,241,.15); border: 1px solid rgba(99,102,241,.3);
  color: #818CF8; font-size: 11px; padding: 3px 10px; border-radius: 5px;
  cursor: pointer; transition: background .15s;
}
.player-transcripcion .trans-btn:hover:not(:disabled) { background: rgba(99,102,241,.28); }
.player-transcripcion .trans-btn:disabled { opacity: .5; cursor: not-allowed; }
.player-transcripcion .trans-text {
  color: #CBD5E1; font-size: 13px; line-height: 1.5; min-height: 20px;
}
.player-transcripcion .trans-text.loading { color: #475569; font-style: italic; }

.player-download {
  background: rgba(255,255,255,.07); border: none; color: #64748B;
  width: 36px; height: 36px; border-radius: 50%; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.player-download:hover { background: rgba(255,255,255,.14); color: #10B981; }

/* ─── Sidebar colapsable ──────────────────────────────── */
#sidebar { transition: transform .22s ease, width .22s ease; }
#main    { transition: margin-left .22s ease; }

#app.sidebar-collapsed #sidebar { transform: translateX(-240px); }
#app.sidebar-collapsed #main    { margin-left: 0; }

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}

/* ─── Columnas ordenables ─────────────────────────────── */
th[data-col]:hover { background: rgba(99,102,241,.08); }
th[data-col] .sort-icon { font-size: 11px; margin-left: 4px; color: var(--primary); }

/* ─── Validar correos ─────────────────────────────────── */
.em-card { margin-bottom: 20px; }
.em-card .card-body { padding: 20px; }

/* fila input correo único */
.em-single { display: flex; gap: 10px; flex-wrap: wrap; }
.em-single .form-control { flex: 1; min-width: 260px; }

/* cabecera del resultado individual */
.em-result-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius);
  background: #F8FAFC; border: 1px solid var(--border); margin-top: 16px;
}
.em-result-head .email { font-size: 15px; font-weight: 700; color: var(--text); }

/* grid de metadatos (chips) */
.em-meta {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px; margin-top: 14px;
}
.em-meta-item { background: #F8FAFC; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.em-meta-item .k { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.em-meta-item .v { font-size: 13.5px; font-weight: 600; color: var(--text); margin-top: 3px; word-break: break-word; }

/* drop zone para archivos */
.em-drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; cursor: pointer; transition: .15s; background: #F8FAFC;
}
.em-drop:hover, .em-drop.drag { border-color: var(--primary); background: var(--primary-light); }
.em-drop .icon { font-size: 32px; line-height: 1; }
.em-drop .main { font-weight: 600; color: var(--text); margin-top: 8px; }
.em-drop .main .link { color: var(--primary); text-decoration: underline; }
.em-drop .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.em-drop.has-file { border-style: solid; border-color: var(--primary); background: var(--primary-light); }

.em-lote-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* pills de resumen */
.em-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.em-pill { display: flex; align-items: center; gap: 7px; background: #F8FAFC; border: 1px solid var(--border);
  border-radius: 22px; padding: 7px 15px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: box-shadow .15s, border-color .15s; }
.em-pill.cv-pill:hover { border-color: var(--primary); }
.em-pill b { font-weight: 800; font-size: 15px; color: var(--text); }
.em-pill.green b { color: var(--success); }
.em-pill.red b   { color: var(--danger); }
.em-pill.amber b { color: var(--warning); }

/* badge de resultado */
.em-rb { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.em-rb.ok    { background: #D1FAE5; color: #065F46; }
.em-rb.warn  { background: #FEF3C7; color: #92400E; }
.em-rb.bad   { background: #FEE2E2; color: #991B1B; }

/* badges de origen */
.badge-manual { background: #DBEAFE; color: #1E40AF; }
.badge-lista  { background: #EDE9FE; color: #5B21B6; }

/* toolbar de filtros */
.em-filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.em-filters .fg { display: flex; flex-direction: column; gap: 5px; }
.em-filters .fg label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.em-filters .fg .form-control { min-width: 150px; }

/* paginación */
.em-pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 16px; }
.em-pager .info { color: var(--text-muted); font-size: 13px; }

/* ─── Email marketing ─────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab { padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .12s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.cm-tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cm-tpl { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; }
.cm-tpl .cat { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--primary); background: var(--primary-light); padding: 2px 8px; border-radius: 5px; align-self: flex-start; }
.cm-tpl h4 { margin: 10px 0 4px; font-size: 15px; }
.cm-tpl .desc { font-size: 13px; color: var(--text-muted); flex: 1; line-height: 1.5; }
.cm-tpl .subj { font-size: 12px; color: var(--text); margin: 10px 0; padding: 8px 10px; background: #f8fafc;
  border-radius: 7px; border: 1px solid var(--border); }
.cm-tpl .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cm-modelo-tag { font-size: 10px; background: #FEF3C7; color: #92400E; padding: 2px 7px; border-radius: 5px; font-weight: 700; }

.cm-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px){ .cm-editor { grid-template-columns: 1fr; } }
.cm-preview-frame { width: 100%; height: 460px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.cm-vars { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.7; }
.cm-vars code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; color: var(--primary); cursor: pointer; }

.cm-prog { height: 10px; background: #f1f5f9; border-radius: 6px; overflow: hidden; margin: 6px 0; }
.cm-prog > i { display: block; height: 100%; background: var(--primary); transition: width .4s; }

.cm-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center;
  cursor: pointer; transition: .15s; background: #F8FAFC; }
.cm-drop:hover, .cm-drop.drag { border-color: var(--primary); background: var(--primary-light); }

.estado-borrador  { background:#F1F5F9; color:#475569; }
.estado-enviando  { background:#DBEAFE; color:#1E40AF; }
.estado-enviada   { background:#D1FAE5; color:#065F46; }
.estado-fallida   { background:#FEE2E2; color:#991B1B; }
.estado-pendiente { background:#F1F5F9; color:#475569; }
.estado-enviado   { background:#DBEAFE; color:#1E40AF; }
.estado-entregado { background:#D1FAE5; color:#065F46; }
.estado-abierto   { background:#E0E7FF; color:#3730A3; }
.estado-clic      { background:#EDE9FE; color:#5B21B6; }
.estado-rebotado  { background:#FEE2E2; color:#991B1B; }
.estado-quejado   { background:#FEE2E2; color:#991B1B; }
.estado-fallido   { background:#FEE2E2; color:#991B1B; }

/* ─── Editor de plantillas (modo Normal) ──────────────── */
.pe-modetabs { display:inline-flex; background:#f1f5f9; border-radius:8px; padding:3px; gap:3px; }
.pe-modetab { padding:6px 16px; font-size:13px; font-weight:600; color:var(--text-muted); border-radius:6px; cursor:pointer; }
.pe-modetab.active { background:#fff; color:var(--primary); box-shadow:var(--shadow); }

.pe-block { border:1px solid var(--border); border-radius:9px; padding:12px 14px; margin-bottom:10px; background:#fff; }
.pe-block .pe-bhead { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.pe-block .pe-btype { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--primary); }
.pe-block .pe-bctrls button { background:none; border:1px solid var(--border); border-radius:6px; cursor:pointer; padding:2px 7px; margin-left:3px; font-size:12px; color:var(--text-muted); }
.pe-block .pe-bctrls button:hover { background:var(--bg); color:var(--text); }
.pe-block label { display:block; font-size:11px; color:var(--text-muted); font-weight:600; margin:6px 0 3px; }
.pe-block input, .pe-block textarea { width:100%; padding:8px 10px; border:1.5px solid var(--border); border-radius:6px; font-family:inherit; font-size:13px; }
.pe-block textarea { resize:vertical; min-height:54px; }

.pe-addbar { display:flex; gap:6px; flex-wrap:wrap; margin:6px 0 14px; }
.pe-addbar button { font-size:12px; padding:6px 11px; border:1px dashed var(--border); background:#f8fafc; border-radius:7px; cursor:pointer; color:var(--text); }
.pe-addbar button:hover { border-color:var(--primary); color:var(--primary); }

.pe-varbar { font-size:11.5px; color:var(--text-muted); margin:4px 0 12px; line-height:1.9; }
.pe-varbar code { background:#f1f5f9; padding:2px 7px; border-radius:5px; color:var(--primary); cursor:pointer; }
.pe-varbar code:hover { background:var(--primary-light); }
.pe-color { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.pe-color input[type=color] { width:46px; height:34px; border:1px solid var(--border); border-radius:7px; padding:2px; cursor:pointer; }

/* ─── Dashboard de inicio (mejorado) ──────────────────── */
.dash-hero {
  background: linear-gradient(120deg, #4F46E5 0%, #7C3AED 55%, #9333EA 100%);
  border-radius: 16px; padding: 26px 30px; color: #fff; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  box-shadow: 0 10px 30px -10px rgba(79,70,229,.5); position: relative; overflow: hidden;
}
.dash-hero::after { content:''; position:absolute; right:-40px; top:-40px; width:220px; height:220px;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); }
.dash-hero h2 { font-size: 24px; font-weight: 800; margin: 0; }
.dash-hero p { margin: 6px 0 0; opacity: .9; font-size: 14px; }
.dash-hero .actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.dash-hero .actions .btn { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(4px); }
.dash-hero .actions .btn:hover { background: rgba(255,255,255,.28); }

.dash-grid { display: grid; gap: 20px; grid-template-columns: 1.6fr 1fr; }
@media (max-width: 980px){ .dash-grid { grid-template-columns: 1fr; } }

.kpi-trend { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.kpi-trend.up   { background:#D1FAE5; color:#065F46; }
.kpi-trend.down { background:#FEE2E2; color:#991B1B; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-list li:last-child { border-bottom: none; }
.mini-list .bar { flex: 1; height: 7px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.mini-list .bar > i { display: block; height: 100%; border-radius: 4px; }
.mini-list .val { font-weight: 700; min-width: 54px; text-align: right; }
