/* xamz/web/styles.css
   Design system de XAMZ. Los tokens y las primitivas salen del prototipo
   validado (../demo/marketing-ventas.html); los componentes de cada vista se
   portan a medida que se construyen las vistas.
   Fucsia pitahaya como acento (hereda del color de producto de la wiki). */

:root {
  --ground:   #f7f5f4;
  --surface:  #ffffff;
  --surface-2:#f0edeb;
  --ink:      #23201f;
  --muted:    #6f6763;
  --faint:    #9a918c;
  --line:     #e6e1de;
  --line-2:   #d8d2ce;
  --accent:   #b8327f;
  --accent-ink:#ffffff;
  --accent-wash:#f7e6f1;
  --ok:   #3f7d54; --ok-wash:  #e4efe6;
  --warn: #a06f16; --warn-wash:#f5ebd8;
  --crit: #b23b3b; --crit-wash:#f4e2e0;
  --shadow: 0 1px 2px rgba(30,20,25,.06), 0 8px 24px -12px rgba(30,20,25,.18);
  --radius: 10px;
  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:#171315; --surface:#211c1f; --surface-2:#2b2429;
    --ink:#ece7e6; --muted:#a89f9c; --faint:#7c726f;
    --line:#362e32; --line-2:#453a40;
    --accent:#e070b0; --accent-ink:#241016; --accent-wash:#3a2130;
    --ok:#6bb387; --ok-wash:#22322a; --warn:#d7a648; --warn-wash:#352c1d;
    --crit:#e5776f; --crit-wash:#38241f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --ground:#171315; --surface:#211c1f; --surface-2:#2b2429;
  --ink:#ece7e6; --muted:#a89f9c; --faint:#7c726f;
  --line:#362e32; --line-2:#453a40;
  --accent:#e070b0; --accent-ink:#241016; --accent-wash:#3a2130;
  --ok:#6bb387; --ok-wash:#22322a; --warn:#d7a648; --warn-wash:#352c1d;
  --crit:#e5776f; --crit-wash:#38241f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- shell ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
/* Red de seguridad: `[hidden]` es display:none, y un item con display:none sale
   del grid — o sea que al ocultar la barra lateral, `.main` se corría a la
   columna de 232px y el contenido quedaba espachurrado contra el borde. Si no
   hay barra, no hay dos columnas. */
.app:has(> .side[hidden]) { grid-template-columns: 1fr; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; padding: 8px 8px 18px; }
/* El alto sale del ancho por el viewBox (480x124): a 104px da ~27px de alto,
   por encima del umbral de ~64px de ancho debajo del cual el hueco de las
   letras se cierra y habría que usar el isotipo solo. */
.brand-logo { width: 104px; height: auto; color: var(--ink); }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav-link .ct { margin-left: auto; font-size: 12px; color: var(--faint); }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.view { padding: 26px; max-width: 1180px; }
/* Leads (ocho columnas + filtros) pide el ancho completo: con el tope de
   1180px quedaba media pantalla vacía en monitores anchos. */
.view.view-wide { max-width: none; }
.view-head { margin-bottom: 18px; }
.view-head h1 { font-size: 23px; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }

/* ---- primitivas ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2);
  font-size: 12.5px; font-weight: 500;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.is-crit { background: var(--crit-wash); border-color: color-mix(in srgb, var(--crit) 30%, transparent); color: var(--crit); }
.chip.is-crit .dot { background: var(--crit); }
.chip.is-warn { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.chip.is-warn .dot { background: var(--warn); }
.chip.is-ok { background: var(--ok-wash); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.chip.is-ok .dot { background: var(--ok); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-2); }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: 9px 15px; border-radius: 8px; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--accent-ink); background: var(--accent); }

.state { padding: 40px 26px; color: var(--muted); text-align: center; }
.state code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

/* En pantallas medianas la barra lateral se convierte en barra INFERIOR, no
   desaparece: antes se ocultaba sin reemplazo y en un celular no había forma de
   ir de Bandeja a Leads. Es el mismo marcado, solo cambia la disposición. */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  /* OJO: `.grid2` NO se colapsa acá. Se define más abajo en el archivo, así que
     la regla base le ganaba por orden y el Tablero seguía en dos columnas en el
     celular. El colapso está al final, después de su definición. */

  .side {
    flex-direction: row; justify-content: space-around; align-items: stretch;
    position: fixed; inset: auto 0 0 0; height: auto; top: auto;
    gap: 2px; padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px -12px rgba(0,0,0,.5); z-index: 20;
  }
  .brand, .side-foot { display: none; }   /* la marca ya está en la barra de arriba */
  .nav-link {
    flex-direction: column; justify-content: center; gap: 2px;
    flex: 1 1 0; min-width: 0; min-height: 46px; padding: 7px 2px;
    font-size: 11px; text-align: center; line-height: 1.2;
  }
  .nav-link .ct { margin-left: 0; font-size: 10px; }
  .nav-link[aria-current="page"] { background: var(--accent-wash); }

  /* Que la barra de abajo no tape el final del contenido. */
  .view { padding-bottom: 84px; }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}

/* =====================================================================
   Componentes de vista (portados del prototipo demo/marketing-ventas.html)
   ===================================================================== */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip b { font-variant-numeric: tabular-nums; }

.pill.st-NUEVO        { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.pill.st-CONTACTADO   { background: var(--surface-2); color: var(--ink); }
.pill.st-SEGUIMIENTO  { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill.st-CITA         { background: #e7eef6; color: #3a628c; border-color: transparent; }
.pill.st-SOCIO        { background: var(--ok-wash); color: var(--ok); border-color: transparent; }
.pill.st-PERDIDO      { background: var(--surface-2); color: var(--faint); }
:root[data-theme="dark"] .pill.st-CITA,
:root:not([data-theme="light"]) .pill.st-CITA { background: #26313d; color: #9fc0e0; }

/* Capacidad de inversión declarada (mig. 032): SI = ok, NO = descarte (gris),
   OTRO = todavía sin clasificar (warn, para que se note que hay que mirarlo). */
.cap-inv { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.cap-inv.cap-si   { background: var(--ok-wash);   color: var(--ok); }
.cap-inv.cap-no   { background: var(--surface-2); color: var(--faint); }
.cap-inv.cap-otro { background: var(--warn-wash); color: var(--warn); }

.tag {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 6px; background: var(--surface-2);
  color: var(--muted); border: 1px solid var(--line-2);
}
.who-mini { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }

/* ---- bandeja ---- */
.stack { display: flex; flex-direction: column; }
.inbox-row {
  display: grid; grid-template-columns: 4px 130px 1fr 96px 150px 100px;
  align-items: center; gap: 14px;
  padding: 13px 16px 13px 0; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left;
}
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: var(--surface-2); }
.inbox-row .sem { align-self: stretch; border-radius: 3px; background: var(--ok); min-height: 34px; }
.inbox-row.sem-crit .sem { background: var(--crit); }
.inbox-row.sem-warn .sem { background: var(--warn); }
.inbox-link { display: contents; text-decoration: none; color: inherit; }
.inbox-when { font-size: 12.5px; }
.inbox-when b { display: block; font-weight: 600; }
.inbox-when.crit b { color: var(--crit); }
.inbox-when.warn b { color: var(--warn); }
.inbox-when span { color: var(--faint); }
.inbox-who { min-width: 0; }
.inbox-who b { font-weight: 600; }
/* `>` a propósito: el <span class="mono"> del código va anidado adentro, y con
   el selector suelto heredaba display:block y se caía a su propia línea. */
.inbox-who > span { color: var(--muted); display: block; font-size: 12.5px; }
/* En escritorio el envoltorio no existe para la grilla: el tag y la asesora
   siguen siendo dos celdas propias (columnas de 96px y 150px). En celular pasa
   a ser una caja de verdad y ocupa su propio renglón (ver el @media). */
.inbox-meta { display: contents; }
.inbox-actions { display: flex; gap: 5px; justify-self: end; }
.mini-act {
  width: 27px; height: 27px; padding: 0; border-radius: 7px; line-height: 1;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
  font-size: 13px; display: grid; place-items: center;
}
.mini-act:hover { background: var(--surface-2); color: var(--ink); }
.mini-act.ok:hover { border-color: var(--ok); color: var(--ok); }
.mini-act.crit:hover { border-color: var(--crit); color: var(--crit); }
.mini-act:disabled { opacity: .4; }

/* ---- bandeja: tabs de vista (Lista / Calendario) ---- */
.view-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.view-tab {
  background: none; border: 0; padding: 9px 4px; margin-right: 16px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tab:hover { color: var(--ink); }
.view-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- bandeja: vista calendario ---- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-head h2 {
  font-size: 16px; text-transform: capitalize; min-width: 160px;
  font-family: var(--font-ui); font-weight: 700;
}
.cal-head #cal-hoy { margin-left: auto; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.cal-weekdays span {
  padding: 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; text-align: center;
}
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 96px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.cal-days .cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell-out { background: var(--surface-2); }
.cal-cell-hoy { background: var(--accent-wash); }
.cal-daynum { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-cell-hoy .cal-daynum { color: var(--accent); }
.cal-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-event {
  display: block; font-size: 11px; line-height: 1.3; padding: 2px 5px; border-radius: 4px;
  text-decoration: none; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 2px solid var(--faint); background: var(--surface-2);
}
.cal-event b { font-variant-numeric: tabular-nums; font-weight: 600; }
.cal-event.cal-ev-warn { border-left-color: var(--warn); background: var(--warn-wash); }
.cal-event.cal-ev-crit { border-left-color: var(--crit); background: var(--crit-wash); }
.cal-event.cal-ev-ok   { border-left-color: var(--ok);   background: var(--ok-wash); }
.cal-event.cal-ev-muted{ border-left-color: var(--line-2); color: var(--faint); }
.cal-more { font-size: 10.5px; color: var(--muted); padding: 0 5px; }

/* ---- leads ---- */
.tablewrap { overflow-x: auto; border-radius: var(--radius); }
table.leads { width: 100%; border-collapse: collapse; min-width: 720px; background: var(--surface); }
table.leads th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600;
  padding: 11px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
table.leads td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.leads tr:last-child td { border-bottom: 0; }
table.leads tbody tr:hover td { background: var(--surface-2); }

/* ---- fila de filtros en los encabezados (pedido de Flor) ------------------
   Filtran en el SERVIDOR, no la página cargada: la lista viene de a 50 con
   cursor, así que filtrar en el navegador filtraría 50 leads de 20 000 y
   diría que no hay más. El <thead> entero se pinta UNA vez y después solo se
   reemplaza el <tbody>; si se redibujara, escribir un nombre perdería el foco
   en cada tecla. */
table.leads tr.filtros th {
  padding: 7px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
  text-transform: none; letter-spacing: 0; font-weight: 400;
}
table.leads tr.filtros input,
table.leads tr.filtros select {
  width: 100%; min-width: 0; box-sizing: border-box;
  padding: 5px 8px; font: inherit; font-size: 12px; line-height: 1.4;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--surface); color: inherit;
}
table.leads tr.filtros input:focus,
table.leads tr.filtros select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* El filtro puesto se marca: con nueve columnas es fácil dejar uno activo de
   ayer y no entender por qué faltan leads. */
table.leads tr.filtros .puesto { border-color: var(--accent); color: var(--accent); font-weight: 600; }
table.leads tr.norows td { padding: 0; }
table.leads tr.norows:hover td { background: transparent; }
/* El boton para plegar los filtros solo tiene sentido donde estorban. */
.solo-movil { display: none; }
.lead-name { font-weight: 600; }
.lead-name a { color: inherit; text-decoration: none; }
.lead-name a:hover { text-decoration: underline; text-underline-offset: 2px; }
.lead-name .code { font-family: var(--font-mono); font-size: 11px; color: var(--faint); font-weight: 400; }
/* Aviso de posible duplicado. Deliberadamente discreto: el telefono repetido ya
   no puede entrar, asi que esto marca una SOSPECHA (mismo correo o mismo
   nombre con otro numero), no un error. Si gritara, se ignoraria. */
.dupflag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  background: var(--warn-wash); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.dupflag.soft { background: var(--surface-2); color: var(--muted); border-color: var(--line-2); }
/* Reingreso (mig. 033): no es una alerta, es buena señal -- el cliente volvió. */
.dupflag.reingreso { background: var(--ok-wash); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }

/* Lead que entró por WhatsApp sin dar su nombre: en la base tiene su propio
   número en el campo del nombre (5 080 casos, decisión del 2026-09-08). Se
   escribe "Sin nombre" en cursiva apagada para que se lea como lo que es —un
   dato que falta— y no como un nombre roto. El teléfono está en su columna, al
   lado, así que la asesora no pierde nada: sabe a quién llamar. */
.sinnombre { font-style: italic; color: var(--muted); font-weight: 500; }
.stale { color: var(--crit); font-weight: 600; }
.reassign {
  font: inherit; font-size: 12.5px; padding: 5px 8px;
  border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink);
}
.rowlock { font-size: 12px; color: var(--faint); }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 14px; flex-wrap: wrap; }
.toolbtn {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
}
.toolbtn.accent { border-color: var(--accent); color: var(--accent); }
.toolbtn:hover { background: var(--surface-2); }
/* Un botón que cambia el orden de la lista tiene que verse encendido mientras
   está encendido: si no, la lista sale en otro orden sin nada que lo explique. */
.toolbtn.activo {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.toolbtn.activo:hover { background: var(--accent); }
.toolbar .hint { font-size: 12px; color: var(--faint); }

/* ---- prioridad: el score del modelo (migración 029) ---------------------
   Tres tramos de color y no un degradado: el ojo distingue tres estados de un
   vistazo, no cien. El número igual va escrito porque el color solo no alcanza
   —hay daltonismo, y hay pantallas de sol— y porque ordenar por prioridad
   necesita que se pueda comparar 62 contra 58. */
.score {
  font: inherit; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  min-width: 38px; padding: 4px 8px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; font-variant-numeric: tabular-nums;
}
.score.alta  { background: var(--ok-wash);   color: var(--ok);
               border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.score.media { background: var(--warn-wash); color: var(--warn);
               border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.score.baja  { background: var(--surface-2); color: var(--muted); border-color: var(--line-2); }
.score:hover { filter: brightness(.97); }
.score:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.score.inline { cursor: default; vertical-align: middle; }
.score-na { color: var(--faint); font-size: 12.5px; }

/* Desglose del score. La barra es relativa al motivo más fuerte de ESE lead,
   así que compara motivos entre sí — no es una escala absoluta y por eso no
   lleva números: escribir "+1.42 log-odds" sería preciso e inútil. */
.raz-h { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase;
         letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.raz { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center;
       padding: 5px 0; }
.raz-txt { font-size: 13px; }
.raz-bar { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.raz-bar i { display: block; height: 100%; border-radius: 4px; }
.raz-bar i.up   { background: var(--ok); }
.raz-bar i.down { background: var(--crit); }

/* ---- cuándo contestan: mapa de día × hora (migración 030) ----------------
   Con 13 horas la grilla no entra en un celular, así que desborda dentro de su
   propia caja en vez de empujar la página entera. */
/* `min-width:0` en el panel + `max-width:100%` acá: sin los dos, la grilla
   ensancha la página entera en celular en vez de desplazarse adentro. Un
   elemento de grilla trae `min-width:auto`, que le prohíbe achicarse por debajo
   de su contenido — con 13 horas eso son ~520 px y el teléfono tiene 375. */
#t-franjas { min-width: 0; }
.fr-wrap { overflow-x: auto; max-width: 100%; }
.fr-grid { border-collapse: separate; border-spacing: 3px; font-size: 11.5px;
           font-variant-numeric: tabular-nums; }
.fr-grid th { color: var(--muted); font-weight: 600; font-size: 11px; padding: 2px 5px; }
.fr-grid tbody th { text-align: right; }
.fr-grid td { min-width: 34px; text-align: center; padding: 6px 4px; border-radius: 5px;
              color: var(--ink); cursor: default; }
/* Tres niveles y no un degradado: la pregunta es "¿acá conviene llamar o no?",
   y para eso alcanzan mejor / igual / peor. Un degradado continuo obliga a
   comparar tonos, que es justo lo que nadie hace de un vistazo. */
.fr-alto  { background: var(--ok-wash);   color: var(--ok);    font-weight: 700; }
.fr-bajo  { background: var(--crit-wash); color: var(--crit); }
.fr-medio { background: var(--surface-2); }
/* Sin respaldo suficiente. Va apagado a propósito: el número está, pero no se
   lo debe usar para decidir. */
.fr-flojo { background: transparent; color: var(--faint); border: 1px dashed var(--line-2); }
.fr-na    { background: transparent; }
.fr-leyenda { padding: 1px 6px; border-radius: 4px; }

/* ---- tablero ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-h { padding: 15px 18px 0; }
.card-h h3 { font-size: 15px; }
.card-h p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.card-b { padding: 16px 18px 18px; }
.funnel { display: flex; flex-direction: column; gap: 11px; }
.fbar-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.fbar-label b { font-variant-numeric: tabular-nums; }
.fbar-track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.fbar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.fbar.mut .fbar-fill { background: var(--line-2); }
.callout { margin-top: 14px; padding: 11px 13px; border-radius: 8px; background: var(--accent-wash); color: var(--accent); font-size: 12.5px; font-weight: 500; }
.callout.warn { background: var(--warn-wash); color: var(--warn); }
.adbars { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding-top: 6px; }
.adbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.adbar .col { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; }
.adbar.nodata .col { background: repeating-linear-gradient(45deg, var(--line-2), var(--line-2) 4px, transparent 4px, transparent 8px); border: 1px dashed var(--line-2); }
.adbar small { font-size: 10.5px; color: var(--muted); }
.adbar .v { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.adbar.nodata .v { color: var(--warn); font-weight: 600; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini th, table.mini td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 12.5px; text-align: right; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td.num { font-variant-numeric: tabular-nums; }
table.mini tr.me td { background: var(--accent-wash); }

/* ---- ficha (lead) ---- */
.ficha-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.ficha-head h2 { font-size: 19px; }
.ficha-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.ficha-body { padding: 16px 20px 22px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.tl { position: relative; padding-left: 20px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item.cita::before { border-color: var(--warn); }
.tl-item.estado::before { border-color: var(--ok); }
.tl-item .t { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-item .h { font-weight: 600; font-size: 13px; margin: 1px 0; }
.tl-item .d { font-size: 12.5px; color: var(--muted); }
/* Items históricos (del lead duplicado anterior) en la línea de tiempo. */
.tl-item.historico { opacity: .72; }
.tl-item.historico::before { border-color: var(--muted); background: color-mix(in srgb, var(--muted) 20%, transparent); }
.tl-tag {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); background: color-mix(in srgb, var(--warn) 15%, transparent);
  margin-left: 6px; vertical-align: middle;
}
/* Posibles duplicados en la ficha: quienes son, no solo que los hay. */
.dupbox {
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  background: var(--warn-wash); border-radius: 9px; padding: 12px 14px; margin-bottom: 18px;
}
.dupbox-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--warn); }
.dupbox p { margin: 5px 0 9px; font-size: 12.5px; color: var(--muted); }
.dupbox ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.dupbox li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; font-size: 12.5px; }
.dupbox li a { color: var(--ink); font-weight: 600; text-decoration: none; }
.dupbox li a:hover { text-decoration: underline; text-underline-offset: 2px; }
.dupbox .mono { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.dupbox .dup-why {
  padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
  background: var(--surface); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.dupbox .dup-meta { color: var(--muted); font-size: 11.5px; }

.oppbox { border: 1px solid var(--line-2); border-radius: 9px; padding: 13px; margin-bottom: 18px; }
.oppbox .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.etapa { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--accent); }
.btn-wide { width: 100%; margin-top: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 8px; }
.section-head h3 { font-size: 14px; margin: 0; }
.contacto-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.contacto-form select, .contacto-form input { flex: 1 1 140px; }
.contacto-form textarea { flex: 1 1 100%; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--ground); color: var(--ink); resize: vertical; min-height: 52px; }

/* ---- modal (cerrar venta / importar) ---- */
.modal-scrim { position: fixed; inset: 0; background: rgba(20,12,16,.5); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal-scrim.open { display: grid; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 96vw); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.modal-head h2 { font-size: 18px; }
.modal-head span { color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; }
.fieldset { border: 1px solid var(--line-2); border-radius: 10px; padding: 13px; }
.fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.frow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.frow:last-child { margin-bottom: 0; }
.frow label { font-size: 12.5px; color: var(--muted); min-width: 92px; }
input[type="number"], input[type="text"], input[type="email"], input[type="date"], input[type="password"], select {
  font: inherit; font-size: 13px; padding: 7px 9px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--ground); color: var(--ink);
}
.mini-add { font-size: 12px; padding: 4px 9px; border-radius: 6px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.checkline .ic { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; background: var(--crit); flex: none; }
.checkline.good .ic { background: var(--ok); }
.semaforo { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); font-weight: 700; font-family: var(--font-display); }
.semaforo .lamp { width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 20%, transparent); }
.semaforo.listo { color: var(--ok); }
.semaforo.revisar { color: var(--crit); }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ---- importar leads: selector de archivo + detalle fila a fila ---- */
.filepick {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px; border-radius: 8px; border: 1px dashed var(--line-2);
  background: var(--ground); cursor: pointer;
}
.filepick:hover { border-color: var(--accent); }
.filepick-btn {
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--surface);
}
.filepick-name { font-family: var(--font-mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.filepick-name.set { color: var(--ink); }
.imp-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.imp-hint b { color: var(--ink); }
#impResult { font-size: 12.5px; color: var(--muted); min-height: 18px; }
#impResult b { color: var(--ink); }
.imp-detalle { border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.imp-detalle-h { padding: 8px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.imp-detalle-list { max-height: 160px; overflow-y: auto; }
.imp-detalle-row {
  display: grid; grid-template-columns: 44px 1fr 110px 1fr; gap: 8px;
  padding: 6px 12px; font-size: 12px; border-top: 1px solid var(--line);
  align-items: baseline;
}
.imp-detalle-row span:last-child { color: var(--muted); }
.imp-detalle-more { padding: 6px 12px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); }
/* Selector de hojas del Excel: los libros del área traen 24 hojas y solo las
   mensuales son listas de personas. */
.imp-hoja {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: baseline;
  padding: 6px 12px; font-size: 12.5px; border-top: 1px solid var(--line); cursor: pointer;
}
.imp-hoja:hover { background: var(--surface-2); }
.imp-hoja input[disabled] { opacity: .35; }
.imp-hoja input[disabled] ~ * { opacity: .45; }
.imp-hoja-n { font-weight: 600; }
.imp-hoja .mono { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.imp-hoja-no { font-size: 10.5px; color: var(--faint); }

.imp-preview-body { max-height: 260px; overflow: auto; }
.imp-preview { width: 100%; border-collapse: collapse; font-size: 11.5px; white-space: nowrap; }
.imp-preview th, .imp-preview td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.imp-preview th { background: var(--surface-2); position: sticky; top: 0; color: var(--muted); font-weight: 600; }
.imp-nota { margin-top: 7px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.imp-nota b { color: var(--ink); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--ground);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 60; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Pantalla de acceso (login / activar / reset) ---------------------
   La clase va en <html> y no en <body> porque `pre.js` la pone desde el <head>,
   antes de que el <body> exista. Asi el primer frame ya sale con este layout en
   vez de mostrar el armazon de la app y saltar. */
/* El acceso es ACROMATICO: negro sobre blanco en claro, blanco sobre negro en
   oscuro. No es una falta de diseno — XAMZ no tiene color propio, el color lo
   pone la empresa inquilina y hasta que alguien no entra no se sabe cual es.
   Se neutralizan los tokens de acento en vez de reescribir cada componente, asi
   el boton, los links y el logo (que usan var(--accent)) caen solos. El color
   real vuelve despues del login, porque `.auth` deja de estar en <html>.
   Los semanticos (--crit para los errores del formulario) NO se tocan.

   Va como `:root.auth` y no `html.auth` por especificidad: los bloques de tema
   son `:root:not([data-theme="light"])` (0,2,0) y le ganaban a `html.auth`
   (0,1,1), asi que en modo oscuro el acento seguia saliendo fucsia. `:root.auth`
   empata en especificidad y gana por venir despues en el archivo. */
:root.auth {
  --accent: var(--ink);
  --accent-ink: var(--surface);
  --accent-wash: var(--surface-2);
}
html.auth .app { grid-template-columns: 1fr; }
html.auth .side,
html.auth .topbar { display: none; }
html.auth .view {
  max-width: none; padding: 24px;
  min-height: 100vh; display: grid; place-items: center;
  background: var(--ground);
}
.auth-card { width: 100%; max-width: 384px; }
.auth-brand {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.auth-logo { display: block; width: 168px; height: auto; color: var(--ink); }
.auth-panel { padding: 24px 22px; }
.auth-title { font-size: 18px; margin: 0 0 4px; }
.auth-sub { margin: 0 0 4px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.auth-foot { text-align: center; color: var(--faint); font-size: 11px; margin: 16px 0 0; }
@media (max-width: 480px) {
  html.auth .view { place-items: start center; padding-top: 7vh; }
  .auth-logo { width: 148px; }
}

/* =====================================================================
   Celular (≤700px). La app se usa en la calle: el objetivo es que cada
   pantalla se lea de una pasada, sin scroll horizontal y sin apuntar.
   ===================================================================== */
@media (max-width: 700px) {
  .view { padding: 16px 14px 84px; }
  .view-head { margin-bottom: 14px; }
  .view-head h1 { font-size: 20px; }
  .view-head p { font-size: 13px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .state { padding: 28px 16px; }

  /* Tipear en un input de menos de 16px hace que iOS haga zoom solo y deje la
     pantalla corrida. Va con !important porque varias vistas traen el tamaño
     en el atributo style. */
  input, select, textarea { font-size: 16px !important; }

  /* --- bandeja: de 6 columnas rígidas a tarjeta de 3 renglones ---------
     Antes el nombre salía una palabra por línea y el teléfono se partía a la
     mitad, porque las columnas eran de ancho fijo. */
  .inbox-row {
    grid-template-columns: 4px minmax(0, 1fr) auto;
    grid-template-areas:
      "sem  quien acts"
      "sem  cuando acts"
      "sem  meta  acts";
    gap: 3px 12px; padding: 12px 14px 12px 0;
  }
  .inbox-row .sem { grid-area: sem; }
  .inbox-who     { grid-area: quien; }
  .inbox-when    { grid-area: cuando; }
  .inbox-meta    { grid-area: meta; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .inbox-actions { grid-area: acts; align-self: center; }
  .inbox-when b  { display: inline; }
  .inbox-when span { margin-left: 6px; }
  .inbox-who b   { display: block; }
  .inbox-who > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mini-act { width: 36px; height: 36px; font-size: 15px; }   /* dedo, no mouse */

  /* --- tablas: cada fila pasa a ser una tarjeta ------------------------
     Una tabla de 6 columnas en 375px obligaba a hacer scroll lateral para ver
     el estado de un lead. Las etiquetas salen del data-label de cada celda. */
  .tablewrap { overflow-x: visible; border-radius: 0; }
  table.leads { display: block; min-width: 0; background: transparent; }
  /* Los encabezados se ocultan, pero la fila de FILTROS no: en el celular es
     lo único con lo que se puede buscar. Pasa a ser una rejilla de dos
     columnas arriba de las tarjetas, con el nombre de la columna como
     etiqueta (el <th> de arriba ya no está para decirlo). */
  table.leads thead { display: block; }
  table.leads thead tr:not(.filtros) { display: none; }
  .solo-movil { display: inline-flex; }
  /* Plegados por defecto: siete controles con etiqueta son ~500 px, o sea la
     pantalla entera antes del primer lead. El boton los abre. */
  table.leads tr.filtros { display: none; }
  table.leads.con-filtros tr.filtros {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
    padding: 12px 14px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  table.leads tr.filtros th { display: block; padding: 0; background: transparent; border-bottom: 0; }
  table.leads tr.filtros th:empty { display: none; }
  table.leads tr.filtros th::before {
    content: attr(data-label); display: block; margin-bottom: 3px;
    color: var(--muted); font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
  }
  table.leads tr.filtros input,
  table.leads tr.filtros select { font-size: 16px; }  /* menos de 16px y iOS hace zoom al tocar */
  table.leads tbody { display: block; }
  table.leads tr {
    display: block; padding: 12px 14px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  table.leads td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 4px 0; border-bottom: 0; text-align: left;
  }
  table.leads td::before {
    content: attr(data-label);
    flex: 0 0 auto; color: var(--muted);
    font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  }
  table.leads td:not([data-label]) { display: block; }
  table.leads td.lead-name {
    display: block; padding-bottom: 8px; margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
  }
  /* El título de la tarjeta nunca lleva etiqueta, aunque la celda traiga
     data-label: se pegaba al texto ("PROYECTOMARACUYA"). */
  table.leads td.lead-name::before { content: none; }
  table.leads tbody tr:hover td { background: transparent; }
  table.leads td .reassign { max-width: 60%; }
  table.leads td[data-label="Correo"] { word-break: break-all; }
  /* El nombre es la acción principal de la tarjeta: que se pueda apretar con
     el dedo, no con la punta del mouse. */
  table.leads td.lead-name a { display: inline-block; padding: 6px 0; }

  /* Nada por debajo de ~38px de alto: son botones para el pulgar. */
  .btn.sm, .toolbtn, .reassign, .mini-add { min-height: 38px; }

  /* --- barra de herramientas: buscador a lo ancho, sin notas de más ---- */
  .toolbar { gap: 8px; margin-bottom: 12px; }
  .toolbar > input { flex: 1 1 100%; min-width: 0 !important; }
  .toolbar .hint { display: none; }   /* nota para el equipo, no para la calle */
  .chips { gap: 6px; margin-bottom: 12px; }

  /* --- ficha del lead ------------------------------------------------- */
  .ficha-head, .ficha-body { padding-left: 14px; padding-right: 14px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt {
    margin-top: 12px; font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
  }
  .kv dd { margin: 3px 0 0; }
  /* Los campos de la ficha traen ancho fijo en el atributo style (140px, 220px,
     130px…), pensado para escritorio. En 375px eso cortaba el teléfono a la
     mitad, así que acá mandan el flex y el ancho disponible. */
  .kv dd > div { gap: 8px; }
  .kv dd input, .kv dd select { width: auto !important; min-width: 0; }
  .kv dd input { flex: 1 1 140px; }
  #f-tel, #f-mail { flex: 1 1 100%; }
  .kv dd .btn { flex: 1 1 auto; }

  .contacto-form { flex-direction: column; align-items: stretch; }
  .contacto-form select, .contacto-form input, .contacto-form textarea { width: 100%; }

  /* Oportunidad: etapa y proyecto se salían a la derecha por el margin-left:auto. */
  .oppbox { padding: 12px; }
  .oppbox .row { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
  .oppbox .row > select { margin-left: 0 !important; flex: 1 1 130px; }
  .opp-encuentros { gap: 10px 14px; }

  /* --- modales: hoja que sube desde abajo ------------------------------ */
  .modal-scrim { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .frow { flex-direction: column; align-items: stretch; gap: 5px; }
  .frow label { min-width: 0; }
  .frow input, .frow select, .frow textarea { width: 100% !important; }
  .modal-foot { flex-direction: column-reverse; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .btn { width: 100%; padding: 12px 15px; }
  .imp-detalle-row { grid-template-columns: 40px 1fr; gap: 2px 8px; }
}

/* Colapso de la grilla de 2 columnas del Tablero. Va acá, al final, y no en el
   @media de arriba: `.grid2` se define después de aquel bloque y le ganaba por
   orden de cascada, así que el Tablero nunca colapsaba en celular. */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 700px) {
  .card-h { padding: 14px 15px 0; }
  .card-b { padding: 14px 15px 16px; }
  /* El gráfico de publicidad tiene una barra por mes: en 375px se aprieta hasta
     ser ilegible, así que se desplaza en horizontal dentro de su tarjeta. */
  .adbars { overflow-x: auto; gap: 12px; padding-bottom: 4px; }
  .adbar { flex: 0 0 42px; }
  table.mini th, table.mini td { padding: 8px 4px; font-size: 12px; }

  /* Calendario: la grilla de 7 columnas no tiene a dónde encogerse mas que el
     propio texto de los eventos. Se compacta en vez de scrollear en horizontal. */
  .cal-head h2 { min-width: 0; font-size: 14px; }
  .cal-cell { min-height: 64px; padding: 4px; gap: 2px; }
  .cal-weekdays span { padding: 6px 2px; font-size: 9.5px; }
  .cal-daynum { font-size: 11px; }
  .cal-event { font-size: 10px; padding: 1px 4px; }
  .cal-more { font-size: 9.5px; }
}
