/* ==========================================================================
   PackFlow Comercial · vistas.css
   Piezas propias de cada sección: embudo, barras, próximas acciones,
   tablero del pipeline, actividades e historial.
   ========================================================================== */

/* Resumen: embudo y barras */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.frow { display: grid; grid-template-columns: 136px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.frow label { font-weight: 600; color: var(--ink); font-size: 13px; }
.bar { height: 26px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 7px; background: var(--accent); opacity: var(--o, 1); min-width: 4px; }
.frow label small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.frow-auto .bar i { background: var(--ink); opacity: .55; }
.frow b { text-align: right; font: 500 13px var(--f-mono); color: var(--ink); }
.conv { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-2); display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); }
.conv b { color: var(--ink); font: 500 12px var(--f-mono); }
.srcs { display: flex; flex-direction: column; gap: 10px; }
.src { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) 32px; gap: 10px; align-items: center; font-size: 13px; }
.src .bar { height: 10px; }
.src .bar i { background: var(--ink); opacity: .8; }
.src-bad .bar i { background: var(--bad); opacity: 1; }
.src b { font: 500 12px var(--f-mono); text-align: right; color: var(--ink); }

.kpi-link:hover { border-color: var(--accent); }

/* Resumen: origen de los contactos */
.origenes { display: flex; flex-direction: column; }
.og-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 96px 72px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.og-row:first-child { border-top: 0; }
.og-head { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 0; }
a.og-row:hover .chip { outline: 1px solid currentColor; }
.og-row b { font: 500 13px var(--f-mono); color: var(--ink); }
.og-bar { display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 8px; align-items: center; }
.og-bar .bar { height: 10px; }
.og-bar b { text-align: right; }

/* Bandeja de entradas */
.entradas td small { display: block; }
.canal { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.canal .ico { width: 16px; height: 16px; color: var(--accent); }
.acciones-entrada { white-space: nowrap; }
.acciones-entrada > * + * { margin-top: 6px; }
.acciones-entrada .btn { display: flex; margin-left: auto; }
.acciones-entrada form { display: block; }
.nota-pie { margin: 0; font-size: 12px; color: var(--muted); max-width: 820px; }
h3.sub { margin: 16px 0 10px; font: 800 13px var(--f-display); color: var(--ink); }

/* Resumen: próximas acciones */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item:hover strong { color: var(--accent); }
.when { font: 500 12px/1.3 var(--f-mono); color: var(--muted); }
.when b { display: block; font-size: 13px; color: var(--ink); }
.item .t, .act .t { min-width: 0; }
.item .t strong, .act .t strong { display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t span, .act .t span { font-size: 12px; color: var(--muted); }

/* Pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(236px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.col h3 { margin: 0; display: flex; justify-content: space-between; align-items: center; font: 800 12px var(--f-display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.col h3 span { font: 500 12px var(--f-mono); color: var(--muted); }
.col .sum { font: 500 11px var(--f-mono); color: var(--muted); margin-top: -6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.card.moving { opacity: .5; }
.card-link strong { color: var(--ink); font-size: 14px; }
.card-link:hover strong { color: var(--accent); }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.card .next { font-size: 12px; color: var(--text); padding-top: 8px; border-top: 1px dashed var(--line); }
.card .move { display: flex; gap: 6px; }
.empty-col { font-size: 12px; color: var(--muted); text-align: center; padding: 14px 6px; border: 1px dashed var(--line-2); border-radius: 10px; }

/* Actividades */
.acts { display: flex; flex-direction: column; }
.act { display: grid; grid-template-columns: 34px 112px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.act:first-child { border-top: 0; }
.aico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink); }
.aico .ico { width: 16px; height: 16px; }
.aico.demo { background: var(--accent-soft); color: var(--accent); }
.aico.reunion { background: var(--info-soft); color: var(--info); }
.done-btn { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line-2); background: transparent; white-space: nowrap; }
.done-btn:hover { color: var(--ink); border-color: var(--ink); }
.done-btn.is-done { color: var(--ok); border-color: transparent; background: var(--ok-soft); }

/* Ficha del lead */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; color: var(--ink); font-weight: 600; min-width: 0; }
.dl .wrap { overflow-wrap: anywhere; }
.detail-grid { align-items: start; }
.timeline { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.timeline div { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; }
.timeline span { font: 500 12px var(--f-mono); color: var(--muted); }
.timeline p { margin: 0; }
.timeline b { color: var(--ink); }

@media (max-width: 820px) {
  /* Bandeja como tarjetas: las acciones quedan siempre a mano en el teléfono */
  table.entradas { min-width: 0; }
  .entradas thead { display: none; }
  .entradas tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .entradas tbody tr:last-child { border-bottom: 0; }
  .entradas tbody tr:hover td { background: transparent; }
  .entradas td { display: block; padding: 0; border: 0; }
  .entradas td:nth-child(n+5), .entradas td.empty { grid-column: 1 / -1; }
  .acciones-entrada { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; text-align: left; white-space: normal; }
  .acciones-entrada > * + * { margin-top: 0; }
  .acciones-entrada .btn { margin-left: 0; }
}

@media (max-width: 560px) {
  .dl { grid-template-columns: 1fr; }
  .frow { grid-template-columns: 100px minmax(0, 1fr) 36px; }
  .og-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 52px 48px; gap: 6px; }
  .act { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .act .when { grid-column: 2; grid-row: 1; }
  .act .t { grid-column: 2; grid-row: 2; }
  .act .done-btn { grid-column: 3; grid-row: 1 / 3; }
}

/* ---------- Etiquetas (v1.3) ---------- */
.tag { --c: #6b7280; display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font: 700 11px/1.6 var(--f-body);
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); white-space: nowrap; text-decoration: none; }
.tag-gris { --c: #6b7280; } .tag-azul { --c: #2563eb; } .tag-verde { --c: #16a34a; } .tag-ambar { --c: #d97706; }
.tag-rojo { --c: #dc2626; } .tag-morado { --c: #7c3aed; } .tag-rosa { --c: #db2777; } .tag-turquesa { --c: #0d9488; }
.tag-toggle { cursor: pointer; opacity: .55; }
.tag-toggle:hover { opacity: .85; }
.tag-toggle.is-on { opacity: 1; background: color-mix(in srgb, var(--c) 22%, transparent); border-color: var(--c); }
.tag-toggle:disabled { cursor: wait; }
.tag-item { display: inline-flex; align-items: center; gap: 2px; }
.tag-del { all: unset; cursor: pointer; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--bad); font-size: 14px; }
.tag-del:hover { background: var(--bad-soft); }
.tags-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-new { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-new input { flex: 1 1 140px; min-width: 0; }
.tag-new select { flex: 0 0 auto; width: auto; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card-tags[hidden] { display: none; }
.card-click { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.card-click:hover { border-color: var(--line-2); box-shadow: 0 4px 14px rgba(0, 0, 0, .06); }
.card-click:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 12px; }
.tag-filtro { opacity: .7; }
.tag-filtro:hover, .tag-filtro.is-on { opacity: 1; }
.tag-filtro.is-on { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, transparent); }

/* ---------- Ficha rápida del pipeline ---------- */
dialog.dlg-ficha { width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 40px); }
.dlg-ficha[open] { display: flex; flex-direction: column; }
.dlg-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.ficha-cargando { padding: 30px 22px; color: var(--muted); text-align: center; }
.ficha-cuerpo { padding: 14px 22px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.ficha-cuerpo[hidden] { display: none; }
.ficha-contacto { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--text); }
.ficha-bloque h4 { margin: 0 0 8px; font: 800 13px var(--f-display); color: var(--ink); text-transform: uppercase; letter-spacing: .03em; }
.ficha-bloque h4 small { font-weight: 600; color: var(--muted); margin-left: 4px; }
.ficha-form { display: grid; grid-template-columns: 1.3fr 1fr .8fr; gap: 10px; }
.ficha-form .full { grid-column: 1 / -1; }
.ficha-form .check { grid-column: 1 / 3; }
.ficha-form-acc { display: flex; justify-content: flex-end; }
.ficha-cuerpo .acts { max-height: 260px; overflow-y: auto; }
.dlg-ficha .dlg-f { display: flex; justify-content: space-between; gap: 8px; }
@media (max-width: 640px) {
  .ficha-form { grid-template-columns: 1fr 1fr; }
  .ficha-form .field:first-child { grid-column: 1 / -1; }
  .ficha-form .check { grid-column: 1 / -1; }
}
