:root {
  --verde: #00b050; --verde-esc: #00873c; --azul: #9fc5e8; --manif: #e1f4e3; --cinza: #5a5a5a;
  --texto: #1d1d1f; --borda: #1d1d1f33; --fundo: #f3f5f4;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--texto); background: var(--fundo); font-size: 15px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
input, select, textarea { border: 2px solid var(--verde); border-radius: 6px; padding: 7px 9px; background: #fff; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid #00b05044; }
textarea { width: 100%; resize: vertical; }
label { display: block; font-weight: bold; font-size: 12px; }
label small { font-weight: normal; color: #666; }
label > input, label > select, label > textarea { display: block; margin-top: 3px; width: 100%; }
.dica { color: #666; font-size: 13px; margin: 8px 0; }
.erro { color: #b00020; min-height: 1.2em; }

.btn { background: var(--verde); color: #fff; border: 0; border-radius: 6px; padding: 9px 16px; font-weight: bold; cursor: pointer; }
.btn:hover { background: var(--verde-esc); }
.btn-sec { background: #888; }
.btn-perigo { background: #b00020; }
.btn-fino { background: #fff; color: var(--verde-esc); border: 2px solid var(--verde); border-radius: 6px; padding: 5px 10px; font-weight: bold; cursor: pointer; }
.btn-fino:hover { background: #e8f7ee; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--verde); padding: 16px; }
.login-caixa { background: #fff; border-radius: 14px; padding: 28px 24px; width: min(380px, 100%); text-align: center; box-shadow: 0 8px 30px #0003; }
.login h1 { margin: 0; color: var(--verde-esc); letter-spacing: 3px; }
.sub { color: #666; margin: 4px 0 20px; }
#botaoGoogle { display: flex; justify-content: center; min-height: 44px; }
.aviso-dev { color: #b36b00; font-weight: bold; font-size: 12px; }
#formDev { display: grid; gap: 8px; margin-top: 12px; }

/* Topo */
.topo { background: var(--verde); color: #fff; display: flex; align-items: center; gap: 14px; padding: 8px 14px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.marca { font-weight: bold; font-size: 20px; letter-spacing: 2px; }
.menu { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.menu button { background: transparent; color: #fff; border: 2px solid transparent; border-radius: 6px; padding: 7px 12px; font-weight: bold; cursor: pointer; }
.menu button:hover { background: #ffffff22; }
.menu button.ativo { background: #fff; color: var(--verde-esc); }
.usuario { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.aba { padding: 14px; max-width: 1700px; margin: 0 auto; }
.barra { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; background: #fff; padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; border: 1px solid #0001; }
.barra .grupo { display: flex; gap: 6px; align-items: center; }
.barra label.largo { flex: 1; min-width: 220px; }
.visao { background: #fff; border: 2px solid var(--verde); color: var(--verde-esc); padding: 6px 12px; font-weight: bold; cursor: pointer; border-radius: 0; margin-left: -2px; }
.visao:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.visao:last-child { border-radius: 0 6px 6px 0; }
.visao.ativo { background: var(--verde); color: #fff; }
.periodo { font-weight: bold; color: var(--verde-esc); font-size: 17px; }
.totais { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip { background: var(--verde); color: #fff; border-radius: 20px; padding: 4px 12px; font-weight: bold; font-size: 13px; }
.chip.sec { background: #fff; color: var(--verde-esc); border: 2px solid var(--verde); }

.contadores { background: #fff; border-radius: 8px; margin-bottom: 10px; padding: 8px 12px; border: 1px solid #0001; }
.contadores summary { cursor: pointer; font-weight: bold; color: var(--verde-esc); }
#contadores { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cont { border: 1px solid #0003; border-radius: 6px; overflow: hidden; min-width: 96px; text-align: center; }
.cont b { display: block; background: var(--verde); color: #fff; font-size: 11px; padding: 2px 6px; }
.cont span { display: block; background: var(--azul); font-weight: bold; font-size: 18px; padding: 2px; }
.cont.zero { opacity: .45; }

/* Tabela de cargas */
.lista { overflow-x: auto; }
table.cargas { border-collapse: collapse; width: 100%; background: #fff; font-size: 13px; }
table.cargas th { background: var(--verde); color: #fff; padding: 8px 6px; text-align: center; font-size: 12px; position: sticky; top: 0; border: 1px solid #000; }
table.cargas td { border: 1px solid #000; padding: 6px 8px; vertical-align: middle; text-align: center; white-space: pre-line; user-select: text; }
table.cargas td.conj { text-align: left; min-width: 260px; }
table.cargas tr.azul td { background: var(--azul); }
table.cargas tr.manif td { background: var(--manif); color: #999 !important; font-weight: normal !important; }
table.cargas td.boleto { color: #0000ff; font-weight: bold; min-width: 130px; }
table.cargas td.data { font-weight: bold; }
/* Linha sob o mouse: verde-água da planilha original (as cores do texto continuam) */
table.cargas tr:not(.dia):hover td { background: #26a69a; }
table.cargas tr.manif:hover td { background: #b9e0bf; }
table.cargas tr.dia td { background: #5a5a5a; color: #fff; font-weight: bold; text-align: left; padding: 4px 10px; }
table.cargas td.acoes { white-space: nowrap; min-width: 92px; }
.caixa { width: 26px; height: 26px; accent-color: var(--verde-esc); cursor: pointer; }
.vazio { background: #fff; padding: 30px; text-align: center; color: #777; border-radius: 8px; }
.lnk { background: none; border: 0; color: #0b5ed7; cursor: pointer; text-decoration: underline; padding: 2px 4px; }

/* Calculadora */
.calc { max-width: 460px; margin: 0 auto; background: #fff; border-radius: 10px; padding: 14px; border: 1px solid #0001; }
.calc-abas { display: flex; gap: 6px; margin-bottom: 12px; }
.calc-abas button { flex: 1; border: 2px solid var(--verde); background: #fff; color: var(--verde-esc); font-weight: bold; border-radius: 6px; padding: 9px 6px; cursor: pointer; }
.calc-abas button.ativo { background: var(--verde); color: #fff; }
.calc-painel label { margin: 10px 0 0; }
.linhas > div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #ddd; }
.linhas { margin-top: 12px; }
.total { background: #e6f6ec; border: 2px solid var(--verde); border-radius: 6px; padding: 10px 12px; margin: 12px 0; font-size: 19px; display: flex; justify-content: space-between; gap: 10px; }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* Formulário de carga */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(780px, 96vw); max-height: 94vh; box-shadow: 0 10px 40px #0005; }
dialog::backdrop { background: #0006; }
.form { padding: 16px; display: grid; gap: 10px; }
.form h2 { margin: 0; color: var(--verde-esc); }
.form .grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .grade .cheio { grid-column: 1 / -1; }
.form .rodape { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-top: 4px; }
.form .rodape .dir { display: flex; gap: 8px; flex-wrap: wrap; }
.hist { font-size: 12px; color: #444; background: #f6f6f6; border-radius: 6px; padding: 6px 10px; max-height: 140px; overflow: auto; }
.hist div { padding: 2px 0; border-bottom: 1px dashed #0002; white-space: pre-wrap; }
.aviso-form { color: #b00020; min-height: 1.2em; font-size: 13px; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translate(-50%, 30px); background: #1d1d1f; color: #fff; padding: 10px 18px; border-radius: 22px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 92vw; }
.toast.mostra { opacity: 1; transform: translate(-50%, 0); }
.toast.erro { background: #b00020; }

/* Usuários */
table.simples { border-collapse: collapse; width: 100%; background: #fff; }
table.simples th, table.simples td { border: 1px solid #0002; padding: 8px 10px; text-align: left; }
table.simples th { background: var(--verde); color: #fff; }

/* Celular: cada carga vira um cartão */
@media (max-width: 860px) {
  .aba { padding: 8px; }
  .topo { gap: 8px; }
  .marca { font-size: 17px; }
  .menu button { padding: 6px 8px; font-size: 13px; }
  .totais { margin-left: 0; }
  table.cargas, table.cargas tbody, table.cargas tr, table.cargas td { display: block; width: 100%; }
  table.cargas thead { display: none; }
  table.cargas tr { border: 2px solid #000; border-radius: 8px; margin-bottom: 10px; overflow: hidden; background: #fff; }
  table.cargas tr.dia { border: 0; margin: 12px 0 4px; }
  table.cargas td { border: 0; border-bottom: 1px solid #0002; text-align: left; padding: 6px 10px; }
  table.cargas td::before { content: attr(data-rot); display: block; font-size: 10px; font-weight: bold; color: #555; text-transform: uppercase; }
  table.cargas tr.azul { background: var(--azul); }
  table.cargas td.conj { min-width: 0; }
  table.cargas td.acoes { white-space: normal; }
  .caixa { width: 34px; height: 34px; }
  .form .grade, .duas { grid-template-columns: 1fr; }
}

/* Relatório para impressão (aba Histórico, botão Imprimir relatório) */
.relatorio { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm 10mm 14mm; @bottom-center { content: "Página " counter(page) " de " counter(pages); font: 9px Arial; color: #555; } }
  body.imprimindo { background: #fff; font-size: 10px; }
  body.imprimindo > *:not(#relatorio) { display: none !important; }
  body.imprimindo .relatorio { display: block; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .r-topo { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid #00b050; padding-bottom: 6px; margin-bottom: 6px; }
  .r-topo h1 { margin: 0; font-size: 18px; color: #00873c; }
  .r-sub { color: #555; font-size: 10px; }
  .r-meta { text-align: right; font-size: 10px; line-height: 1.5; }
  .r-resumo { display: flex; gap: 18px; flex-wrap: wrap; font-size: 11px; margin: 4px 0; }
  .r-clientes { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
  .r-cli { border: 1px solid #999; border-radius: 3px; padding: 1px 6px; font-size: 9px; }
  table.r-tabela { width: 100%; border-collapse: collapse; font-size: 9px; }
  .r-tabela th { background: #00b050 !important; color: #fff; border: 1px solid #000; padding: 3px 4px; text-align: center; font-size: 8.5px; }
  .r-tabela td { border: 1px solid #555; padding: 3px 4px; vertical-align: top; text-align: center; white-space: pre-line; }
  .r-tabela tr { break-inside: avoid; }
  .r-tabela thead { display: table-header-group; }
  .r-tabela td.r-conjunto, .r-tabela td.r-boleto { text-align: left; }
  .r-tabela td.r-data { font-weight: bold; white-space: nowrap; }
  .r-tabela td.r-boleto { color: #0000ff; font-weight: bold; }
  .r-tabela tr.r-dia td { background: #5a5a5a !important; color: #fff; font-weight: bold; text-align: left; padding: 2px 6px; }
}
