/* Balanceamento de Estoque — padrão visual DAF Eldorado */
:root {
  --azul-daf: #332882;      /* principal: cabeçalho, links, botões */
  --azul-eldorado: #3E4096; /* destaques secundários */
  --vermelho: #E40915;      /* só filete da marca e alertas */
  --amarelo: #FFF2CC;       /* campos do gestor */
  --cinza-fundo: #f3f4f6;
  --cinza-borda: #e5e7eb;
  --texto: #1f2937;
  --texto-suave: #6b7280;
  --verde: #16a34a;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--texto); background: var(--cinza-fundo); }
a { color: var(--azul-daf); }
h1 { font-size: 22px; color: var(--azul-daf); margin: 0 0 16px; }
h2 { font-size: 17px; color: var(--azul-eldorado); margin: 24px 0 10px; }
small, .texto-suave { color: var(--texto-suave); }
code { background: #eef; padding: 1px 4px; border-radius: 3px; font-size: 13px; }

/* Cabeçalho: dois logos, filete vermelho, menu, faixa das casas */
.marcas { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 12px 20px; gap: 16px; }
.marca-eldorado { height: 26px; display: block; }
.marca-daf { height: 30px; display: block; }
.topo-titulo { font-weight: 600; color: var(--azul-daf); font-size: 16px; }
.filete { height: 3px; background: var(--vermelho); }
.menu { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: var(--azul-daf); padding: 6px 12px; }
.menu a { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 6px; font-size: 14px; }
.menu a:hover, .menu a.ativo { background: rgba(255,255,255,.16); }
.menu-usuario { margin-left: auto; color: #fff; font-size: 13px; padding: 6px 8px; }
.menu-usuario a { padding: 0; text-decoration: underline; }
.casas { display: flex; flex-wrap: wrap; gap: 4px; background: #fff; border-bottom: 1px solid var(--cinza-borda); padding: 6px 12px; }
.casas a { text-decoration: none; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--cinza-borda); color: var(--texto); }
.casas a:hover { border-color: var(--azul-eldorado); }
.casas a.ativo { background: var(--azul-eldorado); border-color: var(--azul-eldorado); color: #fff; }
.conteudo { max-width: 1400px; margin: 0 auto; padding: 20px 16px 40px; }
.rodape { text-align: center; font-size: 12px; color: var(--texto-suave); padding: 16px; }
.linha-topo { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; }

/* Cartões */
.cartoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.cartao { background: #fff; border: 1px solid var(--cinza-borda); border-radius: 8px; padding: 14px 16px; }
.cartao .valor { font-size: 22px; font-weight: 700; color: var(--azul-daf); margin-top: 4px; }
.cartao .rotulo { font-size: 13px; color: var(--texto-suave); }
.bloco { background: #fff; border: 1px solid var(--cinza-borda); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.acoes { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 8px 0 12px; }
.resumo-casa { margin-left: auto; font-size: 14px; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--cinza-borda); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--cinza-borda); text-align: left; vertical-align: middle; }
th { background: #f9fafb; color: var(--texto-suave); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8f9ff; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot th { font-weight: 700; text-align: left; }
tfoot th.num { text-align: right; }
.vazio { padding: 20px; text-align: center; color: var(--texto-suave); }
.matriz th { white-space: normal; }
.param { color: #0000ff; font-weight: 600; }
#parametros .param-input { width: 90px; text-align: right; color: #0000ff; font-weight: 600; background: var(--amarelo); margin: 0; padding: 4px 6px; }

/* Tabela de sugestões (larga, rola na horizontal; cabeçalho e 2 primeiras colunas fixos) */
.tabela-sugestoes { max-height: calc(100vh - 230px); overflow: auto; }
.tabela-sugestoes table { font-size: 13px; }
.tabela-sugestoes th, .tabela-sugestoes td { padding: 5px 8px; }
.tabela-sugestoes thead th { position: sticky; z-index: 2; }
.tabela-sugestoes thead tr.grupos th { top: 0; background: var(--azul-daf); color: #fff; text-align: center; font-size: 12px; border-right: 1px solid rgba(255,255,255,.25); }
.tabela-sugestoes thead tr.grupos th.decisao { background: var(--amarelo); color: var(--texto); }
.tabela-sugestoes thead tr.campos th { top: 29px; background: #eef0f8; white-space: normal; min-width: 72px; max-width: 110px; font-size: 12px; line-height: 1.2; vertical-align: bottom; cursor: help; }
.tabela-sugestoes thead tr.campos th.decisao { background: var(--amarelo); }
.tabela-sugestoes td.decisao { background: var(--amarelo); }
.tabela-sugestoes tbody tr:hover td.decisao { background: #fde9a8; }
.tabela-sugestoes td.desc { min-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.tabela-sugestoes td.decisao select, .tabela-sugestoes td.decisao input { margin: 0; padding: 4px 6px; font-size: 13px; }
.tabela-sugestoes td.decisao input[type=number] { width: 70px; }
.tabela-sugestoes td.decisao input[type=text] { width: 190px; }
.tabela-sugestoes td.decidido { white-space: nowrap; font-size: 12px; }
.tabela-sugestoes td:nth-child(1), .tabela-sugestoes th:nth-child(1) { position: sticky; left: 0; z-index: 1; background: #fff; }
.tabela-sugestoes thead tr.campos th:nth-child(1) { background: #eef0f8; z-index: 3; }
.tabela-sugestoes thead tr.grupos th:nth-child(1) { position: static; }
tr.dec-sim td { background: #f0fdf4; }
tr.dec-sim td:nth-child(1) { background: #f0fdf4; }
tr.dec-nao td { background: #f3f4f6; color: var(--texto-suave); }
tr.dec-nao td:nth-child(1) { background: #f3f4f6; }
tr.salvando td.decisao { opacity: .6; }
tr.erro td.decisao { background: #fee2e2; }
.so-pendentes tr.dec-sim, .so-pendentes tr.dec-nao { display: none; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.sim { background: #dcfce7; color: #166534; }
.badge.nao, .badge.inativo { background: #f3f4f6; color: #4b5563; }
.badge.admin { background: #ede9fe; color: #5b21b6; }
.badge.gestor { background: #e0f2fe; color: #075985; }

/* Legenda */
.amostra { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; margin-right: 6px; }
.amostra.grupo { background: var(--azul-daf); color: #fff; }
.amostra.campo { background: #eef0f8; }
.amostra.decisao { background: var(--amarelo); }
.amostra.sim { background: #f0fdf4; border: 1px solid #bbf7d0; }
.amostra.nao { background: #f3f4f6; border: 1px solid var(--cinza-borda); }
table.legenda th { white-space: normal; color: var(--texto); }
table.legenda tr.dec-linha th, table.legenda tr.dec-linha td { background: #fffbeb; }

/* Formulários */
.btn { display: inline-block; border: 1px solid var(--cinza-borda); background: #fff; color: var(--texto); padding: 8px 14px; border-radius: 6px; font-size: 14px; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #f3f4f6; }
.btn.primario { background: var(--azul-daf); border-color: var(--azul-daf); color: #fff; font-weight: 600; }
.btn.primario:hover { background: var(--azul-eldorado); }
.btn.pequeno { padding: 4px 9px; font-size: 13px; }
.btn.largo { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
label { display: block; font-size: 13px; color: var(--texto-suave); margin: 10px 0 2px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--cinza-borda); border-radius: 6px; font-size: 14px; margin-top: 3px; background: #fff; color: var(--texto); }
input[type=checkbox] { width: auto; margin-right: 6px; vertical-align: middle; }
label.inline { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--texto); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-eldorado); border-color: var(--azul-eldorado); }
.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.alerta { padding: 10px 12px; border-radius: 6px; margin: 12px 0; font-size: 14px; }
.alerta.erro { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alerta.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alerta.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.msg:empty { display: none; }

/* Modais */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(17, 24, 39, .55); }
dialog form { padding: 18px 22px 20px; }
dialog h3 { margin: 0 0 4px; color: var(--azul-daf); font-size: 17px; }
dialog .botoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Login */
.tela-login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.cartao-login { width: 100%; max-width: 400px; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.08); overflow: hidden; }
.cartao-login h1 { font-size: 18px; margin: 20px 24px 4px; }
.cartao-login form, .cartao-login .alerta { margin-left: 24px; margin-right: 24px; }
.cartao-login form { margin-bottom: 8px; }
.cartao-login .btn { margin-top: 18px; }
.rodape-login { text-align: center; font-size: 12px; color: var(--texto-suave); padding: 14px; margin: 0; border-top: 1px solid var(--cinza-borda); }

@media print {
  .menu, .casas, .acoes, .btn, .rodape, dialog { display: none !important; }
  body { background: #fff; }
  .conteudo { max-width: none; padding: 0; }
  .tabela-sugestoes { max-height: none; overflow: visible; }
}
