/* =====================================================================
   Calculadora de Propostas | Hedge Co
   Identidade visual de hedgemkt.com e app.hedgemkt.com:
   azul #0700D1, azul-noite #06061E, DM Serif Display (títulos e números
   de destaque) + DM Sans (interface). Fontes servidas pelo próprio site
   (licença OFL em assets/fontes/).
   ===================================================================== */

@font-face { font-family: "DM Sans"; src: url("assets/fontes/DMSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("assets/fontes/DMSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("assets/fontes/DMSans-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "DM Serif Display"; src: url("assets/fontes/DMSerifDisplay-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  /* Cores da marca */
  --azul: #0700d1;
  --azul-escuro: #05009e;       /* hover/ativo do botão principal */
  --azul-suave: #eeeefe;        /* seleção, itens marcados */
  --noite: #06061e;             /* texto principal e superfície escura */
  --noite-2: #0e0e2c;           /* campos na superfície escura */
  --fundo: #fafafd;
  --superficie: #ffffff;
  --superficie-2: #f5f5fd;      /* cabeçalhos de tabela, painéis secundários */
  --texto: #06061e;
  --texto-2: #5c5c7f;           /* secundário (≥ 4.5:1 sobre branco) */
  --texto-3: #6e6e91;           /* metadados, placeholders (≥ 4.5:1 sobre branco) */
  --linha: #e5e5f2;
  --linha-forte: #c9c9de;
  --verde: #00855f;             /* sucesso em texto (o #00C896 da marca não passa em contraste) */
  --erro: #c62828;

  /* Tipografia */
  --fonte: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fonte-titulo: "DM Serif Display", Georgia, serif;

  /* Espaço, raio, sombra, movimento (escala de app.hedgemkt.com) */
  --e-1: 4px; --e-2: 8px; --e-3: 12px; --e-4: 16px; --e-5: 20px; --e-6: 24px; --e-8: 32px; --e-10: 40px;
  --raio-sm: 6px; --raio-md: 8px; --raio-lg: 12px;
  --sombra-card: 0 1px 2px rgba(6, 6, 30, .04), 0 4px 12px rgba(6, 6, 30, .05);
  --sombra-resumo: 0 2px 4px rgba(6, 6, 30, .05), 0 12px 28px rgba(6, 6, 30, .08);
  --foco: 0 0 0 3px rgba(7, 0, 209, .2);
  --rapido: .15s;
  --suave: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--fonte);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--fundo);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--azul);
  accent-color: var(--azul);
}
::selection { background: var(--azul); color: #fff; }

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }

/* ---------- Topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: var(--e-4);
  padding: var(--e-3) var(--e-6);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--linha);
}
.topo-marca { display: flex; align-items: center; gap: var(--e-4); min-width: 0; }
.logo { display: block; height: 28px; width: auto; }
.topo-titulo {
  padding-left: var(--e-4); border-left: 1px solid var(--linha);
  font-weight: 500; font-size: .95rem; color: var(--texto-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topo-direita { display: flex; align-items: center; gap: var(--e-1); }
.btn-topo { background: transparent; color: var(--texto); padding: var(--e-2) var(--e-3); font-weight: 500; font-size: .9rem; }
.btn-topo:hover { background: var(--superficie-2); }
/* Login e definição de senha têm a própria marca: sem barra de topo */
body:has(#tela-login:not([hidden])) .topo,
body:has(#tela-senha:not([hidden])) .topo { display: none; }

/* ---------- Telas de acesso (mesma linguagem de app.hedgemkt.com) ---------- */
.tela-acesso {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--e-10) var(--e-4);
  background: radial-gradient(120% 80% at 85% 0%, #14144d 0%, var(--noite) 60%);
  color: #fff;
}
.acesso { width: 100%; max-width: 400px; }
.logo-claro { height: 40px; margin-bottom: var(--e-8); filter: brightness(0) invert(1); }
.acesso h1 { font-family: var(--fonte-titulo); font-weight: 400; font-size: 2.25rem; line-height: 1.1; letter-spacing: -.01em; }
.acesso-texto { margin: var(--e-3) 0 var(--e-8); color: #b8b8d4; line-height: 1.55; }
.acesso label { color: #d6d6ea; }
.acesso input { background: var(--noite-2); border-color: #2d2d58; color: #fff; }
.acesso input:hover { border-color: #4a4a80; }
.acesso input:focus { border-color: #7b77ff; box-shadow: 0 0 0 3px rgba(123, 119, 255, .35); }
.acesso .btn-largo { margin-top: var(--e-6); }
.acesso button:focus-visible { box-shadow: 0 0 0 3px rgba(123, 119, 255, .6); }
.acesso .aviso { color: #ffabab; }

/* ---------- Estrutura ---------- */
.conteudo { max-width: 1200px; margin: 0 auto; padding: var(--e-8) var(--e-6) var(--e-10); }
.titulo-pagina {
  font-family: var(--fonte-titulo); font-weight: 400;
  font-size: 2rem; line-height: 1.15; letter-spacing: -.01em;
  margin-bottom: var(--e-6);
}
.area-trabalho { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--e-6); align-items: start; }
.coluna-principal { min-width: 0; }
/* padding-top alinha o resumo ao primeiro painel (abaixo do título da página) */
.coluna-resumo { position: sticky; top: 76px; padding-top: 61px; }

.painel {
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra-card);
  padding: var(--e-6);
  margin-bottom: var(--e-5);
}
.painel h2 { font-size: 1.05rem; margin-bottom: var(--e-5); }
.nota { color: var(--texto-2); font-size: .9rem; margin: calc(-1 * var(--e-3)) 0 var(--e-5); max-width: 68ch; }
.vazio { color: var(--texto-2); margin: 0; }

/* ---------- Campos ---------- */
label { display: block; font-size: .85rem; font-weight: 500; color: var(--texto-2); margin-bottom: 6px; }
.rotulo-espaco { margin-top: var(--e-4); }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--linha-forte);
  border-radius: var(--raio-md);
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
  font-size: 1rem;
  transition: border-color var(--rapido) var(--suave), box-shadow var(--rapido) var(--suave);
}
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input:hover, select:hover, textarea:hover { border-color: #a9a9c6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul); box-shadow: var(--foco); }
textarea { resize: vertical; line-height: 1.5; }
input[type="number"] { font-variant-numeric: tabular-nums; }

.grade-dados { display: grid; grid-template-columns: minmax(0, 1fr) 210px auto; gap: var(--e-4); align-items: end; }
.grade-item { display: grid; gap: var(--e-4); align-items: end; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.campo-categoria { grid-column: span 5; }
.campo-servico { grid-column: span 7; }
.campo-tipo { grid-column: span 3; }
.campo-qtd { grid-column: span 3; }
.campo-frente { grid-column: span 4; }
.grade-item .campo-botao { grid-column: span 2; }
.grade-convite { display: grid; grid-template-columns: 1fr 1.3fr 180px auto; gap: var(--e-4); align-items: end; }

.caixa-selecao {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; margin: 0; padding: 0 var(--e-4);
  border: 1px solid var(--linha-forte); border-radius: var(--raio-md);
  font-size: .95rem; font-weight: 500; color: var(--texto); cursor: pointer; white-space: nowrap;
  transition: border-color var(--rapido) var(--suave), background var(--rapido) var(--suave);
}
.caixa-selecao:hover { border-color: #a9a9c6; }
.caixa-selecao:has(input:checked) { border-color: var(--azul); background: var(--azul-suave); }
.caixa-selecao:has(input:focus-visible) { box-shadow: var(--foco); }
.caixa-selecao input { width: 18px; height: 18px; min-height: 0; margin: 0; box-shadow: none; }

/* ---------- Botões ---------- */
button {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--raio-md);
  font: inherit; font-size: .95rem; font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--rapido) var(--suave), border-color var(--rapido) var(--suave),
              color var(--rapido) var(--suave), transform var(--rapido) var(--suave);
}
button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(7, 0, 209, .35); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; }
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--azul-escuro); }
.btn-primario:disabled { background: #dcdcef; color: #5c5c7f; }
.btn-secundario { background: var(--superficie); color: var(--texto); border-color: var(--linha-forte); }
.btn-secundario:hover:not(:disabled) { border-color: var(--noite); }
.btn-secundario:disabled { color: #6e6e91; background: var(--superficie-2); }
.btn-texto { background: transparent; color: var(--texto-2); padding-inline: var(--e-2); }
.btn-texto:hover { color: var(--erro); }
.btn-largo { width: 100%; }
button[data-ocupado] { cursor: progress; }

/* ---------- Avisos e estado ---------- */
.aviso { color: var(--erro); font-size: .875rem; margin: var(--e-2) 0 0; }
.aviso:empty { margin: 0; }
.aviso.sucesso, .status-calculo.sucesso { color: var(--verde); }
.status-calculo { color: var(--texto-2); font-size: .875rem; margin: var(--e-3) 0 0; }
.status-calculo:empty { display: none; }

/* ---------- Tabelas da proposta ---------- */
.frente + .frente { margin-top: var(--e-8); }
.frente-titulo { display: flex; justify-content: space-between; align-items: baseline; gap: var(--e-3); margin-bottom: var(--e-3); }
.frente-titulo h3 { font-family: var(--fonte-titulo); font-weight: 400; font-size: 1.35rem; line-height: 1.2; }
.frente-titulo span { color: var(--texto-3); font-size: .85rem; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
th, td { padding: 10px var(--e-3); border-bottom: 1px solid var(--linha); text-align: left; vertical-align: middle; }
thead th {
  background: var(--superficie-2); color: var(--texto-2);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 0;
}
thead th:first-child { border-radius: var(--raio-md) 0 0 var(--raio-md); }
thead th:last-child { border-radius: 0 var(--raio-md) var(--raio-md) 0; }
tbody tr { transition: background var(--rapido) var(--suave); }
tbody tr:hover { background: #fbfbff; }
td.num, th.num { text-align: right; }
.codigo { display: block; color: var(--texto-3); font-size: .78rem; font-weight: 400; }
.col-tipo { width: 112px; }
.col-qtd { width: 150px; }
.col-valor { width: 160px; }
.col-remover { width: 52px; text-align: center; }
td.col-remover { padding: 4px; }
.servico { font-weight: 500; }

.etiqueta {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.etiqueta-recorrente { background: var(--azul-suave); color: var(--azul); }
.etiqueta-pontual { background: #f0f0f6; color: #464666; }

.qtd-celula { display: flex; align-items: center; gap: var(--e-2); }
.qtd-editavel { width: 76px; min-height: 36px; padding: 6px 8px; text-align: right; }
.qtd-periodo { white-space: nowrap; font-size: .85rem; color: var(--texto-2); }
.valor { font-weight: 500; white-space: nowrap; }
.valor small { color: var(--texto-3); font-weight: 400; font-size: .8rem; }
.valor-pendente { color: var(--texto-3); }

tfoot td { border-bottom: 0; padding-top: var(--e-3); font-size: .9rem; color: var(--texto-2); }
tfoot tr + tr td { padding-top: 2px; }
tfoot strong { color: var(--texto); font-weight: 600; }

.btn-remover {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; min-height: 0; padding: 0;
  background: transparent; color: var(--texto-3); border-radius: var(--raio-sm);
}
.btn-remover:hover { background: #fdecec; color: var(--erro); }
.btn-remover svg { width: 16px; height: 16px; }

/* ---------- Resumo ---------- */
.resumo {
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra-resumo);
  padding: var(--e-6);
}
.resumo h2 { font-size: 1.05rem; margin-bottom: var(--e-4); }
.totais { margin: 0; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: var(--e-3); padding: var(--e-3) 0; border-top: 1px solid var(--linha); }
.total dt { color: var(--texto-2); font-size: .9rem; }
.total dt small { margin-top: 0; font-size: .8rem; color: var(--texto-3); }
.total dd { margin: 0; text-align: right; }
.total strong { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; transition: opacity var(--rapido) var(--suave); }
.total-fee { display: block; border-top: 0; padding: 0 0 var(--e-4); }
.total-fee dt { margin-bottom: var(--e-1); }
.total-fee dd { text-align: left; }
.total-fee strong {
  display: block;
  font-family: var(--fonte-titulo); font-weight: 400;
  font-size: 2.5rem; line-height: 1.1; letter-spacing: -.01em; color: var(--azul);
}
.total small { display: block; margin-top: var(--e-1); color: var(--texto-2); font-size: .85rem; }
.resumo .acoes { margin-top: var(--e-5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--e-2); }
.acoes-secundarias { display: flex; justify-content: space-between; gap: var(--e-2); }
.acoes-secundarias button { white-space: nowrap; padding-inline: var(--e-3); }
.acoes-secundarias .btn-secundario { flex: 1; }
/* Recalculando: números anteriores esmaecem até a resposta nova */
.coluna-resumo.atualizando .totais strong { opacity: .35; }

/* ---------- Finalizar proposta ---------- */
.opcoes-finalizar { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr); gap: var(--e-4); }
.opcao-finalizar { border: 1px solid var(--linha); border-radius: var(--raio-md); padding: var(--e-5); background: var(--superficie-2); }
.opcao-finalizar h3 { font-size: .95rem; margin-bottom: var(--e-2); }
.opcao-finalizar .nota { margin: 0 0 var(--e-4); }
.opcao-finalizar input, .opcao-finalizar textarea { background: var(--superficie); }
.opcao-finalizar button { margin-top: var(--e-4); }

/* ---------- Tela Vendedores ---------- */
.rolagem-horizontal { overflow-x: auto; }
.tabela-equipe { table-layout: auto; min-width: 720px; }
.tabela-equipe th { white-space: nowrap; }
.tabela-equipe td:not(:first-child):not(:last-child) { white-space: nowrap; }
.email-linha { color: var(--texto-2); font-size: .85rem; }
.situacao { font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.situacao-ativo { background: #e2f6ee; color: #006b4c; }
.situacao-pendente { background: #fff3d6; color: #7a4f00; }
.situacao-desativado { background: #efeff5; color: var(--texto-2); }
.acoes-linha { display: flex; gap: 6px; flex-wrap: wrap; max-width: 250px; }
.btn-acao {
  min-height: 32px; padding: 4px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: var(--superficie); color: var(--azul); border-color: var(--linha-forte);
}
.btn-acao:hover:not(:disabled) { border-color: var(--azul); }
.btn-acao.perigo { color: var(--erro); }
.btn-acao.perigo:hover:not(:disabled) { border-color: var(--erro); }
.voce { color: var(--texto-3); font-size: .8rem; }

/* ---------- Telas menores ---------- */
@media (max-width: 1080px) {
  .area-trabalho { grid-template-columns: minmax(0, 1fr) 300px; }
  .campo-categoria, .campo-servico { grid-column: span 6; }
  .campo-tipo, .campo-qtd { grid-column: span 3; }
  .campo-frente { grid-column: span 4; }
  .grade-item .campo-botao { grid-column: span 2; }
  .grade-dados { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campo-cliente { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .area-trabalho { grid-template-columns: minmax(0, 1fr); }
  .coluna-resumo { position: static; padding-top: 0; }
  .grade-convite { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topo { padding: var(--e-2) var(--e-4); }
  .topo-titulo { display: none; }
  .conteudo { padding: var(--e-5) var(--e-4) var(--e-8); }
  .titulo-pagina { font-size: 1.6rem; margin-bottom: var(--e-4); }
  .painel, .resumo { padding: var(--e-4); }
  .grade-item { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grade-dados { grid-template-columns: minmax(0, 1fr); }
  .campo-cliente { grid-column: auto; }
  .campo-categoria, .campo-servico, .campo-frente, .grade-item .campo-botao { grid-column: 1 / -1; }
  .campo-tipo, .campo-qtd { grid-column: span 1; }
  .grade-convite, .opcoes-finalizar { grid-template-columns: minmax(0, 1fr); }
  .caixa-selecao { white-space: normal; }

  /* Tabela vira lista: serviço em cima; tipo, quantidade e valor embaixo */
  .frente table, .frente tbody, .frente tfoot { display: block; }
  .frente thead { display: none; }
  .frente tbody tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "nome nome remover" "tipo qtd valor";
    gap: var(--e-2) var(--e-3); align-items: center;
    padding: var(--e-3) 0; border-bottom: 1px solid var(--linha);
  }
  .frente tbody td { padding: 0; border: 0; width: auto; }
  .frente td.servico { grid-area: nome; }
  .frente td.col-tipo { grid-area: tipo; }
  .frente td.col-qtd { grid-area: qtd; }
  .frente td.col-valor { grid-area: valor; }
  .frente td.col-remover { grid-area: remover; }
  .frente tfoot tr { display: flex; justify-content: space-between; gap: var(--e-3); }
  .frente tfoot td { padding: var(--e-2) 0 0; }
  .frente tfoot td:empty { display: none; }
  .qtd-periodo { font-size: .8rem; }
  .total-fee strong { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
  button:active:not(:disabled) { transform: none; }
}
