/* ===== Tokens (paleta validada dataviz) ===== */
:root, .viz-root {
  --surface-0: #f4f4f1;
  --surface-1: #fcfcfb;      /* card */
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a8a85;
  --border: #e6e6e2;
  --border-soft: #efefec;
  --received: #2a78d6;       /* serie 1 azul */
  --sent: #eb6834;           /* serie 2 naranja */
  --grid: #ececE8;
  --good: #1a8f5f;
}
:root[data-theme="dark"], .viz-root[data-theme="dark"] {
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8f86;
  --border: #33332f;
  --border-soft: #262622;
  --received: #3987e5;
  --sent: #d95926;
  --grid: #2a2a26;
  --good: #34d399;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]), .viz-root:not([data-theme="light"]) {
    --surface-0: #111110; --surface-1: #1a1a19; --text-primary: #fff; --text-secondary: #c3c2b7;
    --text-muted: #8f8f86; --border: #33332f; --border-soft: #262622; --received: #3987e5; --sent: #d95926; --grid: #2a2a26; --good: #34d399;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, system-ui, sans-serif; background: var(--surface-0); color: var(--text-primary); -webkit-font-smoothing: antialiased; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface-1); position: sticky; top: 0; z-index: 10;
}
.top__title { display: flex; align-items: center; gap: 12px; }
.top__logo { width: 46px; height: 46px; border-radius: 12px; background: var(--surface-0); display: grid; place-items: center; font-size: 23px; }
.top h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.top__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.top__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* conmutador entre plataformas */
.platsw { display: inline-flex; gap: 4px; background: var(--surface-0); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.platsw__it { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); border-radius: 7px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.platsw__it:hover { background: var(--surface-1); color: var(--text-primary); }
.platsw__it--on { background: var(--accent, #4c8bf5); color: #fff; cursor: default; }
.platsw__it--on:hover { background: var(--accent, #4c8bf5); color: #fff; }
.platsw__ic { font-size: 14px; }
.segmented { display: inline-flex; background: var(--surface-0); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg { padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); border-radius: 7px; cursor: pointer; border: none; background: none; }
.seg--active { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); cursor: pointer; font-size: 16px; }
.icon-btn:hover { color: var(--text-primary); }

.daterange { display: inline-flex; align-items: center; gap: 6px; }
.date-input { padding: 6px 9px; font-size: 12.5px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); color-scheme: light dark; }
.date-input:focus { outline: none; border-color: var(--sent); }
.date-sep { color: var(--text-muted); font-size: 12px; }
.date-btn { padding: 6px 11px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); cursor: pointer; }
.date-btn:hover { background: var(--surface-0); }
.date-btn--clear { padding: 6px 9px; color: var(--text-muted); }

.wrap { max-width: 1560px; margin: 0 auto; padding: 30px clamp(20px, 3vw, 48px); display: flex; flex-direction: column; gap: 26px; }

/* ===== KPIs ===== */
.kpis { display: grid; grid-template-columns: repeat(20, 1fr); gap: 18px; }
.kpi { grid-column: span 4; background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 22px 22px 20px; text-align: center; }
.kpi:nth-last-child(-n+4) { grid-column: span 5; } /* fila de abajo: 4 tarjetas, alineadas al ancho */
/* 7 KPIs (sin costes, cuando no eres super_admin): 4 arriba / 3 abajo */
.kpis--7 { grid-template-columns: repeat(12, 1fr); }
.kpis--7 .kpi { grid-column: span 3; }
.kpis--7 .kpi:nth-last-child(-n+4) { grid-column: span 3; }
.kpis--7 .kpi:nth-last-child(-n+3) { grid-column: span 4; }
/* Vista resumida: 5 tarjetas en una sola fila */
.kpis--5 { grid-template-columns: repeat(5, 1fr); }
.kpis--5 .kpi, .kpis--5 .kpi:nth-last-child(-n+4) { grid-column: auto; }
/* Toggle Detallado / Resumido, alineado a la derecha sobre los KPIs */
.kpiview { display: flex; justify-content: flex-end; margin-bottom: 14px; }
/* Tiempo de run por día: selector de día + panel de detalle */
.exec__headline { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.exec__head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.exec__daysel { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.exec__daysel select { font: inherit; font-size: 12.5px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text); cursor: pointer; }
.exec__detail { margin: 4px 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); }
.exec__dtitle { font-size: 13.5px; margin-bottom: 10px; color: var(--text); }
.exec__drow { display: flex; flex-wrap: wrap; gap: 20px; }
.exec__d { display: flex; flex-direction: column; gap: 2px; }
.exec__dv { font-size: 20px; font-weight: 700; color: var(--text); }
.exec__dl { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.exec__franja { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); margin: 2px 0 12px; }
.exec__hsel { font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text); cursor: pointer; }
.exec__reset { font: inherit; font-size: 11.5px; padding: 4px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text); cursor: pointer; margin-left: 4px; }
.exec__reset:hover { border-color: var(--brand, #2f6df6); color: var(--brand, #2f6df6); }
@media (max-width: 1100px) {
  .kpis, .kpis--7, .kpis--5 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .kpi, .kpi:nth-last-child(-n+4), .kpis--7 .kpi, .kpis--7 .kpi:nth-last-child(-n+3), .kpis--5 .kpi { grid-column: auto; }
}
/* ocultar la columna "Coste IA" (9ª) cuando no eres super_admin */
.msgs--nocost th:nth-child(9), .msgs--nocost td:nth-child(9) { display: none; }
/* ocultar la columna "Modelo" (8ª) — dato interno, solo super_admin */
.msgs--nomodel th:nth-child(8), .msgs--nomodel td:nth-child(8) { display: none; }
/* ocultar la columna "Ganancia" (11ª) cuando no eres super_admin */
.msgs--nomargin th:nth-child(12), .msgs--nomargin td:nth-child(12) { display: none; }
.msgs--noreal .col-real { display: none; }   /* Coste real (n8n): solo super admin */
/* Llamadas: ocultar la columna "Coste" (6ª) — dato interno, solo super_admin */
.calls--nocost th:nth-child(6), .calls--nocost td:nth-child(6) { display: none; }
.msgs__gain { color: var(--ok, #16a34a); font-weight: 700; }
.msgs__loss { color: var(--danger, #dc2626); font-weight: 700; }
/* recap de ganancia/pérdida del rango (solo super_admin) */
.msgs-recap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 4px 0 14px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); font-size: 13px; }
.msgs-recap__tag { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: #d9a400; padding: 2px 7px; border-radius: 5px; }
.msgs-recap__item { color: var(--text-secondary); }
.msgs-recap__item b { color: var(--text-muted); font-weight: 600; margin-right: 4px; }
.msgs-recap__net { margin-left: auto; font-size: 14px; }
.msgs-recap__net b { color: inherit; }
.msgs-recap__pct { font-weight: 800; }
.msgs-recap__break { flex-basis: 100%; height: 0; }   /* salto a la línea del coste real */
/* ajustes: porcentajes con nombre (solo super_admin) */
.pct__tag { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: #d9a400; padding: 2px 7px; border-radius: 5px; }
.pct__input { width: 110px; padding: 9px 11px; font-size: 15px; font-weight: 600; text-align: right; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text); }
.pct__input:focus { outline: none; border-color: var(--accent, #4c8bf5); }
.pct__sign { font-size: 15px; font-weight: 700; color: var(--text-muted); margin-left: -4px; }
.pct__name { flex: 1; min-width: 140px; padding: 9px 11px; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text); }
.pct__name:focus { outline: none; border-color: var(--accent, #4c8bf5); }
.pct__list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pct__item-del { width: 30px; height: 30px; border-radius: 8px; color: var(--text-muted); font-size: 15px; cursor: pointer; background: transparent; border: 0; flex-shrink: 0; }
.pct__item-del:hover { background: rgba(220,38,38,.15); color: #f87171; }
.pct__add { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--border); }
.pct__addbtn { margin-left: 2px; }
/* acordeón de agentes → modelos */
.ag-item { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); overflow: hidden; }
.ag-item--open { border-color: var(--accent, #4c8bf5); }
.ag-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px; cursor: pointer; user-select: none; }
.ag-head:hover { background: var(--surface-2, rgba(255,255,255,.02)); }
.ag-caret { width: 16px; color: var(--text-muted); font-size: 12px; }
.ag-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-count { font-size: 11.5px; color: var(--text-muted); background: var(--input-bg, #14161b); border: 1px solid var(--border); padding: 2px 8px; border-radius: 20px; }
.ag-body { padding: 4px 12px 12px 38px; }
.md-list { display: flex; flex-direction: column; gap: 7px; }
.md-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--input-bg, #14161b); }
.md-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-add { display: flex; align-items: center; gap: 9px; margin-top: 9px; padding-top: 10px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.md-add .pct__name { flex: 1 1 140px; }
.md-field { display: inline-flex; align-items: center; gap: 5px; }
.md-field .pct__input { width: 92px; }
.md-coste, .md-new-coste { width: 92px; }
.md-cur { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.msgs__human { color: var(--sent); font-weight: 600; }
.kpi__label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; justify-content: center; gap: 7px; }
.kpi__dot { width: 9px; height: 9px; border-radius: 50%; }
.kpi__value { font-size: 42px; font-weight: 800; letter-spacing: -.02em; margin-top: 12px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi--sm .kpi__value { font-size: 23px; line-height: 1.2; }
.kpi__trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.kpi__trio .kpi__value { font-size: 30px; margin-top: 0; }
.kpi__trio-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.kpis--5 .kpi--trio .kpi__value { font-size: 24px; }
.kpi__sub { font-size: 13.5px; color: var(--text-secondary); margin-top: 9px; }
.kpi--muted .kpi__value { color: var(--text-muted); font-size: 26px; font-weight: 700; }

/* ===== Cards ===== */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card__head h2 { font-size: 17px; font-weight: 700; }
.card__note { font-size: 12.5px; color: var(--text-muted); margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.axis { fill: var(--text-muted); font-size: 10.5px; font-weight: 500; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--border); stroke-width: 1; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.chart .enddot { stroke: var(--surface-1); stroke-width: 2; }
.dlabel { font-size: 11px; font-weight: 700; }

/* barras de tipos */
.typebars { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.tbar { display: grid; grid-template-columns: 90px 1fr 46px; align-items: center; gap: 10px; font-size: 12.5px; }
.tbar__name { color: var(--text-secondary); font-weight: 600; text-transform: capitalize; }
.tbar__track { height: 12px; border-radius: 6px; background: var(--surface-0); overflow: hidden; }
.tbar__fill { height: 100%; border-radius: 6px; background: var(--sent); }
.tbar__val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ===== Pestañas ===== */
.tabs { display: flex; gap: 4px; max-width: 1560px; margin: 0 auto; width: 100%; padding: 18px clamp(20px, 3vw, 48px) 0; border-bottom: 1px solid var(--border); }
.tab { padding: 11px 20px; font-size: 14.5px; font-weight: 600; color: var(--text-secondary); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; border-radius: 8px 8px 0 0; }
.tab:hover { color: var(--text-primary); background: var(--surface-1); }
.tab--active { color: var(--text-primary); border-bottom-color: var(--sent); }
.tabpanel { display: flex; flex-direction: column; gap: 26px; }
.tabpanel[hidden] { display: none; }

/* ===== Tabla de mensajes detallados ===== */
.tablewrap { overflow-x: auto; margin: 0 -4px; }
table.msgs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.msgs thead th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface-1); }
.msgs th.num { text-align: right; }
.msgs td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.msgs td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msgs td.nowrap { white-space: nowrap; color: var(--text-secondary); }
.msgs td.cap { text-transform: capitalize; }
.msgs td.dim, .msgs .dim { color: var(--text-muted); }
.msgs tbody tr:hover td { background: var(--surface-0); }
.msgs__text { max-width: 520px; color: var(--text-secondary); line-height: 1.45; }
.msgs__empty { text-align: center; color: var(--text-muted); padding: 28px 14px; }

/* vista emparejada: entrante (cliente) + respuesta (bot) en la misma fila */
.msgs--pairs th:nth-child(2), .msgs--pairs th:nth-child(3),
.msgs--pairs td.msgs__in, .msgs--pairs td.msgs__out { width: 34%; }
.msgs--pairs td.msgs__in { border-left: 3px solid var(--received); }
.msgs--pairs td.msgs__out { border-left: 3px solid var(--sent); }
.msgs--pairs td.msgs__in .msgs__text { color: var(--text-primary); }
.msgs--pairs .msgs__text { max-width: 420px; display: block; }

.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.pager__btns { display: flex; align-items: center; gap: 10px; }
.pager__n { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pgbtn { padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.pgbtn:hover:not(:disabled) { background: var(--surface-0); }
.pgbtn:disabled { opacity: .45; cursor: default; }

.search-input { padding: 9px 13px; font-size: 13.5px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); color: var(--text-primary); min-width: 260px; }
.search-input:focus { outline: none; border-color: var(--sent); }
.search-input::placeholder { color: var(--text-muted); }
.msgs__name { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* selector de canal */
.chan-select { padding: 9px 12px; font-size: 13.5px; font-weight: 600; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); color: var(--text-primary); cursor: pointer; }
.chan-select:focus { outline: none; border-color: var(--sent); }

/* chip de canal en la tabla */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.chip--whatsapp   { color: #1f7a4d; background: rgba(37, 211, 102, .13); border-color: rgba(37, 211, 102, .30); }
.chip--instagram  { color: #a12a72; background: rgba(214, 41, 118, .12); border-color: rgba(214, 41, 118, .28); }
.chip--facebook   { color: #1554b8; background: rgba(24, 119, 242, .12); border-color: rgba(24, 119, 242, .28); }
.chip--pagina_web { color: #5c5f66; background: rgba(120, 124, 135, .14); border-color: rgba(120, 124, 135, .30); }
[data-theme="dark"] .chip--whatsapp   { color: #57e08c; }
[data-theme="dark"] .chip--instagram  { color: #f472b6; }
[data-theme="dark"] .chip--facebook   { color: #7ab3ff; }
[data-theme="dark"] .chip--pagina_web { color: #b3b7c0; }

/* ===== Pipeline / Tablero Kanban ===== */
.board__controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.board {
  display: flex; gap: 14px; align-items: stretch;
  height: calc(100vh - 300px); min-height: 460px;
  overflow-x: auto; overflow-y: hidden; padding: 4px; cursor: grab;
  scrollbar-width: none; -ms-overflow-style: none;   /* Firefox / IE: sin barra */
}
.board::-webkit-scrollbar { width: 0; height: 0; display: none; }  /* WebKit: sin barra */
.board--panning { cursor: grabbing; user-select: none; }
.board--panning .oppcard { pointer-events: none; }
.board__err { color: var(--text-muted); padding: 24px; }

.col { flex: 0 0 300px; width: 300px; height: 100%; background: var(--surface-0); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; }
.col--over { outline: 2px dashed var(--sent); outline-offset: -2px; }
.col__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 700; font-size: 13.5px; }
.col__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--stage, #888); flex: none; }
.col__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col__count { font-size: 12px; font-weight: 700; color: var(--text-secondary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; flex: none; }
.col__sum { font-size: 11.5px; font-weight: 600; color: var(--text-muted); padding: 0 14px 8px; font-variant-numeric: tabular-nums; }
.col__sum--empty { padding: 0 14px 4px; }
.col__body { flex: 1; overflow-y: auto; padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; scrollbar-width: none; -ms-overflow-style: none; }
.col__body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.col__empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 10px 0; }

.oppcard { background: var(--surface-1); border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; cursor: grab; transition: box-shadow .12s, border-color .12s; }
.oppcard:hover { border-color: var(--sent); box-shadow: 0 2px 10px rgba(0,0,0,.07); }
.oppcard:active { cursor: grabbing; }
.oppcard--dragging { opacity: .45; }
.oppcard__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.oppcard__title { font-weight: 600; font-size: 13.5px; line-height: 1.3; color: var(--text-primary); }
.oppcard__chan { flex: none; }
.oppcard__quote { margin-top: 7px; font-size: 12px; font-weight: 600; color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); border-radius: 7px; padding: 3px 8px; display: inline-block; }
.oppcard__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.oppcard__phone { font-variant-numeric: tabular-nums; }

/* ===== Pestaña Cotizaciones ===== */
/* recap del rango: monto total, nº de cotizaciones y productos */
.quo__recap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 4px 0 20px; }
.quo__recap[hidden] { display: none; }
.quo__stat { background: var(--surface-0); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.quo__stat-val { font-size: 26px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.quo__stat-lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 4px; }
.quo__stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.quo__stat:first-child .quo__stat-val { color: var(--good); }
@media (max-width: 720px) { .quo__recap { grid-template-columns: 1fr; } }

/* ===== Pestaña Llamadas: desglose por agente y detalle ===== */
.call__agents { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; }
.call__agents-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-right: 2px; }
.call__agent { display: inline-flex; align-items: baseline; gap: 6px; background: var(--surface-0); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; }
.call__rec { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.call__rec audio { height: 34px; max-width: 340px; }
.call__transcript-lbl { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.call__transcript { font-size: 13px; line-height: 1.55; color: var(--text-secondary); white-space: pre-wrap; max-height: 340px; overflow-y: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
/* Detalle de coste (texto): solo lo recibe el super_admin desde el backend. */
.call__costdet { margin-bottom: 14px; background: rgba(234,179,8,.08); border: 1px solid rgba(234,179,8,.35); border-radius: 10px; padding: 12px 14px; }
.call__costdet-lbl { font-size: 11.5px; font-weight: 700; color: #b7860b; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.call__costdet-tag { font-size: 9.5px; font-weight: 800; color: #fff; background: #d9a400; padding: 1px 6px; border-radius: 5px; letter-spacing: .02em; text-transform: none; }
.call__costdet-txt { font-size: 13px; line-height: 1.55; color: var(--text-secondary); white-space: pre-wrap; }

/* fila desplegable con los productos */
.quotes .quo__exp { width: 30px; text-align: center; }
.quo__row { cursor: pointer; }
.quo__row:hover { background: var(--surface-2, rgba(127,127,127,.06)); }
.quo__caret { color: var(--text-muted); font-size: 11px; }
.quo__row--open { background: var(--surface-2, rgba(127,127,127,.06)); }
.quo__row--open .quo__caret { color: var(--text-primary); }
.quo__sent { color: var(--good); font-weight: 600; }

.quo__detail > td { padding: 0 !important; background: var(--surface-0); }
.quo__panel { padding: 14px 18px 16px; border-left: 3px solid var(--accent, #6366f1); }
.quo__loading, .quo__err { padding: 14px 18px; color: var(--text-muted); }
.quo__err { color: var(--bad, #ef4444); }
.quo__meta { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.quo__notes { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }

.quo__lines { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.quo__lines th, .quo__lines td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.quo__lines th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.quo__lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.quo__lines tbody tr:last-child td { border-bottom: none; }
.quo__lines tfoot td { border-top: 2px solid var(--border); border-bottom: none; padding-top: 9px; }

/* ===== Ajustes: agente de llamadas ===== */
.ag__now { display: flex; flex-wrap: wrap; gap: 28px; padding: 14px 16px; margin-bottom: 18px;
  background: var(--surface-0); border: 1px solid var(--border); border-radius: 12px; }
.ag__now-lbl { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ag__now-val { font-size: 15px; font-weight: 600; margin-top: 3px; }
.ag__field { margin-bottom: 14px; max-width: 460px; }
.ag__field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.ag__field select { width: 100%; }
.ag__actions { display: flex; align-items: center; gap: 12px; }
.ag__save { font-weight: 600; }
.ag__save:disabled { opacity: .55; cursor: not-allowed; }
.ag__msg { font-size: 13px; }
.ag__msg--ok { color: var(--good); }
.ag__msg--err { color: var(--bad, #ef4444); }
.ag__err { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-0); color: var(--bad, #ef4444); font-size: 13.5px; }

/* ===== Modal de oportunidad (título, canal, fecha, PDF preview) ===== */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal__box { position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 880px; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal__close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-0); color: var(--text-secondary); cursor: pointer; font-size: 15px; z-index: 1; }
.modal__close:hover { color: var(--text-primary); }
.q__loading { color: var(--text-muted); padding: 18px 0; }
.q__head { margin-bottom: 16px; padding-right: 34px; }
.q__num { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.q__client { font-size: 21px; font-weight: 800; margin-top: 3px; letter-spacing: -.01em; line-height: 1.2; }
.q__dim { color: var(--text-muted); }

/* Datos listados en el cuerpo */
.q__fields { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.q__field { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--border-soft); }
.q__field dt { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.q__field dd { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }

/* Tarjeta de adjunto PDF */
.q__attach { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 13px; padding: 14px 16px; background: var(--surface-0); }
.q__file { display: flex; align-items: center; gap: 13px; min-width: 0; }
.q__fileicon { width: 42px; height: 42px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--border); display: grid; place-items: center; font-size: 20px; flex: none; }
.q__filename { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q__filemeta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.q__fileactions { display: flex; align-items: center; gap: 8px; flex: none; }
.q__btn { font-size: 13px; font-weight: 700; border-radius: 9px; padding: 8px 14px; cursor: pointer; text-decoration: none; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.q__btn:hover { background: var(--surface-0); }
.q__btn--dl { background: var(--sent); color: #fff; border-color: transparent; }
.q__btn--dl:hover { filter: brightness(1.05); background: var(--sent); }
.quo__del { margin-left: 6px; color: #dc2626; border-color: rgba(220,38,38,.4); }
.quo__del:hover { background: #dc2626; color: #fff; border-color: transparent; }

/* Popup interno de vista previa del PDF */
.modal--viewer { z-index: 70; padding: 24px 16px; }
.modal__box--viewer { max-width: 1000px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.viewer__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.viewer__name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.viewer__actions .modal__close { position: static; }
.viewer__frame { display: block; width: 100%; height: 80vh; border: 0; background: #fff; }
.modal__box--pagos { max-width: 560px; }
.pagos__frame { display: block; width: 100%; height: 620px; max-height: calc(100vh - 110px); border: 0; }

/* tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); min-width: 120px;
}
.tip__t { font-weight: 700; margin-bottom: 5px; }
.tip__r { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tip__r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tip__r b { font-variant-numeric: tabular-nums; }

/* ===== sin acceso a la plataforma ===== */
.noacc { max-width: 420px; margin: 12vh auto; padding: 40px 28px; text-align: center; color: var(--text-primary); }
.noacc__ic { font-size: 46px; margin-bottom: 14px; }
.noacc h1 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.noacc p { color: var(--text-secondary); font-size: 14.5px; line-height: 1.5; }
.noacc__links { display: flex; flex-direction: column; gap: 10px; margin: 22px 0; }
.noacc__link { padding: 12px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--sent); font-weight: 600; }
.noacc__out { margin-top: 8px; padding: 10px 20px; border: 1px solid var(--border); border-radius: 10px; color: var(--text-secondary); font-weight: 600; cursor: pointer; background: none; }
.plats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.plat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; cursor: pointer; }
.plat--on { border-color: var(--sent); color: var(--sent); font-weight: 600; }
.plat--lock { opacity: .6; cursor: default; }
.plats__nota { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Eficiencia de Camila (ejecuciones n8n) ─────────────────────────────── */
.camila__updated { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.camila__hero { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding: 4px 0 14px; border-bottom: 1px solid var(--border-soft); margin-bottom: 14px; }
.camila__big { display: flex; flex-direction: column; font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.camila__biglbl { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; margin-top: 8px; }
.camila__tiles { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.camila__tile { display: flex; flex-direction: column; }
.camila__tnum { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.camila__tnum--fail { color: var(--cam-bad); }
.camila__tlbl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.camila__list { display: flex; flex-direction: column; gap: 9px; }
/* Gráfica de eficiencia en el tiempo (debajo de la tarjeta) */
.camila__trend { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.camila__trendhead { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.camila__trendtitle { font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.camila__trendctrls { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.camila__trendtest { font-size: 12px; }
.camila__amp { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.camila__ampin { width: 52px; font: inherit; font-size: 12px; padding: 3px 6px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text); text-align: center; }
.camila__ampsep { color: var(--text-muted); }
.camila__ampauto { font: inherit; font-size: 11.5px; padding: 3px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text); cursor: pointer; }
.camila__ampauto:hover { background: var(--hover, rgba(127,127,127,.12)); }
.camila__legend { display: flex; gap: 14px; }
/* Sub-sección "Mensajes: Camila vs humanos" dentro de la tarjeta de Camila */
.camila__msgsec { margin-top: 20px; padding-top: 16px; border-top: 2px solid var(--border-soft); }
.camila__msgsec-h { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.camila__legitem { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.camila__legitem i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.camila__row { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(90px, 2fr) minmax(150px, auto); align-items: center; gap: 14px; }
.camila__wf { display: flex; align-items: center; gap: 8px; min-width: 0; }
.camila__wfname { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camila__bar { height: 9px; background: var(--border-soft); border-radius: 999px; overflow: hidden; }
.camila__barfill { height: 100%; border-radius: 999px; min-width: 3px; transition: width .4s ease; }
.camila__nums { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* colores de estado (bien / atención / mal) */
:root { --cam-good: #1a8f5f; --cam-warn: #c97a12; --cam-bad: #d64545; }
[data-theme="dark"] { --cam-good: #34d399; --cam-warn: #f0b429; --cam-bad: #f87171; }
.camila__big--good, .camila__eff--good { color: var(--cam-good); }
.camila__big--warn, .camila__eff--warn { color: var(--cam-warn); }
.camila__big--bad,  .camila__eff--bad  { color: var(--cam-bad); }
.camila__big--na,   .camila__eff--na   { color: var(--text-muted); }
.camila__barfill--good { background: var(--cam-good); }
.camila__barfill--warn { background: var(--cam-warn); }
.camila__barfill--bad  { background: var(--cam-bad); }
.camila__barfill--na   { background: var(--text-muted); }

@media (max-width: 640px) {
  .camila__row { grid-template-columns: 1fr; gap: 4px; }
  .camila__nums { text-align: left; }
  .camila__big { font-size: 38px; }
}

/* ── Barra de fechas arrastrable de la tarjeta de Camila ─────────────────── */
.camila__range { margin: 2px 0 16px; }
.camila__rangehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.camila__rangelbl { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.camila__presets { display: inline-flex; gap: 4px; }
.cam-preset { font-size: 12px; font-weight: 600; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.cam-preset:hover { border-color: var(--received); }
.cam-preset--on { background: var(--received); border-color: var(--received); color: #fff; }
.camila__slider { position: relative; height: 30px; margin: 4px 0; touch-action: none; user-select: none; }
.camila__strack { position: absolute; top: 50%; left: 0; right: 0; height: 8px; transform: translateY(-50%); background: var(--border-soft); border-radius: 999px; }
.camila__ssel { position: absolute; top: 50%; height: 8px; transform: translateY(-50%); background: color-mix(in srgb, var(--received) 32%, transparent); border-radius: 999px; cursor: grab; }
.camila__ssel:active { cursor: grabbing; }
.camila__handle { position: absolute; top: 50%; width: 18px; height: 18px; margin-left: -9px; transform: translateY(-50%); padding: 0; border-radius: 50%; background: var(--surface-1); border: 3px solid var(--received); box-shadow: 0 1px 4px rgba(0,0,0,.22); cursor: ew-resize; z-index: 2; }
.camila__handle:hover { background: var(--received); }
.camila__handle:focus-visible { outline: 2px solid var(--received); outline-offset: 2px; }
.camila__ticks { display: flex; justify-content: space-between; margin-top: 2px; }
.camila__ticks span { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Cabecera de la tarjeta de Camila: toggle vista (super admin) + "actualizado" */
.camila__headright { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.camila__viewseg .seg { font-size: 12.5px; }
.camila__botchip { font-size: 13px; padding: 5px 13px; }

/* Controles del detallado (super admin): filtro por agente + excluir test */
.camila__dctrls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 2px 0 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.camila__agentseg .seg { font-size: 12.5px; }
.camila__check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.camila__check input { width: 15px; height: 15px; accent-color: var(--received); cursor: pointer; margin: 0; }

.camila__tnum--ext { color: var(--text-muted); }

/* ── Calendario de semanas completas ─────────────────────────────────────── */
.camila__range { position: relative; }
.cam-cal-btn { font-size: 12px; font-weight: 600; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.cam-cal-btn:hover { border-color: var(--received); color: var(--received); }
.camila__cal { position: absolute; right: 0; top: 34px; z-index: 30; width: 264px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 12px; }
.camcal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.camcal__title { font-size: 13.5px; font-weight: 700; text-transform: capitalize; }
.camcal__nav { width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-secondary); }
.camcal__nav:hover { border-color: var(--received); color: var(--received); }
.camcal__dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.camcal__dow span { text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 700; }
.camcal__week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; border-radius: 8px; cursor: pointer; padding: 2px; border: 1px solid transparent; }
.camcal__week:hover { background: var(--surface-0); border-color: var(--border); }
.camcal__week--sel { background: color-mix(in srgb, var(--received) 20%, transparent); border-color: color-mix(in srgb, var(--received) 45%, transparent); }
.camcal__week--anchor { border-color: var(--received); }
.camcal__day { text-align: center; font-size: 12.5px; padding: 5px 0; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.camcal__day--other { color: var(--text-muted); opacity: .55; }
.camcal__hint { margin-top: 9px; font-size: 11px; color: var(--text-muted); text-align: center; }

/* Fila de modelo: más campos (%, $/msg, $/1M in, $/1M out) → permite envolver */
.md-item { flex-wrap: wrap; }
.md-field .pct__input, .md-coste, .md-new-coste { width: 80px; }
.md-unit { font-size: 11px; font-weight: 600; margin-left: 1px; white-space: nowrap; }

/* ── Precios por horario (UTC) de un modelo ──────────────────────────────── */
.md-tog-win { font-size: 12.5px; font-weight: 600; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.md-tog-win:hover, .md-tog-win--on { border-color: var(--received); color: var(--received); }
.md-windows { flex-basis: 100%; width: 100%; margin-top: 8px; padding: 11px; border: 1px dashed var(--border); border-radius: 9px; background: var(--surface-0); }
.mw-head { font-size: 12px; color: var(--text-muted); margin-bottom: 9px; line-height: 1.5; }
.mw-list { display: flex; flex-direction: column; gap: 8px; }
.mw-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mw-row input[type="time"] { padding: 7px 8px; font-size: 14px; font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); color: var(--text-primary); }
.mw-sep { color: var(--text-muted); font-weight: 700; }
.mw-utc { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-right: 4px; }
.md-win-add { margin-top: 10px; }
.mw-note { display: inline-block; margin-left: 10px; font-size: 11px; color: var(--text-muted); }

/* ── Barra de filtros del pipeline ────────────────────────────────────────── */
.board__filters { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; padding:12px 2px 6px; margin-bottom:6px; border-top:1px solid var(--border-soft); }
.board__filters .flt { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-muted); font-weight:600; }
.num-input { width:82px; padding:7px 9px; font-size:13px; border:1px solid var(--border); border-radius:8px; background:var(--surface-1); color:var(--text-primary); }
.num-input:focus { outline:none; border-color:var(--received); }
.flt__sep { color:var(--text-muted); }
.board__count { margin-left:auto; font-size:12.5px; color:var(--text-secondary); font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
