/* Identidade visual: #063390 (azul), #334783 (azul acinzentado), #18181A (grafite), #838587 (cinza), #D5D5D5 (cinza claro) */
:root {
  --azul: #063390;
  --azul-2: #334783;
  --azul-claro: #e8edf8;
  --preto: #18181A;
  --cinza: #838587;
  --cinza-claro: #D5D5D5;
  --fundo: #f4f5f7;
  --branco: #fff;
  --ok: #2e7d32;
  --ok-bg: #e6f4e7;
  --alerta: #b3261e;
  --alerta-bg: #fdeceb;
  --aviso: #8a5a00;
  --aviso-bg: #fff4d6;
  --raio: 12px;
  --sombra: 0 1px 3px rgba(24,24,26,.10), 0 1px 2px rgba(24,24,26,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--preto); background: var(--fundo); font-size: 16px; line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
.carregando { text-align: center; margin-top: 30vh; color: var(--cinza); }
.muted { color: var(--cinza); }
.pequeno { font-size: .85rem; }
.centro { text-align: center; }
.direita { text-align: right; }
.linha { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.linha.entre { justify-content: space-between; }
.espaco { flex: 1; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

/* ---------- botões ---------- */
.btn {
  appearance: none; border: 0; background: var(--azul); color: #fff; padding: .8rem 1.1rem;
  border-radius: 10px; font-weight: 600; cursor: pointer; min-height: 44px;
}
.btn:hover { background: var(--azul-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: #fff; color: var(--azul); border: 1.5px solid var(--azul); }
.btn.sec:hover { background: var(--azul-claro); }
.btn.cinza { background: var(--cinza-claro); color: var(--preto); }
.btn.perigo { background: var(--alerta); }
.btn.grande { width: 100%; font-size: 1.1rem; padding: 1rem; min-height: 56px; }
.btn.pq { padding: .35rem .7rem; min-height: 32px; font-size: .85rem; border-radius: 8px; }
.btn.link { background: none; color: var(--azul); padding: .3rem .4rem; min-height: 0; text-decoration: underline; }

/* ---------- formulários ---------- */
label.campo { display: block; margin-bottom: .9rem; }
label.campo > span { display: block; font-size: .85rem; font-weight: 600; color: var(--azul-2); margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1.5px solid var(--cinza-claro); border-radius: 10px; background: #fff; min-height: 46px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: 0; border-color: var(--azul); }
input.grandeKm { font-size: 1.6rem; font-weight: 700; text-align: center; letter-spacing: .04em; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .8rem 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }

/* ---------- cartões ---------- */
.cartao { background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1rem; margin-bottom: 1rem; }
.cartao.destaque { border-left: 5px solid var(--azul); }
.aviso, .erro, .sucesso { border-radius: 10px; padding: .7rem .9rem; margin: .7rem 0; font-size: .95rem; }
.aviso { background: var(--aviso-bg); color: var(--aviso); }
.erro { background: var(--alerta-bg); color: var(--alerta); }
.sucesso { background: var(--ok-bg); color: var(--ok); }
.selo { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--cinza-claro); color: var(--preto); }
.selo.azul { background: var(--azul-claro); color: var(--azul); }
.selo.ok { background: var(--ok-bg); color: var(--ok); }
.selo.alerta { background: var(--alerta-bg); color: var(--alerta); }
.selo.aviso { background: var(--aviso-bg); color: var(--aviso); }

/* ---------- topo ---------- */
.topo { background: var(--azul); color: #fff; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); display: flex; align-items: center; gap: .8rem; position: sticky; top: 0; z-index: 20; }
.topo img { height: 34px; display: block; }
.topo .espaco { flex: 1; }
.topo .quem { font-size: .85rem; opacity: .9; text-align: right; line-height: 1.2; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo { min-width: 0; }
@media (max-width: 400px) { .topo { gap: .5rem; padding-left: .7rem; padding-right: .7rem; } .topo img { height: 28px; } .sync { font-size: .7rem; padding: .15rem .4rem; } }
.topo button { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; padding: .4rem .7rem; cursor: pointer; }
.sync { font-size: .78rem; padding: .15rem .55rem; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.sync.off { background: var(--aviso-bg); color: var(--aviso); }
.sync.pend { background: #fff; color: var(--azul); font-weight: 700; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login .cartao { width: 100%; max-width: 380px; padding: 1.6rem; }
.login img.logo { display: block; width: 78%; max-width: 260px; margin: 0 auto 1.2rem; }

/* ---------- motorista (celular) ---------- */
.app-motorista { max-width: 560px; margin: 0 auto; padding: 1rem; padding-bottom: 5rem; }
.veiculo-card { display: flex; gap: .8rem; align-items: center; cursor: pointer; border: 2px solid transparent; }
.veiculo-card.sel { border-color: var(--azul); background: var(--azul-claro); }
.veiculo-card .placa { font-weight: 800; font-size: 1.15rem; letter-spacing: .06em; }
.grade-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1.5px solid var(--cinza-claro); background: #fff; border-radius: 99px; padding: .45rem .85rem; cursor: pointer; font-size: .92rem; min-height: 38px; }
.chip.sel { background: var(--azul); color: #fff; border-color: var(--azul); }
.foto-prev { width: 100%; max-height: 260px; object-fit: contain; background: #000; border-radius: 10px; margin-top: .5rem; }
.foto-btn { display: block; text-align: center; border: 2px dashed var(--azul); color: var(--azul); border-radius: 12px; padding: 1.1rem; font-weight: 700; cursor: pointer; background: var(--azul-claro); }
.foto-btn input { display: none; }
.resumo { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .95rem; }
.resumo b { color: var(--azul-2); font-weight: 600; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.2rem; background: var(--preto); color: #fff; padding: .8rem 1.2rem; border-radius: 12px; z-index: 100; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.ok { background: var(--ok); } .toast.erro { background: var(--alerta); }

/* ---------- admin (desktop) ---------- */
.layout-admin { display: flex; min-height: 100vh; }
.menu { width: 232px; background: var(--preto); color: #fff; padding: 1rem .8rem; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.menu img { width: 100%; display: block; margin: .2rem 0 1.4rem; padding: 0 .3rem; }
.menu a { display: block; padding: .65rem .8rem; border-radius: 9px; color: var(--preto); text-decoration: none; margin-bottom: .35rem; cursor: pointer; font-size: .95rem; font-weight: 600; background: var(--cinza-claro); transition: background .15s ease; }
.menu a:hover { background: var(--cinza); color: #fff; }
.menu a.ativo { background: var(--azul); color: #fff; font-weight: 600; }
.menu a.ativo:hover { background: var(--azul); }
.menu .rodape { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #38383b; font-size: .82rem; color: var(--cinza-claro); }
.menu .rodape button { margin-top: .6rem; width: 100%; }
.conteudo { flex: 1; min-width: 0; padding: 1.4rem 1.6rem 3rem; }
.conteudo header { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.conteudo header h1 { margin: 0 auto 0 0; color: var(--azul); }
.conteudo header .espaco { display: none; }
.filtros { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filtros label { font-size: .8rem; font-weight: 600; color: var(--azul-2); display: block; }
.filtros select, .filtros input { min-height: 40px; padding: .4rem .6rem; width: auto; min-width: 130px; }
.filtros input[type=checkbox] { min-width: 0; min-height: 0; width: 20px; height: 20px; padding: 0; }
.filtros label.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 500; color: var(--preto); margin: 0 0 .4rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: #fff; border-radius: var(--raio); padding: .9rem 1rem; box-shadow: var(--sombra); border-top: 4px solid var(--azul); }
.kpi small { display: block; color: var(--cinza); font-weight: 600; letter-spacing: .04em; font-size: .72rem; text-transform: uppercase; }
.kpi strong { display: block; font-size: 1.6rem; color: var(--azul); margin-top: .15rem; }
.kpi.alerta { border-top-color: var(--alerta); } .kpi.alerta strong { color: var(--alerta); }
.grade2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.grafico-caixa { position: relative; height: 280px; }

.tabela-wrap { overflow: auto; background: #fff; border-radius: var(--raio); box-shadow: var(--sombra); margin-bottom: 1rem; max-height: 72vh; }
table.tab { border-collapse: collapse; width: 100%; font-size: .88rem; }
table.tab th { background: var(--azul); color: #fff; text-align: left; padding: .55rem .6rem; position: sticky; top: 0; white-space: nowrap; z-index: 1; }
table.tab td { padding: .45rem .6rem; border-bottom: 1px solid #ececef; white-space: nowrap; }
table.tab tr:nth-child(even) td { background: #fafafb; }
table.tab tr.total td { background: var(--azul-claro); font-weight: 700; color: var(--azul); }
table.tab td.num, table.tab th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tab tr.linha-alerta td { background: var(--alerta-bg); }
table.tab td.hot { background: var(--alerta-bg); color: var(--alerta); font-weight: 700; }
table.tab td.zero { color: var(--cinza-claro); }

.modal-fundo { position: fixed; inset: 0; background: rgba(24,24,26,.55); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 720px; padding: 1.3rem; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal h2 { color: var(--azul); }
.grade-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 .9rem; }
.foto-grande { max-width: 100%; max-height: 70vh; display: block; margin: .5rem auto; border-radius: 8px; }
.aba-linha { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.aba-linha button { border: 0; background: #e6e7ea; padding: .5rem 1rem; border-radius: 99px; cursor: pointer; font-weight: 600; }
.aba-linha button.ativo { background: var(--azul); color: #fff; }
.diff td:first-child { color: var(--cinza); }
.diff .mudou { background: var(--aviso-bg); font-weight: 600; }

/* barra do celular e menu lateral recolhido: só aparecem em tela estreita */
.barra-movel, .menu-fundo, .btn-fechar-menu { display: none; }

@media (max-width: 860px) {
  .layout-admin { flex-direction: column; }
  .barra-movel { display: flex; align-items: center; gap: .7rem; position: sticky; top: 0; z-index: 30; background: var(--preto); color: #fff;
    padding: .5rem .8rem; padding-top: calc(.5rem + env(safe-area-inset-top)); padding-left: calc(.8rem + env(safe-area-inset-left)); }
  .barra-movel .titulo { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .barra-movel img { height: 30px; flex: none; }
  .btn-menu { position: relative; flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: #2c2c30; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; }
  .ponto-alerta { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--alerta); border: 2px solid #2c2c30; }

  .menu { position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: min(280px, 82vw); height: 100%; overflow-y: auto;
    padding-top: calc(1rem + env(safe-area-inset-top)); padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: 4px 0 18px rgba(0,0,0,.35); }
  .menu-aberto .menu { transform: none; }
  .menu-fundo { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .menu-aberto .menu-fundo { opacity: 1; pointer-events: auto; }
  .btn-fechar-menu { display: block; margin: 0 0 .4rem auto; width: 40px; height: 40px; border: 0; border-radius: 10px; background: #2c2c30; color: #fff; font-size: 1.1rem; cursor: pointer; }
  .menu img { width: 75%; margin: 0 auto 1.1rem; }
  .menu a { padding: .75rem .9rem; }

  .conteudo { padding: 1rem .8rem 3rem; }
  .conteudo header h1 { font-size: 1.3rem; }
  .conteudo header .btn { padding: .4rem .7rem; font-size: .85rem; }
}
@media print { .menu, .barra-movel, .menu-fundo, .filtros, .btn { display: none !important; } .conteudo { padding: 0; } }
