:root {
  --tinta: #0a1128;
  --tinta-2: #3d4459;
  --suave: #6b7280;
  --linea: #e8e3ec;
  --fondo: #faf7fb;
  --papel: #ffffff;
  --rosa: #fceeff;
  --crema: #fff6e0;
  --naranja: #ff6b35;
  --naranja-osc: #d94e1a;
  --azul: #51a5c4;
  --verde: #2f9e6e;
  --rojo: #c8364a;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(10, 17, 40, .05), 0 4px 16px rgba(10, 17, 40, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--tinta);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 650; color: var(--tinta-2); }
small, .suave { color: var(--suave); }
code { background: var(--rosa); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* ---- estructura ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral {
  background: var(--tinta); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; text-decoration: none; }
.marca b { font-size: 16px; }
.marca small { display: block; color: #aeb4c4; font-size: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--naranja); display: grid; place-items: center;
  font-weight: 800; color: #fff; flex: none;
}
.lateral nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none;
  color: #d6d9e2; font-weight: 550;
}
.lateral nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.lateral nav a.activo { background: rgba(255,107,53,.16); color: #fff; }
.lateral nav a .n { margin-left: auto; background: var(--naranja); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; }
.lateral .pie { margin-top: auto; padding: 0 10px; font-size: 13px; color: #aeb4c4; }
.lateral .pie button { background: none; border: 0; color: #d6d9e2; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.principal { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }
.cabecera { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.cabecera p { margin: 4px 0 0; color: var(--suave); }

/* ---- piezas ---- */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; }
.tarjeta > h2 { margin-bottom: 14px; }
.rejilla { display: grid; gap: 16px; }
.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r-ficha { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.cifra { padding: 18px 20px; }
.cifra b { display: block; font-size: 30px; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cifra span { color: var(--suave); font-size: 13px; }
.cifra.destacada { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.cifra.destacada span { color: #c5cad6; }

.boton {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--linea); background: var(--papel);
  color: var(--tinta); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; min-height: 38px;
}
.boton:hover { border-color: #cfc7d6; }
.boton.primario { background: var(--naranja); border-color: var(--naranja); color: #fff; }
.boton.primario:hover { background: var(--naranja-osc); border-color: var(--naranja-osc); }
.boton.oscuro { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.boton.peligro { color: var(--rojo); }
.boton.peq { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.enlace { background: none; border: 0; padding: 0; color: var(--suave); cursor: pointer; font: inherit; text-decoration: underline; }

input[type=text], input[type=email], input[type=search], input[type=password], input[type=tel], input[type=url], input:not([type]),
select, textarea {
  font: inherit; color: inherit; border: 1px solid var(--linea); background: #fff; border-radius: 10px;
  padding: 8px 12px; min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255,107,53,.35); border-color: var(--naranja); }
textarea { min-height: 90px; resize: vertical; }
label { font-weight: 600; font-size: 13px; color: var(--tinta-2); display: block; margin-bottom: 4px; }
.campo { margin-bottom: 14px; }
.campo .error, .errorlist { color: var(--rojo); font-size: 13px; margin: 4px 0 0; padding: 0; list-style: none; }
.casilla { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.casilla input { width: auto; min-height: 0; }

.chip {
  --c: #8a8f9c; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 99px; color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 25%, white);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chip form { display: inline; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fuente { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; letter-spacing: .02em; }
.fuente.hubspot { background: #fff0e9; color: #c2410c; }
.fuente.systeme { background: #e8f4f9; color: #1f6f8b; }
.fuente.crm { background: var(--rosa); color: #7c3a8a; }
.estado { font-size: 12px; font-weight: 650; }
.estado.cliente { color: var(--verde); }
.estado.suscriptor { color: var(--azul); }
.aviso-baja { color: var(--rojo); font-size: 12px; font-weight: 600; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--rosa); color: #7c3a8a; display: grid;
  place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.avatar.grande { width: 64px; height: 64px; font-size: 22px; }

/* ---- tabla ---- */
.tabla-envoltorio { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdfbfe; }
.persona { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.persona b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.col-check { width: 32px; }

/* ---- filtros ---- */
.filtros { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 10px; margin-bottom: 14px; }
.barra-masiva {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--crema); border: 1px solid #f3dfae;
  padding: 10px 14px; border-radius: var(--radio); margin-bottom: 14px;
}
.barra-masiva.visible { display: flex; }
.barra-masiva input, .barra-masiva select { width: auto; min-width: 180px; }
.paginas { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }

/* ---- ficha ---- */
.ficha-cabeza { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.ficha-cabeza p { margin: 2px 0 0; color: var(--suave); word-break: break-all; }
dl.datos { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dl.datos dt { color: var(--suave); }
dl.datos dd { margin: 0; word-break: break-word; }
.respuestas dt { font-weight: 600; color: var(--tinta-2); font-size: 13px; margin-top: 12px; }
.respuestas dd { margin: 2px 0 0; white-space: pre-line; word-break: break-word; }
.seccion + .seccion { margin-top: 16px; }

.historial { list-style: none; margin: 0; padding: 0; position: relative; }
.historial::before { content: ""; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--linea); }
.historial li { position: relative; display: flex; gap: 14px; padding: 0 0 20px; }
.historial .ico {
  width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid var(--linea); display: grid;
  place-items: center; flex: none; z-index: 1; font-size: 15px;
}
.historial .t-formulario .ico, .historial .t-anuncio .ico { border-color: var(--naranja); color: var(--naranja); }
.historial .t-nota .ico { border-color: var(--azul); color: var(--azul); background: #f2f9fc; }
.historial .t-alta .ico { border-color: var(--verde); color: var(--verde); }
.historial .t-reunion .ico, .historial .t-llamada .ico { border-color: #7c5cbf; color: #7c5cbf; }
.historial .cuerpo { min-width: 0; flex: 1; padding-top: 6px; }
.historial .cuerpo b { font-weight: 650; }
.historial .cuerpo .meta { font-size: 13px; color: var(--suave); }
.historial .cuerpo .texto { white-space: pre-line; margin-top: 6px; background: var(--fondo); border-radius: 10px; padding: 10px 12px; font-size: 14px; word-break: break-word; }
.historial .resp { margin-top: 6px; font-size: 14px; background: var(--fondo); border-radius: 10px; padding: 8px 12px; }
.historial .resp div { word-break: break-word; }
.historial .resp span { color: var(--suave); }

/* ---- panel ---- */
.barras { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.barras div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.barras i { display: block; width: 100%; max-width: 38px; background: var(--naranja); border-radius: 6px 6px 2px 2px; opacity: .85; }
.barras div:hover i { opacity: 1; }
.barras small { font-size: 11px; white-space: nowrap; }
.barras em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--tinta-2); }
.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--linea); font-size: 14px; }
.lista-simple li:last-child { border-bottom: 0; }
.lista-simple li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reparto { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--linea); margin: 6px 0 14px; }
.reparto i { display: block; }
.leyenda { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; }
.leyenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; }

/* ---- duplicados ---- */
.pareja { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lado { border: 1px solid var(--linea); border-radius: 12px; padding: 14px; min-width: 0; }
.lado dl.datos { grid-template-columns: 80px 1fr; font-size: 13px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---- mensajes ---- */
.mensajes { list-style: none; padding: 0; margin: 0 0 18px; }
.mensajes li { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; background: #eaf6f0; color: #1e6b4a; font-weight: 550; }
.mensajes li.error { background: #fbeaec; color: var(--rojo); }
.vacio { text-align: center; padding: 40px 20px; color: var(--suave); }

/* ---- acceso ---- */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; background: linear-gradient(160deg, var(--rosa), var(--fondo) 50%, var(--crema)); }
.acceso .tarjeta { width: 100%; max-width: 400px; padding: 30px; }
.acceso .marca { padding: 0 0 22px; color: var(--tinta); }
.acceso .marca small { color: var(--suave); }
.qr { background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 12px; display: grid; place-items: center; margin: 14px 0; }
.qr svg { width: 200px; height: 200px; }
.codigo-grande { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- móvil ---- */
.menu-movil { display: none; }
@media (max-width: 1000px) {
  .r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .r-ficha, .r2 { grid-template-columns: 1fr; }
  .filtros { grid-template-columns: 1fr 1fr; }
  .filtros .busqueda { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; padding: 12px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .marca { padding: 0; }
  .menu-movil { display: inline-flex; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 10px; padding: 6px 12px; font: inherit; }
  .lateral nav, .lateral .pie { display: none; width: 100%; }
  .lateral.abierto nav, .lateral.abierto .pie { display: block; }
  .lateral.abierto nav { margin-top: 12px; }
  .lateral.abierto .pie { margin-top: 10px; }
  .principal { padding: 20px 16px 50px; }
  h1 { font-size: 22px; }
  .pareja { grid-template-columns: 1fr; }
  .ocultar-movil { display: none; }
  .persona small { max-width: 180px; }
  dl.datos { grid-template-columns: 96px 1fr; }
}

/* retoques */
@media (min-width: 761px) { .app { background: linear-gradient(to right, var(--tinta) 232px, transparent 232px); } }
.barras { height: 220px; }
@media (max-width: 760px) {
  .persona b { white-space: normal; }
  .tabla-envoltorio table { table-layout: fixed; }
  .tabla-envoltorio td:nth-child(2) { width: auto; }
}

/* ---- embudo ---- */
.filtros-embudo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filtros-embudo input[type=search] { max-width: 340px; }
.filtros-embudo select { width: auto; }
.tablero { display: grid; grid-template-columns: repeat(5, minmax(196px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.columna { --c: #8a8f9c; background: #f1eef4; border-radius: var(--radio); padding: 10px; min-height: 200px; border-top: 4px solid var(--c); transition: background .15s; }
.columna.encima { background: color-mix(in srgb, var(--c) 14%, #f1eef4); }
.columna header { display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 10px; min-height: 52px; }
.columna header .n { background: #fff; color: var(--tinta-2); border-radius: 99px; font-size: 12px; font-weight: 700; padding: 1px 8px; margin-left: 4px; }
.columna header .total { font-size: 13px; font-weight: 700; color: var(--tinta-2); font-variant-numeric: tabular-nums; }
.tarjetas { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.op { background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 12px; box-shadow: 0 1px 2px rgba(10,17,40,.05); cursor: grab; }
.op:hover { border-color: #cfc7d6; }
.op.arrastrando { opacity: .45; }
.op-titulo { display: block; font-weight: 650; text-decoration: none; line-height: 1.3; }
.op-titulo:hover { text-decoration: underline; }
.op-contacto { display: block; font-size: 13px; color: var(--suave); text-decoration: none; margin-top: 2px; }
.op-pie { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 8px; margin-top: 10px; }
.op-pie .chip { white-space: normal; text-align: left; line-height: 1.3; padding: 2px 8px; }
.op-sin { font-size: 13px; font-weight: 500; color: var(--suave); }
.op-importe { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.op-meta { font-size: 12px; color: var(--suave); margin-top: 8px; }
.op-mover { display: none; margin-top: 8px; min-height: 32px; padding: 4px 8px; font-size: 13px; }
@media (hover: none) { .op-mover { display: block; } .op { cursor: default; } }
.anadir { display: block; text-align: center; padding: 8px; margin-top: 8px; border-radius: 10px; color: var(--suave); text-decoration: none; font-weight: 600; font-size: 14px; }
.anadir:hover { background: rgba(255,255,255,.7); color: var(--tinta); }
.cifra.destacada b { font-size: 28px; }
.columna header > div { display: flex; align-items: center; white-space: nowrap; min-width: 0; }
.columna header > div b { overflow: hidden; text-overflow: ellipsis; }
