/* Panel de control Motofalca (estilo AsistentePro) */
.panel {
  --fondo: #f4f5f7; --borde: #e6e8eb; --texto-2: #5b6068; --texto-3: #8b9098;
  --c-dentro: #9aa1ab; --c-fuera: #eb0a1e; --c-bar: #2b2e33;
  background: var(--fondo); display: grid; grid-template-columns: 250px 1fr; min-height: 100dvh; font-size: 14px;
}
.hide-sm { }
.side { background: #111214; color: #c9ccd1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 18px 14px; gap: 18px; z-index: 50; }
.side-logo { background: #fff; border-radius: 12px; padding: 10px 12px; }
.side-logo img { height: 36px; width: auto; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav button { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #c9ccd1; text-align: left; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500; }
.side-nav button span { width: 22px; text-align: center; }
.side-nav button:hover { background: #1d1f23; color: #fff; }
.side-nav button.on { background: var(--rojo); color: #fff; }
.pill { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: #fff; color: var(--rojo); border-radius: 99px; padding: 1px 7px; }
.pill:empty { display: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.side-foot a, .side-foot .link { color: #9aa0a8; text-decoration: none; background: none; border: 0; padding: 0; text-align: left; font-size: 13px; }
.side-foot a:hover, .side-foot .link:hover { color: #fff; }
.side-foot .powered { color: #7c8189; margin-top: 6px; } .side-foot .powered b { color: #c4b5fd; }
.ia-on { display: flex; align-items: center; gap: 8px; background: #0f2a1b; color: #6ee7a0; padding: 8px 10px; border-radius: 10px; font-weight: 600; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: live 1.6s infinite; flex: none; display: inline-block; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

.main { min-width: 0; padding: 0 28px 40px; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 0; position: sticky; top: 0; background: var(--fondo); z-index: 30; }
.top h1 { font-family: var(--fuente-tit); font-size: 28px; margin: 0; line-height: 1.1; }
.top small { color: var(--texto-2); }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.live { display: inline-flex; align-items: center; gap: 7px; background: #e8f8ee; color: #137a3c; font-weight: 600; font-size: 12.5px; padding: 6px 11px; border-radius: 99px; }
.live.small { padding: 3px 9px; font-size: 11.5px; }
.user { display: flex; align-items: center; gap: 10px; }
.user > span { width: 38px; height: 38px; border-radius: 50%; background: var(--negro); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user div { display: flex; flex-direction: column; line-height: 1.2; } .user small { color: var(--texto-3); }
.burger-p { display: none; border: 0; background: #fff; border-radius: 10px; width: 40px; height: 40px; font-size: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.vista { display: none; flex-direction: column; gap: 18px; }
.vista.on { display: flex; animation: ari-in .25s; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.kpis-sm { grid-template-columns: repeat(4, 1fr); }
.kpi { background: #fff; border: 1px solid var(--borde); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi small { color: var(--texto-2); font-weight: 500; font-size: 12.5px; }
.kpi strong { font-family: var(--fuente-tit); font-size: 30px; line-height: 1.05; }
.kpi em { font-style: normal; font-size: 12px; color: var(--texto-3); }
.kpi em b { color: #137a3c; }
.kpi.flash { animation: flash 1.4s; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--rojo); } 100% { box-shadow: 0 0 0 0 transparent; } }
.kpi.hero { background: var(--negro); color: #fff; border-color: var(--negro); }
.kpi.hero small, .kpi.hero em { color: #aeb2b8; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.box { background: #fff; border: 1px solid var(--borde); border-radius: 16px; padding: 18px; min-width: 0; }
.box-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.box-h h3 { font-family: var(--fuente); font-size: 15px; font-weight: 700; margin: 0; }
.leyenda { display: flex; gap: 12px; font-size: 12px; color: var(--texto-2); }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.insight { margin: 10px 0 0; font-size: 13px; color: var(--texto-2); }
.insight b { color: var(--negro); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ax { font-size: 10.5px; fill: var(--texto-3); font-family: var(--fuente); }
.chart .grid-l { stroke: #eef0f2; }
.chart rect.b { transition: opacity .15s; }
.chart rect.hit { fill: transparent; cursor: crosshair; }

/* barras horizontales */
.hbar { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.hbar span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--texto-2); }
.hbar .track { height: 12px; border-radius: 4px; background: #f1f2f4; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--c-bar); transition: width .6s; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }
.embudo .fill { background: var(--rojo); }
.embudo .hbar:nth-child(n+2) .fill { opacity: .85; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 330px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start; padding: 10px; border-radius: 12px; background: #fafbfc; border: 1px solid var(--borde); font-size: 13px; }
.feed li.nuevo { animation: nuevo 2.5s; border-color: var(--rojo); }
@keyframes nuevo { 0% { background: #ffe8ea; transform: scale(1.02); } 100% { background: #fafbfc; transform: none; } }
.feed .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff; border: 1px solid var(--borde); font-size: 16px; }
.feed b { display: block; }
.feed small { color: var(--texto-3); white-space: nowrap; }
.feed p { margin: 0; color: var(--texto-2); }
.vacio { color: var(--texto-3); text-align: center; padding: 30px 10px; font-size: 13px; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #f1f2f4; color: var(--texto-2); white-space: nowrap; }
.chip.ia { background: #efe9ff; color: #5b21b6; }
.chip.caliente { background: #ffe4e6; color: #be123c; }
.chip.tibio { background: #fff4d6; color: #8a5a00; }
.chip.frio { background: #e0ecff; color: #1d4ed8; }
.chip.ventas { background: #fee2e2; color: #b91c1c; }
.chip.taller { background: #e0f2fe; color: #075985; }
.chip.ok { background: #dcfce7; color: #166534; }

/* conversaciones */
.conv { display: grid; grid-template-columns: 340px 1fr; background: #fff; border: 1px solid var(--borde); border-radius: 16px; overflow: hidden; height: calc(100dvh - 120px); min-height: 480px; }
.conv-lista { border-right: 1px solid var(--borde); display: flex; flex-direction: column; min-height: 0; }
.conv-filtros { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.conv-filtros button, .dias button { border: 1px solid var(--borde); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; }
.conv-filtros button.on, .dias button.on { background: var(--negro); color: #fff; border-color: var(--negro); }
#lista-conv { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#lista-conv li { padding: 12px 14px; border-bottom: 1px solid #f1f2f4; cursor: pointer; display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
#lista-conv li:hover { background: #fafbfc; }
#lista-conv li.on { background: #fff1f2; }
.av { width: 40px; height: 40px; border-radius: 50%; background: #e5e7eb; display: grid; place-items: center; font-weight: 700; color: var(--texto-2); font-size: 13px; position: relative; }
.av.vivo::after { content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
.cl-top { display: flex; justify-content: space-between; gap: 6px; }
.cl-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-top small { color: var(--texto-3); white-space: nowrap; }
.cl-msg { color: var(--texto-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 4px; }
.cl-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.conv-detalle { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.cd-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.cd-head div { flex: 1; min-width: 0; }
.cd-head small { color: var(--texto-3); display: block; }
.btn-p { border: 1px solid var(--borde); background: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 13px; }
.btn-p.rojo { background: var(--rojo); color: #fff; border-color: var(--rojo); }
.cd-msgs { flex: 1; overflow-y: auto; background: var(--wa-bg); padding: 16px; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
.cd-msgs .ari-b { max-width: 70%; }
.cd-resumen { padding: 12px 16px; border-top: 1px solid var(--borde); font-size: 13px; color: var(--texto-2); background: #fafbfc; }
.cd-resumen b { color: var(--negro); }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: #eceef1; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.col-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; padding: 2px 4px 4px; }
.col-h span { background: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--texto-2); }
.card-k { background: #fff; border-radius: 12px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 5px; font-size: 13px; border: 1px solid transparent; }
.card-k.nuevo { border-color: var(--rojo); animation: nuevo 2.5s; }
.card-k b { font-size: 14px; }
.card-k .m { color: var(--texto-2); }
.card-k .row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.card-k .row small { margin-left: auto; color: var(--texto-3); }
.kanban-taller { grid-auto-columns: minmax(200px, 1fr); }

/* agenda taller */
.dias { display: flex; gap: 6px; flex-wrap: wrap; }
.agenda-dia { display: grid; gap: 8px; }
.slot { display: grid; grid-template-columns: 86px 1fr; gap: 12px; align-items: stretch; }
.slot > time { font-weight: 700; font-variant-numeric: tabular-nums; padding-top: 10px; color: var(--texto-2); }
.slot-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.cita { flex: 1 1 220px; max-width: 360px; border-left: 4px solid var(--c-bar); background: #fafbfc; border-radius: 10px; padding: 9px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.cita.ia { border-left-color: #7c3aed; background: #f7f3ff; }
.cita.nuevo { animation: nuevo 2.5s; }
.cita .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.libre { flex: 1; border: 1px dashed var(--gris-3); border-radius: 10px; padding: 9px 12px; color: var(--texto-3); font-size: 13px; }

/* tablas */
.tabla-wrap { overflow-x: auto; }
.tabla-p { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla-p th { text-align: left; font-size: 12px; color: var(--texto-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla-p td { padding: 10px; border-bottom: 1px solid #f1f2f4; white-space: nowrap; }
.tabla-p td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-p img { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; }
.tabla-p .modelo { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.stock-bar { width: 80px; height: 6px; background: #f1f2f4; border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.stock-bar i { display: block; height: 100%; background: var(--c-bar); }

/* toasts y tooltip */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--negro); color: #fff; border-radius: 14px; padding: 12px 16px; box-shadow: var(--sombra-2); max-width: 340px; display: flex; gap: 10px; align-items: flex-start; animation: ari-in .25s; font-size: 13.5px; }
.toast b { display: block; }
.toast small { color: #aeb2b8; }
.tip { position: fixed; pointer-events: none; z-index: 120; background: var(--negro); color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 8px; opacity: 0; transition: opacity .1s; white-space: nowrap; }
.tip.on { opacity: 1; }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpis.kpis-sm { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .panel { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: .25s; box-shadow: var(--sombra-2); }
  .side.abierto { transform: none; }
  .burger-p { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .conv { grid-template-columns: 1fr; height: auto; }
  .conv-lista { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--borde); }
  .conv-detalle { height: 70dvh; }
}
@media (max-width: 640px) {
  .main { padding: 0 12px 30px; }
  .hide-sm { display: none !important; }
  .top h1 { font-size: 22px; }
  .kpis, .kpis.kpis-sm { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi strong { font-size: 24px; }
  .hbar { grid-template-columns: 96px 1fr 36px; }
  .slot { grid-template-columns: 64px 1fr; }
  .cd-msgs .ari-b { max-width: 88%; }
  .live:not(.small) { display: none; }
}

/* íconos */
.side-nav button span { display: grid; place-items: center; }
.side-nav button .ico { width: 19px; height: 19px; }
.side-foot .ico { width: 14px; height: 14px; }
.burger-p { display: none; place-items: center; }
.burger-p .ico { width: 20px; height: 20px; }
.feed .ic { color: var(--gris-9); }
.feed .ic .ico { width: 18px; height: 18px; }
.toast .t-ic { width: 34px; height: 34px; border-radius: 10px; background: #2b2e33; display: grid; place-items: center; flex: none; color: #fff; }
.toast .t-ic .ico { width: 18px; height: 18px; }
.chip .ico { width: 12px; height: 12px; vertical-align: -1px; }
.card-k .m .ico, .cd-resumen .ico { width: 14px; height: 14px; color: var(--texto-2); }
.cd-resumen .ico { color: #6d28d9; }
@media (max-width: 980px) { .burger-p { display: grid; } }

/* créditos */
.grid-cr { grid-template-columns: 1.6fr 1fr; align-items: start; }
.tabla-cr tr[data-id] { cursor: pointer; }
.tabla-cr tr[data-id]:hover td { background: #fafbfc; }
.tabla-cr tr.sel td { background: #fff1f2; }
.tabla-cr tr.nuevo td, .tabla-p tr.nuevo td { animation: nuevo 2.5s; }
.tabla-cr td small { color: var(--texto-3); }
.score { width: 90px; height: 7px; border-radius: 4px; background: #eef0f2; overflow: hidden; }
.score i { display: block; height: 100%; background: linear-gradient(90deg, #f2a100, #1faa59); border-radius: 4px; }
.score.grande { width: 100%; height: 10px; }
.cr-score { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cr-score strong { font-family: var(--fuente-tit); font-size: 44px; line-height: 1; }
.cr-score > div { flex: 1; }
.cr-score small { color: var(--texto-3); font-size: 12px; }
.cr-datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 13.5px; }
.cr-datos dt { color: var(--texto-2); } .cr-datos dd { margin: 0; font-weight: 600; text-align: right; }
.cr-factores { list-style: none; margin: 0 0 10px; padding: 12px 0 0; border-top: 1px solid var(--borde); display: grid; gap: 6px; font-size: 13px; }
.cr-factores li { display: flex; gap: 8px; align-items: flex-start; }
.cr-factores li .ico { width: 15px; height: 15px; margin-top: 2px; }
.cr-factores li.si { color: #137a3c; } .cr-factores li.no { color: #9a6700; }

/* toma humana */
.cd-msgs .ari-b.equipo { background: #ffedd5; }
.cd-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--borde); background: #fff; }
.cd-form input { flex: 1; min-width: 0; border: 1px solid var(--borde); border-radius: 10px; padding: 10px 12px; font: inherit; }
.chip.ok { background: #dcfce7; color: #166534; }

/* automatizaciones */
.autos { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.auto { background: #fff; border: 1px solid var(--borde); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.auto-h { display: flex; gap: 10px; align-items: flex-start; }
.auto-h div { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.auto-h small { color: var(--texto-3); font-size: 12px; }
.auto-ic { width: 36px; height: 36px; border-radius: 10px; background: #fff1f2; color: var(--rojo); display: grid; place-items: center; flex: none; }
.auto-ic .ico { width: 18px; height: 18px; }
.auto-msg { background: var(--wa-bg); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.auto-msg .ari-b { max-width: 100%; font-size: 13px; }
.auto-n { color: var(--texto-2); font-size: 12px; font-weight: 600; }
.sw { position: relative; width: 38px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw i { position: absolute; inset: 0; border-radius: 99px; background: #d7dade; cursor: pointer; transition: .2s; }
.sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.sw input:checked + i { background: #1faa59; }
.sw input:checked + i::after { transform: translateX(16px); }
.sw input:focus-visible + i { outline: 2px solid var(--azul); outline-offset: 2px; }
@media (max-width: 1280px) { .grid-cr { grid-template-columns: 1fr; } }
