/* JV Gestão — estilos base. Telas de módulo usam só estas classes (sem CSS próprio), para manter o visual único. */
:root {
  --azul: #1f3a5f; --azul-2: #2c5282; --azul-claro: #e3ebf5; --amarelo: #f2a900;
  --fundo: #eef1f5; --cartao: #ffffff; --texto: #1b1f24; --suave: #5f6b7a; --borda: #d9dee5; --linha: #eef1f5;
  --ok: #1e7e34; --ok-fundo: #e3f4e8; --erro: #b00020; --erro-fundo: #fde7ea; --aviso: #8a5a00; --aviso-fundo: #fff4d6;
  --raio: 8px; --sombra: 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--fundo); }
a { color: var(--azul-2); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14.5px; margin: 0 0 8px; }
.carregando-tela { display: grid; place-items: center; min-height: 100vh; color: var(--suave); }

/* ---------- casca ---------- */
.casca { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.casca > div { min-width: 0; }
.lateral { background: var(--azul); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marca { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 700; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.marca img { width: 28px; height: 28px; }
.menu { list-style: none; margin: 0; padding: 8px 0; flex: 1; }
.menu a { display: block; padding: 9px 16px; color: #dfe7f1; text-decoration: none; border-left: 3px solid transparent; }
.menu a:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu a.ativo { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--amarelo); font-weight: 600; }
.menu .grupo { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9fb3cc; }
/* grupos recolhíveis (acordeão) */
.menu .grupo-titulo { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: 0; border-radius: 0;
  color: #dfe7f1; padding: 10px 16px; font-weight: 600; text-align: left; border-left: 3px solid transparent; }
.menu .grupo-titulo:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu .grupo-titulo .seta { transition: transform .15s; font-size: 16px; line-height: 1; color: #9fb3cc; }
.menu .grupo-menu.aberto > .grupo-titulo { color: #fff; }
.menu .grupo-menu.aberto > .grupo-titulo .seta { transform: rotate(90deg); }
.menu .submenu { list-style: none; margin: 0; padding: 0 0 6px; display: none; background: rgba(0,0,0,.12); }
.menu .grupo-menu.aberto > .submenu { display: block; }
.menu .submenu a { padding: 7px 16px 7px 28px; font-size: 13.5px; }
.usuario { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #c8d5e5; }
.usuario button { margin-top: 6px; }
.principal { min-width: 0; padding: 18px 22px 40px; }
.topo-movel { display: none; }
.cabecalho { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cabecalho .acoes { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .casca { grid-template-columns: minmax(0, 1fr); }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .casca.menu-aberto .lateral { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topo-movel { display: flex; align-items: center; gap: 10px; background: var(--azul); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 30; }
  .topo-movel button { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 4px; cursor: pointer; }
  .principal { padding: 14px 16px 40px; }
}

/* ---------- blocos ---------- */
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); padding: 14px 16px; margin-bottom: 14px; }
.grade { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.grade-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grade > *, .grade-2 > * { min-width: 0; }
.indicador { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; box-shadow: var(--sombra); }
.indicador .rotulo { font-size: 12.5px; color: var(--suave); }
.indicador .valor { font-size: 22px; font-weight: 700; margin-top: 2px; }
.indicador .detalhe { font-size: 12.5px; color: var(--suave); margin-top: 2px; }
.indicador.alerta .valor { color: var(--erro); }
.indicador.bom .valor { color: var(--ok); }
.linha { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espaco { flex: 1; }
.suave { color: var(--suave); }
.pequeno { font-size: 12.5px; }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.negrito { font-weight: 600; }
.vermelho { color: var(--erro); }
.verde { color: var(--ok); }
.oculto { display: none !important; }

/* ---------- botões ---------- */
button, .botao { font: inherit; border: 1px solid var(--borda); background: #fff; color: var(--texto); border-radius: 6px; padding: 7px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
button:hover, .botao:hover { background: #f5f7fa; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primario, .botao.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
button.primario:hover { background: var(--azul-2); }
button.perigo { color: var(--erro); border-color: #efb9c2; }
button.perigo:hover { background: var(--erro-fundo); }
button.verde { background: var(--ok); border-color: var(--ok); color: #fff; }
button.pequeno { padding: 3px 8px; font-size: 12.5px; }
button.link { border: 0; background: none; color: var(--azul-2); padding: 0; text-decoration: underline; }

/* ---------- formulários ---------- */
.form { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.form .largo { grid-column: 1 / -1; }
label.campo { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--suave); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--texto); border: 1px solid var(--borda); border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0ea; border-color: var(--azul-2); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: end; }
.filtros input, .filtros select { width: auto; min-width: 140px; }
.filtros input[type=search] { min-width: 220px; flex: 1; max-width: 360px; }

/* ---------- tabelas ---------- */
.tabela-rolagem { overflow-x: auto; border: 1px solid var(--borda); border-radius: var(--raio); background: #fff; }
table.tabela { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela th { text-align: left; background: #f5f7fa; color: var(--suave); font-weight: 600; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--borda); white-space: nowrap; }
.tabela td { padding: 8px 10px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tr.clicavel { cursor: pointer; }
.tabela tr.clicavel:hover td { background: #f7fafd; }
.tabela tfoot td { font-weight: 700; background: #fafbfc; border-top: 1px solid var(--borda); }
.tabela .vazio { text-align: center; color: var(--suave); padding: 22px; }

/* ---------- etiquetas ---------- */
.etiqueta { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--azul-claro); color: var(--azul); white-space: nowrap; }
.etiqueta.verde { background: var(--ok-fundo); color: var(--ok); }
.etiqueta.vermelho { background: var(--erro-fundo); color: var(--erro); }
.etiqueta.amarelo { background: var(--aviso-fundo); color: var(--aviso); }
.etiqueta.cinza { background: #eceff3; color: var(--suave); }
.aviso { padding: 9px 12px; border-radius: 6px; background: var(--aviso-fundo); color: var(--aviso); margin-bottom: 12px; }
.aviso.erro { background: var(--erro-fundo); color: var(--erro); }
.aviso.ok { background: var(--ok-fundo); color: var(--ok); }

/* ---------- modal e toast ---------- */
.fundo-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.largo { width: min(980px, 100%); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--borda); display: flex; justify-content: space-between; align-items: center; }
.modal header button { border: 0; font-size: 20px; padding: 0 6px; }
.modal .corpo { padding: 16px 18px; overflow-y: auto; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--borda); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { background: #1b1f24; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 420px; }
.toast.erro { background: var(--erro); }
.toast.ok { background: var(--ok); }

/* ---------- login ---------- */
.tela-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--azul) 0%, #13263f 100%); }
.tela-login .cartao { width: min(380px, 100%); padding: 26px 24px; }
.tela-login .marca-login { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.tela-login .marca-login img { width: 40px; height: 40px; }
.tela-login form { display: grid; gap: 12px; }

/* ---------- OS ---------- */
.itens-os td input { padding: 5px 7px; }
.busca-resultados { border: 1px solid var(--borda); border-radius: 6px; max-height: 260px; overflow-y: auto; background: #fff; }
.busca-resultados div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--linha); display: flex; justify-content: space-between; gap: 10px; }
.busca-resultados div:hover, .busca-resultados div.sel { background: var(--azul-claro); }
.total-os { font-size: 22px; font-weight: 700; color: var(--azul); }
canvas.assinatura { width: 100%; max-width: 520px; height: 180px; border: 1px dashed var(--suave); border-radius: 6px; background: #fff; touch-action: none; display: block; }
img.assinatura { max-width: 260px; max-height: 90px; border-bottom: 1px solid var(--suave); }
.barras { display: grid; gap: 4px; }
.barra { display: grid; grid-template-columns: 70px 1fr 110px; gap: 8px; align-items: center; font-size: 12.5px; }
.barra .trilho { background: var(--linha); border-radius: 4px; height: 16px; position: relative; overflow: hidden; }
.barra .cheio { background: var(--azul-2); height: 100%; border-radius: 4px; }
.barra .cheio.nf { background: var(--amarelo); position: absolute; top: 0; left: 0; height: 5px; }

/* ---------- assistente (chat) ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: min(60vh, 560px); min-height: 160px; overflow-y: auto; padding: 4px 2px 10px; }
.chat-vazio { padding: 20px; text-align: center; }
.bolha { max-width: min(78%, 620px); padding: 8px 12px; border-radius: 12px; background: var(--azul-claro); align-self: flex-start; }
.bolha.eu, .bolha.contato { background: #fff; border: 1px solid var(--borda); }
.bolha.eu { align-self: flex-end; background: #e7f1e9; border-color: #cfe5d4; }
.bolha.equipe { align-self: flex-end; background: var(--aviso-fundo); }
.bolha-quem { font-size: 11.5px; color: var(--suave); margin-bottom: 2px; }
.bolha-texto { white-space: pre-wrap; word-break: break-word; }
.chat-envio { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.chat-envio textarea { min-height: 52px; }
@media (max-width: 860px) { .bolha { max-width: 92%; } .chat { max-height: 58vh; } }

@media print {
  .lateral, .topo-movel, .cabecalho .acoes, button, #toasts { display: none !important; }
  .casca { display: block; } .principal { padding: 0; } body { background: #fff; }
  .cartao { box-shadow: none; border: 0; }
}
