/* ═══════════════════════════════════════════════════════════════════
   Elevia Admin
   Escuro por defeito; [data-tema="claro"] no <html> troca as variáveis.
   Ferramenta interna de dados: calma, densa, rápida de ler.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:         #0a0b0f;
  --lado:       #0d0e13;
  --surface:    #13141b;
  --surface-2:  #191b23;
  --surface-3:  #22242f;
  --borda:      #24262f;
  --borda-2:    #31343f;
  --texto:      #eceef4;
  --texto-2:    #a9aec0;
  --texto-3:    #8a8fa3;
  --acento:     #b48cff;              /* ligações e foco */
  --primario:   #7c3aed;              /* fundo do botão principal (texto branco) */
  --primario-h: #6d2fd9;
  --pos:        #3fcf8e;
  --pos-fundo:  rgba(63,207,142,.12);
  --aviso:      #f2b04b;
  --aviso-fundo:rgba(242,176,75,.12);
  --neg:        #ff7a96;
  --neg-fundo:  rgba(255,122,150,.12);
  --info:       #7aaeff;              /* texto de estado azul (não é a cor da série) */
  --s-vendas:   #4a8cf0;              /* validado: CVD ok contra --surface */
  --s-mensal:   #cc7a26;
  --sombra:     0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --raio:       12px;
  --raio-s:     8px;
  --f-ui:       'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-titulo:   'Bricolage Grotesque', var(--f-ui);
  --f-mono:     'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

:root[data-tema="claro"] {
  --bg:         #f3f4f8;
  --lado:       #ffffff;
  --surface:    #ffffff;
  --surface-2:  #f6f7fb;
  --surface-3:  #eceef5;
  --borda:      #e3e5ee;
  --borda-2:    #d0d3df;
  --texto:      #161925;
  --texto-2:    #4b5167;
  --texto-3:    #5f6579;
  --acento:     #6d28d9;
  --primario:   #6d28d9;
  --primario-h: #5b21b6;
  --pos:        #0f7a52;
  --pos-fundo:  rgba(15,122,82,.10);
  --aviso:      #925400;
  --aviso-fundo:rgba(201,116,22,.12);
  --neg:        #b8234a;
  --neg-fundo:  rgba(184,35,74,.09);
  --info:       #1f5fbf;
  --s-vendas:   #2f76e8;
  --s-mensal:   #c97416;
  --sombra:     0 1px 2px rgba(22,25,37,.05), 0 6px 18px rgba(22,25,37,.05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
/* hidden tem de esconder sempre, mesmo em elementos com display próprio (.btn, .campo...) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font: 400 14px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
b { font-weight: 600; }
small { font-size: .78em; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sec { color: var(--texto-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ic { flex: none; }

.saltar { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--primario); color: #fff;
  padding: 8px 14px; border-radius: var(--raio-s); }
.saltar:focus { top: 12px; }

/* ── estrutura ───────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.lado {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px;
  background: var(--lado);
  border-right: 1px solid var(--borda);
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--texto);
  font: 700 19px/1 var(--f-titulo); letter-spacing: -.02em; }
.marca:hover { text-decoration: none; }
.marca small { font: 500 11px/1 var(--f-mono); color: var(--texto-3); letter-spacing: .04em;
  padding: 3px 6px; border: 1px solid var(--borda-2); border-radius: 5px; margin-left: 2px; }
.marca.grande { justify-content: center; font-size: 24px; margin-bottom: 22px; }

.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a, .menu-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--raio-s);
  color: var(--texto-2); font: 500 14px/1.2 var(--f-ui);
  background: none; border: 0; cursor: pointer; width: 100%; text-align: left;
}
.menu a:hover, .menu-btn:hover { background: var(--surface-2); color: var(--texto); text-decoration: none; }
.menu a.on { background: var(--surface-3); color: var(--texto); }
.menu a.on .ic { color: var(--acento); }
.lado-fim { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--borda); padding-top: 12px; }
.quem { padding: 8px 10px 0; font-size: 12px; color: var(--texto-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conteudo { padding: 26px 32px 64px; max-width: 1360px; width: 100%; }
.cab { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; min-height: 40px; }
.cab h1 { font: 700 26px/1.15 var(--f-titulo); letter-spacing: -.02em; }
.cab-acoes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── botões ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--raio-s); border: 1px solid var(--borda-2);
  background: var(--surface); color: var(--texto);
  font: 500 13.5px/1 var(--f-ui); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.principal { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn.principal:hover { background: var(--primario-h); border-color: var(--primario-h); }
.btn.perigo { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); background: transparent; }
.btn.perigo:hover { background: var(--neg-fundo); }
.btn.largo { width: 100%; height: 42px; }
.btn.icone { width: 36px; padding: 0; font-size: 18px; }
.btn.mini { height: 28px; padding: 0 10px; font-size: 12.5px; }
.encostar-dir { margin-left: auto; }

/* ── avisos ──────────────────────────────────────────────────────── */
.aviso { padding: 11px 14px; border-radius: var(--raio-s); margin-bottom: 18px; font-size: 13.5px;
  border: 1px solid var(--borda-2); background: var(--surface-2); }
.aviso.ok { border-color: color-mix(in srgb, var(--pos) 35%, transparent); background: var(--pos-fundo); }
.aviso.erro { border-color: color-mix(in srgb, var(--neg) 40%, transparent); background: var(--neg-fundo); }
.aviso.aviso-amarelo { border-color: color-mix(in srgb, var(--aviso) 40%, transparent); background: var(--aviso-fundo); }

/* ── cartões ─────────────────────────────────────────────────────── */
.cartao { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio); padding: 18px 20px; box-shadow: var(--sombra); }
.cartao h2 { font-size: 14px; color: var(--texto); }
.cartao-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cartao > h2 { margin-bottom: 12px; }
.cartao.perigo h2 { color: var(--neg); }
.ligacao { font-size: 13px; font-weight: 500; }
.coluna-lado { display: flex; flex-direction: column; gap: 16px; }

.lista-simples { list-style: none; margin: 0 0 12px; padding: 0; }
.lista-simples li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--borda); }
.lista-simples li:last-child { border-bottom: 0; }
.lista-simples a { color: var(--texto); font-weight: 500; }
.destaque-linha { font-weight: 600; margin: 0 0 12px; }
.tudo-ok { color: var(--pos); margin: 0; font-weight: 500; }

.vazio { border: 1px dashed var(--borda-2); border-radius: var(--raio); padding: 28px; text-align: center; margin-bottom: 22px; }
.vazio p { margin: 0 0 16px; color: var(--texto-2); max-width: 52ch; margin-inline: auto; }
.vazio.boas-vindas { background: var(--surface); }

/* ── estados (projetos) ──────────────────────────────────────────── */
.estado, .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap;
  background: var(--surface-3); color: var(--texto-2);
}
.estado::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.e-proposta   { color: var(--texto-2); }
.e-em_curso   { color: var(--acento);  background: color-mix(in srgb, var(--acento) 14%, transparent); }
.e-entregue   { color: var(--pos);     background: var(--pos-fundo); }
.e-manutencao { color: var(--info);    background: color-mix(in srgb, var(--info) 14%, transparent); }
.e-pausado    { color: var(--aviso);   background: var(--aviso-fundo); }
.e-perdido    { color: var(--texto-3); text-decoration: line-through; }
.pill.ok { color: var(--pos); background: var(--pos-fundo); }
.pill.aviso-pill { color: var(--aviso); background: var(--aviso-fundo); }
.divida { color: var(--neg); margin-top: 3px; }

/* ── tabelas ─────────────────────────────────────────────────────── */
.tabela-env { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio); overflow-x: auto; box-shadow: var(--sombra); }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela thead th { font-size: 11.5px; font-weight: 600; color: var(--texto-3); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.tabela th.num, .tabela td.num { text-align: right; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: var(--surface-2); }
.tabela .linha-link { color: var(--texto); }
/* a linha inteira abre o projeto: o link do nome estica-se por cima dela */
.linhas-clicaveis tbody tr { position: relative; cursor: pointer; }
.linhas-clicaveis .linha-link::after { content: ''; position: absolute; inset: 0; }
.linhas-clicaveis .linha-link:focus-visible { outline: none; }
.linhas-clicaveis tbody tr:has(.linha-link:focus-visible) { outline: 2px solid var(--acento); outline-offset: -2px; }
.tabela.compacta th, .tabela.compacta td { padding: 7px 10px; font-size: 13px; }
.tabela tfoot th, .tabela tfoot td { border-top: 1px solid var(--borda-2); border-bottom: 0; background: var(--surface-2); font-size: 12.5px; }

.barra-filtros { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.separadores { display: flex; gap: 4px; flex-wrap: wrap; }
.separadores a { padding: 7px 12px; border-radius: var(--raio-s); color: var(--texto-2); font-weight: 500; font-size: 13.5px; }
.separadores a:hover { background: var(--surface-2); color: var(--texto); text-decoration: none; }
.separadores a.on { background: var(--surface-3); color: var(--texto); }
.separadores .n { font: 500 11.5px/1 var(--f-mono); color: var(--texto-3); margin-left: 4px; }
.pesquisa input { width: 260px; }

/* ── formulários ─────────────────────────────────────────────────── */
.form fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.form legend { font-size: 14px; font-weight: 600; color: var(--texto); margin-bottom: 12px; padding: 0; }
.form fieldset + fieldset { border-top: 1px solid var(--borda); padding-top: 20px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; flex: 1; }
.campo label { font-size: 13px; font-weight: 500; color: var(--texto-2); }
.opc { font-weight: 400; color: var(--texto-3); font-size: 12px; }
.linha-campos { display: flex; gap: 14px; flex-wrap: wrap; }
.linha-campos > .campo { flex: 1 1 180px; }
.linha-campos > .campo.largo-2 { flex: 2 1 280px; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  font: 400 14px/1.4 var(--f-ui); color: var(--texto);
  background: var(--surface-2); border: 1px solid var(--borda-2); border-radius: var(--raio-s);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 25%, transparent); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--neg); }
input::placeholder, textarea::placeholder { color: var(--texto-3); opacity: 1; }
.dica { font-size: 12px; color: var(--texto-3); }
.erro-campo { font-size: 12.5px; color: var(--neg); font-weight: 500; }
.com-sufixo { position: relative; display: flex; align-items: center; }
.com-sufixo input { padding-right: 58px; font-variant-numeric: tabular-nums; }
.com-sufixo span { position: absolute; right: 11px; color: var(--texto-3); font-size: 13px; pointer-events: none; }
.form-fim { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 6px; }

.grelha-ficha { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.grelha-ficha > .form { padding: 22px 24px; }

/* ── entrada / registo ───────────────────────────────────────────── */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; position: relative;
  background:
    radial-gradient(600px 300px at 50% -10%, color-mix(in srgb, #7c3aed 22%, transparent), transparent 70%),
    var(--bg); }
.caixa { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--borda); border-radius: 16px; padding: 30px 28px; box-shadow: var(--sombra); }
.caixa h1 { font: 700 22px/1.2 var(--f-titulo); margin-bottom: 6px; text-align: center; }
.caixa .sub { text-align: center; color: var(--texto-3); margin: 0 0 18px; font-size: 13px; }
.caixa h1 + form, .caixa h1 + .aviso { margin-top: 18px; }
.nota-baixo { text-align: center; font-size: 13px; color: var(--texto-3); margin: 18px 0 0; }
.tema-solto { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--borda-2); color: var(--texto-2); cursor: pointer; }
.tema-solto:hover { color: var(--texto); }

/* ── dashboard ───────────────────────────────────────────────────── */
.topo-dash { display: grid; grid-template-columns: minmax(260px, .9fr) minmax(0, 2.6fr); gap: 16px; margin-bottom: 16px; }
.heroi {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  padding: 22px; border-radius: var(--raio);
  background: color-mix(in srgb, var(--pos) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--pos) 28%, transparent); box-shadow: var(--sombra);
}
/* faturação a verde: é o número que interessa e dá cor ao topo do dashboard */
.heroi-val { font: 600 48px/1.05 var(--f-ui); letter-spacing: -.03em; color: var(--pos); }
.heroi-sub { color: var(--texto-3); font-size: 13px; }
/* propostas em aberto a amarelo: dinheiro que ainda pode entrar */
.kpi-propostas {
  background: color-mix(in srgb, var(--aviso) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--aviso) 30%, transparent);
}
.kpi-propostas .kpi-val { color: var(--aviso); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); min-width: 0; }
.kpi-rot { font-size: 12.5px; color: var(--texto-3); font-weight: 500; }
.kpi-val { font: 600 24px/1.15 var(--f-ui); letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; }
.kpi-val small { font-size: 13px; font-weight: 500; color: var(--texto-3); letter-spacing: 0; margin-left: -3px; }
.kpi-val.pos { color: var(--pos); }
.kpi-val.alerta { color: var(--neg); }
.kpi-sub { font-size: 12.5px; color: var(--texto-3); margin-top: auto; }
.medidor { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--pos) 18%, transparent); overflow: hidden; }
.medidor span { display: block; height: 100%; background: var(--pos); border-radius: 999px; }

.grelha-dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

/* gráfico de colunas empilhadas */
.legenda-graf { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--texto-2); }
.legenda-graf li { display: flex; align-items: center; gap: 7px; }
.legenda-graf i { width: 10px; height: 10px; border-radius: 3px; }
.s-vendas { background: var(--s-vendas); }
.s-mensal { background: var(--s-mensal); }

.grafico { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; height: 280px; }
.eixo-y { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 24px;
  font: 400 11px/1 var(--f-mono); color: var(--texto-3); text-align: right; font-variant-numeric: tabular-nums; }
.eixo-y span { transform: translateY(50%); }
.eixo-y span:first-child { transform: translateY(0); }
.area-graf { position: relative; }
.grelha-graf { position: absolute; inset: 0 0 24px; display: flex; flex-direction: column-reverse; justify-content: space-between; pointer-events: none; }
.grelha-graf i { display: block; height: 1px; background: var(--borda); }
.grelha-graf i:first-child { background: var(--borda-2); }   /* linha de base */
.colunas { position: absolute; inset: 0; display: flex; gap: 2px; }
.coluna { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; border-radius: 6px; cursor: default; }
.coluna:hover, .coluna:focus-visible { background: color-mix(in srgb, var(--texto) 4%, transparent); }
.pilha { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.seg { width: min(24px, 62%); display: block; min-height: 2px; }
.seg.fim { border-radius: 4px 4px 0 0; }
.rot-topo { position: absolute; left: 50%; transform: translateX(-50%); font: 600 11.5px/1 var(--f-ui); color: var(--texto); white-space: nowrap; }
.rot-mes { height: 24px; display: flex; align-items: flex-end; font-size: 11.5px; color: var(--texto-3); }
.coluna.atual .rot-mes { color: var(--texto); font-weight: 600; }
.dica-graf { position: absolute; z-index: 5; pointer-events: none; min-width: 168px;
  background: var(--surface-3); border: 1px solid var(--borda-2); border-radius: var(--raio-s);
  padding: 10px 12px; font-size: 12.5px; box-shadow: 0 10px 28px rgba(0,0,0,.3); }
.dica-graf b { display: block; margin-bottom: 6px; font-size: 13px; }
.dica-graf div { display: flex; justify-content: space-between; gap: 14px; color: var(--texto-2); }
.dica-graf div i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.dica-graf .tot { color: var(--texto); font-weight: 600; border-top: 1px solid var(--borda-2); margin-top: 6px; padding-top: 6px; }
.ver-tabela { margin-top: 16px; }
.ver-tabela summary { cursor: pointer; font-size: 13px; color: var(--texto-2); font-weight: 500; }
.ver-tabela summary:hover { color: var(--texto); }
.ver-tabela table { margin-top: 10px; }

.estados-linha { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.estados-linha a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px;
  border-radius: var(--raio-s); background: var(--surface-2); border: 1px solid var(--borda); color: var(--texto); }
.estados-linha a:hover { background: var(--surface-3); text-decoration: none; }
.estados-linha b { font-size: 16px; font-variant-numeric: tabular-nums; }

.lista-eventos { list-style: none; margin: 0; padding: 0; }
.lista-eventos li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--borda); }
.lista-eventos li:last-child { border-bottom: 0; }
.ev-data { flex: none; width: 42px; display: flex; flex-direction: column; align-items: center; padding: 4px 0;
  border-radius: var(--raio-s); background: var(--surface-2); font-size: 11px; color: var(--texto-3); text-transform: uppercase; }
.ev-data b { font-size: 16px; color: var(--texto); line-height: 1.1; }
.ev-txt { display: flex; flex-direction: column; min-width: 0; }
.ev-txt a { color: var(--texto); font-weight: 500; }

/* ── mensalidades (matriz) ───────────────────────────────────────── */
.nav-meses { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mes-atual { font-weight: 600; min-width: 140px; text-align: center; }
.instrucao { color: var(--texto-3); font-size: 13px; margin: 0; }
.barra-acoes { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.barra-acoes form { margin: 0; }
/* com JS, o "Guardar" só aparece na linha cujo valor mudou */
.js .valor-inline .btn.mini { visibility: hidden; }
.js .valor-inline.mudou .btn.mini { visibility: visible; }
.matriz th.mes { text-align: center; }
.matriz th.mes small { display: block; font-size: 10.5px; font-weight: 500; opacity: .75; }
.matriz th.mes.hoje { color: var(--texto); }
.matriz td.celula { text-align: center; padding: 8px 6px; }
.matriz td.celula form { margin: 0; }
.marca-mes {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 92px; height: 32px; padding: 0 10px;
  border-radius: 999px; border: 1px dashed var(--borda-2); background: transparent;
  color: var(--texto-3); font: 500 12.5px/1 var(--f-ui); cursor: pointer;
  font-variant-numeric: tabular-nums; transition: background .15s, border-color .15s, color .15s;
}
.marca-mes:hover { border-color: var(--acento); color: var(--texto); }
.marca-mes.pago { border: 1px solid transparent; background: var(--pos-fundo); color: var(--pos); }
.marca-mes.pago:hover { border-color: var(--pos); }
.marca-mes.atraso { border: 1px solid color-mix(in srgb, var(--neg) 45%, transparent); background: var(--neg-fundo); color: var(--neg); }
.nao-cobra { color: var(--texto-3); }
.matriz td.total b { display: block; font-size: 13px; }
.matriz td.total small { color: var(--texto-3); }
.matriz td.total.completo b { color: var(--pos); }
.valor-inline { display: inline-flex; align-items: center; gap: 6px; }
.valor-inline input { width: 76px; min-height: 30px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.valor-inline span { color: var(--texto-3); }

/* ── calendário ──────────────────────────────────────────────────── */
.nav-cal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vistas { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--borda); }
.vistas a { padding: 6px 12px; border-radius: 7px; color: var(--texto-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.vistas a:hover { color: var(--texto); text-decoration: none; background: var(--surface-3); }
.vistas a.on { background: var(--surface); color: var(--texto); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.linha-periodo { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin: -6px 0 14px; }
.periodo { font-size: 17px; margin: 0; }

/* grelha de horas (dia / semana): meia hora = --slot px */
/* o dia cabe no ecrã: --slots meias horas visíveis, cada uma com --slot px.
   O JS acerta --slot ao espaço real; isto é só o valor de arranque. */
.cal-vista { --slot: max(18px, calc((100vh - 250px) / var(--slots, 24)));
  background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio); overflow: clip; box-shadow: var(--sombra); }
.cal-scroll { position: relative; }
.cal-cabeca { position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--borda-2); }
.cal-linha, .cal-corpo { display: grid; grid-template-columns: 58px repeat(var(--dias), minmax(0, 1fr)); }
.cal-canto { font-size: 11px; color: var(--texto-3); padding: 6px 8px 0 0; text-align: right; }
.cal-cab-dia { display: flex; align-items: baseline; gap: 7px; padding: 10px 10px 8px; border-left: 1px solid var(--borda); color: var(--texto-2); }
.cal-cab-dia:hover { text-decoration: none; background: var(--surface-2); }
.cal-cab-dia small { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-3); }
.cal-cab-dia b { font-size: 20px; font-weight: 600; color: var(--texto); line-height: 1; }
.cal-cab-dia.hoje b { background: var(--primario); color: #fff; border-radius: 999px; padding: 4px 8px; font-size: 16px; }
.cal-todo-dia { border-top: 1px solid var(--borda); }
.cal-todo-dia .cal-canto { padding-top: 8px; }
.cal-todo-cel { min-height: 32px; padding: 4px; border-left: 1px solid var(--borda); display: flex; flex-direction: column; gap: 3px; cursor: cell; }
.cal-horas { position: relative; height: calc(var(--slot) * var(--slots, 48)); }
.cal-horas span { position: absolute; right: 8px; transform: translateY(-50%); font: 400 11px/1 var(--f-mono); color: var(--texto-3); }
.cal-horas span.primeira { transform: translateY(4px); }
.cal-col {
  position: relative; height: calc(var(--slot) * var(--slots, 48));
  border-left: 1px solid var(--borda);
  /* hora certa: linha cheia; meia hora: linha mais leve */
  background-image:
    linear-gradient(to bottom, var(--borda) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--borda) 50%, transparent) 1px, transparent 1px);
  background-size: 100% calc(var(--slot) * 2), 100% var(--slot);
  cursor: cell; touch-action: pan-x pan-y; user-select: none;
}
.cal-col.hoje { background-color: color-mix(in srgb, var(--acento) 5%, transparent); }

.cal-bloco {
  position: absolute; z-index: 1;
  left: calc(3px + (100% - 6px) * var(--p) / var(--n));
  width: calc((100% - 6px) / var(--n) - 2px);
  display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  padding: 3px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--cor-ev, var(--texto-3)) 22%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--cor-ev, var(--texto-3)) 55%, transparent);
  color: var(--texto); font-size: 12px; line-height: 1.3; cursor: grab;
  transition: box-shadow .15s;
}
.cal-bloco:hover { text-decoration: none; z-index: 2; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.cal-bloco .h { font: 500 10.5px/1.3 var(--f-mono); color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-bloco .t { font-weight: 600; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.cal-bloco.curto .t { display: block; white-space: nowrap; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.cal-bloco .c { color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-bloco.curto { flex-direction: row; align-items: center; gap: 6px; padding-block: 1px; white-space: nowrap; }
.cal-bloco.a-arrastar { z-index: 5; cursor: grabbing; opacity: .92; box-shadow: 0 10px 28px rgba(0,0,0,.35); transition: none; }
.cal-puxador { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.cal-fantasma, .cal-selecao {
  position: absolute; left: 3px; right: 3px; height: calc(var(--slot) - 2px); z-index: 0; pointer-events: none;
  border-radius: 6px; padding: 3px 7px; font: 500 10.5px/1.3 var(--f-mono); color: var(--texto-2);
  background: color-mix(in srgb, var(--acento) 10%, transparent);
  border: 1px dashed color-mix(in srgb, var(--acento) 55%, transparent);
}
.cal-selecao { z-index: 3; border-style: solid; background: color-mix(in srgb, var(--acento) 22%, transparent); color: var(--texto); }
.cal-agora { position: absolute; left: -1px; right: 0; height: 2px; background: var(--neg); z-index: 4; pointer-events: none; }
.cal-agora::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--neg); }
.dica-cal { margin-top: 10px; }

/* painel de criar / editar evento */
.painel-evento {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--borda-2); border-radius: 14px;
  background: var(--surface); color: var(--texto); box-shadow: 0 24px 64px rgba(0,0,0,.45);
}
.painel-evento::backdrop { background: rgba(5,6,10,.55); }
.painel-evento form { padding: 18px 22px 20px; }
.painel-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.painel-cab h2 { font-size: 17px; }
.fechar-painel { font-size: 22px; border-color: transparent; background: transparent; }
.rot-campo { font-size: 13px; font-weight: 500; color: var(--texto-2); padding: 0; }
.horas { display: flex; align-items: center; gap: 8px; }
.horas select { width: auto; flex: 1; font-variant-numeric: tabular-nums; }
.horas span { color: var(--texto-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--texto-2); margin: -4px 0 14px; cursor: pointer; }
.check input { width: 16px; min-height: 16px; height: 16px; accent-color: var(--primario); }
fieldset.campo { border: 0; padding: 0; margin: 0 0 14px; }
.tipos { display: flex; flex-wrap: wrap; gap: 6px; }
.tipo input { position: absolute; opacity: 0; pointer-events: none; }
.tipo span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--borda-2); background: var(--surface-2); color: var(--texto-2); font-size: 13px; font-weight: 500; }
.tipo span i { width: 8px; height: 8px; border-radius: 2px; background: var(--cor-ev); }
.tipo input:checked + span { color: var(--texto); border-color: var(--cor-ev); background: color-mix(in srgb, var(--cor-ev) 16%, var(--surface)); }
.tipo input:focus-visible + span { outline: 2px solid var(--acento); outline-offset: 2px; }

/* extras dos projetos */
.extras-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.extras-chips span { font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; color: var(--acento);
  background: color-mix(in srgb, var(--acento) 12%, transparent); }
.total-cliente { font-size: 13px; color: var(--texto-2); }
.total-cliente b { color: var(--texto); }
.tabela-env.sem-moldura { border: 0; box-shadow: none; background: transparent; margin-bottom: 16px; }
.tabela-extras th, .tabela-extras td { vertical-align: middle; }
.tabela-extras tr.a-editar td { background: color-mix(in srgb, var(--acento) 8%, transparent); }
.acoes-linha { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.acoes-linha form { margin: 0; }
.form-extra { border-top: 1px solid var(--borda); padding-top: 16px; }
.form-extra h3 { font-size: 14px; margin-bottom: 12px; }
.nota-extras { margin-top: 4px; font-size: 12px; }
.calendario { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; box-shadow: var(--sombra); }
.cal-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cab div { padding: 9px 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-3); background: var(--surface-2); border-bottom: 1px solid var(--borda); }
.cal-dia { min-height: 112px; padding: 6px 6px 8px; border-right: 1px solid var(--borda); border-bottom: 1px solid var(--borda); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-semana .cal-dia:last-child { border-right: 0; }
.cal-semana:last-child .cal-dia { border-bottom: 0; }
.cal-dia.fora { background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.cal-dia.fora .cal-num { color: var(--texto-3); opacity: .6; }
.cal-num { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 500; color: var(--texto-2); }
.cal-num:hover { background: var(--surface-3); text-decoration: none; color: var(--texto); }
.cal-dia.hoje .cal-num { background: var(--primario); color: #fff; }
/* o tipo do evento é um quadradinho de cor à frente do texto (igual ao da
   legenda), não uma barra lateral */
.cal-ev { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  padding: 3px 7px; border-radius: 5px; font-size: 12px; line-height: 1.35;
  color: var(--texto); background: var(--surface-2); overflow: hidden; overflow-wrap: anywhere; }
.cal-ev::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 2px;
  background: var(--cor-ev, var(--texto-3)); margin-right: 6px; vertical-align: 1px; }
.cal-ev:hover { background: var(--surface-3); text-decoration: none; }
.cal-ev .h { font: 500 11px/1 var(--f-mono); color: var(--texto-3); margin-right: 5px; }
.t-reuniao   { --cor-ev: var(--s-vendas); }
.t-prazo     { --cor-ev: var(--neg); }
.t-entrega   { --cor-ev: var(--pos); }
.t-pagamento { --cor-ev: var(--s-mensal); }
.t-outro     { --cor-ev: var(--texto-3); }
.legenda { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--texto-3); }
.legenda span { display: flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; background: var(--cor-ev); }
.agenda { display: none; }
.agenda-dia { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; margin-bottom: 10px; }
.agenda-dia.hoje { border-color: var(--acento); }
.agenda-dia h2 { font-size: 12.5px; color: var(--texto-3); font-weight: 600; margin-bottom: 8px; }
.agenda-dia .cal-ev { display: block; margin-bottom: 4px; padding: 7px 10px; font-size: 13.5px; }

/* ── responsivo ──────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .topo-dash { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grelha-dash, .grelha-ficha { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  /* align-content: start impede a grelha de esticar a barra do topo
     quando a página tem pouco conteúdo */
  .app { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .lado {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; align-content: start; gap: 6px 10px;
    padding: 10px 16px 8px; border-right: 0; border-bottom: 1px solid var(--borda);
  }
  .marca { padding: 4px 0; }
  /* separadores: os 4 sempre visíveis, sem scroll lateral */
  .menu { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .menu a { flex-direction: column; gap: 4px; padding: 7px 2px; font-size: 11.5px; text-align: center; }
  .menu a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* tabelas: scroll lateral dentro do cartão, cliente sempre à vista */
  .tabela:not(.compacta) { min-width: 640px; }
  .tabela.matriz { min-width: 860px; }
  .tabela:not(.compacta) th:first-child, .tabela:not(.compacta) td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface);
    box-shadow: 1px 0 0 var(--borda); min-width: 150px; max-width: 170px;
  }
  .tabela:not(.compacta) thead th:first-child,
  .tabela:not(.compacta) tfoot th:first-child { background: var(--surface-2); }
  .lado-fim { order: 2; margin-left: auto; flex-direction: row; border-top: 0; padding-top: 0; gap: 2px; }
  .lado-fim .menu-btn { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .lado-fim .menu-btn span, .quem { display: none; }
  .conteudo { padding: 20px 16px 48px; }
  .cab h1 { font-size: 22px; }
  .pesquisa, .pesquisa input { width: 100%; }
  .kpis.kpis-3 { grid-template-columns: 1fr; }
  .calendario, .legenda { display: none; }
  .agenda { display: block; }
  .nav-cal { width: 100%; }
  .vistas { width: 100%; }
  .vistas a { flex: 1; text-align: center; padding: 7px 4px; }
  .cal-cab-dia { padding: 8px 6px; flex-direction: column; gap: 2px; align-items: center; }
  .dica-cal { display: none; }
  .painel-evento { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .mes-atual { min-width: 0; }
}

@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .heroi-val { font-size: 38px; }
  .tabela th, .tabela td { padding: 10px 12px; }
  .grafico { height: 220px; }
  .rot-mes { font-size: 10px; }
}

/* ecrãs de toque: tudo o que se clica com o dedo tem pelo menos 44 px */
@media (pointer: coarse) {
  .btn { height: 44px; }
  .btn.icone { width: 44px; }
  .btn.mini { height: 40px; padding: 0 14px; }
  .marca-mes { height: 44px; min-width: 96px; }
  .menu a, .menu-btn { min-height: 44px; }
  .lado-fim .menu-btn { width: 44px; height: 44px; }
  .cal-num { min-width: 36px; height: 36px; }
  .valor-inline input { min-height: 40px; }
  input, select { min-height: 44px; }
  .separadores a { padding: 11px 14px; }
  .tipo span { min-height: 44px; padding-inline: 14px; }
  .vistas a { padding-block: 11px; }
  .check input { width: 22px; height: 22px; }
}

/* botão enquanto o pedido segue: sem duplo clique, com sinal de que está a trabalhar */
.a-enviar { opacity: .6; pointer-events: none; cursor: progress; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
