/* Módulo: comissoes (V49 — equipe, previsão de recebimento e próximos ganhos). Substituível junto com index.js. */
#appView .cx-head .page-header-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
#appView .cx-add{display:inline-flex;align-items:center;gap:8px;white-space:nowrap}
#appView .cx-add svg{width:16px;height:16px;pointer-events:none}
/* Cores da composição do recebimento (validadas para daltonismo, claro e escuro) */
#appView{--cx-fixo:#9AA6B4;--cx-com:#2F6DB0;--cx-bonif:#1BAF7A;--cx-bonus:#134FD0;--cx-prem:#7A5CC4}
html[data-theme="dark"] #appView{--cx-fixo:#6B7A8E;--cx-com:#4B7FD1;--cx-bonif:#199E70;--cx-bonus:#275AC6;--cx-prem:#9085E9}

/* Resumo da equipe */
#appView .cx-strip{display:grid;grid-template-columns:1.25fr 1fr 1fr 1fr;margin-bottom:14px;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-sm)}
#appView .cx-strip>div{min-width:0;display:grid;align-content:start;gap:4px;padding:14px 18px;border-left:1px solid var(--line-soft)}
#appView .cx-strip>div:first-child{border-left:0}
#appView .cx-strip.is-loading .cx-big{opacity:.45}
#appView .cx-lbl{font-family:var(--font-secondary);font-size:10.5px;font-weight:600;letter-spacing:.12em;text-transform:uppercase;color:var(--text-3)}
#appView .cx-big{font-size:21px;font-weight:800;letter-spacing:-.02em;color:var(--text-1);font-variant-numeric:tabular-nums}
#appView .cx-big small{font-size:13px;font-weight:600;letter-spacing:0;color:var(--text-3)}
#appView .cx-sub{font-size:12.5px;color:var(--text-3)}

/* Ferramentas: Equipe / Por vendedor + busca ou seletor */
#appView .cx-tools{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:12px}
#appView .cx-switch{flex:0 0 auto}
#appView .cx-tools .seller-selection-toolbar{margin:0;padding:0;border:0;display:flex;align-items:center;gap:8px}
#appView .cx-tools .seller-selection-field{display:flex;align-items:center;gap:10px}
#appView .cx-tools .seller-selection-field select{min-width:240px}
#appView .cx-search{margin-left:auto;width:250px;height:36px;display:flex;align-items:center;gap:8px;padding:0 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--text-3)}
#appView .cx-search:focus-within{border-color:var(--blue);box-shadow:var(--focus)}
#appView .cx-search svg{flex:0 0 auto;width:15px;height:15px}
#appView .cx-search input{width:100%;min-width:0;height:100%;border:0;background:transparent;font:inherit;font-size:13px;color:var(--text-1);outline:0}

/* Tabela da equipe */
#appView .cx-table{overflow:hidden;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-sm)}
#appView .cx-row{--cx-cols:minmax(190px,1.5fr) repeat(2,minmax(84px,.8fr)) 58px 64px repeat(4,minmax(84px,.8fr)) minmax(96px,.9fr) 24px;width:100%;display:grid;grid-template-columns:var(--cx-cols);align-items:center;gap:10px;min-height:54px;padding:0 16px;border:0;border-top:1px solid var(--line-soft);background:transparent;font:inherit;color:inherit;text-align:left}
#appView button.cx-row{cursor:pointer}
#appView button.cx-row:hover{background:var(--row-hover)}
#appView button.cx-row:hover .cx-go{color:var(--text-1)}
#appView .cx-headrow{min-height:40px;border-top:0;border-bottom:1px solid var(--line);background:var(--surface-2);font-family:var(--font-secondary);font-size:10.5px;font-weight:600;letter-spacing:.09em;text-transform:uppercase;color:var(--text-3)}
#appView .cx-headrow+button.cx-row,#appView .cx-loading+button.cx-row{border-top:0}
#appView .cx-row>span:not(.cx-who):not(.cx-go){text-align:right;justify-self:end}
#appView .cx-headrow>span.cx-var{display:inline-flex;align-items:center;gap:4px}
#appView .cx-headrow svg{width:12px;height:12px}
#appView .cx-who{min-width:0;display:flex;align-items:center;gap:10px}
#appView .cx-who>span:last-child{min-width:0;display:grid;gap:1px}
#appView .cx-who b{overflow:hidden;font-size:14px;font-weight:700;color:var(--text-1);white-space:nowrap;text-overflow:ellipsis}
#appView .cx-who small{display:inline-flex;align-items:center;gap:4px;font-family:var(--font-secondary);font-size:11px;font-weight:600;color:var(--text-3)}
#appView .cx-who small svg{width:12px;height:12px;color:#B07A00}
#appView .cx-ini{flex:0 0 auto;width:32px;height:32px;display:grid;place-items:center;border:1px solid var(--line);border-radius:50%;background:var(--surface-2);font-family:var(--font-secondary);font-size:11px;font-weight:600;color:var(--text-1)}
#appView .cx-num{font-size:13.5px;font-weight:600;color:var(--text-1);font-variant-numeric:tabular-nums;white-space:nowrap}
#appView .cx-num.zero{font-weight:500;color:var(--navy-40)}
#appView .cx-num.strong{font-weight:800}
#appView .cx-row.is-zero .cx-who b{font-weight:600;color:var(--text-2)}
#appView .cx-go{display:grid;place-items:center;color:var(--text-3)}
#appView .cx-go svg{width:16px;height:16px}
#appView .cx-total{border-top:1px solid var(--line);background:var(--surface-2)}
#appView .cx-total .cx-who b{font-weight:800}
#appView .cx-total .cx-num{font-weight:800}
#appView .cx-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:11px 16px;border-top:1px solid var(--line);font-size:12.5px;color:var(--text-3)}
#appView .cx-link{display:inline-flex;align-items:center;gap:5px;padding:0;border:0;background:none;font:inherit;font-weight:650;color:var(--blue);cursor:pointer}
#appView .cx-link svg{width:14px;height:14px;pointer-events:none}
#appView .cx-empty,#appView .cx-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:22px 16px;font-size:13.5px;color:var(--text-3)}
#appView .cx-loading svg{width:16px;height:16px;animation:cx-spin 1s linear infinite}
@keyframes cx-spin{to{transform:rotate(360deg)}}

/* Detalhe: recebimento + produção */
#appView .cx-hero{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(280px,1fr);margin-bottom:18px;overflow:hidden;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-sm)}
#appView .cx-hero-main{min-width:0;padding:20px 22px}
#appView .cx-hero-side{min-width:0;padding:18px 22px;border-left:1px solid var(--line-soft);background:var(--surface-2)}
#appView .cx-person{display:flex;align-items:center;gap:12px}
#appView .cx-person b{display:block;font-size:17px;color:var(--text-1)}
#appView .cx-person small{font-size:12.5px;color:var(--text-3)}
#appView .cx-avatar{flex:0 0 auto;width:44px;height:44px;display:grid;place-items:center;overflow:hidden;border:1px solid var(--line);border-radius:50%;background:var(--surface-2);font-family:var(--font-secondary);font-size:14px;font-weight:600;color:var(--text-1)}
#appView .cx-avatar img{width:100%;height:100%;object-fit:cover}
#appView .cx-recv{margin-top:18px}
#appView .cx-recv strong{display:block;margin-top:4px;font-size:40px;font-weight:800;line-height:1.05;letter-spacing:-.03em;color:var(--text-1);font-variant-numeric:tabular-nums}
#appView .cx-recv p{margin:6px 0 0;font-size:13.5px;color:var(--text-3)}
#appView .cx-recv p b{color:var(--text-1)}
#appView .cx-inc{font-size:12.5px}
#appView .cx-comp{display:flex;gap:2px;height:12px;margin-top:14px;overflow:hidden;border-radius:999px;background:var(--line)}
#appView .cx-comp span{flex-basis:0;min-width:4px;height:100%}
#appView :is(.cx-comp span,.cx-legend i).fixo{background:var(--cx-fixo)}
#appView :is(.cx-comp span,.cx-legend i).com{background:var(--cx-com)}
#appView :is(.cx-comp span,.cx-legend i).bonif{background:var(--cx-bonif)}
#appView :is(.cx-comp span,.cx-legend i).bonus{background:var(--cx-bonus)}
#appView :is(.cx-comp span,.cx-legend i).prem{background:var(--cx-prem)}
#appView .cx-legend{display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:10px;font-size:12.5px;color:var(--text-3)}
#appView .cx-legend span{display:inline-flex;align-items:center;gap:6px}
#appView .cx-legend i{display:inline-block;width:9px;height:9px;border-radius:3px}
#appView .cx-legend b{color:var(--text-1);font-variant-numeric:tabular-nums}
#appView .cx-prod{display:grid;margin-top:6px}
#appView .cx-prod>div{display:flex;align-items:center;gap:10px;padding:9px 0;border-top:1px solid var(--line)}
#appView .cx-prod>div:first-child{border-top:0}
#appView .cx-prod svg{flex:0 0 auto;width:16px;height:16px;color:var(--text-3)}
#appView .cx-prod span{font-size:13.5px;color:var(--text-2)}
#appView .cx-prod b{margin-left:auto;font-size:14px;color:var(--text-1);font-variant-numeric:tabular-nums}

/* Próximos ganhos */
#appView .cx-section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin:0 0 10px}
#appView .cx-section-head h3{margin:3px 0 0;font-size:17px;font-weight:700;color:var(--text-1)}
#appView .cx-section-head small{font-size:12.5px;color:var(--text-3)}
#appView .cx-nexts{display:grid;grid-template-columns:repeat(var(--cx-cols,4),minmax(0,1fr));gap:12px;margin-bottom:20px}
#appView .cx-next{min-width:0;display:flex;flex-direction:column;padding:14px 16px;border:1px solid var(--line);border-radius:14px;background:var(--surface);box-shadow:var(--shadow-sm)}
#appView .cx-next.is-first{border-color:var(--orange-40);background:linear-gradient(180deg,#FDFEFF,var(--surface) 60%)}
#appView .cx-next-t{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:700;color:var(--text-1)}
#appView .cx-next-t svg{flex:0 0 auto;width:15px;height:15px;color:var(--orange)}
#appView .cx-next-t span{min-width:0}
#appView .cx-next-t em{flex:0 0 auto;margin-left:auto;padding:2px 9px;border-radius:999px;background:var(--ok-bg);font-size:12.5px;font-style:normal;font-weight:800;color:var(--ok-fg);white-space:nowrap}
#appView .cx-next>b{margin-top:12px;font-size:19px;font-weight:800;letter-spacing:-.01em;color:var(--text-1);font-variant-numeric:tabular-nums}
#appView .cx-next>small{margin-top:2px;font-size:12.5px;color:var(--text-3)}
#appView .cx-bar{position:relative;display:block;height:6px;margin-top:12px;overflow:hidden;border-radius:99px;background:var(--line)}
#appView .cx-bar>span{position:absolute;inset:0 auto 0 0;border-radius:inherit;background:var(--orange)}
#appView .cx-bar.alt>span{background:var(--blue)}
#appView .cx-next-ft{display:flex;justify-content:space-between;gap:8px;margin-top:auto;padding-top:6px;font-size:12px;color:var(--text-3);font-variant-numeric:tabular-nums}
#appView .cx-next.is-wait{background:var(--surface-2);box-shadow:none}
#appView .cx-next.is-wait .cx-next-t em{background:var(--surface);color:var(--text-3)}
#appView .cx-allmax{display:flex;align-items:center;gap:8px;margin-bottom:20px;padding:14px 16px;border-radius:14px;background:var(--ok-bg);font-weight:700;color:var(--ok-fg)}
#appView .cx-allmax svg{width:16px;height:16px}

/* Detalhamento */
#appView .cx-breakdown{overflow:hidden;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-sm)}
#appView .cx-line{display:grid;grid-template-columns:220px minmax(0,1fr) 140px 32px;align-items:center;gap:14px;min-height:44px;padding:8px 18px;border-top:1px solid var(--line-soft)}
#appView .cx-line-label{display:flex;align-items:center;gap:8px;padding-left:24px;font-size:13.5px;font-weight:600;color:var(--text-1)}
#appView .cx-line-detail{min-width:0;font-size:13px;color:var(--text-3)}
#appView .cx-line-detail .pos{font-weight:700;color:var(--ok-fg)}
#appView .cx-line-value{grid-column:3;text-align:right;font-size:13.5px;font-weight:600;color:var(--text-3);font-variant-numeric:tabular-nums}
#appView .cx-line.is-earned .cx-line-value{color:var(--text-1)}
#appView .cx-group{border-top:1px solid var(--line);background:var(--surface-2)}
#appView .cx-group:first-child{border-top:0}
#appView .cx-group .cx-line-label{padding-left:0;font-size:14px;font-weight:700}
#appView .cx-group .cx-line-label svg{width:16px;height:16px;color:var(--orange)}
#appView .cx-group .cx-line-value{font-weight:800;color:var(--text-1)}
#appView .cx-sum{border-top:0;background:var(--brand-navy)}
#appView .cx-sum .cx-line-label{padding-left:0;font-size:15px;font-weight:800;color:#fff}
#appView .cx-sum .cx-line-detail{color:rgba(255,255,255,.72)}
#appView .cx-sum .cx-line-value{font-size:15px;font-weight:800;color:#fff}
#appView .cx-manual-title{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
#appView .cx-remove{grid-column:4;width:30px;height:30px;display:grid;place-items:center;padding:0;border:0;border-radius:8px;background:transparent;color:var(--text-3);cursor:pointer}
#appView .cx-remove:hover{background:var(--bad-bg);color:var(--bad-fg)}
#appView .cx-remove svg{width:15px;height:15px;pointer-events:none}
#appView .cx-note{display:flex;align-items:center;gap:6px;margin:12px 0 0;font-size:12.5px;color:var(--text-3)}
#appView .cx-note svg{flex:0 0 auto;width:14px;height:14px}

html[data-theme="dark"] #appView .cx-next.is-first{border-color:rgba(59,115,237,.4);background:linear-gradient(180deg,rgba(59,115,237,.10),var(--surface) 60%)}
html[data-theme="dark"] #appView .cx-sum{background:#1A1A1D}
html[data-theme="dark"] #appView .cx-num.zero,html[data-theme="dark"] #appView .cx-line-value{color:var(--text-subtle)}
html[data-theme="dark"] #appView .cx-line.is-earned .cx-line-value,html[data-theme="dark"] #appView .cx-group .cx-line-value{color:var(--text-1)}
html[data-theme="dark"] #appView .cx-sum .cx-line-value{color:#fff}

@media (max-width:1280px){
  #appView .cx-row{--cx-cols:minmax(170px,1.4fr) repeat(2,minmax(76px,.8fr)) 48px 56px repeat(4,minmax(70px,.75fr)) minmax(84px,.9fr) 20px;gap:8px;padding:0 12px}
  #appView .cx-nexts{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:1100px){
  #appView .cx-strip{grid-template-columns:repeat(2,minmax(0,1fr))}
  #appView .cx-strip>div:nth-child(3){border-left:0}
  #appView .cx-strip>div:nth-child(n+3){border-top:1px solid var(--line-soft)}
  #appView .cx-headrow{display:none}
  /* Cada vendedor vira um cartão com rótulos */
  #appView .cx-row{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px 12px;padding:12px 14px}
  #appView .cx-row>.cx-who{grid-column:1/-2}
  #appView .cx-row>.cx-go{grid-column:-2/-1;grid-row:1;justify-self:end}
  #appView .cx-row>span:not(.cx-who):not(.cx-go){display:grid;gap:1px;justify-self:stretch;text-align:left}
  #appView .cx-row>span[data-label]::before{content:attr(data-label);font-family:var(--font-secondary);font-size:9.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--text-3)}
  #appView .cx-hero{grid-template-columns:1fr}
  #appView .cx-hero-side{border-left:0;border-top:1px solid var(--line-soft)}
  #appView .cx-line{grid-template-columns:minmax(0,1fr) auto auto;grid-template-areas:"label value act" "detail detail detail";gap:2px 10px}
  #appView .cx-line-label{grid-area:label;padding-left:0}
  #appView .cx-line-detail{grid-area:detail}
  #appView .cx-line-value{grid-area:value}
  #appView .cx-remove{grid-area:act}
}
@media (max-width:640px){
  #appView .cx-strip{grid-template-columns:1fr 1fr}
  #appView .cx-strip>div{padding:11px 12px}
  #appView .cx-big{font-size:18px}
  #appView .cx-tools{gap:8px}
  #appView .cx-switch{width:100%}
  #appView .cx-switch>*{flex:1;justify-content:center}
  #appView .cx-search{width:100%;margin-left:0}
  #appView .cx-tools .seller-selection-toolbar{width:100%}
  #appView .cx-tools .seller-selection-field{flex:1;min-width:0}
  #appView .cx-tools .seller-selection-field>span{display:none}
  #appView .cx-tools .seller-selection-field select{min-width:0;width:100%}
  #appView .cx-tools .seller-selection-step span{display:none}
  #appView .cx-row{grid-template-columns:repeat(3,minmax(0,1fr))}
  #appView .cx-recv strong{font-size:32px}
  #appView .cx-hero-main,#appView .cx-hero-side{padding:16px}
  #appView .cx-nexts{grid-template-columns:1fr}
  #appView .cx-section-head{flex-direction:column;align-items:flex-start;gap:2px}
  #appView .cx-head .page-header-actions{width:100%;justify-content:stretch}
  #appView .cx-add{flex:1 1 100%;justify-content:center}
  #appView .cx-head .month-stepper{flex:1 1 100%;justify-content:space-between}
  #appView .cx-foot>span:last-child{display:none}
}
html[data-theme="dark"] #appView .cx-search input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]){background:transparent!important;border:0!important;box-shadow:none!important}
