/* ═══ CRM Ventas: componentes propios (se suma a main.css) ═══════════════ */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--font-head); font-size: 20px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.page-head .sub { color: var(--text3); font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .form-control, .toolbar .form-select { width: auto; min-width: 140px; }
.btn-xs { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px; font-size: 11px;
        font-weight: 500; background: var(--bg3); color: var(--text2); border: 1px solid var(--border2); white-space: nowrap; }
.chip.warn { background: var(--amber-dim); color: var(--amber); border-color: rgba(245,158,11,.3); }
.chip.danger { background: var(--red-dim); color: #f87171; border-color: rgba(239,68,68,.3); }
.chip.ok { background: var(--green-dim); color: var(--green); border-color: rgba(34,201,122,.3); }
.chip.info { background: var(--blue-dim); color: #93c5fd; border-color: rgba(59,126,246,.3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.avatar-xs { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
             font-size: 9.5px; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--blue), var(--violet)); flex-shrink: 0; }
.muted { color: var(--text3); }
.sep { height: 1px; background: var(--border); margin: 12px 0; }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); margin-bottom: 8px; }
.form-label { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.form-text, .helptext { font-size: 11.5px; color: var(--text3); }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: #f87171; font-size: 12px; }
.table-hover tbody tr { cursor: default; }
.table td { vertical-align: middle; }
.card-pad { padding: 16px; }
.nav-item .nav-badge.info { background: var(--green); color: #0d1117; }

/* ── Tablero kanban ─────────────────────────────────────────────────── */
.board-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px 12px; }
.board { display: flex; gap: 12px; align-items: flex-start; min-width: max-content; }
.col { width: 272px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 205px); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--bg2);
            border: 1px solid var(--border); border-radius: 10px 10px 0 0; border-top: 3px solid var(--c, var(--blue)); }
.col-head .t { font-size: 12.5px; font-weight: 600; flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-head .n { font-size: 11px; color: var(--text2); background: var(--bg3); padding: 1px 8px; border-radius: 10px; }
.col-body { flex: 1; overflow-y: auto; padding: 8px; background: rgba(255,255,255,.015); border: 1px solid var(--border);
            border-top: none; border-radius: 0 0 10px 10px; display: flex; flex-direction: column; gap: 7px; min-height: 120px; }
.col-body.over { background: var(--blue-dim); outline: 2px dashed var(--blue); outline-offset: -4px; }
.col.cierre { width: 190px; }
.col.cierre .col-body { align-items: center; justify-content: center; text-align: center; color: var(--text3); font-size: 12px; min-height: 160px; }
.col.cierre.ganado .col-head { border-top-color: var(--green); }
.col.cierre.perdido .col-head { border-top-color: var(--red); }
.col.cierre .col-body.over { background: var(--c-dim, var(--blue-dim)); }
.tcard { background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: grab;
         transition: border-color .12s, box-shadow .12s, transform .12s; position: relative; }
.tcard:hover { border-color: var(--border2); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.tcard.dragging { opacity: .45; }
.tcard.pausada { opacity: .7; border-style: dashed; }
.tcard .nom { font-weight: 600; font-size: 13px; color: var(--text); text-decoration: none; display: block; line-height: 1.25;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 50px; }
.tcard .nom:hover { color: #6fa8ff; }
.tcard .tel { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
.tcard .meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; font-size: 11px; color: var(--text3); }
.tcard .acc { position: absolute; top: 7px; right: 7px; display: flex; gap: 3px; opacity: .55; transition: opacity .12s; }
.tcard:hover .acc { opacity: 1; }
.tcard .acc button, .tcard .acc a { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border2); background: var(--bg3);
            color: var(--text2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; padding: 0; text-decoration: none; }
.tcard .acc button:hover, .tcard .acc a:hover { color: var(--text); background: var(--bg4); }
.tcard .acc .wa:hover { color: var(--green); }
.tcard .acc .call:hover { color: #6fa8ff; }
.ver-mas { font-size: 12px; }

/* ── Ficha de oportunidad ───────────────────────────────────────────── */
.ficha-head { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 14px; }
.ficha-head .nombre { font-family: var(--font-head); font-size: 21px; font-weight: 600; margin: 0; }
.ficha-head .datos { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text2); font-size: 13px; margin-top: 4px; }
.ficha-head .datos a { color: var(--text2); text-decoration: none; }
.ficha-acciones { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper { display: flex; gap: 3px; margin-top: 14px; overflow-x: auto; }
.step { flex: 1; min-width: 96px; padding: 7px 8px; font-size: 11.5px; text-align: center; border: none; color: var(--text2);
        background: var(--bg3); cursor: pointer; transition: all .12s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%); }
.step:first-child { clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); border-radius: 6px 0 0 6px; }
.step:hover { background: var(--bg4); color: var(--text); }
.step.hecho { background: color-mix(in srgb, var(--c) 28%, var(--bg3)); color: var(--text); }
.step.actual { background: var(--c); color: #fff; font-weight: 600; }
.step.ganado:not(.actual) { color: var(--green); }
.step.perdido:not(.actual) { color: #f87171; }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--text3); font-weight: 400; }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 4px; bottom: 4px; width: 1px; background: var(--border2); }
.tl-item { position: relative; padding: 0 0 14px; }
.tl-item .ic { position: absolute; left: -26px; top: 0; width: 21px; height: 21px; border-radius: 50%; background: var(--bg3);
               border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: var(--text2); }
.tl-item.nota .ic { color: var(--amber); }
.tl-item.llamada .ic, .tl-item.intento .ic { color: #6fa8ff; }
.tl-item.whatsapp .ic { color: var(--green); }
.tl-item.cierre .ic { color: var(--violet); }
.tl-item.cambio .ic { color: #6fa8ff; }
.tl-item .cuerpo.cambios { white-space: normal; font-size: 12.5px; }
.tl-item .cab { font-size: 11.5px; color: var(--text3); }
.tl-item .cuerpo { font-size: 13px; color: var(--text); white-space: pre-wrap; margin-top: 2px; }
.tl-item.nota .cuerpo { background: var(--amber-dim); border: 1px solid rgba(245,158,11,.18); border-radius: 8px; padding: 7px 10px; }
.tl-item audio { height: 30px; margin-top: 5px; max-width: 100%; }

/* ── Chat WhatsApp ──────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #0a1019; display: flex; flex-direction: column; gap: 4px; }
.burbuja { max-width: 75%; padding: 7px 10px 5px; border-radius: 10px; font-size: 13.5px; line-height: 1.4; position: relative;
           white-space: pre-wrap; word-break: break-word; }
.burbuja.in { align-self: flex-start; background: var(--bg3); border-top-left-radius: 3px; }
.burbuja.out { align-self: flex-end; background: #11432f; border-top-right-radius: 3px; }
.burbuja.out.auto { background: #1b2f55; }
.burbuja .pie { font-size: 10.5px; color: rgba(255,255,255,.45); text-align: right; margin-top: 2px; display: flex; gap: 5px; justify-content: flex-end; align-items: center; }
.burbuja .pie .bi-check2-all.leido { color: #53bdeb; }
.burbuja.fallido { outline: 1px solid var(--red); }
.burbuja img, .burbuja video { max-width: 260px; border-radius: 7px; display: block; margin-bottom: 4px; }
.burbuja audio { max-width: 260px; }
.dia-sep { align-self: center; font-size: 11px; color: var(--text3); background: var(--bg2); padding: 2px 10px; border-radius: 10px; margin: 8px 0; }
.chat-input { border-top: 1px solid var(--border); padding: 10px; background: var(--bg2); }
.chat-input textarea { resize: none; min-height: 40px; max-height: 140px; }
.ventana-aviso { font-size: 12px; background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,.25);
                 border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.rr-menu { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--bg3); border: 1px solid var(--border2); border-radius: 8px;
           max-height: 200px; overflow-y: auto; display: none; z-index: 20; }
.rr-menu .item { padding: 6px 10px; cursor: pointer; font-size: 12.5px; }
.rr-menu .item:hover, .rr-menu .item.sel { background: var(--bg4); }

/* Inbox de 3 columnas */
.inbox { display: grid; grid-template-columns: 330px 1fr 290px; height: calc(100vh - var(--topbar-h) - 40px);
         border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg2); }
.inbox-lista { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-lista .filtros { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.inbox-lista .items { overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.conv-item:hover { background: var(--bg3); color: var(--text); }
.conv-item.activo { background: var(--blue-dim); }
.conv-item .av { width: 36px; height: 36px; border-radius: 50%; background: var(--bg4); display: flex; align-items: center; justify-content: center;
                 font-size: 12px; font-weight: 600; flex-shrink: 0; color: var(--text2); }
.conv-item .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .pv { font-size: 12px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .hr { font-size: 10.5px; color: var(--text3); white-space: nowrap; }
.conv-item .nl { background: var(--green); color: #0d1117; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 0 6px; }
.inbox-chat { display: flex; flex-direction: column; min-height: 0; }
.inbox-chat .cab { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.inbox-lado { border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; }
@media (max-width: 1199.98px) { .inbox { grid-template-columns: 290px 1fr; } .inbox-lado { display: none; } }
@media (max-width: 767.98px) { .inbox { grid-template-columns: 1fr; height: auto; } .inbox.con-chat .inbox-lista { display: none; }
  .inbox:not(.con-chat) .inbox-chat { display: none; } .inbox-chat { height: calc(100vh - 110px); } }

/* ── Widget de llamada (persistente en todas las pantallas) ─────────── */
#callWidget { position: fixed; right: 18px; bottom: 18px; z-index: 1080; min-width: 290px; background: var(--bg2);
              border: 1px solid var(--border2); border-left: 4px solid var(--blue); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.55);
              padding: 11px 13px; display: none; align-items: center; gap: 12px; }
#callWidget.show { display: flex; }
#callWidget.en_curso { border-left-color: var(--green); }
#callWidget.fin { border-left-color: var(--text3); }
#callWidget .pulse { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-dim); color: #6fa8ff;
                     display: flex; align-items: center; justify-content: center; font-size: 16px; }
#callWidget.en_curso .pulse { background: var(--green-dim); color: var(--green); animation: latido 1.6s infinite; }
@keyframes latido { 0% { box-shadow: 0 0 0 0 rgba(34,201,122,.45); } 70% { box-shadow: 0 0 0 10px rgba(34,201,122,0); } 100% { box-shadow: 0 0 0 0 rgba(34,201,122,0); } }
#callWidget .quien { font-weight: 600; font-size: 13.5px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#callWidget .quien a { color: var(--text); text-decoration: none; }
#callWidget .est { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; }

/* Toasts */
#toasts { position: fixed; top: 64px; right: 18px; z-index: 1090; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: var(--bg3); border: 1px solid var(--border2); border-left: 4px solid var(--blue); color: var(--text);
             padding: 9px 14px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow); max-width: 360px; animation: entra .18s ease-out; }
.toast-msg.ok { border-left-color: var(--green); }
.toast-msg.error { border-left-color: var(--red); }
.toast-msg.warn { border-left-color: var(--amber); }
@keyframes entra { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Búsqueda global */
.buscador { position: relative; flex: 1; max-width: 420px; }
.buscador .res { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg2); border: 1px solid var(--border2);
                 border-radius: 10px; box-shadow: var(--shadow); z-index: 1050; display: none; max-height: 420px; overflow-y: auto; }
.buscador .res a { display: block; padding: 8px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.buscador .res a:hover, .buscador .res a.sel { background: var(--bg3); }
.buscador .res small { color: var(--text3); display: block; }

.disponible-toggle { font-size: 12px; border-radius: 20px; padding: 3px 10px; border: 1px solid var(--border2); background: transparent; color: var(--text2); }
.disponible-toggle.si { color: var(--green); border-color: rgba(34,201,122,.35); background: var(--green-dim); }
.disponible-toggle.no { color: var(--amber); border-color: rgba(245,158,11,.35); background: var(--amber-dim); }

/* Cola de trabajo */
.cola-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cola-item:last-child { border-bottom: none; }
.cola-item .ic { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--bg3); color: var(--text2); flex-shrink: 0; }
.cola-item.vencida .ic { background: var(--red-dim); color: #f87171; }
.cola-item a.nom { color: var(--text); font-weight: 600; text-decoration: none; }
.hero-num { font-family: var(--font-head); font-size: 30px; font-weight: 600; line-height: 1.1; }

/* Reportes */
.kpi { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; height: 100%; }
.kpi .v { font-family: var(--font-head); font-size: 24px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11.5px; color: var(--text3); }
.kpi .d { font-size: 11.5px; color: var(--text2); margin-top: 2px; }
.kpi.alerta .v { color: var(--amber); }
.bar-row { display: grid; grid-template-columns: 170px 1fr 44px; align-items: center; gap: 10px; font-size: 12.5px; margin-bottom: 7px; }
.bar-row .lbl { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 14px; background: transparent; position: relative; }
.bar-row .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--viz, #3987e5); min-width: 2px; }
.bar-row .num { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 240px; }

/* Checkboxes múltiples en columnas */
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; }
.checks-grid label, ul.checks-list label { font-size: 13px; display: flex; gap: 6px; align-items: center; }
ul.checks-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; }
.perm-grupo { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.qr-box { width: 260px; height: 260px; background: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.qr-box img { width: 240px; height: 240px; }
code.copiable { cursor: pointer; background: var(--bg3); padding: 3px 7px; border-radius: 5px; color: #93c5fd; word-break: break-all; }
.progress { background: var(--bg3); height: 10px; border-radius: 6px; }
.progress-bar { background: var(--blue); }
