/* Tema escuro (padrão) e claro. A cor fica reservada aos departamentos; o destaque da
   interface (ícones, botão principal, medidor) usa um violeta que não é de nenhum deles. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  /* fundo em cinza-carvão neutro (sem azul); os textos secundários são um cinza claro, bem
     separado do fundo, e as cores dos departamentos são tons mais suaves que os do tema claro */
  --background: #101012;
  --card: #19191c;
  --elevado: #232327;
  --foreground: #f2f2f3;
  --muted: #252529;
  --muted-foreground: #b2b2ba;
  --border: #2c2c31;
  --input: #3c3c43;
  --destaque: #9287f3;
  --destaque-fundo: rgba(146, 135, 243, 0.14);
  --destructive: #ee8080;
  --shadow-xs: none;
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.5);
  --depto-contabil: #558ed6;
  --depto-fiscal: #ce7443;
  --depto-dp: #399e78;
  --depto-outros: #85858d;
  --aviso: #fab219;
  /* resultado: lucro e prejuízo (sempre junto com o sinal ou a palavra, nunca só a cor) */
  --bom: #4cc27a;
  --ruim: #ee8080;
}
:root[data-theme="light"] {
  color-scheme: light;
  --background: #f6f7fb;
  --card: #ffffff;
  --elevado: #ffffff;
  --foreground: #111528;
  --muted: #eef0f6;
  --muted-foreground: #646b82;
  --border: #e3e6ef;
  --input: #d5d9e6;
  --destaque: #5b4be0;
  --destaque-fundo: rgba(91, 75, 224, 0.10);
  --destructive: #d03b3b;
  --shadow-xs: 0 4px 12px rgba(17, 21, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(17, 21, 40, 0.12);
  --depto-contabil: #2a78d6;
  --depto-fiscal: #eb6834;
  --depto-dp: #1baf7a;
  --depto-outros: #a3a8a6;
  --bom: #0a7a2a;
  --ruim: #c93030;
}
:root {
  --radius: 0.75rem;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.5 var(--font-sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 18px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* menu lateral */
.lateral {
  width: 232px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  border-right: 1px solid var(--border);
}
.lateral svg { width: 18px; height: 18px; flex: none; }
/* logotipo do escritório com o nome do sistema embaixo, um pouco menor */
.marca { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px 8px 20px; }
.logotipo svg { display: block; width: 124px; height: auto; fill: currentColor; stroke: none; }
.nome-sistema { font-size: 13px; font-weight: 500; letter-spacing: 0.02em; color: var(--muted-foreground); }
.grupo { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-foreground); padding: 6px 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.lateral a[data-rota], #tema, #sair {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: calc(var(--radius) - 4px);
  color: var(--muted-foreground); font-weight: 500; border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer;
}
.lateral a[data-rota]:hover, #tema:hover, #sair:hover { color: var(--foreground); background: var(--muted); }
.lateral a.ativa { color: var(--foreground); background: var(--muted); }
.lateral-fim { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

#quem { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#quem small { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted-foreground); }
.lateral a[hidden] { display: none; }

/* entrada no sistema (primeiro acesso e login): ocupa a página inteira, sem menu */
body.fora .lateral, body.fora .pagina { display: none; }
body:not(.fora) #acesso { display: none; }
#acesso { flex: 1; display: grid; place-items: center; padding: 24px; }
.entrada { width: min(100%, 400px); }
.entrada .marca { align-items: center; padding-bottom: 22px; }
.entrada .logotipo svg { width: 150px; }
.entrada h2 { font-size: 18px; margin-bottom: 4px; }
.entrada .nota { margin-bottom: 18px; display: block; }
.formulario { display: grid; gap: 14px; }
.formulario label { display: grid; gap: 4px; color: var(--muted-foreground); font-size: 12.5px; font-weight: 500; }
.formulario input, .formulario select { width: 100%; padding: 8px 10px; color: var(--foreground); }
.formulario .botao-primario { justify-content: center; border: 0; padding: 9px 14px; cursor: pointer; }
.formulario .erro-formulario { color: var(--destructive); font-size: 13px; min-height: 20px; }
.formulario .ok-formulario { color: var(--depto-dp); }
.formulario.em-linha { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.formulario.em-linha .erro-formulario { grid-column: 1 / -1; }
td select { padding: 4px 8px; }
td .acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
td .acoes button { font-size: 12.5px; padding: 4px 10px; }
input:disabled, select:disabled { opacity: 0.6; cursor: not-allowed; }

/* área principal */
.pagina { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 88%, transparent); backdrop-filter: blur(8px);
}
.periodo { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.periodo > span { display: inline-flex; gap: 4px; align-items: center; color: var(--muted-foreground); }
.periodo [hidden], .periodo[hidden], .mais[hidden] { display: none; }
main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 24px 24px 72px; display: grid; gap: 20px; }

button, select, input {
  font: inherit; letter-spacing: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--input); border-radius: calc(var(--radius) - 4px); padding: 6px 10px;
}
button { cursor: pointer; }
button:hover { background: var(--muted); }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid color-mix(in oklab, var(--destaque) 60%, transparent); outline-offset: 1px; }
input::placeholder { color: var(--muted-foreground); }
input[type="checkbox"] { accent-color: var(--destaque); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.erro { border-color: var(--destructive); }
.botao-primario {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: calc(var(--radius) - 4px);
  background: var(--destaque); color: #fff; font-weight: 500;
}
.botao-primario:hover { filter: brightness(1.1); }
.botao-primario svg { width: 16px; height: 16px; }

.cabecalho { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cabecalho h1 { font-size: 22px; letter-spacing: -0.02em; }
.cabecalho .sub { color: var(--muted-foreground); }
.voltar { color: var(--muted-foreground); font-size: 13px; width: fit-content; margin-bottom: -10px; }
.voltar:hover { color: var(--foreground); }

/* cartões */
.cartao { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); padding: 20px 22px; min-width: 0; }
.cartao-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cartao-topo .nota, .nota { color: var(--muted-foreground); font-size: 13px; }
.cartao-topo a.nota:hover { color: var(--foreground); }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.duas-um { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 20px; }
@media (max-width: 1100px) { .duas-um { grid-template-columns: minmax(0, 1fr); } }

/* indicadores: ícone e nome em cima, número no meio, comparação embaixo */
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.indicadores.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .indicadores.tres { grid-template-columns: minmax(0, 1fr); } }
.indicador { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); min-width: 0; }
.indicador .rotulo { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 500; }
.indicador .icone { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: none; background: var(--destaque-fundo); color: var(--destaque); border: 1px solid color-mix(in oklab, var(--destaque) 30%, transparent); }
.indicador .icone svg { width: 16px; height: 16px; }
.indicador .valor { font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; padding: 14px 16px 2px; }
.indicador .detalhe { color: var(--muted-foreground); font-size: 12.5px; padding: 6px 16px 14px; min-height: 40px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.indicador .detalhe a { text-decoration: underline; text-underline-offset: 2px; }
/* variação contra o mês anterior: neutra, porque mais horas não é bom nem ruim por si */
.selo { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--muted); color: var(--foreground); white-space: nowrap; font-variant-numeric: tabular-nums; }

.bom { color: var(--bom); }
.ruim { color: var(--ruim); }
.selo.bom { background: color-mix(in oklab, var(--bom) 16%, transparent); color: var(--bom); }
.selo.ruim { background: color-mix(in oklab, var(--ruim) 16%, transparent); color: var(--ruim); }
.campo select { width: 100%; padding: 7px 10px; }
.etiqueta { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); margin-left: 6px; white-space: nowrap; vertical-align: 1px; }
.alerta { display: inline-flex; align-items: center; gap: 6px; }
.alerta::before { content: "!"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--aviso); color: #0b0b0b; font-size: 11px; font-weight: 700; }

/* lista com barras (maiores clientes, colaboradores, departamentos) */
.barras { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.barras .item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; }
.barras .linha { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.barras .nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.barras a.item:hover .nome { text-decoration: underline; text-underline-offset: 2px; }
.barras .valor { font-variant-numeric: tabular-nums; white-space: nowrap; }
.barras .valor small { color: var(--muted-foreground); font-size: 12.5px; margin-left: 6px; }
.trilho { display: block; height: 8px; border-radius: 4px; background: var(--muted); overflow: hidden; }
.trilho .cheio { display: flex; gap: 2px; height: 100%; }
.trilho i { display: block; min-width: 0; }
.trilho i:last-child { border-radius: 0 4px 4px 0; }
.ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex: none; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted-foreground); }
.legenda span { display: inline-flex; align-items: center; white-space: nowrap; }
.grafico-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.grafico-topo .alternador button { font-size: 12.5px; padding: 2px 10px; }
/* legenda que liga e desliga departamentos */
.legenda button { display: inline-flex; align-items: center; white-space: nowrap; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; color: var(--foreground); }
.legenda button[aria-pressed="false"] { color: var(--muted-foreground); text-decoration: line-through; background: var(--muted); border-color: transparent; }
.legenda button[aria-pressed="false"] .ponto { opacity: 0.3; }

/* medidor em arco (produtividade do escritório) */
.arco { position: relative; width: min(100%, 280px); margin: 4px auto 0; }
.arco svg { display: block; width: 100%; overflow: visible; }
.arco .fundo { stroke: var(--muted); stroke-width: 12; }
.arco .valor-arco { stroke: var(--destaque); stroke-width: 12; }
.arco .centro { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; }
.arco .centro b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.arco .centro span { color: var(--muted-foreground); font-size: 12.5px; }
.divisor { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.subtitulo { font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 12px; }

/* tabelas */
.rolagem { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th { color: var(--muted-foreground); font-weight: 600; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; padding-top: 0; }
th.ordenavel { cursor: pointer; user-select: none; }
th.ordenavel:hover { color: var(--foreground); }
th[aria-sort="descending"]::after { content: " ↓"; }
th[aria-sort="ascending"]::after { content: " ↑"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.fraco { color: var(--muted-foreground); }
tbody tr:last-child td { border-bottom: 0; }
tr.clicavel { cursor: pointer; }
tr.clicavel:hover td { background: var(--muted); }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--border); }
td a:hover { text-decoration: underline; text-underline-offset: 2px; }
td .principal { font-weight: 500; }
td .secundario { color: var(--muted-foreground); font-size: 12.5px; }
.barra-cel { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.barra-cel .trilho { width: 70px; flex: none; }
/* campo editável dentro da tabela: discreto até passar o mouse ou focar */
td.col-larga { min-width: 240px; }
input.na-linha { width: 100%; min-width: 150px; padding: 5px 8px; font-size: 13px; border-color: transparent; background: transparent; text-overflow: ellipsis; }
tr:hover input.na-linha, input.na-linha:focus { border-color: var(--input); background: var(--elevado); }
input.na-linha.salvo { border-color: var(--depto-dp); }
td.campo-cel { padding-top: 4px; padding-bottom: 4px; }
input.na-linha.valor { min-width: 110px; width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.controles { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.controles label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 13px; }
.aviso-recalculo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--input); border-radius: calc(var(--radius) - 4px); background: var(--muted); }
.aviso-recalculo[hidden] { display: none; }
textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--input); border-radius: calc(var(--radius) - 4px); padding: 8px 10px; width: 100%; min-height: 120px; resize: vertical; font-variant-numeric: tabular-nums; }
/* área para soltar os relatórios */
.soltar { display: grid; place-items: center; gap: 6px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--input); border-radius: var(--radius); color: var(--muted-foreground); }
.soltar:hover, .soltar.sobre { border-color: var(--destaque); background: var(--destaque-fundo); color: var(--foreground); }
.soltar b { color: var(--foreground); font-weight: 500; }
.soltar input { display: none; }
.envios { display: grid; gap: 10px; margin-top: 16px; }
.envio { border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); padding: 12px 14px; }
.envio .cabeca { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 500; }
.envio .corpo { color: var(--muted-foreground); font-size: 13px; margin-top: 4px; white-space: pre-line; }
.envio.falhou { border-color: var(--ruim); }
details.importar { margin-top: 16px; }
details.importar summary { color: var(--muted-foreground); cursor: pointer; width: fit-content; }
details.importar[open] summary { margin-bottom: 10px; }
.resultado-importacao { color: var(--muted-foreground); font-size: 13px; margin-top: 8px; white-space: pre-line; }
/* grade de percentuais da Configuração */
input.celula { width: 84px; padding: 5px 8px; }
td.celula-cel { padding-top: 5px; padding-bottom: 5px; }
.explicacao { color: var(--muted-foreground); max-width: 78ch; margin-bottom: 16px; }
.explicacao b { color: var(--foreground); font-weight: 500; }

.filtros input[type="search"] { width: 340px; max-width: 100%; }
.alternador { display: inline-flex; background: var(--muted); border-radius: calc(var(--radius) - 4px); padding: 3px; gap: 2px; }
.alternador button { border: 0; background: transparent; border-radius: calc(var(--radius) - 6px); padding: 3px 12px; color: var(--muted-foreground); font-weight: 500; }
.alternador button[aria-pressed="true"] { background: var(--elevado); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }

.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.campo label { display: block; color: var(--muted-foreground); font-size: 12.5px; font-weight: 500; margin-bottom: 4px; }
.campo input { width: 100%; }
.campo .ajuda { color: var(--muted-foreground); font-size: 12px; margin-top: 4px; min-height: 18px; }
.com-sufixo { display: flex; align-items: center; gap: 6px; }
.com-sufixo input { flex: 1; min-width: 0; }
.com-sufixo span { color: var(--muted-foreground); }
.opcao { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 13px; cursor: pointer; }

/* gráfico de colunas */
.grafico { position: relative; }
.grafico svg { display: block; width: 100%; overflow: visible; stroke: none; }
.grafico text { font-size: 11.5px; fill: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.grafico text.forte { fill: var(--foreground); font-weight: 600; }
.grafico .linha-grade { stroke: var(--border); stroke-width: 1; }
.grafico g.fraca { opacity: 0.45; }
.grafico .referencia { stroke: var(--foreground); stroke-width: 1; opacity: 0.55; }
.grafico text.rotulo-referencia { fill: var(--foreground); font-weight: 500; }
.grafico .alvo { fill: transparent; outline: none; }
.grafico .alvo.clicavel { cursor: pointer; }
.grafico .alvo:hover, .grafico .alvo:focus { fill: color-mix(in oklab, var(--foreground) 6%, transparent); }
.dica {
  position: absolute; pointer-events: none; z-index: 3; min-width: 160px;
  background: var(--elevado); border: 1px solid var(--input); border-radius: calc(var(--radius) - 4px);
  box-shadow: var(--shadow-md); padding: 8px 10px; font-size: 12.5px;
}
.dica .titulo { color: var(--muted-foreground); }
.dica .principal { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dica .parte { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--muted-foreground); }
.dica .parte span { display: inline-flex; align-items: center; gap: 6px; }
.dica .parte b { color: var(--foreground); font-weight: 500; font-variant-numeric: tabular-nums; }
.dica .traco { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
details.tabela-dados { margin-top: 12px; font-size: 13px; }
details.tabela-dados summary { color: var(--muted-foreground); cursor: pointer; width: fit-content; }
details.tabela-dados[open] summary { margin-bottom: 10px; }

/* medidor de produtividade: quanto da jornada foi registrado (a barra enche em 100%) */
.medidor { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.medidor .trilho { width: 110px; flex: none; }
.medidor .trilho i { height: 100%; background: var(--destaque); border-radius: 4px; }
.medidor b { font-weight: 500; min-width: 44px; }

.vazio { color: var(--muted-foreground); padding: 20px 0; text-align: center; }
.mais { display: block; margin: 14px auto 0; color: var(--muted-foreground); }
.carregando { opacity: 0.5; transition: opacity 0.15s; }

/* telas estreitas: o menu lateral vira uma faixa no topo */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .lateral { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .marca { padding: 4px 8px; }
  .grupo { display: none; }
  #nav, .lateral-fim { flex-direction: row; flex-wrap: wrap; }
  .lateral-fim { margin: 0; padding: 0; border: 0; }
  .lateral a[data-rota], #tema, #sair { width: auto; }
  .topo { position: static; }
}
