:root {
  color-scheme: light;
  --fundo: #f4f3f0;
  --superficie: #fcfcfb;
  --superficie-2: #f0efeb;
  --borda: #e2e0da;
  --texto: #0b0b0b;
  --texto-2: #52514e;
  --texto-3: #7a7975;
  --grade: #e8e6e1;
  --acento: #2a78d6;
  --acento-texto: #ffffff;
  --s1: #2a78d6; /* job */
  --s2: #eb6834; /* conteudo */
  --s3: #1baf7a; /* videochamada */
  --bom: #0f7a3a;
  --alerta: #b45309;
  --critico: #c0262d;
  --sombra: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fundo: #121211;
    --superficie: #1a1a19;
    --superficie-2: #232321;
    --borda: #33332f;
    --texto: #f0efec;
    --texto-2: #c3c2b7;
    --texto-3: #8e8d85;
    --grade: #2c2c29;
    --acento: #3987e5;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --bom: #4ade80;
    --alerta: #fbbf24;
    --critico: #f87171;
    --sombra: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fundo: #121211; --superficie: #1a1a19; --superficie-2: #232321; --borda: #33332f;
  --texto: #f0efec; --texto-2: #c3c2b7; --texto-3: #8e8d85; --grade: #2c2c29; --acento: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --bom: #4ade80; --alerta: #fbbf24; --critico: #f87171; --sombra: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--texto-2); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--borda); border-radius: 8px; background: var(--superficie);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--texto-2); }
button {
  cursor: pointer; border: 1px solid var(--borda); background: var(--superficie); border-radius: 8px; padding: .45rem .8rem;
}
button:hover { background: var(--superficie-2); }
button.primario { background: var(--acento); color: var(--acento-texto); border-color: transparent; font-weight: 600; }
button.primario:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; color: var(--acento); padding: 0 .2rem; }
button.perigo { color: var(--critico); }
button:disabled { opacity: .6; cursor: wait; }
.sutil { color: var(--texto-3); font-size: .85rem; }
.erro { color: var(--critico); font-size: .9rem; min-height: 1em; margin: .3rem 0; }
[hidden] { display: none !important; }

/* topo */
.topo {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding: .7rem 16px;
  background: var(--superficie); border-bottom: 1px solid var(--borda); position: sticky; top: 0; z-index: 5;
}
.marca { display: flex; align-items: center; gap: .5rem; }
.abas { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
.abas button { border: 0; background: none; color: var(--texto-2); white-space: nowrap; }
.abas button.ativa { background: var(--superficie-2); color: var(--texto); font-weight: 600; }
.usuario { color: var(--texto-2); font-size: .9rem; white-space: nowrap; }

.filtros {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; padding: .8rem 16px;
  max-width: 1280px; margin: 0 auto;
}
.presets { display: flex; flex-wrap: wrap; gap: .25rem; }
.presets button { padding: .4rem .65rem; font-size: .85rem; }
.presets button.ativa { background: var(--texto); color: var(--superficie); border-color: var(--texto); }
.compacto { min-width: 130px; }
#novo-lanc { margin-left: auto; }

main { max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }
.aba { display: grid; gap: 16px; }

.cartao {
  background: var(--superficie); border: 1px solid var(--borda); border-radius: 12px; padding: 16px; box-shadow: var(--sombra);
  min-width: 0;
}
.cartao-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .rotulo { font-size: .8rem; color: var(--texto-2); }
.kpi .valor { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; margin: .15rem 0; overflow-wrap: anywhere; }
.kpi .extra { font-size: .8rem; color: var(--texto-3); }
.kpi.destaque { border-color: var(--acento); }
.barra-meta { height: 8px; border-radius: 4px; background: var(--superficie-2); overflow: hidden; margin-top: .4rem; }
.barra-meta > i { display: block; height: 100%; background: var(--acento); border-radius: 4px; }

.duas { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.metade { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 900px) { .duas, .metade { grid-template-columns: 1fr; } }

/* acertos */
.saldos { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.saldo { border: 1px solid var(--borda); border-radius: 10px; padding: 12px 14px; background: var(--superficie); }
.saldo .linha { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-top: 1px dashed var(--borda); align-items: center; flex-wrap: wrap; }
.saldo .linha:first-of-type { border-top: 0; }
.etiqueta { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.etiqueta.deve { color: var(--alerta); }
.etiqueta.devo { color: var(--critico); }
.etiqueta.ok { color: var(--bom); }

/* tabelas */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .5rem .55rem; text-align: left; border-bottom: 1px solid var(--grade); white-space: nowrap; }
th { color: var(--texto-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
td.quebra { white-space: normal; min-width: 160px; color: var(--texto-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--borda); }
tr.removivel:hover { background: var(--superficie-2); }
.vazio { color: var(--texto-3); text-align: center; padding: 1.5rem; }

.ponto { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.c-job { background: var(--s1); fill: var(--s1); }
.c-conteudo { background: var(--s2); fill: var(--s2); }
.c-videochamada { background: var(--s3); fill: var(--s3); }
.c-acento { fill: var(--s1); }

/* graficos */
.legenda { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--texto-2); }
.grafico { width: 100%; display: block; overflow: visible; }
.grafico text { fill: var(--texto-3); font-size: 11px; }
.grafico .grade-linha { stroke: var(--grade); stroke-width: 1; }
.grafico .base { stroke: var(--borda); stroke-width: 1; }
.grafico .alvo { fill: transparent; cursor: pointer; }
.grafico .coluna:hover .seg, .grafico .coluna.foco .seg { filter: brightness(1.12); }
.grafico .rotulo-valor { fill: var(--texto-2); font-size: 11px; font-weight: 600; }
.dica {
  position: fixed; z-index: 20; pointer-events: none; background: var(--superficie); color: var(--texto); border: 1px solid var(--borda);
  border-radius: 8px; padding: .5rem .65rem; font-size: .82rem; box-shadow: 0 6px 24px rgb(0 0 0 / 18%); min-width: 170px;
}
.dica .t { font-weight: 700; margin-bottom: .25rem; }
.dica .l { display: flex; justify-content: space-between; gap: 1rem; }

/* formularios */
dialog {
  border: 1px solid var(--borda); border-radius: 14px; padding: 0; background: var(--superficie); color: var(--texto);
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
.formulario { padding: 18px; }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.grade .largo { grid-column: 1 / -1; }
.acoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .6rem; }
.previa { background: var(--superficie-2); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; margin: .8rem 0 0; }
.previa:empty { display: none; }
.form-linha { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }

.aviso {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--texto); color: var(--superficie);
  padding: .6rem 1rem; border-radius: 10px; z-index: 30; font-size: .9rem; max-width: calc(100vw - 32px);
}

/* login */
.tela-login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(360px, 100%); display: grid; gap: .8rem; }

@media (max-width: 640px) {
  .filtros { gap: .5rem; }
  .compacto { min-width: calc(50% - .25rem); flex: 1; }
  #novo-lanc { width: 100%; margin: 0; }
  .kpi .valor { font-size: 1.3rem; }
}

@media print {
  .topo, .filtros, .acoes-tabela, button { display: none !important; }
  body { background: #fff; }
  .cartao { box-shadow: none; break-inside: avoid; }
}
.mt { margin-top: 1rem; }
@media (max-width: 760px) {
  .abas { order: 3; flex-basis: 100%; }
  .usuario { margin-left: auto; }
}
.opcoes { display: grid; gap: 8px; }
.opcao { display: flex; gap: .7rem; align-items: flex-start; border: 1px solid var(--borda); border-radius: 10px; padding: .7rem .8rem; cursor: pointer; color: var(--texto); font-size: .92rem; }
.opcao:has(input:checked) { border-color: var(--acento); background: var(--superficie-2); }
.opcao input[type="radio"] { width: auto; margin-top: .2rem; }
.opcao > span { display: grid; gap: .2rem; flex: 1; }
.opcao input[type="date"] { max-width: 200px; margin-top: .3rem; }
.impacto-mais { color: var(--bom); font-weight: 600; }
.impacto-menos { color: var(--critico); font-weight: 600; }
