/* ════════════════════════════════════════════════════════════════════
   DASHBOARD V2 — Cards clicáveis + Modal de lista
   ════════════════════════════════════════════════════════════════════ */

/* Indicador visual nos cards clicáveis */
.cp-card-indicator{
  position:absolute;
  top:8px;
  right:8px;
  font-size:11px;
  opacity:.4;
  pointer-events:none;
  transition:opacity .15s, transform .15s;
}
.kpi:hover .cp-card-indicator{
  opacity:1;
  transform:scale(1.2);
}
.kpi[data-cp-v2-wired="1"]{
  position:relative;
}
.kpi[data-cp-v2-wired="1"]:hover{
  transform:translateY(-2px);
  box-shadow:0 8px 20px -8px rgba(167,139,250,.4);
}

/* ─── MODAL DE LISTA ──────────────────────────────────────────── */
.cp-dash-lista-modal{
  position:fixed;
  inset:0;
  background:rgba(10,4,24,.78);
  backdrop-filter:blur(10px);
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
  animation:cpFadeIn .2s ease;
}

.cp-dash-lista-inner{
  background:rgba(15,7,26,.98);
  backdrop-filter:blur(28px);
  border:1px solid rgba(167,139,250,.3);
  border-radius:14px;
  width:100%;
  max-width:1100px;
  max-height:calc(100vh - 40px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  box-shadow:0 24px 64px rgba(0,0,0,.7);
}
[data-theme="light"] .cp-dash-lista-inner{
  background:rgba(255,255,255,.98);
  border-color:rgba(124,58,237,.3);
}

.cp-dash-lista-head{
  padding:14px 18px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  border-bottom:1px solid rgba(167,139,250,.15);
  background:linear-gradient(90deg, rgba(167,139,250,.08), transparent);
}
.cp-dash-lista-title{
  font-family:var(--dp);
  font-weight:800;
  font-size:18px;
  color:var(--tx);
  margin-bottom:2px;
}
.cp-dash-lista-sub{
  font-family:var(--mo);
  font-size:11px;
  color:var(--t2);
}
.cp-dash-lista-close{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.1);
  border-radius:8px;
  color:var(--t2);
  width:34px;
  height:34px;
  cursor:pointer;
  font-size:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
  transition:background .15s, color .15s;
}
.cp-dash-lista-close:hover{
  background:rgba(244,63,94,.15);
  color:#f87171;
}

.cp-dash-lista-body{
  padding:14px 18px 18px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0;
}

.cp-dash-lista-stats{
  display:flex;
  gap:24px;
  padding:10px 14px;
  background:rgba(167,139,250,.06);
  border:1px solid rgba(167,139,250,.15);
  border-radius:8px;
  margin-bottom:12px;
  font-family:var(--fn);
  font-size:12.5px;
  flex-shrink:0;
}
.cp-dash-lista-stats > div{
  display:flex;
  align-items:center;
  gap:8px;
}
.cp-dash-lista-stats span{color:var(--t3);}
.cp-dash-lista-stats strong{color:var(--tx);}

.cp-dash-lista-tablewrap{
  flex:1;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  border:1px solid rgba(167,139,250,.1);
  border-radius:8px;
  min-height:0;
  /* Indicador sutil de scroll horizontal disponível */
  position:relative;
}

.cp-dash-lista-table{
  width:100%;
  border-collapse:collapse;
  font-family:var(--fn);
  font-size:12.5px;
}
.cp-dash-lista-table thead{
  position:sticky;
  top:0;
  background:rgba(15,7,26,.98);
  z-index:2;
}
[data-theme="light"] .cp-dash-lista-table thead{
  background:rgba(255,255,255,.98);
}
.cp-dash-lista-table th{
  padding:10px 12px;
  font-family:var(--mo);
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:var(--t2);
  border-bottom:1px solid rgba(167,139,250,.15);
  background:rgba(0,0,0,.2);
  white-space:nowrap;  /* cabeçalhos nunca quebram */
}
[data-theme="light"] .cp-dash-lista-table th{
  background:rgba(0,0,0,.04);
}
.cp-dash-lista-table td{
  padding:9px 12px;
  border-bottom:1px solid rgba(167,139,250,.06);
  color:var(--tx);
  vertical-align:top;
}

/* Coluna Cliente — quebra em múltiplas linhas mas com largura mínima */
.cp-dash-lista-table td:first-child{
  min-width:140px;
  max-width:200px;
}

/* Valor sempre alinhado à direita e nowrap */
.cp-dash-lista-table td[style*="text-align:right"],
.cp-dash-lista-table th[style*="text-align:right"]{
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

.cp-dash-row:hover{
  background:rgba(167,139,250,.08);
}
.cp-dash-row{
  transition:background .12s;
}

/* ─── MOBILE: modal fullscreen + tabela responsiva ─── */
@media (max-width:600px){
  .cp-dash-lista-modal{
    padding:0;
    align-items:stretch;  /* não centralizar - estica vertical */
    justify-content:stretch;
  }
  .cp-dash-lista-inner{
    height:100vh;          /* força altura total */
    max-height:100vh;
    width:100vw;
    max-width:100vw;
    border-radius:0;
    border:none;
  }
  .cp-dash-lista-body{
    padding:10px 12px 14px;
    flex:1;
    min-height:0;          /* permite encolher */
    overflow:hidden;       /* tabelas internas que rolam */
    display:flex;
    flex-direction:column;
  }
  .cp-dash-lista-stats{
    padding:8px 10px;
    gap:14px;
    font-size:12px;
    flex-wrap:wrap;
  }
  .cp-dash-lista-tablewrap{
    flex:1;
    min-height:200px;      /* sempre visível */
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
  .cp-dash-lista-table{
    font-size:12px;
    min-width:560px;
    table-layout:auto;
  }
  .cp-dash-lista-table th,
  .cp-dash-lista-table td{
    padding:8px 10px;
    line-height:1.35;
    vertical-align:top;
  }
  .cp-dash-lista-table tr{
    border-bottom:1px solid rgba(167,139,250,.06);
  }
  .cp-dash-lista-table td:first-child,
  .cp-dash-lista-table th:first-child{
    min-width:130px;
    max-width:170px;
    width:170px;
    font-size:11.5px;
    word-break:break-word;
    white-space:normal;       /* permite quebrar em várias linhas */
    line-height:1.3;
  }
  .cp-dash-lista-table td:nth-child(2),
  .cp-dash-lista-table td:nth-child(3),
  .cp-dash-lista-table td:nth-child(4),
  .cp-dash-lista-table td:nth-child(5){
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:120px;
  }
  .cp-dash-lista-table td[style*="right"]{
    white-space:nowrap !important;
    text-align:right;
  }
  .cp-dash-lista-tablewrap{
    box-shadow:inset -8px 0 8px -8px rgba(167,139,250,.3);
  }
  .cp-dash-lista-tablewrap::after{
    content:'';
    position:absolute;
    top:0;
    right:0;
    bottom:0;
    width:20px;
    background:linear-gradient(90deg, transparent, rgba(15,7,26,.5));
    pointer-events:none;
    opacity:.7;
  }
  [data-theme="light"] .cp-dash-lista-tablewrap::after{
    background:linear-gradient(90deg, transparent, rgba(255,255,255,.5));
  }

  /* Header com título: tipografia menor no mobile */
  .cp-dash-lista-head{
    padding:12px 14px;
  }
  .cp-dash-lista-title{
    font-size:15px;
    line-height:1.2;
  }
  .cp-dash-lista-sub{
    font-size:10px;
  }
}

/* ─── FILTRO DE PERÍODO NA ANÁLISE DE MOTIVOS ──────────────── */
.cp-motivos-filtro-periodo{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  background:rgba(167,139,250,.06);
  border-bottom:1px solid rgba(167,139,250,.15);
  font-family:var(--fn);
  font-size:12px;
}
.cp-motivos-filtro-periodo label{
  font-weight:700;
  color:var(--t2);
}
.cp-motivos-filtro-periodo select{
  padding:5px 10px;
  background:rgba(0,0,0,.25);
  border:1px solid rgba(167,139,250,.2);
  border-radius:6px;
  color:var(--tx);
  font-family:var(--fn);
  font-size:12px;
  cursor:pointer;
  outline:none;
}
[data-theme="light"] .cp-motivos-filtro-periodo select{
  background:rgba(245,243,255,.7);
}
.cp-motivos-filtro-periodo select:focus{
  border-color:rgba(34,211,238,.5);
}
.cp-motivos-info{
  margin-left:auto;
  color:var(--t3);
  font-size:11px;
  font-family:var(--mo);
}

@keyframes cpFadeIn{
  from{opacity:0; transform:scale(0.96);}
  to{opacity:1; transform:scale(1);}
}

/* ════════════════════════════════════════════════════════════════
   v2.1 — Resumo agrupado (MRR e Carteira)
   ════════════════════════════════════════════════════════════════ */
.cp-dash-resumo-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

@media (max-width:900px){
  .cp-dash-resumo-grid{
    grid-template-columns:1fr;
    gap:18px;
  }
}

.cp-dash-resumo-bloco{
  background:rgba(167,139,250,.04);
  border:1px solid rgba(167,139,250,.12);
  border-radius:10px;
  padding:12px;
  /* No mobile, usa overflow simples sem altura fixa */
  overflow:hidden;
}

.cp-dash-resumo-titulo{
  font-family:var(--dp);
  font-weight:800;
  font-size:13px;
  color:var(--tx);
  margin-bottom:10px;
  padding-bottom:8px;
  border-bottom:1px solid rgba(167,139,250,.15);
}

/* Tabela DENTRO do bloco: tabela normal, sem position absoluta */
.cp-dash-resumo-bloco .cp-dash-lista-table{
  font-size:12px;
  width:100%;
  border-collapse:collapse;
  display:table;  /* força layout tabular */
}

.cp-dash-resumo-bloco .cp-dash-lista-table thead{
  position:relative;  /* não sticky no mobile - estava quebrando */
}

.cp-dash-resumo-bloco .cp-dash-lista-table th,
.cp-dash-resumo-bloco .cp-dash-lista-table td{
  padding:8px 6px;
  word-break:break-word;
  vertical-align:top;
}

/* No mobile, fontes menores e quebra de linha */
@media (max-width:600px){
  .cp-dash-resumo-bloco .cp-dash-lista-table{
    font-size:11px;
  }
  .cp-dash-resumo-bloco .cp-dash-lista-table th,
  .cp-dash-resumo-bloco .cp-dash-lista-table td{
    padding:6px 4px;
  }
}

.cp-dash-btn-completa{
  background:linear-gradient(135deg, rgba(167,139,250,.15), rgba(236,72,153,.15));
  border:1px solid rgba(167,139,250,.3);
  color:var(--tx);
  padding:10px 22px;
  border-radius:10px;
  cursor:pointer;
  font-family:var(--fn);
  font-weight:600;
  font-size:13px;
  transition:transform .12s, background .15s;
}
.cp-dash-btn-completa:hover{
  background:linear-gradient(135deg, rgba(167,139,250,.25), rgba(236,72,153,.25));
  transform:translateY(-1px);
}

/* ════════════════════════════════════════════════════════════════
   v2.2 — Filtros, busca e ordenação na lista
   ════════════════════════════════════════════════════════════════ */

.cp-dash-filtros{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  padding:10px 14px;
  background:rgba(167,139,250,.04);
  border:1px solid rgba(167,139,250,.1);
  border-radius:8px;
  margin-bottom:10px;
  flex-shrink:0;
}

.cp-dash-busca{
  flex:1;
  min-width:200px;
  padding:8px 12px;
  background:rgba(0,0,0,.25);
  border:1px solid rgba(167,139,250,.2);
  border-radius:7px;
  color:var(--tx);
  font-family:var(--fn);
  font-size:13px;
  outline:none;
  transition:border-color .15s;
}
.cp-dash-busca:focus{
  border-color:rgba(34,211,238,.5);
}
[data-theme="light"] .cp-dash-busca{
  background:rgba(245,243,255,.7);
}

.cp-dash-filtros select{
  padding:7px 10px;
  background:rgba(0,0,0,.25);
  border:1px solid rgba(167,139,250,.2);
  border-radius:7px;
  color:var(--tx);
  font-family:var(--fn);
  font-size:12px;
  cursor:pointer;
  outline:none;
  max-width:180px;
}
[data-theme="light"] .cp-dash-filtros select{
  background:rgba(245,243,255,.7);
}
.cp-dash-filtros select:focus{
  border-color:rgba(34,211,238,.5);
}

.cp-dash-btn-limpar{
  padding:7px 12px;
  background:rgba(244,63,94,.1);
  border:1px solid rgba(244,63,94,.25);
  border-radius:7px;
  color:#f87171;
  font-family:var(--fn);
  font-size:12px;
  cursor:pointer;
  font-weight:600;
  transition:background .15s;
}
.cp-dash-btn-limpar:hover{
  background:rgba(244,63,94,.2);
}

/* Cabeçalhos clicáveis pra ordenação */
.cp-dash-th-sort{
  user-select:none;
  transition:background .12s, color .12s;
}
.cp-dash-th-sort:hover{
  color:var(--tx) !important;
  background:rgba(167,139,250,.15) !important;
}

@media (max-width:600px){
  .cp-dash-filtros{
    padding:8px;
    gap:6px;
  }
  .cp-dash-busca{
    min-width:100%;
    flex-basis:100%;
  }
  .cp-dash-filtros select{
    flex:1;
    max-width:none;
    font-size:11px;
  }
}

/* ════════════════════════════════════════════════════════════════
   v2.3 — Opção Quitado/Pendente no modal de renovação
   ════════════════════════════════════════════════════════════════ */

.cp-ren-status-box{
  background:rgba(167,139,250,.04);
  border:1px solid rgba(167,139,250,.18);
  border-radius:10px;
  padding:14px;
  margin-top:12px;
}

.cp-ren-status-label{
  font-family:var(--fn);
  font-size:13px;
  font-weight:700;
  color:var(--tx);
  margin-bottom:10px;
}

.cp-ren-status-radios{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

@media (max-width:600px){
  .cp-ren-status-radios{
    grid-template-columns:1fr;
  }
}

.cp-ren-status-opt{
  cursor:pointer;
  user-select:none;
  margin:0;
  display:block;
}
.cp-ren-status-opt input[type="radio"]{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.cp-ren-status-card{
  background:rgba(0,0,0,.18);
  border:2px solid rgba(167,139,250,.15);
  border-radius:10px;
  padding:12px 14px;
  transition:all .15s;
  text-align:center;
}
[data-theme="light"] .cp-ren-status-card{
  background:rgba(0,0,0,.04);
}
.cp-ren-status-opt:hover .cp-ren-status-card{
  border-color:rgba(167,139,250,.4);
  background:rgba(167,139,250,.08);
}

.cp-ren-status-card-active{
  border-color:#22d3ee !important;
  background:rgba(34,211,238,.12) !important;
  box-shadow:0 0 0 3px rgba(34,211,238,.15);
}

.cp-ren-status-titulo{
  font-family:var(--dp);
  font-weight:800;
  font-size:14px;
  color:var(--tx);
  margin-bottom:3px;
}

.cp-ren-status-sub{
  font-family:var(--fn);
  font-size:11.5px;
  color:var(--t2);
}

.cp-ren-status-aviso{
  margin-top:10px;
  padding:8px 12px;
  background:rgba(244,63,94,.08);
  border:1px solid rgba(244,63,94,.2);
  border-radius:8px;
  font-size:11.5px;
  color:#f87171;
  text-align:center;
  font-family:var(--fn);
}

/* ════════════════════════════════════════════════════════════════
   v2.4 — Modal de detalhes com filtros + gráfico + explicação
   ════════════════════════════════════════════════════════════════ */

.cp-dash-detalhe-inner{
  max-width:880px;
}

.cp-dash-detalhe-body{
  gap:14px;
}

.cp-dash-detalhe-periodos{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  padding:10px 14px;
  background:rgba(167,139,250,.05);
  border:1px solid rgba(167,139,250,.15);
  border-radius:10px;
  flex-shrink:0;
}

.cp-dash-per-label{
  font-family:var(--fn);
  font-weight:700;
  font-size:12px;
  color:var(--t2);
  margin-right:6px;
}

.cp-dash-per-btn{
  padding:6px 12px;
  background:rgba(0,0,0,.18);
  border:1px solid rgba(167,139,250,.2);
  border-radius:7px;
  color:var(--t2);
  font-family:var(--fn);
  font-size:12px;
  cursor:pointer;
  transition:all .15s;
}
[data-theme="light"] .cp-dash-per-btn{
  background:rgba(245,243,255,.6);
}
.cp-dash-per-btn:hover{
  border-color:rgba(167,139,250,.4);
  color:var(--tx);
}
.cp-dash-per-btn.cp-dash-per-ativa{
  background:linear-gradient(135deg, #a78bfa, #ec4899);
  border-color:transparent;
  color:#fff;
  font-weight:700;
}

/* Cards de números */
.cp-dash-detalhe-numeros{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
@media (max-width:600px){
  .cp-dash-detalhe-numeros{grid-template-columns:1fr;}
}

.cp-dash-detalhe-num-card{
  background:rgba(167,139,250,.06);
  border:1px solid rgba(167,139,250,.18);
  border-radius:10px;
  padding:14px 16px;
}

.cp-dash-num-principal{
  background:linear-gradient(135deg, rgba(167,139,250,.12), rgba(236,72,153,.08));
  border-color:rgba(167,139,250,.4);
}

.cp-dash-num-lb{
  font-family:var(--mo);
  font-size:10px;
  font-weight:700;
  color:var(--t3);
  text-transform:uppercase;
  letter-spacing:.05em;
  margin-bottom:5px;
}

.cp-dash-num-vl{
  font-family:var(--dp);
  font-size:26px;
  font-weight:800;
  color:var(--tx);
  margin-bottom:6px;
}

.cp-dash-num-vl-sec{
  font-family:var(--dp);
  font-size:18px;
  font-weight:700;
  color:var(--t2);
}

.cp-dash-num-var{
  font-family:var(--mo);
  font-size:11px;
  font-weight:600;
}
.cp-dash-var-up{color:#10b981;}
.cp-dash-var-down{color:#f43f5e;}
.cp-dash-var-flat{color:var(--t3);}

/* Gráfico */
.cp-dash-detalhe-grafico{
  background:rgba(0,0,0,.18);
  border:1px solid rgba(167,139,250,.15);
  border-radius:10px;
  padding:12px 14px;
}
[data-theme="light"] .cp-dash-detalhe-grafico{
  background:rgba(0,0,0,.03);
}

.cp-dash-detalhe-grafico-titulo{
  font-family:var(--dp);
  font-weight:700;
  font-size:13px;
  color:var(--tx);
  margin-bottom:10px;
}

/* Explicação */
.cp-dash-detalhe-explicacao{
  background:rgba(167,139,250,.04);
  border:1px solid rgba(167,139,250,.12);
  border-radius:10px;
  padding:14px 16px;
}

.cp-dash-explica-titulo{
  font-family:var(--dp);
  font-weight:800;
  font-size:14px;
  color:var(--tx);
  margin-bottom:8px;
}

.cp-dash-explica-texto{
  font-family:var(--fn);
  font-size:13px;
  color:var(--t2);
  line-height:1.5;
  margin-bottom:10px;
}

.cp-dash-explica-formula{
  font-family:var(--fn);
  font-size:11.5px;
  color:var(--t3);
  padding:8px 10px;
  background:rgba(0,0,0,.18);
  border-radius:6px;
  margin-bottom:12px;
}
.cp-dash-explica-formula code{
  font-family:var(--mo);
  color:var(--ac2);
  font-size:11px;
}
[data-theme="light"] .cp-dash-explica-formula{
  background:rgba(0,0,0,.04);
}

.cp-dash-explica-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-bottom:10px;
}
@media (max-width:600px){
  .cp-dash-explica-grid{grid-template-columns:1fr;}
}

.cp-dash-explica-card{
  padding:10px 12px;
  border-radius:8px;
  font-family:var(--fn);
  font-size:12px;
  line-height:1.4;
}
.cp-dash-explica-bom{
  background:rgba(16,185,129,.08);
  border:1px solid rgba(16,185,129,.25);
  color:var(--t1);
}
.cp-dash-explica-ruim{
  background:rgba(244,63,94,.08);
  border:1px solid rgba(244,63,94,.25);
  color:var(--t1);
}
.cp-dash-explica-card-titulo{
  font-family:var(--dp);
  font-weight:700;
  font-size:12px;
  margin-bottom:4px;
  color:var(--tx);
}

.cp-dash-explica-acao{
  padding:9px 12px;
  background:linear-gradient(90deg, rgba(34,211,238,.08), transparent);
  border-left:3px solid #22d3ee;
  border-radius:0 6px 6px 0;
  font-family:var(--fn);
  font-size:12.5px;
  color:var(--t1);
  font-weight:600;
}

/* ════════════════════════════════════════════════════════════════
   v2.5 — Painel enriquecido injetado em modais existentes
   ════════════════════════════════════════════════════════════════ */

.cp-dash-enrich-painel{
  margin-bottom:18px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.cp-dash-enrich-section{
  background:rgba(167,139,250,.04);
  border:1px solid rgba(167,139,250,.18);
  border-radius:10px;
  overflow:hidden;
}

.cp-dash-enrich-section[open]{
  background:rgba(167,139,250,.06);
}

.cp-dash-enrich-summary{
  padding:11px 14px;
  cursor:pointer;
  font-family:var(--dp);
  font-weight:700;
  font-size:13px;
  color:var(--tx);
  user-select:none;
  list-style:none;
  display:flex;
  align-items:center;
  gap:8px;
  transition:background .15s;
}
.cp-dash-enrich-summary::-webkit-details-marker{display:none;}
.cp-dash-enrich-summary::before{
  content:'▶';
  font-size:9px;
  color:var(--t3);
  transition:transform .2s;
  display:inline-block;
}
.cp-dash-enrich-section[open] .cp-dash-enrich-summary::before{
  transform:rotate(90deg);
}
.cp-dash-enrich-summary:hover{
  background:rgba(167,139,250,.08);
}

.cp-dash-enrich-content{
  padding:12px 14px 14px;
  border-top:1px solid rgba(167,139,250,.12);
}

/* ════════════════════════════════════════════════════════════════
   v2.6 — Esconder card duplicado "Novos no Mês" (Visão Rápida)
   Mantém o card "Novos Contratos" do Movimento do Período
   ════════════════════════════════════════════════════════════════ */

/* Esconde card que contém o KPI #kNovosMes (duplicado) */
.kpi:has(#kNovosMes){
  display:none !important;
}
