:root {
    --green-950: #12372a;
    --green-900: #174a35;
    --green-700: #247451;
    --green-500: #42a579;
    --green-100: #dff3e9;
    --green-50: #f0f8f4;
    --ink: #183029;
    --muted: #667872;
    --line: #dce6e1;
    --surface: #ffffff;
    --page: #f4f7f5;
    --red: #c74444;
    --red-soft: #fff0ef;
    --amber: #b7791f;
    --amber-soft: #fff7e6;
    --blue: #3977b8;
    --blue-soft: #edf5ff;
    --shadow: 0 8px 24px rgba(28, 64, 49, .07);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--page);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}
.container { width: min(100% - 40px, 1440px); margin-inline: auto; }

/* Navegação */
.topo { background: var(--green-950); color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.topo .container { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 15px; white-space: nowrap; }
.logo-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #7bd6aa; color: var(--green-950); font-weight: 900; font-size: 18px; }
.topo nav { min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topo nav a { color: #cce2d7; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 650; font-size: 13px; }
.topo nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topo nav a.ativo { background: #fff; color: var(--green-900); }
.topo nav a.sair { margin-left: 5px; background: rgba(255,255,255,.1); color: #fff; }
.topo nav a.sair:hover { background: #a93232; }

main.container { padding-top: 34px; padding-bottom: 64px; }
h1 { font-size: clamp(25px, 3vw, 34px); line-height: 1.15; letter-spacing: -.6px; margin-bottom: 8px; color: var(--green-950); }
h2 { font-size: 19px; line-height: 1.25; color: var(--ink); }
h3 { font-size: 16px; line-height: 1.3; }
p { margin: 6px 0; }
a { color: var(--green-700); }
small { color: var(--muted); }

/* Introdução e filtros de período */
.dashboard-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 12px; }
.dashboard-subtitulo { color: var(--muted); font-size: 16px; margin-top: 4px; }
.eyebrow { margin: 0 0 4px; color: var(--green-700); font-size: 11px; line-height: 1.2; font-weight: 800; text-transform: uppercase; letter-spacing: 1.1px; }
.periodo-form { flex: 0 0 230px; display: flex; flex-direction: column; gap: 5px; }
.periodo-form label { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .6px; }
.periodo-form select { width: 100%; padding: 10px 34px 10px 12px; border: 1px solid #bfcfc7; border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-weight: 650; }
.nota-fonte { color: var(--muted); font-size: 12px; margin: 0 0 24px; }

/* Estrutura da dashboard */
.dashboard-section { margin-top: 30px; min-width: 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.section-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.section-description { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.dashboard-two-columns { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 22px; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; }
.kpi-card { min-width: 0; min-height: 138px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: flex-start; }
.kpi-principal { background: linear-gradient(145deg, var(--green-950), var(--green-700)); border-color: transparent; color: #fff; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .5px; }
.kpi-principal .kpi-label { color: #d8eee3; }
.kpi-value { display: block; margin: 13px 0 9px; font-size: clamp(22px, 2vw, 29px); line-height: 1; letter-spacing: -.7px; overflow-wrap: anywhere; }
.kpi-contexto { margin-top: auto; color: var(--muted); font-size: 11px; }
.delta { display: inline-flex; margin-top: auto; padding: 4px 7px; border-radius: 6px; font-size: 10px; font-weight: 750; line-height: 1.25; }
.delta-positivo { background: var(--green-100); color: #17633f; }
.delta-negativo { background: var(--red-soft); color: #a23434; }
.kpi-principal .delta-positivo { background: rgba(255,255,255,.15); color: #fff; }
.kpi-principal .delta-negativo { background: #fff0ef; color: #9f3030; }

/* Leitura executiva */
.insight-banner { margin-top: 22px; padding: 17px 20px; border-radius: 13px; display: grid; grid-template-columns: 38px 1fr; gap: 14px; align-items: center; }
.insight-alerta { background: var(--amber-soft); border: 1px solid #ead4a5; }
.insight-ok { background: var(--green-50); border: 1px solid #b9dec9; }
.insight-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--amber); font-size: 20px; font-weight: 900; }
.insight-banner strong { color: var(--ink); }
.insight-banner p { color: #5d655f; }

/* Retenção */
.retencao-layout { display: grid; grid-template-columns: minmax(280px,.85fr) minmax(0,1.5fr); gap: 16px; }
.retencao-resumo { padding: 22px; border-radius: 15px; background: var(--green-950); color: #fff; box-shadow: var(--shadow); }
.retencao-resumo .kpi-label { color: #cce2d7; }
.retencao-numero { display: block; margin: 12px 0 10px; font-size: 48px; line-height: 1; letter-spacing: -2px; }
.progress-track { width: 100%; height: 9px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: #7bd6aa; }
.retencao-resumo > p { margin-top: 14px; color: #e3eee8; }
.gestor-leitura { margin-top: 17px; padding: 12px; border-radius: 9px; background: rgba(255,255,255,.09); color: #e3eee8; font-size: 12px; }
.segment-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.segment-card { position: relative; min-width: 0; padding: 18px 18px 17px 23px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; display: flex; flex-direction: column; }
.segment-card:hover { border-color: #a9cbb9; transform: translateY(-1px); }
.segment-card strong { font-size: 27px; line-height: 1.1; }
.segment-card > span:not(.segment-dot) { margin-top: 7px; font-weight: 750; }
.segment-card small { margin-top: 3px; }
.segment-dot { position: absolute; left: 0; top: 18px; bottom: 18px; width: 5px; border-radius: 0 5px 5px 0; }
.segment-dot.verde { background: var(--green-500); }
.segment-dot.azul { background: var(--blue); }
.segment-dot.amarelo { background: #e1a328; }
.segment-dot.vermelho { background: var(--red); }

/* Ações comerciais */
.action-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.action-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-top: 4px solid var(--green-500); border-radius: 14px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.acao-risco { border-top-color: #e59433; }
.acao-reativacao { border-top-color: var(--red); }
.acao-fidelizacao { border-top-color: var(--blue); }
.action-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; color: var(--muted); }
.action-top span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--green-50); color: var(--green-700); font-size: 11px; font-weight: 900; }
.action-top strong { font-size: 13px; }
.action-card h3 { margin-bottom: 8px; }
.action-card p { color: #52635d; font-size: 12px; }
.action-card .action-why { margin: 8px 0 14px; padding-top: 8px; border-top: 1px solid #edf1ef; }
.action-card > a { margin-top: auto; font-weight: 750; text-decoration: none; }

/* Gráficos */
.chart-panel { min-width: 0; padding: 22px 18px 14px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); overflow-x: auto; }
.bar-chart { min-width: 720px; min-height: 255px; display: flex; align-items: flex-end; gap: 8px; }
.bar-item { height: 235px; flex: 1; min-width: 38px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar-value { margin-bottom: 6px; color: var(--muted); font-size: 9px; white-space: nowrap; transform: rotate(-35deg); transform-origin: center; opacity: .75; }
.bar-column { width: min(100%,44px); min-height: 5px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg,#63bd91,var(--green-700)); transition: filter .15s; }
.bar-item:hover .bar-column { filter: brightness(.86); }
.bar-date { margin-top: 7px; color: var(--muted); font-size: 10px; font-weight: 650; }

/* Rankings e canais */
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #edf1ef; vertical-align: top; }
th { background: var(--green-900); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .45px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--green-50); }
td.acao { color: #52635d; max-width: 240px; font-size: 12px; }
td.mini .badge { margin: 1px; display: inline-block; }
.ranking-table { min-width: 580px; box-shadow: none; margin: 0; }
.ranking-table td:nth-child(2) { max-width: 280px; font-size: 12px; line-height: 1.3; }
.rank { width: 32px; color: var(--muted); font-weight: 800; }
.trend { display: inline-flex; padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.trend.up { background: var(--green-100); color: #17633f; }
.trend.down { background: var(--red-soft); color: #aa3737; }
.channel-list { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.channel-row { display: grid; grid-template-columns: 180px minmax(120px,1fr) 130px; align-items: center; gap: 15px; padding: 9px 0; }
.channel-name { min-width: 0; display: flex; flex-direction: column; }
.channel-name strong { overflow: hidden; text-overflow: ellipsis; }
.channel-name span { color: var(--muted); font-size: 11px; }
.channel-track { height: 9px; background: #edf2ef; border-radius: 99px; overflow: hidden; }
.channel-track span { display: block; height: 100%; border-radius: inherit; background: var(--green-500); }
.channel-value { text-align: right; white-space: nowrap; }
.data-caveat { margin-top: 24px; padding: 12px 15px; border-left: 4px solid #d09a2f; border-radius: 6px; background: var(--amber-soft); color: #655b46; font-size: 12px; }

/* Componentes usados nas demais telas */
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(205px,1fr)); gap: 14px; margin: 14px 0; }
.card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 5px; }
.card-link { color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.card-link:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(28,64,49,.11); }
.card .num { font-size: 25px; font-weight: 800; }
.card .lbl { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .5px; }
.card .sub { color: var(--muted); font-size: 12px; }
.st-verde { border-top: 4px solid var(--green-500); }
.st-amarelo { border-top: 4px solid #e4b438; }
.st-laranja { border-top: 4px solid #e58b32; }
.st-vermelho { border-top: 4px solid var(--red); }
.grid2 { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.painel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.secao-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dica { margin-bottom: 16px; padding: 12px 15px; border-left: 4px solid var(--green-700); border-radius: 6px; background: var(--green-50); }
.aviso-dados { margin: 14px 0; padding: 12px 15px; border-left: 4px solid #d09a2f; border-radius: 6px; background: var(--amber-soft); }
.destaque-acao { margin-top: 10px; padding: 12px; border: 1px solid #e4c679; border-radius: 8px; background: #fffbea; }
.resultado-resumo { margin: 9px 0 14px; color: var(--muted); }
.vazio { padding: 28px; text-align: center; color: var(--muted); }
.motivo { min-width: 220px; max-width: 320px; font-size: 12px; }
.acoes-marketing { display: flex; flex-wrap: wrap; gap: 6px; }
.canal { font-size: 11px; padding: 5px 8px; }

/* Badges, ajuda e tooltip */
.badge { display: inline-flex; padding: 3px 9px; border-radius: 20px; color: #fff; font-size: 10px; font-weight: 800; white-space: nowrap; }
.b-verde { background: #369765; }
.b-amarelo { background: #c89120; }
.b-laranja { background: #dc762a; }
.b-vermelho { background: #c74444; }
.b-cinza { background: #84948e; }
.legenda-status { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 10px 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.legenda-instrucao { color: var(--muted); font-size: 11px; }
.ajuda { width: 18px; height: 18px; margin-left: 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #dfeae4; color: var(--green-900); font-size: 11px; font-weight: 900; cursor: help; vertical-align: middle; }
.tem-tooltip { position: relative; cursor: help; }
.tem-tooltip::after { content: attr(data-tooltip); position: absolute; z-index: 1000; left: 50%; bottom: calc(100% + 9px); transform: translateX(-50%); width: max-content; max-width: 300px; padding: 9px 11px; border-radius: 7px; background: #1e2e28; color: #fff; box-shadow: 0 5px 18px rgba(0,0,0,.25); font-size: 12px; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: 0; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s; }
.tem-tooltip:hover::after, .tem-tooltip:focus::after { opacity: 1; visibility: visible; }

/* Botões e filtros */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--green-700); border-radius: 8px; background: #fff; color: var(--green-700); text-decoration: none; cursor: pointer; font-size: 13px; font-weight: 750; }
.btn:hover { background: var(--green-50); }
.btn-ativo { background: var(--green-700); color: #fff; }
.btn-ativo:hover { background: var(--green-900); }
.btn-pq { padding: 4px 9px; font-size: 11px; }
.filtros { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.filtros .campo { min-width: 170px; flex: 1 1 180px; display: flex; flex-direction: column; gap: 5px; }
.filtros label { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.filtros input[type=text], .filtros select { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid #bdcbc4; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
.paginacao { display: flex; gap: 6px; margin: 15px 0; }

/* Rodapé */
.rodape { margin-top: 30px; padding: 17px 0; border-top: 1px solid var(--line); background: #e9efeb; color: var(--muted); text-align: center; font-size: 11px; }

/* Login */
.login-fundo { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(140deg,var(--green-950),var(--green-700)); }
.login-box { width: min(100% - 32px,380px); padding: 38px 34px; border-radius: 16px; background: #fff; box-shadow: 0 18px 50px rgba(0,0,0,.25); text-align: center; }
.login-logo { margin-bottom: 8px; font-size: 42px; }
.login-box h1 { margin-bottom: 6px; font-size: 22px; }
.login-box p { margin-bottom: 18px; color: var(--muted); }
.login-box input[type=text], .login-box input[type=password] { width: 100%; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #b8c8c0; border-radius: 9px; font-size: 15px; text-align: center; }
.login-box input:focus { outline: 3px solid #c9ebda; border-color: var(--green-500); }
.login-box button { width: 100%; padding: 12px; border: 0; border-radius: 9px; background: var(--green-700); color: #fff; cursor: pointer; font-size: 15px; font-weight: 800; }
.login-box button:hover { background: var(--green-900); }
.login-erro { margin-bottom: 14px; padding: 10px; border: 1px solid #efb3b3; border-radius: 8px; background: var(--red-soft); color: #a73232; }

/* Responsividade */
@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .action-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .dashboard-two-columns { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .topo .container { padding: 13px 0; align-items: flex-start; flex-direction: column; }
    .topo nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
    .topo nav a { white-space: nowrap; }
    .retencao-layout { grid-template-columns: 1fr; }
    .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .container { width: min(100% - 24px,1440px); }
    main.container { padding-top: 24px; }
    .dashboard-intro { align-items: stretch; flex-direction: column; }
    .periodo-form { flex-basis: auto; width: 100%; }
    .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .kpi-principal { grid-column: 1 / -1; }
    .segment-grid, .action-grid { grid-template-columns: 1fr; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .section-note { white-space: normal; }
    .channel-row { grid-template-columns: 1fr auto; gap: 7px 12px; }
    .channel-track { grid-column: 1 / -1; grid-row: 2; }
    .channel-value { grid-column: 2; grid-row: 1; }
    .insight-banner { grid-template-columns: 1fr; }
    table { display: block; overflow-x: auto; }
    .tem-tooltip::after { left: 0; transform: none; max-width: 250px; }
}
@media (max-width: 440px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-principal { grid-column: auto; }
    .kpi-card { min-height: 125px; }
    .retencao-numero { font-size: 42px; }
}
