/* Portal de empleados de Bikerland — diseño RESPONSIVO, mobile-first (celular 360-430, tablet 768, computador 1280-1920).
   Reglas del estándar: sin scroll horizontal; objetivos táctiles >= 44 px; campos de formulario >= 16 px (evita el zoom de iOS);
   alto de pantalla con 100dvh (+ respaldo 100vh) y env(safe-area-inset-*) para el borde inferior del iPhone;
   tablas en tarjetas apiladas en pantallas angostas (o con scroll DENTRO de su contenedor, nunca de toda la página). */
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #111318; --mut: #5b6472; --line: #e5e7eb; --ac: #d71920; --ac-osc: #b3141a;
  --ok: #166534; --mal: #b91c1c; --aviso: #92400e; --radio: 14px; --alto-top: 56px; --menu-ancho: 244px;
  --seguro-abajo: env(safe-area-inset-bottom, 0px); --seguro-izq: env(safe-area-inset-left, 0px); --seguro-der: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.portal { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
body.portal img { max-width: 100%; height: auto; }
.portal .p-top img { height: 30px; width: auto; max-width: none; }
.portal .p-marca img { width: 150px; height: auto; }
.portal .p-login-caja img { width: 170px; height: auto; }
body.portal a { color: inherit; }
.portal h1, .portal h2, .portal h3, .portal p, .portal td, .portal li, .portal label { overflow-wrap: anywhere; }
.portal h1 { font-size: 1.4rem; line-height: 1.25; margin: .3rem 0 .6rem; }
.portal h2 { font-size: 1.1rem; margin: .2rem 0 .6rem; }
.portal h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
.mut { color: var(--mut); }
.mal { color: var(--mal); font-weight: 600; }
.vacio { color: var(--mut); }
.p-saltar { position: absolute; left: -999px; top: 0; background: #fff; padding: .6rem 1rem; z-index: 100; }
.p-saltar:focus { left: 0; }

/* ---------- armazón: barra superior + menú (cajón en celular/tablet, barra lateral en computador) ---------- */
.p-top { position: sticky; top: 0; z-index: 30; height: var(--alto-top); display: flex; align-items: center; gap: .6rem; padding: 0 .75rem 0 calc(.5rem + var(--seguro-izq));
         background: #fff; border-bottom: 3px solid var(--ac); }
.p-top img { display: block; flex: none; }
.p-titulo { color: var(--mut); font-size: .85rem; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.p-hamb { width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; display: grid; place-content: center; gap: 5px; padding: 0; }
.p-hamb span, .p-hamb::before, .p-hamb::after { content: ""; display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; }
.p-menu { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); background: #fff; border-right: 1px solid var(--line); overflow-y: auto;
          padding: calc(.75rem) .75rem calc(1rem + var(--seguro-abajo)) calc(.75rem + var(--seguro-izq)); transform: translateX(-102%); visibility: hidden;
          transition: transform .2s ease, visibility 0s linear .2s; display: flex; flex-direction: column; gap: 2px; }
body.menu-abierto .p-menu { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.25); }
body.menu-abierto { overflow: hidden; }
.p-velo { position: fixed; z-index: 40; inset: 0; background: rgba(0,0,0,.45); }
.p-velo[hidden] { display: none; }
.p-marca { padding: .25rem .5rem .9rem; border-bottom: 1px solid var(--line); margin-bottom: .4rem; }
.p-marca img { display: block; margin-bottom: .5rem; }
.p-marca small { display: block; color: var(--mut); font-size: .82rem; }
.p-menu a, .p-menu button { display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: .5rem .75rem; border-radius: 12px; text-decoration: none; color: var(--ink);
                            font: inherit; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
.p-menu a i, .p-menu button i { font-style: normal; width: 1.5rem; text-align: center; flex: none; }
.p-menu a:hover, .p-menu button:hover { background: #f3f4f6; }
.p-menu a.on { background: #fdecec; color: var(--ac-osc); font-weight: 700; }
.p-menu .p-sep { flex: 1; }
.p-menu form { margin: 0; }
.p-main { padding: 14px calc(14px + var(--seguro-der)) calc(28px + var(--seguro-abajo)) calc(14px + var(--seguro-izq)); max-width: 1180px; margin: 0 auto; min-width: 0; }
.p-yo { margin: 0 0 .7rem; color: var(--mut); font-size: .88rem; }

@media (min-width: 1000px) {
  .p-top, .p-velo { display: none !important; }
  .p-menu { transform: none; visibility: visible; width: var(--menu-ancho); box-shadow: none; transition: none; }
  body.menu-abierto { overflow: auto; }
  .p-main { margin-left: var(--menu-ancho); max-width: none; padding: 22px 28px 40px; }
  .p-main > * { max-width: 1100px; }
  .portal.pagina-chat .p-main > * { max-width: none; }
}

/* ---------- componentes ---------- */
.flash { margin: .5rem 0; padding: .65rem .9rem; border-radius: 12px; font-size: .95rem; border: 1px solid var(--line); background: var(--card); }
.flash.success { border-color: #86efac; background: #f0fdf4; } .flash.danger { border-color: #fca5a5; background: #fef2f2; }
.flash.info { border-color: #93c5fd; background: #eff6ff; } .flash.warning { border-color: #fcd34d; background: #fffbeb; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radio); padding: .85rem 1rem; margin: .6rem 0; }
.card > :first-child { margin-top: 0; } .card > :last-child { margin-bottom: 0; }
.ceo-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; }
.ceo-head h1 { margin: .3rem 0; }
.volver { display: inline-flex; align-items: center; min-height: 44px; color: var(--mut); text-decoration: none; }
.pill { display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .76rem; font-weight: 700; background: #dbeafe; color: #1e40af; white-space: nowrap; }
.pill.tomada { background: #fde68a; color: #92400e; } .pill.ia { background: #dcfce7; color: #166534; }
.pill.linea-bikerland { background: #dbeafe; color: #1e40af; } .pill.linea-tusam { background: #ede9fe; color: #5b21b6; }
.btn-ceo, .portal button.btn-ceo { font: inherit; font-size: 1rem; font-weight: 700; min-height: 44px; padding: .55rem 1.1rem; border-radius: 12px; border: 1px solid var(--ac); background: var(--ac); color: #fff;
                                   cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; line-height: 1.2; }
.btn-ceo:hover { background: var(--ac-osc); }
.btn-ceo.sec { background: #fff; color: var(--ink); border-color: #cbd5e1; } .btn-ceo.sec:hover { background: #f3f4f6; }
.btn-ceo[disabled] { opacity: .55; cursor: not-allowed; }
.portal input:not([type=checkbox]):not([type=radio]), .portal select, .portal textarea { font: inherit; font-size: 1rem; min-height: 44px; padding: .55rem .75rem; border: 1px solid #cbd5e1; border-radius: 12px;
                                                                                        background: #fff; color: var(--ink); width: 100%; max-width: 100%; }
.portal input[type=checkbox], .portal input[type=radio] { width: 1.25rem; height: 1.25rem; flex: none; }
.portal :focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.portal-form, .form-ceo { display: grid; gap: .8rem; max-width: 36rem; }
.portal-form label, .form-ceo label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.portal-inline { display: inline-block; margin: 0 .5rem .5rem 0; }
.portal-filtros { display: grid; grid-template-columns: 1fr; gap: .5rem; margin: .6rem 0; }
.portal-chk { display: flex !important; align-items: center; gap: .5rem; min-height: 44px; }
.portal-barra { display: grid; gap: .6rem; margin: .8rem 0; padding: .8rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radio); }
.portal-barra label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.portal-aviso { display: flex; gap: .6rem .9rem; align-items: center; flex-wrap: wrap; }
.portal-paginas { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; margin: .8rem 0; }
.portal-paginas a { display: inline-flex; align-items: center; min-height: 44px; }
.portal-grupos { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: .8rem 0; }
.portal-grupos .card { margin: 0; }
.portal-grupos ul, .wa-datos { margin: 0; padding-left: 1.1rem; }
.portal-clave-valor code { display: inline-block; font-size: 1.3rem; letter-spacing: .06em; background: #f3f4f6; padding: .4rem .7rem; border-radius: 10px; user-select: all; overflow-wrap: anywhere; }
.portal-lineas { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .5rem; }
.portal-linea { padding: .25rem .7rem; border-radius: 999px; font-size: .82rem; background: #e5e7eb; }
.portal-linea.ok { background: #dcfce7; color: #166534; } .portal-linea.mal { background: #fee2e2; color: #991b1b; }
.portal-leyenda { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- tablas: tarjetas apiladas en pantallas angostas ---------- */
.portal-tabla { width: 100%; border-collapse: collapse; background: #fff; }
.portal-tabla th, .portal-tabla td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.portal-tabla th { font-size: .82rem; color: var(--mut); }
.portal-tabla tr.inactivo td { opacity: .55; }
.portal-tabla td a { display: inline-flex; align-items: center; min-height: 44px; }
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radio); background: #fff; }
.tabla-scroll .portal-tabla { min-width: 760px; }
.tabla-scroll .portal-tabla th, .tabla-scroll .portal-tabla td { overflow-wrap: normal; white-space: nowrap; }
.tabla-scroll .portal-tabla td.detalle { white-space: normal; min-width: 16rem; overflow-wrap: anywhere; }
@media (max-width: 719px) {
  .portal-tabla.resp, .portal-tabla.resp tbody, .portal-tabla.resp tr, .portal-tabla.resp td { display: block; width: 100%; }
  .portal-tabla.resp thead { position: absolute; left: -9999px; }
  .portal-tabla.resp tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radio); padding: .4rem .8rem; margin: 0 0 .6rem; }
  .portal-tabla.resp td { display: flex; gap: .75rem; justify-content: space-between; align-items: baseline; border-bottom: 1px solid #f1f2f4; padding: .45rem 0; text-align: right; }
  .portal-tabla.resp td:last-child { border-bottom: 0; }
  .portal-tabla.resp td::before { content: attr(data-label); flex: none; max-width: 42%; color: var(--mut); font-size: .8rem; font-weight: 600; text-align: left; }
  .portal-tabla.resp td.vacio { display: block; text-align: left; } .portal-tabla.resp td.vacio::before { content: none; }
  .portal-tabla.resp td.sin-etiqueta::before { content: none; } .portal-tabla.resp td.sin-etiqueta { justify-content: flex-start; text-align: left; }
}
@media (min-width: 720px) {
  .portal-filtros { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); align-items: center; }
  .portal-grupos { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
  .portal-barra { grid-template-columns: 1fr auto; align-items: end; }
}

/* ---------- ventana de chat tipo WhatsApp Web ---------- */
.portal.pagina-chat { overflow: hidden; }
.portal.pagina-chat .p-main { padding: 0; margin: 0; max-width: none; height: calc(100vh - var(--alto-top)); height: calc(var(--alto-app, 100dvh) - var(--alto-top));
                              display: flex; flex-direction: column; overflow: hidden; }
.portal.pagina-chat .p-main > .flash { margin: .4rem .6rem; }
.wa { position: relative; flex: 1; min-height: 0; display: flex; background: #fff; overflow: hidden; }
.wa-lista, .wa-chat { flex: 1; min-width: 0; min-height: 0; }
.wa-lista { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: .6rem .6rem calc(1rem + var(--seguro-abajo)); background: #fafafa; border-right: 1px solid var(--line); }
.wa:not(.abierto) .wa-chat, .wa:not(.abierto) .wa-ficha { display: none; }
.wa.abierto .wa-lista { display: none; }
.wa-filtros .btn-ceo { width: 100%; }
.wa-cuenta { margin: .3rem 0; font-size: .88rem; }
.wa-items { list-style: none; margin: 0; padding: 0; }
.wa-item a { display: block; padding: .6rem .6rem; min-height: 64px; border-radius: 10px; color: inherit; text-decoration: none; border-bottom: 1px solid #eee; }
.wa-item a:hover, .wa-item.activa a { background: #e8f0fe; }
.wa-item.sin-leer strong { color: #0b5cad; }
.wa-item-arriba { display: flex; justify-content: space-between; gap: .5rem; min-width: 0; }
.wa-item-arriba strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item-arriba .mut { flex: none; font-size: .8rem; }
.wa-tel { font-size: .82rem; }
.wa-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92rem; }
.wa-etiquetas { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .2rem; font-size: .76rem; }
.wa-chat { display: flex; flex-direction: column; background: #efeae2; container-type: inline-size; container-name: chat; }
.wa-vacio { margin: auto; text-align: center; padding: 2rem; }
.wa-cabecera { flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .1rem .5rem; padding: .4rem .6rem; background: #f0f2f5; border-bottom: 1px solid var(--line); }
.wa-atras { grid-row: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; text-decoration: none; font-weight: 700; border-radius: 12px; }
.wa-quien { grid-row: 1; min-width: 0; }
.wa-quien h1 { margin: 0; font-size: 1.05rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-quien h1 small { display: block; font-size: .8rem; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.wa-sub { display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: center; font-size: .8rem; min-width: 0; }
.wa-sub > span { min-width: 0; }
.wa-info { grid-row: 1; width: 44px; height: 44px; border-radius: 12px; border: 1px solid #cbd5e1; background: #fff; cursor: pointer; font-size: 1.1rem; }
.wa-acciones { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.wa-acciones:empty { display: none; }
.wa-acciones .btn-ceo { flex: 1 1 8rem; }
.wa-simulacro { flex: none; background: #fef3c7; color: #92400e; padding: .35rem .8rem; font-size: .8rem; }
.wa-chat .portal-leyenda { display: none; flex: none; padding: .25rem .8rem; background: #f7f7f7; }
.wa-recorte { flex: none; padding: .2rem .8rem; margin: 0; font-size: .85rem; }
.portal-chat { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; gap: .4rem; padding: .7rem .75rem; }
.portal-dia { align-self: center; color: #6b7280; font-size: .78rem; margin: .5rem 0 .15rem; }
.burbuja { padding: .45rem .7rem; border-radius: 12px; max-width: 86%; background: #f3f4f6; min-width: 0; }
.burbuja .meta { font-size: .72rem; color: #6b7280; margin-bottom: .1rem; }
.burbuja .texto { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.burbuja .adjunto { font-style: italic; color: #4b5563; }
.burbuja.cliente { align-self: flex-start; background: #fff; } .burbuja.ia { align-self: flex-end; background: #dbeafe; }
.burbuja.externo { align-self: flex-end; background: #fef3c7; } .burbuja.humano { align-self: flex-end; background: #dcfce7; }
.portal-leyenda .burbuja { max-width: none; font-size: .78rem; padding: .1rem .6rem; }
.wa-barra { flex: none; background: #f0f2f5; border-top: 1px solid var(--line); padding: .45rem calc(.6rem + var(--seguro-der)) calc(.45rem + var(--seguro-abajo)) calc(.6rem + var(--seguro-izq)); }
.wa-aviso { min-height: 0; font-size: .85rem; } .wa-aviso:not(:empty) { min-height: 1.2rem; padding-bottom: .25rem; }
.wa-escribir { display: flex; gap: .4rem; align-items: flex-end; }
.wa-escribir textarea { flex: 1; min-width: 0; resize: none; border-radius: 22px !important; line-height: 1.4; max-height: 7.2rem; overflow-y: auto; padding: .6rem .9rem !important; }
.wa-escribir .btn-ceo { flex: none; border-radius: 22px; min-width: 44px; padding: .55rem 1rem; }
.wa-escribir.deshabilitado { align-items: center; flex-wrap: wrap; }
.wa-icono { flex: none; min-width: 44px; min-height: 44px; border: 1px solid #cbd5e1; background: #fff; border-radius: 22px; padding: 0 .7rem; cursor: not-allowed; opacity: .55; font: inherit; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.wa-icono .txt { display: none; }
.wa-icono svg { width: 20px; height: 20px; flex: none; }
.wa-ficha { position: absolute; z-index: 20; top: 0; right: 0; bottom: 0; width: min(100%, 380px); overflow-y: auto; background: #fff; border-left: 1px solid var(--line); padding: .8rem .9rem calc(1rem + var(--seguro-abajo));
            box-shadow: -10px 0 30px rgba(0,0,0,.18); transform: translateX(105%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
.wa.ficha-abierta .wa-ficha { transform: none; visibility: visible; transition: transform .2s ease; }
.wa-ficha-cerrar { float: right; min-width: 44px; min-height: 44px; border: 1px solid #cbd5e1; background: #fff; border-radius: 12px; font-size: 1.1rem; cursor: pointer; }
.wa-datos { list-style: none; padding: 0; font-size: .92rem; } .wa-datos li { margin: .3rem 0; }
/* el chat abierto en celular usa TODA la pantalla: se oculta el pie de la página y la leyenda */
@media (min-width: 640px) {
  .wa-chat .portal-leyenda { display: flex; }
  .wa-filtros .btn-ceo { width: auto; }
}
/* tablet: lista + conversacion lado a lado */
@media (min-width: 768px) {
  .wa { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); }
  .wa:not(.abierto) .wa-chat { display: flex; }
  .wa.abierto .wa-lista { display: block; }
  .wa-atras { display: none; }
  .wa-cabecera { grid-template-columns: 1fr auto; }
  .wa-acciones { grid-column: 1 / -1; }
  .wa-acciones .btn-ceo { flex: 0 0 auto; }
}
/* computador muy ancho: tres columnas, la ficha siempre visible (menu 244 + lista 340 + chat >= 600 + ficha 300) */
@media (min-width: 1500px) {
  .wa { grid-template-columns: 340px minmax(0, 1fr) 300px; }
  .wa:not(.abierto) .wa-ficha { display: none; }
  .wa-ficha { position: static; transform: none; visibility: visible; width: auto; box-shadow: none; transition: none; display: block; }
  .wa-info, .wa-ficha-cerrar { display: none; }
  .wa-cabecera { grid-template-columns: 1fr auto; }
}
@media (min-width: 1000px) {
  .portal.pagina-chat .p-main { height: 100vh; height: var(--alto-app, 100dvh); margin-left: var(--menu-ancho); }
}
@container chat (min-width: 600px) { .wa-icono .txt { display: inline; } .wa-icono { padding: 0 .9rem; } }
@media (prefers-reduced-motion: reduce) { .p-menu, .wa-ficha { transition: none !important; } }

/* ---------- pantalla de entrada ---------- */
.portal.p-login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem calc(1rem + var(--seguro-der)) calc(1rem + var(--seguro-abajo)) calc(1rem + var(--seguro-izq)); }
.p-login-caja { width: 100%; max-width: 26rem; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 1.4rem 1.2rem 1.2rem; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.p-login-caja img { display: block; margin: 0 auto .8rem; }
.p-login-caja h1 { text-align: center; margin: .2rem 0; }
.p-login-caja > p { text-align: center; margin: .2rem 0 .8rem; }
.p-login-caja .portal-form { max-width: none; }
.p-login-ayuda { font-size: .88rem; margin-top: 1rem !important; }

/* ---------- leads (fase 4) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .3rem .85rem; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; text-decoration: none; font-size: .92rem; }
.chip b { background: #eef2f7; border-radius: 999px; padding: 0 .5rem; font-size: .82rem; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); } .chip.on b { background: rgba(255,255,255,.2); }
.pill.e-new { background: #e0e7ff; color: #3730a3; } .pill.e-contacted { background: #cffafe; color: #155e75; } .pill.e-interested { background: #fef3c7; color: #92400e; }
.pill.e-quote { background: #fde68a; color: #78350f; } .pill.e-follow_up { background: #fed7aa; color: #9a3412; } .pill.e-won { background: #bbf7d0; color: #166534; }
.pill.e-lost { background: #fecaca; color: #991b1b; } .pill.aviso { background: #fecaca; color: #991b1b; } .pill.hoy { background: #fde68a; color: #92400e; }
.filtros-plegables { margin: .4rem 0 .6rem; } .filtros-plegables summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.campo-fecha { display: grid; gap: .25rem; font-size: .88rem; color: var(--mut); }
.lead-resumen { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; margin: .4rem 0 .8rem; }
.acciones-lead, .acciones { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0; }
.acciones-lead .btn-ceo { flex: 1 1 9rem; } .acciones-lead [aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.portal fieldset { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; margin: 0; display: grid; gap: .8rem; min-width: 0; }
.portal legend { font-weight: 700; font-size: .92rem; padding: 0 .3rem; }
.par { display: grid; grid-template-columns: 1fr 7rem; gap: .6rem; }
.js .solo-si { display: none; } .js .solo-si.visible { display: grid; }
.fila-form { display: flex; gap: .5rem; align-items: center; } .fila-form input { flex: 1; min-width: 0; }
details.card > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.45rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: #94a3b8; border: 2px solid #fff; }
.timeline .t-estado::before { background: #2563eb; } .timeline .t-venta::before { background: #16a34a; } .timeline .t-nota::before { background: #d97706; } .timeline .t-adjudicacion::before { background: #7c3aed; }
.t-cab { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .1rem .6rem; } .t-cab .mut { font-size: .8rem; } .t-det { margin-top: .15rem; overflow-wrap: anywhere; }
.pend-cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .4rem 0; }
.pend-cifras a { display: grid; gap: .1rem; align-content: start; text-align: center; padding: .6rem .3rem; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; background: #fafafa; min-height: 44px; }
.pend-cifras a b { font-size: 1.5rem; line-height: 1.1; } .pend-cifras a span { font-size: .78rem; color: var(--mut); } .pend-cifras a.mal b { color: var(--mal); }
.pend-lista { list-style: none; margin: .5rem 0 0; padding: 0; } .pend-lista li a { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; min-height: 44px; padding: .3rem 0; text-decoration: none; border-bottom: 1px solid #f1f2f4; }
@media (max-width: 380px) { .pend-cifras { grid-template-columns: 1fr; } }

/* === Móvil compacto: -30 % (pedido de Miguel 21/11). Solo celular (<720 px). ===
   Todo lo que está en rem baja al 70 %; el cuerpo y las alturas fijas se ajustan aparte.
   Los campos de texto se quedan en 16 px: por debajo, iPhone hace zoom solo al tocarlos. */
@media (max-width: 719px) {
  html { font-size: 70%; }
  body.portal { font-size: 11.5px; line-height: 1.4; }
  :root { --alto-top: 40px; --radio: 10px; }
  .portal .p-top img { height: 22px; }
  .portal .p-marca img { width: 105px; }
  .p-hamb, .wa-info { width: 32px; height: 32px; }
  .volver, .btn-ceo, .portal button.btn-ceo, .portal-chk, .portal-paginas a, .portal-tabla td a,
  .wa-atras, .wa-icono, .wa-ficha-cerrar, .chip, .filtros-plegables summary, details.card > summary,
  .wa-escribir .btn-ceo { min-height: 32px; }
  .wa-atras, .wa-icono, .wa-ficha-cerrar, .wa-escribir .btn-ceo { min-width: 32px; }
  .portal input:not([type=checkbox]):not([type=radio]), .portal select, .portal textarea {
    font-size: 16px; min-height: 34px; padding: .3rem .5rem;
  }
}

/* === Cabecera del chat compacta (pedido de Miguel 21/11): estado + acciones en UNA fila, botones chicos === */
.wa-cabecera { padding: .25rem .5rem; gap: 0 .4rem; }
.wa-quien h1 { font-size: 1rem; }
.wa-quien h1 small { display: inline; margin-left: .3rem; font-size: .8rem; }
.wa-sub { flex-wrap: nowrap; overflow: hidden; gap: .35rem; font-size: .78rem; white-space: nowrap; }
.wa-sub .wa-resp { overflow: hidden; text-overflow: ellipsis; color: var(--mut); }
.wa-sub .wa-resp::before { content: "👤 "; }
.wa-acciones { display: flex; flex-wrap: nowrap; align-items: center; gap: .4rem; margin-top: .2rem; }
.wa-acciones .pill { flex: none; font-size: .78rem; padding: .2rem .6rem; }
.pill.ia::before { content: "🤖 "; } .pill.tomada::before { content: "✋ "; }
.wa-botones { display: flex; flex: 1 1 auto; justify-content: flex-end; gap: .35rem; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.wa-botones::-webkit-scrollbar { display: none; }
.wa-acciones .btn-ceo { flex: none; min-height: 32px; padding: .2rem .7rem; font-size: .88rem; border-radius: 16px; white-space: nowrap; display: inline-flex; align-items: center; }
.wa-atras { min-width: 36px; min-height: 36px; }
.wa-info { width: 36px; height: 36px; }
.wa-simulacro { padding: .2rem .6rem; font-size: .74rem; line-height: 1.25; }
@media (max-width: 719px) {
  .wa-acciones .btn-ceo { min-height: 30px; font-size: 1.05rem; padding: .15rem .6rem; }
  .wa-sub { font-size: .95rem; } .wa-acciones .pill { font-size: .92rem; }
  .wa-atras, .wa-info { min-width: 32px; min-height: 32px; width: 32px; height: 32px; }
  .wa-simulacro { font-size: .85rem; }
}

/* === Cabecera del chat en 2 líneas, botones a la mitad (Miguel 21/11) === */
.wa-cabecera { grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; padding: .2rem .45rem; gap: 0 .35rem; }
.wa-atras { grid-column: 1; grid-row: 1; } .wa-quien { grid-column: 2; grid-row: 1; }
.wa-acciones { grid-column: 3; grid-row: 1; margin: 0; display: flex; gap: 4px; flex-wrap: nowrap; }
.wa-info { grid-column: 4; grid-row: 1; }
.wa-acciones .btn-ceo, .wa-acciones button.btn-ceo { min-height: 22px; height: 22px; padding: 0 8px; font-size: 11px; line-height: 1; border-radius: 11px; font-weight: 700; }
.wa-info, .wa-atras { width: 26px; height: 26px; min-width: 26px; min-height: 26px; font-size: 13px; border-radius: 8px; padding: 0; }
.wa-sub { gap: 4px; }
.wa-sub .pill, .wa-acciones .pill { font-size: 10px; padding: 1px 7px; }
.pill.reg { background: #dcfce7; color: #166534; } .pill.noreg { background: #fee2e2; color: #991b1b; }
.wa-sub .wa-resp { font-size: 10px; }
.wa-simulacro { padding: 1px 8px; font-size: 10px; }
@media (min-width: 768px) {
  .wa-cabecera { grid-template-columns: minmax(0,1fr) auto auto; }
  .wa-quien { grid-column: 1; } .wa-acciones { grid-column: 2; } .wa-info { grid-column: 3; }
  .wa-acciones .btn-ceo { min-height: 24px; height: 24px; font-size: 12px; padding: 0 10px; }
  .wa-sub .pill { font-size: 11px; }
}
@media (min-width: 1500px) { .wa-cabecera { grid-template-columns: minmax(0,1fr) auto; } }

/* === Cabecera del chat: +15 % y todo integrado (Miguel 21/11) === */
.wa-cabecera { padding: .25rem .5rem; gap: 0 .4rem; background: #f0f2f5; }
.wa-acciones { gap: 5px; align-items: center; }
.wa-acciones .btn-ceo, .wa-acciones button.btn-ceo { min-height: 25px; height: 25px; padding: 0 10px; font-size: 12.5px; border-radius: 13px; box-shadow: none; }
.wa-info, .wa-atras { width: 30px; height: 30px; min-width: 30px; min-height: 30px; font-size: 15px; border-radius: 15px; background: #fff; border: 1px solid #d5dae1; }
.wa-quien h1 { font-size: 1.05rem; }
.wa-sub { gap: 5px; margin-top: 1px; }
.wa-sub .pill, .wa-acciones .pill { font-size: 11.5px; padding: 1px 8px; line-height: 1.35; }
.wa-sub .wa-resp { font-size: 11.5px; }
.wa-simulacro { padding: 2px 10px; font-size: 11.5px; }
@media (min-width: 768px) {
  .wa-acciones .btn-ceo, .wa-acciones button.btn-ceo { min-height: 28px; height: 28px; font-size: 13.5px; padding: 0 12px; border-radius: 14px; }
  .wa-sub .pill { font-size: 12.5px; } .wa-sub .wa-resp { font-size: 12.5px; }
}

/* === «Redactar con IA» (orden #016): panel plegable sobre la barra de escribir; no empuja la conversacion (scroll propio, max 34 % de la pantalla) === */
.wa-icono.activo { cursor: pointer; opacity: 1; border-color: #7c3aed; color: #6d28d9; background: #f5f3ff; }
.wa-icono.activo[aria-expanded="true"] { background: #ede9fe; }
.wa-redactar { background: #fff; border: 1px solid #c4b5fd; border-radius: 12px; padding: .4rem .5rem; margin-bottom: .4rem; max-height: 34vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wa-redactar[hidden], .wa-redactar [hidden] { display: none !important; }
.wa-redactar-t { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .2rem; }
.wa-redactar textarea { width: 100%; box-sizing: border-box; font-size: 16px; line-height: 1.35; resize: none; border-radius: 10px; }
.wa-redactar-acc { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .3rem; }
.wa-redactar-acc .btn-ceo { min-height: 32px; padding: .2rem .7rem; border-radius: 16px; font-size: .9rem; }
.wa-redactar-n { margin-left: auto; font-size: .78rem; }
.wa-verificar { margin: .35rem 0 0; padding: .3rem .5rem .3rem 1.4rem; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; font-size: .85rem; }
.wa-verificar::before { content: "Confirma antes de enviar:"; display: block; margin-left: -.9rem; font-weight: 600; }
.wa-redactar-nota { margin: .25rem 0 0; font-size: .76rem; }
@media (max-width: 719px) {
  .wa-redactar { max-height: 30vh; padding: .3rem .4rem; }
  .wa-redactar-acc .btn-ceo { min-height: 30px; font-size: 1.05rem; padding: .15rem .6rem; }
  .wa-redactar-t, .wa-verificar { font-size: 1rem; } .wa-redactar-nota, .wa-redactar-n { font-size: .9rem; }
}

/* === Adjuntos del chat (orden #017): miniatura, audio, tarjeta y visor a pantalla completa === */
.adj-img { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; max-width: 100%; }
.adj-img img { display: block; max-width: min(260px, 100%); max-height: 240px; border-radius: 8px; object-fit: cover; background: #e5e7eb; min-width: 80px; min-height: 60px; }
.adj-audio { display: block; width: min(260px, 100%); height: 36px; }
.adj-card { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit; text-decoration: none; cursor: pointer; font: inherit; font-size: .9rem; min-height: 32px; }
.burbuja .adj-card { max-width: 100%; }
.visor { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.88); display: flex; flex-direction: column; }
.visor[hidden] { display: none !important; }
.visor-barra { display: flex; justify-content: flex-end; gap: .5rem; padding: .5rem .7rem; }
.visor-barra .btn-ceo { min-height: 32px; padding: .25rem .8rem; }
.visor-cuerpo { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; color: #fff; padding: .3rem; }
.visor-cuerpo img, .visor-cuerpo video { max-width: 100%; max-height: 100%; object-fit: contain; }
body.visor-abierto { overflow: hidden; }
@media (max-width: 719px) { .adj-card { font-size: 1rem; } .adj-img img { max-width: min(220px, 100%); } }

/* === 📎 Adjuntar (orden #017): hoja desplegable pequeña, vista previa y producto del catalogo; paneles con scroll propio para no tapar la conversacion === */
.wa-hoja { display: flex; flex-wrap: wrap; gap: .35rem; background: #fff; border: 1px solid #cbd5e1; border-radius: 12px; padding: .35rem; margin-bottom: .4rem; }
.wa-hoja[hidden], .wa-panel[hidden] { display: none !important; }
.wa-hoja button { flex: 1 1 auto; min-height: 34px; border: 1px solid #cbd5e1; border-radius: 16px; background: #f8fafc; padding: .25rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; }
.wa-panel { background: #fff; border: 1px solid #94a3b8; border-radius: 12px; padding: .4rem .5rem; margin-bottom: .4rem; max-height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wa-panel [hidden] { display: none !important; }
.wa-panel-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; }
.wa-x { border: 0; background: none; font-size: 1.1rem; cursor: pointer; min-width: 32px; min-height: 32px; }
.wa-panel textarea, .wa-panel input[type=search], .wa-panel select { width: 100%; box-sizing: border-box; font-size: 16px; border-radius: 10px; }
.wa-previa img { display: block; max-width: 100%; max-height: 22vh; border-radius: 8px; object-fit: contain; margin-bottom: .3rem; }
.wa-prod-busca { display: flex; gap: .35rem; margin-bottom: .3rem; } .wa-prod-busca input { flex: 1 1 auto; } .wa-prod-busca select { flex: 0 0 auto; width: auto; }
.wa-prod-lista { list-style: none; margin: 0 0 .3rem; padding: 0; }
.wa-prod-lista li { border-bottom: 1px solid #e2e8f0; }
.wa-prod-lista label { display: flex; align-items: center; gap: .5rem; padding: .3rem .1rem; cursor: pointer; }
.wa-prod-lista img, .wa-prod-lista .sin-foto { flex: none; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #e5e7eb; font-size: .65rem; display: inline-flex; align-items: center; justify-content: center; color: #64748b; }
.wa-prod-lista .tx { display: flex; flex-direction: column; min-width: 0; } .wa-prod-lista small { color: #64748b; }
.wa-prod-item { border-bottom: 1px solid #e2e8f0; padding: .3rem 0; } .wa-prod-item img { display: block; max-height: 16vh; border-radius: 8px; margin: .2rem 0; }
@media (max-width: 719px) { .wa-hoja button { font-size: 1rem; } .wa-panel { max-height: 38vh; padding: .3rem .4rem; } }

/* === Inventario del portal (orden #018): contadores de faltantes, miniaturas y fotos === */
.inv-faltan { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; padding: .4rem .6rem; margin: .4rem 0; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; font-size: .9rem; }
.inv-faltan a { text-decoration: none; padding: .1rem .5rem; border-radius: 12px; background: #fff; border: 1px solid #fcd34d; color: inherit; } .inv-faltan a.on { background: #fde68a; font-weight: 600; }
.inv-pend { color: #b45309; font-weight: 600; } .inv-mini { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; vertical-align: middle; background: #e5e7eb; }
.inv-fotos { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .5rem; } .inv-fotos figure { margin: 0; width: 150px; } .inv-fotos img { width: 150px; height: 110px; object-fit: cover; border-radius: 8px; background: #e5e7eb; }
.inv-fotos figcaption { font-size: .8rem; } .chk { display: flex; align-items: center; gap: .4rem; }
@media (max-width: 719px) { .inv-faltan { font-size: 1rem; } .inv-fotos figure, .inv-fotos img { width: 120px; } .inv-fotos img { height: 90px; } }
