/* Tareas de seguimiento del CRM: próximo contacto, vista Tareas y calendario */
:root {
  --t-vencida:    var(--cyc-st-fuera, #DC2626);
  --t-vencida-bg: var(--cyc-st-fuera-bg, rgba(220, 38, 38, 0.12));
  --t-vencida-ink: var(--cyc-st-fuera-ink, #B91C1C);
  --t-hoy:        var(--cyc-st-mantencion, #D97706);
  --t-hoy-bg:     var(--cyc-st-mantencion-bg, rgba(217, 119, 6, 0.13));
  --t-hoy-ink:    #B45309;
}

.chip {
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
  background: var(--bg-card); color: var(--text-main); white-space: nowrap;
}
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.link-btn { background: none; border: none; color: var(--text-muted); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
.muted { color: var(--text-muted); font-size: 12px; }

/* ── Ficha: Próximo contacto ───────────────────────────────────────────── */
.next-contact {
  margin: 0 20px 12px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); border-left: 4px solid var(--c-green);
  background: var(--bg-card); display: flex; flex-direction: column; gap: 8px;
}
.next-contact:empty { display: none; }
.next-contact.vencida { border-left-color: var(--t-vencida); background: var(--t-vencida-bg); }
.next-contact.hoy { border-left-color: var(--t-hoy); background: var(--t-hoy-bg); }
.next-contact.sin { border-left-color: var(--t-vencida); }
.next-head { display: flex; justify-content: space-between; align-items: center; }
.next-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.next-mas { background: none; border: none; color: var(--c-primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.next-fecha { font-weight: 700; font-size: 14px; }
.next-contact.vencida .next-fecha { color: var(--t-vencida-ink); }
.next-contact.hoy .next-fecha { color: var(--t-hoy-ink); }
.next-titulo { font-size: 13.5px; }
.next-resp { font-size: 12px; color: var(--text-muted); }
.next-vacio { font-weight: 600; color: var(--t-vencida-ink); font-size: 13px; }
.next-acciones, .next-nueva { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.next-nueva { border-top: 1px dashed var(--border); padding-top: 8px; font-size: 12px; color: var(--text-muted); }
.next-hecha {
  font-family: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  border-radius: 8px; padding: 6px 12px; border: 1px solid var(--c-green); background: var(--c-green); color: #fff;
}
.next-repro { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.next-repro input, .t-repro input {
  font-family: inherit; font-size: 12px; padding: 3px 6px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-main);
}

/* ── Ventanas de tarea ─────────────────────────────────────────────────── */
.tarea-modal { max-width: 520px; }
.tarea-modal h4 { font-size: 13px; margin: 0 0 8px; }
.tarea-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.tarea-form label, .tarea-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.tarea-form .ancho, .tarea-atajos { grid-column: 1 / -1; }
.tarea-form input, .tarea-form select, .tarea-label input {
  font-family: inherit; font-size: 13px; padding: 7px 9px; color: var(--text-main);
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-main);
}
.tarea-atajos { display: flex; gap: 6px; flex-wrap: wrap; }
.que-sigue { display: flex; flex-direction: column; gap: 12px; }
.que-sigue section { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.que-sigue .lost-ok, .que-sigue button {
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-main);
}
.que-sigue .lost-ok { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.que-sigue .chip { padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: 999px; }
.t-cierre { display: flex; gap: 8px; }
.que-sigue .t-ganado { border-color: var(--c-green); color: var(--c-green); }
.que-sigue .t-perdido { border-color: var(--c-red); color: var(--c-red); }
.t-lista-mini { display: flex; flex-direction: column; gap: 6px; }
.t-mini { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.t-mini.vencida .t-fecha { color: var(--t-vencida-ink); font-weight: 700; }

/* ── Kanban ────────────────────────────────────────────────────────────── */
.card-next {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--c-gray); color: var(--text-main); white-space: nowrap;
}
.card-next.vencida, .card-next.sin { background: var(--t-vencida-bg); color: var(--t-vencida-ink); }
.card-next.hoy { background: var(--t-hoy-bg); color: var(--t-hoy-ink); }

/* ── Vista Tareas ──────────────────────────────────────────────────────── */
.tareas-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 14px; }
.tareas-toolbar label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.tareas-toolbar select {
  font-family: inherit; font-size: 12.5px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-card); color: var(--text-main); max-width: 240px;
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--c-gray); color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--c-primary); color: #fff; }

.t-grupo { margin-bottom: 18px; }
.t-grupo h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.t-grupo h3 span { background: var(--c-gray); border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-left: 4px; }
.t-grupo-vencidas h3 { color: var(--t-vencida-ink); }
.t-grupo-hoy h3 { color: var(--t-hoy-ink); }
.t-fila {
  display: grid; grid-template-columns: 34px 92px minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, .8fr) auto;
  gap: 12px; align-items: center; padding: 10px 12px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
}
.t-fila.vencida { border-left: 4px solid var(--t-vencida); }
.t-fila.hoy { border-left: 4px solid var(--t-hoy); }
.t-check {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--c-green); background: transparent;
  color: var(--c-green); font-weight: 800; cursor: pointer;
}
.t-check:hover { background: var(--c-green); color: #fff; }
.t-cuando { display: flex; flex-direction: column; font-size: 12.5px; }
.t-fila.vencida .t-cuando strong { color: var(--t-vencida-ink); }
.t-fila.hoy .t-cuando strong { color: var(--t-hoy-ink); }
.t-cuando span { color: var(--text-muted); font-size: 11.5px; }
.t-titulo { font-weight: 600; font-size: 13.5px; }
.t-opp { font-size: 12px; margin-top: 2px; }
.t-opp a { color: var(--c-primary); text-decoration: none; }
.t-opp a:hover { text-decoration: underline; }
.t-etapa { font-size: 11px; color: var(--text-muted); background: var(--c-gray); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.t-contacto { font-size: 12.5px; }
.t-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.t-links a { color: var(--c-primary); font-weight: 600; text-decoration: none; font-size: 12px; }
.t-resp { font-size: 12px; color: var(--text-muted); }
.t-repro { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Calendario */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-head strong { text-transform: capitalize; font-size: 15px; min-width: 150px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; text-align: center; padding: 4px 0; }
.cal-dia { min-height: 96px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 4px; padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-dia.fuera { opacity: .5; }
.cal-dia.hoy { border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary); }
.cal-num { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.cal-t {
  font: inherit; font-size: 11px; text-align: left; cursor: pointer; border: none; border-radius: 4px;
  padding: 2px 5px; background: var(--c-gray); color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-t.vencida { background: var(--t-vencida-bg); color: var(--t-vencida-ink); font-weight: 600; }
.cal-t.hecha, .cal-t.cancelada { text-decoration: line-through; opacity: .6; }
.cal-mas { font-size: 10.5px; color: var(--text-muted); }

#view-tareas { container-type: inline-size; }
/* Contenedor angosto: fecha y tarea arriba; contacto, responsable y reprogramar abajo */
@container (max-width: 1000px) {
  .t-fila { grid-template-columns: 34px 92px minmax(0, 1fr) auto; }
  .t-fila > .t-contacto { grid-column: 3; }
  .t-fila > .t-resp { grid-column: 4; grid-row: 1; text-align: right; }
  .t-fila > .t-repro { grid-column: 4; }
}
@container (max-width: 640px) {
  .t-fila { grid-template-columns: 34px 1fr; }
  .t-fila > .t-cuando, .t-fila > .t-que, .t-fila > .t-contacto, .t-fila > .t-resp, .t-fila > .t-repro { grid-column: 2; grid-row: auto; text-align: left; }
  .t-repro { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .next-contact { margin: 0 12px 10px; }
  .tarea-form { grid-template-columns: 1fr; }
  .cal-dia { min-height: 64px; }
  .cal-t { font-size: 0; padding: 4px; }
  .cal-t::first-letter { font-size: 12px; }
}
.tarea-modal .lost-actions .lost-ok { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* Línea de tiempo de la ficha */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: 12px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-punto {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; background: var(--c-gray); border: 2px solid var(--bg-card); position: relative; z-index: 1;
}
.tl-etapa .tl-punto { background: var(--c-primary); }
.tl-etapa.ganado .tl-punto { background: var(--c-green); }
.tl-etapa.perdido .tl-punto { background: var(--c-red); }
.tl-tarea .tl-punto { background: var(--border); }
.tl-titulo { font-size: 13.5px; }
.tl-texto { font-size: 13px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.tl-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* Configuración del CRM */
.cfg-modal { max-width: 760px; }
.cfg-lista { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.cfg-fila {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 6px 10px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.cfg-fila .ancho { grid-column: 1 / -1; }
.cfg-fila input[data-c="nombre"], .cfg-fila input[data-c="email"], .cfg-fila input[data-c="zonas"] {
  font-family: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-main); color: var(--text-main);
}
.cfg-fila label { font-size: 12px; display: inline-flex; gap: 5px; align-items: center; color: var(--text-muted); }
@media (max-width: 600px) { .cfg-fila { grid-template-columns: 1fr; } }
