/* ============================================================================
   SAPIEN9 COLD · sistema visual
   ----------------------------------------------------------------------------
   Identidad tomada del logo: perfil dorado y escudo cian glacial sobre negro.
   El cian es el acento FUNCIONAL (lo que esta vivo, el foco, los datos); el
   dorado es el acento de MARCA y de jerarquia superior (el numero que importa,
   la identidad). Nunca compiten en el mismo bloque.

   Todo color, medida y tiempo sale de un token. Si algo necesita un valor que
   no esta acá, falta un token: agregalo, no lo escribas suelto. Antes los
   badges tenian rgba fijos y en tema claro quedaban azul-negro sobre blanco.

   Las clases viejas (.card .btn .tbl .badge .kpi .funnel ...) siguen existiendo
   con los mismos nombres: las 19 plantillas dependen de ellas y el rediseño es
   progresivo, no un corte.
   ============================================================================ */

@import url('/static/fonts/fuentes.css');

/* ── tokens ────────────────────────────────────────────────────────────── */

:root {
  /* superficies, de la mas profunda a la mas cercana */
  --bg:          #06090f;
  --bg-2:        #0a0f18;
  --panel:       #0f1622;
  --panel-2:     #16202e;
  --panel-3:     #1d2938;
  --border:      #22304222;
  --border-1:    #223042;
  --border-soft: #18222f;

  /* texto */
  --text:        #e8eef6;
  --text-dim:    #93a3b8;
  --text-faint:  #5d6b7e;

  /* acento funcional: cian electrico */
  --accent:      #2ee6ff;
  --accent-2:    #0aa8c8;
  --accent-deep: #07657a;
  --accent-glow: rgba(46, 230, 255, .14);
  --accent-line: rgba(46, 230, 255, .32);
  --on-accent:   #02171d;

  /* acento de marca: dorado del logo */
  --gold:        #e8b23a;
  --gold-2:      #b8841c;
  --gold-glow:   rgba(232, 178, 58, .14);
  --on-gold:     #1c1304;

  /* semanticos */
  --green:       #34d8a0;
  --green-glow:  rgba(52, 216, 160, .13);
  --amber:       #f5b544;
  --amber-glow:  rgba(245, 181, 68, .13);
  --red:         #ff6b6b;
  --red-glow:    rgba(255, 107, 107, .13);
  --purple:      #a98bfa;
  --purple-glow: rgba(169, 139, 250, .13);
  --neutral-glow: rgba(147, 163, 184, .10);

  /* tipografia */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-micro: 10.5px;
  --fs-xs:    11.5px;
  --fs-sm:    12.5px;
  --fs-base:  13.5px;
  --fs-md:    15px;
  --fs-lg:    18px;
  --fs-xl:    22px;
  --fs-2xl:   28px;
  --fs-3xl:   36px;

  /* espaciado */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;
  --sp-7: 40px;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.34);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.45), 0 24px 60px rgba(0,0,0,.5);
  --ring:      0 0 0 3px var(--accent-glow);

  --t-fast: .12s cubic-bezier(.4,0,.2,1);
  --t-base: .2s cubic-bezier(.4,0,.2,1);
  --t-slow: .32s cubic-bezier(.4,0,.2,1);

  --sidebar-w: 236px;

  color-scheme: dark;
}

html[data-theme="light"] {
  --bg:          #f2f5f9;
  --bg-2:        #ffffff;
  --panel:       #ffffff;
  --panel-2:     #eef2f7;
  --panel-3:     #e3e9f1;
  --border:      #d5dde800;
  --border-1:    #d5dde8;
  --border-soft: #e7ecf3;

  --text:        #101a26;
  --text-dim:    #4d5d73;
  --text-faint:  #8593a5;

  --accent:      #0b7c95;
  --accent-2:    #0a6076;
  --accent-deep: #084858;
  --accent-glow: rgba(11, 124, 149, .11);
  --accent-line: rgba(11, 124, 149, .26);
  --on-accent:   #ffffff;

  --gold:        #97690c;
  --gold-2:      #7a5408;
  --gold-glow:   rgba(151, 105, 12, .11);
  --on-gold:     #ffffff;

  --green:       #0d8f61;
  --green-glow:  rgba(13, 143, 97, .11);
  --amber:       #9a6608;
  --amber-glow:  rgba(154, 102, 8, .11);
  --red:         #cf2f2f;
  --red-glow:    rgba(207, 47, 47, .10);
  --purple:      #6b46d9;
  --purple-glow: rgba(107, 70, 217, .10);
  --neutral-glow: rgba(77, 93, 115, .08);

  --shadow:    0 1px 2px rgba(16,26,38,.05), 0 6px 20px rgba(16,26,38,.07);
  --shadow-lg: 0 2px 6px rgba(16,26,38,.08), 0 20px 50px rgba(16,26,38,.13);

  color-scheme: light;
}

[x-cloak] { display: none !important; }

/* ── base ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
}

/* Rejilla tenue de fondo: da profundidad sin competir con el contenido. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 52px 52px;
  opacity: .5;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 20%, transparent 78%);
}
html[data-theme="light"] body::before { opacity: .75; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-glow); color: var(--text); }

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel-3);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); background-clip: content-box; }

/* ── layout ────────────────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; justify-content: center; padding: var(--sp-2) 0 var(--sp-5); }
.brand-img { width: 142px; max-width: 100%; height: auto; display: block; }
.brand-logo { display: block; }
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; }
.brand-name small { display: block; font-size: var(--fs-micro); color: var(--text-faint); letter-spacing: .14em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--fs-base);
  font-weight: 500;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}
/* barra viva a la izquierda del item activo */
.nav a.active::before {
  content: '';
  position: absolute;
  left: -11px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.nav-ico { width: 18px; text-align: center; font-size: var(--fs-md); opacity: .9; flex: 0 0 18px; }

.nav-group {
  padding: var(--sp-4) 11px var(--sp-1);
  font-size: var(--fs-micro);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-soft);
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.01em;
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: flex-end; }

.content { padding: var(--sp-6); max-width: 1320px; width: 100%; }

/* ── tipografia de pagina ──────────────────────────────────────────────── */

.page-sub { font-size: var(--fs-sm); color: var(--text-dim); margin: -6px 0 var(--sp-5); max-width: 76ch; }

.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -.005em;
  margin: var(--sp-6) 0 var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.section-title:first-child { margin-top: 0; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.micro { font-size: var(--fs-xs); }
.num   { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--border-soft); border: 0; margin: var(--sp-5) 0; }

code.inline {
  font-family: var(--font-mono);
  font-size: .92em;
  background: var(--panel-2);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-1);
}

/* ── superficies ───────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow);
  position: relative;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}
.card-head h3 { margin: 0; font-family: var(--font-display); font-size: var(--fs-md); font-weight: 700; }

/* tarjeta destacada: el bloque que el usuario tiene que mirar primero */
.card-accent { border-color: var(--accent-line); box-shadow: var(--shadow), inset 0 1px 0 var(--accent-glow); }
.card-accent::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .7;
}

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ── metricas ──────────────────────────────────────────────────────────── */

.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-4) var(--sp-5);
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--accent-glow);
  filter: blur(26px);
  opacity: .5;
  pointer-events: none;
}
.k-val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.k-label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.k-foot { font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--sp-1); }
.k-accent { color: var(--accent); }
.k-gold   { color: var(--gold); }
.k-green  { color: var(--green); }
.k-amber  { color: var(--amber); }
.k-red    { color: var(--red); }
/* el KPI principal de una pantalla: dorado y con halo de marca */
.kpi-hero .k-val { font-size: var(--fs-3xl); color: var(--gold); }
.kpi-hero::after { background: var(--gold-glow); }

.trend { font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--text-faint); }

/* ── tablas ────────────────────────────────────────────────────────────── */

.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover td { background: var(--panel-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.tbl-row-link { cursor: pointer; }
.cell-strong { font-weight: 600; }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--text-faint); }

/* ── badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--neutral-glow);
  color: var(--text-dim);
}
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 5px;
}
.badge-plain::before { display: none; }

/* variantes por color semantico */
.b-accent, .b-queued, .b-in_sequence, .b-active, .b-valid {
  background: var(--accent-glow); color: var(--accent); border-color: var(--accent-line);
}
.b-green, .b-interested, .b-meeting, .b-replied, .b-sending {
  background: var(--green-glow); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent);
}
.b-amber, .b-paused, .b-catch_all, .b-closed, .b-idle {
  background: var(--amber-glow); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent);
}
.b-red, .b-bounced, .b-error, .b-invalid, .b-stopped, .b-not_interested {
  background: var(--red-glow); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent);
}
.b-purple, .b-opened, .b-clicked, .b-admin {
  background: var(--purple-glow); color: var(--purple); border-color: color-mix(in srgb, var(--purple) 30%, transparent);
}
.b-gold, .b-completed {
  background: var(--gold-glow); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 30%, transparent);
}
.b-new, .b-draft, .b-unknown, .b-none, .b-account_executive, .b-empty, .b-other {
  background: var(--neutral-glow); color: var(--text-dim); border-color: var(--border-1);
}
/* clasificaciones de respuesta que antes no tenian estilo y salian en crudo */
.b-more_info { background: var(--accent-glow); color: var(--accent); border-color: var(--accent-line); }
.b-stop      { background: var(--red-glow); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.b-autoreply, .b-bounce { background: var(--neutral-glow); color: var(--text-faint); border-color: var(--border-1); }

/* ── botones ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-1);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--panel-3); border-color: var(--text-faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 6px 22px var(--accent-glow);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: var(--on-gold);
  border-color: transparent;
}
.btn-danger { background: var(--red-glow); color: var(--red); border-color: color-mix(in srgb, var(--red) 34%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: var(--border-1); color: var(--text-dim); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: var(--fs-xs); border-radius: 7px; }
.btn-lg { padding: 12px 20px; font-size: var(--fs-base); }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* ── formularios ───────────────────────────────────────────────────────── */

label { display: block; font-size: var(--fs-sm); color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="time"], input[type="date"], input[type="search"], input[type="url"], select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: var(--font);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
textarea { line-height: 1.6; resize: vertical; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }

.form-row { margin-bottom: var(--sp-4); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); }
.field-hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 4px; }

.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
.toolbar .spacer, .spacer { flex: 1 1 auto; }

/* ── modales ───────────────────────────────────────────────────────────── */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: var(--sp-4);
  animation: fadeIn var(--t-base);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  padding: var(--sp-5);
  width: 540px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: popIn var(--t-base);
}
.modal h3 { margin: 0 0 var(--sp-4); font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; }
.modal-wide { width: 800px; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }

/* ── avisos ────────────────────────────────────────────────────────────── */

.flash, .alert-err, .alert-warn, .alert-ok, .alert-info {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-base);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}
.flash, .alert-info { background: var(--accent-glow); color: var(--accent); border-color: var(--accent-line); }
.alert-err  { background: var(--red-glow);   color: var(--red);   border-color: color-mix(in srgb, var(--red) 32%, transparent); }
.alert-warn { background: var(--amber-glow); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 32%, transparent); }
.alert-ok   { background: var(--green-glow); color: var(--green); border-color: color-mix(in srgb, var(--green) 32%, transparent); }

/* ── pestanas ──────────────────────────────────────────────────────────── */

.pill-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.pill-toggle a, .pill-toggle button {
  padding: 6px 13px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-dim);
  border-radius: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.pill-toggle a:hover, .pill-toggle button:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.pill-toggle a.on, .pill-toggle button.on { background: var(--accent-glow); color: var(--accent); font-weight: 600; }
.pill-count { font-variant-numeric: tabular-nums; opacity: .75; margin-left: 3px; }

.tb-toggle { display: inline-flex; border: 1px solid var(--border-1); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.tb-toggle a, .tb-toggle button {
  padding: 5px 11px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.tb-toggle a.on, .tb-toggle button.on { background: var(--accent-glow); color: var(--accent); }
.tb-toggle a:hover, .tb-toggle button:hover { text-decoration: none; color: var(--text); }

.tb-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  font-size: var(--fs-md);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.tb-icon-btn:hover { background: var(--panel-2); color: var(--accent); border-color: var(--accent-line); }

/* ── barras, embudo y medidores ────────────────────────────────────────── */

.funnel { display: flex; flex-direction: column; gap: var(--sp-2); }
.funnel-row { display: flex; align-items: center; gap: var(--sp-3); }
.funnel-label { width: 128px; flex: 0 0 128px; font-size: var(--fs-sm); color: var(--text-dim); }
.funnel-bar-wrap {
  flex: 1;
  height: 28px;
  background: var(--panel-2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  color: var(--on-accent);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  padding-left: 9px;
  border-radius: 5px 0 0 5px;
  transition: width var(--t-slow);
  box-shadow: 0 0 14px var(--accent-glow);
}
.funnel-count { width: 52px; flex: 0 0 52px; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }

.cap-bar-wrap { height: 7px; background: var(--panel-2); border-radius: var(--radius-pill); overflow: hidden; }
.cap-bar { height: 100%; background: var(--accent); border-radius: var(--radius-pill); transition: width var(--t-slow); }
.cap-bar.is-warn { background: var(--amber); }
.cap-bar.is-full { background: var(--red); }

/* medidor con etiqueta: "18 de 25 hoy" */
.meter { display: flex; flex-direction: column; gap: 5px; min-width: 120px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); font-size: var(--fs-xs); }
.meter-val { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── pasos ─────────────────────────────────────────────────────────────── */

.step-card { background: var(--panel-2); border: 1px solid var(--border-1); border-radius: var(--radius); padding: var(--sp-4); }
.step-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.step-num {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  border: 1px solid var(--accent-line);
}

/* ── linea de tiempo ───────────────────────────────────────────────────── */

.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.tl-item { display: flex; gap: var(--sp-3); padding: var(--sp-3) 0; position: relative; }
.tl-item::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 26px;
  bottom: -2px;
  width: 1px;
  background: var(--border-1);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border-radius: 50%;
  border: 2px solid var(--border-1);
  background: var(--panel);
  margin-top: 3px;
  z-index: 1;
  display: grid;
  place-items: center;
  font-size: 9px;
}
.tl-dot.is-sent   { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.tl-dot.is-open   { border-color: var(--purple); color: var(--purple); }
.tl-dot.is-reply  { border-color: var(--green); color: var(--green); }
.tl-dot.is-error  { border-color: var(--red); color: var(--red); }
.tl-body { flex: 1; min-width: 0; }
.tl-when { font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--font-mono); }

/* ── estados vacios ────────────────────────────────────────────────────── */

.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--text-faint); }
.empty-ico { font-size: 34px; opacity: .35; display: block; margin-bottom: var(--sp-3); }
.empty-title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; color: var(--text-dim); margin-bottom: var(--sp-1); }

/* ── login ─────────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-glow), transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 100%, var(--gold-glow), transparent 70%),
    var(--bg);
  position: relative;
  z-index: 1;
}
.login-card { width: 380px; max-width: 100%; }

/* ── onboarding ────────────────────────────────────────────────────────── */

.onb-card { border-color: var(--accent-line); box-shadow: var(--shadow), 0 0 0 3px var(--accent-glow); }
.onb-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.onb-progress { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; color: var(--accent); }
.onb-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-3); }
.onb-step { display: flex; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-1); border-radius: var(--radius-sm); background: var(--panel-2); }
.onb-step.done { opacity: .62; }
.onb-num {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-glow); color: var(--accent);
  font-size: var(--fs-xs); font-weight: 700;
}
.onb-step.done .onb-num { background: var(--green-glow); color: var(--green); }
.onb-label { font-weight: 600; font-size: var(--fs-sm); }
.onb-cta { font-size: var(--fs-xs); }
.onb-tag { font-size: var(--fs-xs); color: var(--text-faint); }

/* ── avisos flotantes ──────────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(420px, calc(100vw - 2 * var(--sp-5)));
}
.toast {
  pointer-events: auto;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border-1);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  animation: toastIn var(--t-base);
  border-left-width: 3px;
}
.toast-ok    { border-left-color: var(--green); color: var(--text); }
.toast-error { border-left-color: var(--red);   color: var(--text); }
.toast-info  { border-left-color: var(--accent); color: var(--text); }
.toast.is-out { animation: toastOut var(--t-base) forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px) } }

/* ── utilidades de estado vivo ─────────────────────────────────────────── */

/* punto que late: para "enviando ahora" */
.pulse { position: relative; }
.pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid currentColor;
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { opacity: .55; transform: scale(.94); }
  70%  { opacity: 0;   transform: scale(1.25); }
  100% { opacity: 0;   transform: scale(1.25); }
}

.skeleton {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 5px;
  color: transparent;
}
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* ── responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .content { padding: var(--sp-5) var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: var(--sp-3) var(--sp-2); }
  .brand-img { width: 40px; }
  .nav a { justify-content: center; padding: 11px 0; }
  .nav a span:not(.nav-ico) { display: none; }
  .nav a.active::before { left: -8px; }
  .nav-group { text-align: center; font-size: 8px; letter-spacing: .04em; padding: var(--sp-3) 0 var(--sp-1); }
  .sidebar-foot { text-align: center; font-size: var(--fs-micro); }
  .sidebar-foot .sidebar-name { display: none; }
  .funnel-label { width: 84px; flex-basis: 84px; font-size: var(--fs-xs); }
  .topbar h1 { font-size: var(--fs-md); }
}

@media (max-width: 560px) {
  .content { padding: var(--sp-4) var(--sp-3); }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
  .k-val { font-size: var(--fs-xl); }
  .modal { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .sidebar, .topbar-actions, .btn, .modal-bg { display: none !important; }
  body::before { display: none; }
  .card { box-shadow: none; border-color: #ccc; }
}


/* Respuesta sugerida: el boton Copiar flota arriba a la derecha del recuadro. En pantalla angosta
   el texto lo alcanzaba y quedaban encimados -"...por aca abajoCopiar"-, asi que abajo de 640px
   el boton deja de flotar y se apoya debajo del texto. */
.sugerida { position: relative; }
.sugerida .sugerida-txt { padding-right: 76px; }
.sugerida .sugerida-copiar { position: absolute; top: 8px; right: 8px; }

@media (max-width: 640px) {
  .sugerida .sugerida-txt { padding-right: 0; }
  .sugerida .sugerida-copiar {
    position: static;
    display: block;
    margin: 10px 0 0 auto;
  }
}


/* ── Bandeja de respuestas: peso y confirmacion ─────────────────────────────────── */

/* La pestana "Otros" de produccion trae 633 correos: 1 MB de HTML y 6.426 nodos, 812 ms hasta que
   la pagina responde (medido en navegador real el 15-sep). Con esto el navegador saltea el layout
   y el pintado de las tarjetas que estan fuera de pantalla. El `auto` del tamano intrinseco hace
   que recuerde el alto real de cada tarjeta ya medida, asi el scroll no salta. Los navegadores que
   no lo soportan lo ignoran y quedan como antes. */
[data-reply-card] {
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;   /* plegada mide ~110px desde el 12-oct */
}

/* Al accionar una respuesta que NO cambia de bandeja, la tarjeta se queda en su lugar y solo se
   repinta el badge. Sin una senal, el usuario no sabe si el clic hizo algo: este destello dura lo
   justo para verse y no molesta al que acciona cien seguidas. */
@keyframes repConfirmada {
  0%   { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-glow); }
  100% { box-shadow: none; }
}
.rep-confirmada { animation: repConfirmada .9s ease-out; }

@media (prefers-reduced-motion: reduce) {
  /* La regla global acelera todo a .01ms, que aca dejaria el destello invisible pero tambien
     inofensivo. Se apaga explicitamente para no dejar una animacion a medio camino. */
  .rep-confirmada { animation: none; }
}

/* ── Bandeja plegable (reunión del 12-oct) ──────────────────────────────────────────
   Con 80 respuestas en una pestaña había que bajar tarjeta por tarjeta, cada una con el correo
   entero abierto. Ahora cada tarjeta muestra solo quién, de qué campaña, el asunto y una línea
   del mensaje; el correo se abre con un clic y, si es largo, se desplaza adentro de su caja. */
.rep-barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--border-1); border-radius: var(--radius-sm);
}
.rep-barra.con-seleccion { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-glow); }
.rep-selall { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
.rep-card { margin-bottom: 10px; padding-top: 14px; padding-bottom: 14px; }
.rep-card.elegida { box-shadow: inset 0 0 0 1px var(--accent-line); }
.rep-cabecera { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; user-select: none; }
.rep-cabecera a, .rep-cabecera .cell-strong { user-select: text; }
.rep-check { width: auto; margin-top: 3px; flex: none; cursor: pointer; }
.rep-flecha { color: var(--text-faint); width: 12px; display: inline-block; }
.rep-snippet { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rep-card:not(.abierta):hover { border-color: var(--accent-line); }
.rep-detalle { margin-top: 14px; }
.rep-cuerpo {
  background: var(--panel-2); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px;
  border-left: 3px solid var(--accent-line); white-space: pre-wrap; font-size: 13px;
  max-height: 60vh; overflow: auto; overscroll-behavior: contain;
}
.rep-html {
  display: block; width: 100%; height: 160px; border: 0; margin-bottom: 14px;
  background: #fff; border-radius: var(--radius-sm); border-left: 3px solid var(--accent-line);
}
.rep-saltos { position: fixed; right: 18px; bottom: 18px; z-index: 6; display: flex; flex-direction: column; gap: 6px; }
.rep-saltos .btn { width: 38px; height: 38px; padding: 0; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
@media (max-width: 640px) {
  .rep-saltos { right: 10px; bottom: 10px; }
  .rep-snippet { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

/* ── Editor visual de correos (rich.js): negrita/cursiva/enlace a la vista ── */
.rich { border: 1px solid var(--border-1); border-radius: var(--radius-sm); background: var(--bg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.rich:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.rich-bar { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--border-soft); }
.rich-btn { min-width: 30px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-dim); font-family: var(--font); font-size: 14px; cursor: pointer; }
.rich-btn:hover { background: var(--panel-2); color: var(--text); }
.rich-btn.on { background: var(--panel-2); border-color: var(--border-1); color: var(--accent); }
.rich-ed { position: relative; padding: 9px 11px; font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text);
  outline: none; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow-y: auto; }
.rich-ed a { color: var(--accent); text-decoration: underline; }
.rich-ed.rich-vacio::before { content: attr(data-ph); color: var(--text-faint); white-space: pre-wrap; pointer-events: none; position: absolute; }
.rich-ed.rich-error { box-shadow: inset 0 0 0 1px var(--red); }
textarea.rich-oculto { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  border: 0 !important; opacity: 0; pointer-events: none; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 640px) {
  .step-head { flex-wrap: wrap; }
  .step-head > div[style*="flex:1"] { min-width: 0; flex-basis: calc(100% - 50px); }
  .step-head > div[style*="flex:1"] div[style*="min-width:200px"] { min-width: 0 !important; }
}
