/* Radar de Contratos — layout: menu lateral fixo + área de trabalho; telas são listas densas com filtros no topo e detalhe em gaveta lateral */
:root {
  --fundo: #f5f4f9; --painel: #ffffff; --painel-2: #faf9fd; --linha: #e4e1ee; --texto: #16131f; --suave: #6a6580;
  --acento: #6a35f0; --acento-suave: #efe9ff; --acento-texto: #ffffff;
  --perigo: #c8364f; --perigo-suave: #fdecef; --alerta: #b8740c; --alerta-suave: #fdf3e2; --ok: #1a8a5e; --ok-suave: #e5f5ee;
  --barra: #cfc8e6; --sombra: 0 8px 30px rgba(22, 19, 31, .12);
  --f-titulo: 'Bricolage Grotesque', 'Manrope', system-ui, sans-serif; --f-texto: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --raio: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fundo: #0e0c14; --painel: #16131f; --painel-2: #1b1826; --linha: #2a2639; --texto: #ece9f6; --suave: #9c96b1;
    --acento: #9d80ff; --acento-suave: #251d42; --acento-texto: #120e1c;
    --perigo: #ff6b84; --perigo-suave: #3a1820; --alerta: #f0b14a; --alerta-suave: #33260f; --ok: #4fd39c; --ok-suave: #12301f;
    --barra: #3b3456; --sombra: 0 8px 30px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-tema="escuro"] {
  --fundo: #0e0c14; --painel: #16131f; --painel-2: #1b1826; --linha: #2a2639; --texto: #ece9f6; --suave: #9c96b1;
  --acento: #9d80ff; --acento-suave: #251d42; --acento-texto: #120e1c;
  --perigo: #ff6b84; --perigo-suave: #3a1820; --alerta: #f0b14a; --alerta-suave: #33260f; --ok: #4fd39c; --ok-suave: #12301f;
  --barra: #3b3456; --sombra: 0 8px 30px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); font-family: var(--f-texto); font-size: 14px; line-height: 1.5; }
a { color: var(--acento); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--f-titulo); font-weight: 700; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--suave); }
.pequeno { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* marca */
.marca { display: flex; align-items: center; gap: 10px; font-family: var(--f-titulo); font-weight: 700; font-size: 16px; }
.marca-sinal { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--acento); position: relative; flex: none; }
.marca-sinal::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 2px solid var(--acento); opacity: .55; }
.marca-sinal::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--acento); }

/* estrutura */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.lateral { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; background: var(--painel); border-right: 1px solid var(--linha); }
.menu { display: grid; gap: 2px; }
.menu a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--texto); text-decoration: none; font-weight: 500; }
.menu a:hover { background: var(--painel-2); }
.menu a.ativo { background: var(--acento-suave); color: var(--acento); font-weight: 700; }
.lateral-pe { margin-top: auto; display: grid; gap: 8px; }
.usuario { color: var(--texto); text-decoration: none; font-weight: 600; }
.topo-movel { display: none; }
.conteudo { padding: 28px max(16px, 3vw) 60px; min-width: 0; outline: none; }
.cabeca { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 24px; margin-bottom: 20px; }
.cabeca p { margin: 6px 0 0; max-width: 72ch; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra); }
  .lateral.aberta { transform: none; }
  .topo-movel { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; padding: 10px max(16px, env(safe-area-inset-left)); background: var(--painel); border-bottom: 1px solid var(--linha); }
}

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--linha); background: var(--painel); color: var(--texto); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--suave); }
.btn.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
.btn.primario:hover { filter: brightness(1.08); }
.btn.fantasma { background: transparent; border-color: transparent; }
.btn.fantasma:hover { background: var(--painel-2); }
.btn.perigo { color: var(--perigo); }
.btn.pequeno { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--linha); background: var(--painel); color: var(--texto); min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
label { font-size: 12px; font-weight: 600; color: var(--suave); }
.campo { display: grid; gap: 4px; min-width: 0; }

/* filtros */
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; padding: 14px; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); margin-bottom: 14px; }
.filtros .largo { grid-column: span 2; }
@media (max-width: 520px) { .filtros .largo { grid-column: auto; } }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texto); font-weight: 500; padding: 8px 0; }
.barra-res { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.barra-res .totais { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.barra-res b { font-family: var(--f-titulo); font-size: 16px; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: grid; gap: 4px; align-content: start; text-align: left; padding: 14px 16px; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); cursor: pointer; color: var(--texto); }
.kpi:hover { border-color: var(--acento); }
.kpi .rotulo { font-size: 12px; color: var(--suave); font-weight: 600; }
.kpi .valor { font-family: var(--f-titulo); font-size: 30px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--suave); font-variant-numeric: tabular-nums; }
.kpi.quente { border-color: var(--perigo); background: linear-gradient(var(--perigo-suave), var(--painel) 70%); }
.kpi.quente .valor { color: var(--perigo); }
.kpi.morno .valor { color: var(--alerta); }
.kpi.destaque { border-color: var(--acento); background: linear-gradient(var(--acento-suave), var(--painel) 70%); }
.kpi.destaque .valor { color: var(--acento); }

.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; margin-bottom: 14px; }
.cartao { background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; min-width: 0; display: grid; gap: 10px; align-content: start; }
.cartao .nota { margin: 0; font-size: 12px; color: var(--suave); }
.cartao.largo { grid-column: 1 / -1; }

/* gráficos */
.grafico { position: relative; min-height: 220px; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .barra { fill: var(--barra); cursor: pointer; }
.grafico .barra.forte { fill: var(--acento); }
.grafico .barra:hover { fill: var(--acento); opacity: .85; }
.grafico text { fill: var(--suave); font-size: 11px; font-family: var(--f-texto); }
.grafico text.v { fill: var(--texto); font-weight: 600; }
.lista-barras { display: grid; gap: 6px; }
.lb { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 3px 4px; border-radius: 6px; cursor: pointer; background: none; border: 0; text-align: left; color: var(--texto); width: 100%; }
.lb:hover { background: var(--painel-2); }
.lb .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lb .trilho { display: block; height: 10px; border-radius: 6px; background: var(--painel-2); overflow: hidden; }
.lb .enche { display: block; height: 100%; border-radius: 6px; background: var(--barra); }
.lb:first-child .enche { background: var(--acento); }
.lb .q { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.dica { position: absolute; pointer-events: none; background: var(--painel); border: 1px solid var(--linha); border-radius: 8px; box-shadow: var(--sombra); padding: 6px 10px; font-size: 12px; white-space: nowrap; z-index: 5; }

/* tabela */
.tabela-caixa { overflow: auto; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { position: sticky; top: 0; z-index: 1; background: var(--painel-2); text-align: left; font-size: 12px; color: var(--suave); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--linha); white-space: nowrap; }
.t th button { all: unset; cursor: pointer; }
.t th button:focus-visible { outline: 2px solid var(--acento); }
.t th[aria-sort] button::after { content: " ↓"; }
.t th[aria-sort=ascending] button::after { content: " ↑"; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.t tbody tr { cursor: pointer; }
.t tbody tr:hover { background: var(--painel-2); }
.t td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t td.d { white-space: nowrap; font-variant-numeric: tabular-nums; }
.t .principal { font-weight: 700; }
.t .sec { color: var(--suave); font-size: 12px; }
.t .obj { color: var(--suave); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 44ch; }
@media (max-width: 760px) { .t .esconde { display: none; } }
.paginas { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.vazio { padding: 40px 16px; text-align: center; color: var(--suave); }

/* etiquetas */
.pilula { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--painel-2); color: var(--suave); border: 1px solid var(--linha); }
.pilula.urgente { background: var(--perigo-suave); color: var(--perigo); border-color: transparent; }
.pilula.breve { background: var(--alerta-suave); color: var(--alerta); border-color: transparent; }
.pilula.ok { background: var(--ok-suave); color: var(--ok); border-color: transparent; }
.pilula.acento { background: var(--acento-suave); color: var(--acento); border-color: transparent; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--acento-suave); color: var(--acento); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.escolha { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--linha); background: var(--painel); cursor: pointer; font-size: 12px; font-weight: 600; user-select: none; }
.escolha input { position: absolute; opacity: 0; pointer-events: none; }
.escolha:has(input:checked) { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
.escolha:has(input:focus-visible) { outline: 2px solid var(--acento); outline-offset: 2px; }

/* gaveta de detalhe */
.gaveta-fundo { position: fixed; inset: 0; background: rgba(10, 8, 16, .45); z-index: 50; }
.gaveta { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--fundo); z-index: 51; overflow: auto; box-shadow: var(--sombra); padding: 22px max(16px, 2.4vw) 60px; display: grid; gap: 16px; align-content: start; }
.gaveta .topo { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.fatos { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.fato { background: var(--painel); border: 1px solid var(--linha); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.fato span { display: block; font-size: 11px; color: var(--suave); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.fato b { display: block; font-size: 15px; margin-top: 2px; overflow-wrap: anywhere; }
.oferta { border-left: 3px solid var(--acento); background: var(--painel); padding: 10px 12px; border-radius: 0 8px 8px 0; }
.oferta b { display: block; margin-bottom: 2px; }
.notas { display: grid; gap: 8px; }
.nota-item { background: var(--painel); border: 1px solid var(--linha); border-radius: 8px; padding: 8px 12px; }
.nota-item .quem { font-size: 11px; color: var(--suave); }
.form-linha { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }

/* funil */
.funil { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.coluna { background: var(--painel-2); border: 1px solid var(--linha); border-radius: var(--raio); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.coluna h3 { display: flex; justify-content: space-between; font-size: 13px; }
.card-funil { background: var(--painel); border: 1px solid var(--linha); border-radius: 8px; padding: 10px; display: grid; gap: 4px; cursor: pointer; text-align: left; color: var(--texto); width: 100%; }
.card-funil:hover { border-color: var(--acento); }

/* alertas */
.alertas { display: grid; gap: 12px; }
.alerta-card { display: grid; gap: 10px; }
.previa { white-space: pre-wrap; font-size: 12px; background: var(--painel-2); border: 1px solid var(--linha); border-radius: 8px; padding: 12px; max-height: 360px; overflow: auto; }
.faixa-aviso { padding: 10px 14px; border-radius: 8px; background: var(--alerta-suave); color: var(--texto); border: 1px solid var(--alerta); font-size: 13px; }

/* aviso flutuante */
.aviso { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--texto); color: var(--fundo); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--sombra); font-weight: 600; max-width: calc(100% - 32px); }

/* login */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 80% -10%, var(--acento-suave), transparent 60%), var(--fundo); }
.login-box { width: min(420px, 100%); background: var(--painel); border: 1px solid var(--linha); border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--sombra); }
.login-box h1 { font-size: 22px; }
.login-box p { margin: 0; }
.login-box form { display: grid; gap: 8px; }
.login-box .btn { margin-top: 8px; padding: 10px; }
.erro { color: var(--perigo); font-weight: 600; margin: 4px 0 0; }

.esqueleto { background: linear-gradient(90deg, var(--painel-2), var(--linha), var(--painel-2)); background-size: 200% 100%; border-radius: 8px; min-height: 18px; }
@media (prefers-reduced-motion: no-preference) { .esqueleto { animation: brilho 1.2s linear infinite; } @keyframes brilho { to { background-position: -200% 0; } } }

.menu a.com-sino { display: flex; justify-content: space-between; align-items: center; }
.sino { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--perigo); color: #fff; font-size: 11px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
