/* Caminhão 360 — mobile-first. Identidade: Verde Estrada (esmeralda + teal). */
:root {
  /* âncora escura (topo, barra lateral, botões) — emerald-700, passa contraste AA com texto branco */
  --navy: #047857;
  --navy-2: #059669;          /* hover / brand-600 */
  /* destaque (FAB, item ativo, "360" do logo) — teal-600 */
  --ambar: #0d9488;
  --ambar-escuro: #0f766e;    /* usado onde precisa de verde-escuro de texto */
  --brand-050: #ecfdf5;       /* superfície verde bem clara */
  --hero-grad: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  --fundo: #eff5f2;           /* fundo levemente esverdeado (o "claro" que o Gabriel pediu) */
  --card: #ffffff;
  --texto: #0f172a;
  --texto-2: #64748b;
  --borda: #e3eae7;
  --verde: #047857;           /* positivo = on-brand */
  --verde-fundo: #d1fae5;
  --vermelho: #b91c1c;
  --vermelho-fundo: #fee2e2;
  --amarelo: #d97706;         /* alerta continua âmbar (semântico, não é marca) */
  --amarelo-escuro: #b45309;
  --amarelo-fundo: #fef3c7;
  --raio: 14px;
  --sombra: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .05);
  --sombra-alta: 0 4px 12px rgba(15, 23, 42, .08), 0 16px 40px rgba(15, 23, 42, .1);
  /* tints dos chips de ícone dos KPIs (multi-cor pra escaneabilidade, padrão da referência) */
  --chip-green-bg: #dcfce7; --chip-green: #16a34a;
  --chip-amber-bg: #fef3c7; --chip-amber: #d97706;
  --chip-blue-bg: #dbeafe;  --chip-blue: #2563eb;
  --chip-purple-bg: #ede9fe; --chip-purple: #7c3aed;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--navy-2); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
img { max-width: 100%; }

.tela-carregando {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: var(--texto-2);
}

/* ---------------------------------------------------------- estrutura ---- */
.app { min-height: 100dvh; }
.layout { display: flex; min-height: 100dvh; }
.conteudo {
  flex: 1; padding: 20px 16px calc(84px + env(safe-area-inset-bottom));
  max-width: 1080px; margin: 0 auto; width: 100%;
}
@media (min-width: 900px) {
  .conteudo { padding: 28px 32px 40px; }
}

/* topo */
.topo {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
}
.topo .marca { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.02rem; }
.topo .marca b { color: #5eead4; }  /* "360" em mint claro pra pop no topo esmeralda */
.topo .espaco { flex: 1; }
.topo .chip-offline {
  background: var(--amarelo); color: #422006; border-radius: 99px;
  font-size: .72rem; font-weight: 700; padding: 3px 10px; display: none;
}
.topo .chip-offline.on { display: inline-block; }
.btn-fila {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 99px;
  padding: 5px 12px; font-size: .78rem; font-weight: 600; display: none;
}
.btn-fila.on { display: inline-block; }
.btn-sair { background: none; border: 0; color: rgba(255,255,255,.75); font-size: .8rem; padding: 6px; }
.btn-sair:hover { color: #fff; }

/* navegação inferior (mobile) */
.navbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--borda);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.navbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--texto-2); font-size: .66rem; font-weight: 600;
  padding: 4px 8px; border-radius: 10px; min-width: 56px;
}
.navbar a svg { width: 22px; height: 22px; }
.navbar a.ativo { color: var(--navy); background: var(--brand-050); }
@media (min-width: 900px) {
  .navbar { display: none; }
}

/* menu lateral (desktop) */
.lateral {
  display: none; width: 220px; flex-shrink: 0;
  background: var(--navy); color: #dbe6f2; padding: 12px 10px;
  flex-direction: column; gap: 2px;
}
.lateral a {
  color: inherit; text-decoration: none; padding: 9px 12px; border-radius: 9px;
  font-size: .9rem; font-weight: 500; display: flex; gap: 9px; align-items: center;
}
.lateral a svg { width: 18px; height: 18px; flex-shrink: 0; }
.lateral a:not(.ativo) svg { opacity: .7; }
.lateral a.ativo svg { opacity: 1; }
.lateral a.ativo { background: var(--ambar); color: #fff; font-weight: 700; }
.lateral a:not(.ativo):hover { background: rgba(255,255,255,.08); }
.lateral .sep { border-top: 1px solid rgba(255,255,255,.14); margin: 8px 6px; }
@media (min-width: 900px) {
  .lateral { display: flex; }
}

/* --------------------------------------------------------------- cards --- */
.card {
  background: var(--card); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 16px 18px; margin-bottom: 16px;
  transition: box-shadow .2s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--sombra-alta); transform: translateY(-2px); }
.card:active { transform: translateY(0); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--card); border-radius: var(--raio); box-shadow: var(--sombra); padding: 16px;
  transition: box-shadow .2s ease, transform .15s ease;
}
.kpi:hover { box-shadow: var(--sombra-alta); transform: translateY(-2px); }
.kpi .rotulo { font-size: .8rem; font-weight: 600; color: #334155; margin-top: 1px; }
.kpi .valor { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; }
.kpi .sub { font-size: .72rem; color: var(--texto-2); margin-top: 1px; }
.kpi.positivo .valor { color: var(--verde); }
.kpi.negativo .valor { color: var(--vermelho); }

/* ------------------------------------------------------------ tabelas ---- */
.tabela-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--borda); white-space: nowrap; }
th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); }
td.num, th.num { text-align: right; }
tr.total td { font-weight: 800; border-top: 2px solid var(--navy); }

/* ------------------------------------------------------------- badges ---- */
.badge { display: inline-block; border-radius: 99px; font-size: .68rem; font-weight: 700; padding: 4px 10px; }
.badge.ok { background: var(--verde-fundo); color: var(--verde); }
.badge.alerta { background: var(--amarelo-fundo); color: var(--amarelo-escuro); }
.badge.erro { background: var(--vermelho-fundo); color: var(--vermelho); }
.badge.neutro { background: #e2e8f0; color: #334155; }

/* ------------------------------------------------------------- botões ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--navy); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; font-size: .9rem;
  transition: background .15s, transform .1s;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { background: var(--navy-2); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.secundario { background: #e2e8f0; color: var(--texto); }
.btn.secundario:hover { background: #cbd5e1; }
.btn.perigo { background: var(--vermelho); }
.btn.mini { padding: 5px 10px; font-size: .76rem; border-radius: 8px; }
.btn.largura { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.fab {
  position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--ambar); color: #fff; font-size: 1.7rem; font-weight: 800;
  box-shadow: 0 6px 18px rgba(13, 148, 136, .45);
  transition: transform .15s ease, box-shadow .15s ease;
  display: grid; place-items: center;
}
.fab:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(13, 148, 136, .5); }
.fab:active { transform: scale(0.96); }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* ---------------------------------------------------------------- forms --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid .col2 { grid-column: 1 / -1; }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--texto-2); }
label.campo input, label.campo select, label.campo textarea {
  border: 1px solid var(--borda); border-radius: 9px; padding: 10px 11px;
  font-size: .95rem; color: var(--texto); background: #fff; width: 100%;
}
label.campo input:focus, label.campo select:focus, label.campo textarea:focus {
  outline: 2px solid var(--ambar); outline-offset: 0; border-color: var(--ambar);
}
label.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 6px 0; }
label.check input { width: 20px; height: 20px; accent-color: var(--navy); }

dialog.modal {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: 92dvh; box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
dialog.modal::backdrop { background: rgba(10, 20, 35, .55); }
.modal-cab { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--borda); position: sticky; top: 0; background: #fff; }
.modal-corpo { padding: 16px 18px; overflow-y: auto; }
.modal-rodape { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--borda); }
.fechar-x { background: none; border: 0; font-size: 1.3rem; color: var(--texto-2); }

/* --------------------------------------------------------------- filtros -- */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: end; }
.filtros label.campo { flex: 1; min-width: 130px; }
.filtros .btn { flex-shrink: 0; }

/* ---------------------------------------------------------------- abas ---- */
.abas { display: flex; gap: 4px; border-bottom: 2px solid var(--borda); margin-bottom: 16px; overflow-x: auto; }
.abas button {
  background: none; border: 0; padding: 9px 14px; font-weight: 700; font-size: .86rem;
  color: var(--texto-2); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.abas button.ativa { color: var(--navy); border-bottom-color: var(--ambar); }

/* ------------------------------------------------------------ item lista -- */
.item-lista {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  margin-bottom: 6px; background: var(--card);
  transition: background .15s;
}
.item-lista:last-child { margin-bottom: 0; border-bottom: 0; }
.item-lista:hover { background: var(--brand-050); }
.item-lista .item-icone { flex-shrink: 0; }
.item-lista .item-corpo { flex: 1; min-width: 0; }
.item-lista .principal { font-weight: 600; font-size: .92rem; }
.item-lista .sub { font-size: .76rem; color: var(--texto-2); margin-top: 2px; }
.item-lista .direita { text-align: right; flex-shrink: 0; }
.item-lista .direita .valor { font-weight: 800; font-size: .95rem; }

/* ------------------------------------------------------------ avisos ------ */
.banner-bloqueio {
  background: var(--vermelho-fundo); color: var(--vermelho);
  border: 1px solid #fecaca; border-radius: var(--raio);
  padding: 12px 14px; margin-bottom: 14px; font-weight: 600; font-size: .9rem;
}
.banner-trial {
  background: var(--amarelo-fundo); color: var(--amarelo-escuro);
  border: 1px solid #fde68a; border-radius: var(--raio);
  padding: 10px 14px; margin-bottom: 14px; font-weight: 600; font-size: .86rem;
}

.vazio {
  text-align: center; color: var(--texto-2); padding: 40px 16px;
}
.vazio svg {
  width: 48px; height: 48px; color: var(--borda); margin-bottom: 12px;
  animation: pulsar 2.5s ease-in-out infinite;
}
.vazio .vazio-msg { font-size: .9rem; margin-bottom: 4px; }
.vazio .vazio-dica { font-size: .78rem; color: var(--texto-2); opacity: .7; }
.vazio .btn { margin-top: 12px; }
@keyframes pulsar {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: .8; transform: scale(1.05); }
}

.toasts { position: fixed; bottom: calc(88px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast {
  background: var(--navy); color: #fff; border-radius: 10px; padding: 11px 15px;
  font-size: .86rem; font-weight: 600; box-shadow: var(--sombra);
  animation: sobe .25s ease-out;
}
.toast.erro { background: var(--vermelho); }
.toast.sucesso { background: var(--verde); }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------- login (split) - */
.tela-login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: var(--brand-050); padding: 20px;
}
.login-split {
  width: min(860px, 100%); background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(4, 47, 33, .18); display: grid; grid-template-columns: 1fr 1fr;
}
.login-painel {
  background: var(--hero-grad); color: #fff; padding: 34px 30px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
.login-painel .logo { display: flex; align-items: center; gap: 11px; }
.login-painel .logo .mark {
  width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.16);
  display: grid; place-items: center;
}
.login-painel .logo .mark svg { width: 30px; height: 30px; }
.login-painel .logo .nome { font-size: 1.4rem; font-weight: 800; }
.login-painel .logo .nome b { color: #a7f3d0; font-weight: 800; }
.login-painel p { font-size: .9rem; opacity: .9; line-height: 1.55; }
.login-form { padding: 34px 30px; display: flex; flex-direction: column; justify-content: center; }
.login-form .mark {
  width: 56px; height: 56px; border-radius: 15px; background: var(--brand-050);
  display: grid; place-items: center; margin: 0 auto 6px; color: var(--navy);
}
.login-form .mark svg { width: 30px; height: 30px; }
.login-form .nome { text-align: center; font-size: 1.1rem; font-weight: 800; color: var(--navy); margin-bottom: 2px; }
.login-form .sub { text-align: center; color: var(--texto-2); font-size: .8rem; margin-bottom: 14px; }
.caixa-login form, .login-form form { display: flex; flex-direction: column; gap: 12px; }
.link-simples { background: none; border: 0; color: var(--navy-2); font-size: .84rem; text-decoration: underline; }
@media (max-width: 640px) {
  .login-split { grid-template-columns: 1fr; max-width: 420px; }
  .login-painel { display: none; }
}

/* fotos */
.foto-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--borda); }
.foto-preview { max-height: 130px; border-radius: 10px; border: 1px solid var(--borda); }

/* planos (registro) */
.planos-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .planos-grid { grid-template-columns: repeat(3, 1fr); } }
.plano-card { border: 2px solid var(--borda); border-radius: var(--raio); padding: 14px; cursor: pointer; }
.plano-card.escolhido { border-color: var(--ambar); background: #fffbeb; }
.plano-card .preco { font-size: 1.2rem; font-weight: 800; color: var(--navy); }

/* -------------------------------------------- hero + KPIs ricos (Verde Estrada) */
.hero-visao {
  background: var(--hero-grad); color: #fff; border-radius: var(--raio);
  padding: 18px 20px; margin-bottom: 16px; display: flex; align-items: center; gap: 13px;
  box-shadow: 0 8px 22px rgba(5, 150, 105, .22);
}
.hero-visao .h-chip {
  width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.18);
  display: grid; place-items: center; flex-shrink: 0;
}
.hero-visao .h-chip svg { width: 23px; height: 23px; }
.hero-visao .h-txt { flex: 1; }
.hero-visao .h-txt b { font-size: 1.15rem; display: block; }
.hero-visao .h-txt small { opacity: .85; font-size: .78rem; }
.hero-visao .h-pill {
  background: rgba(255,255,255,.18); font-size: .7rem; font-weight: 600;
  padding: 5px 11px; border-radius: 99px; white-space: nowrap;
}

/* KPI: cabeça com chip de ícone (esq) + badge de status (dir) — anatomia da referência */
.kpi .kpi-topo { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.chipi { width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center; flex-shrink: 0; }
.chipi svg { width: 21px; height: 21px; }
.chipi.tg { background: var(--chip-green-bg);  color: var(--chip-green); }
.chipi.ta { background: var(--chip-amber-bg);  color: var(--chip-amber); }
.chipi.tb { background: var(--chip-blue-bg);   color: var(--chip-blue); }
.chipi.tp { background: var(--chip-purple-bg); color: var(--chip-purple); }
.chipi.tbrand { background: var(--verde-fundo); color: var(--verde); }
.badge-kpi { font-size: .66rem; font-weight: 800; padding: 4px 9px; border-radius: 99px; }
.badge-kpi.pos { background: var(--verde-fundo); color: var(--verde); }
.badge-kpi.neu { background: #eef2f7; color: #475569; }

/* Adições de polimento visual */
.card-boasvindas {
  background: var(--hero-grad); color: #fff; border-radius: var(--raio);
  padding: 20px; margin-bottom: 16px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 8px 24px rgba(5, 150, 105, .25);
}
.card-boasvindas .avatar {
  width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  flex-shrink: 0; letter-spacing: .02em;
}
.card-boasvindas .bv-info { flex: 1; }
.card-boasvindas .bv-info .bv-nome { font-size: 1.2rem; font-weight: 800; }
.card-boasvindas .bv-info .bv-empresa { font-size: .82rem; opacity: .85; }

.titulo-tela {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.titulo-tela h1 { margin: 0; }
.titulo-tela .chipi { flex-shrink: 0; }
.titulo-tela h1 svg { width: 18px; height: 18px; }
/* svg solto em título (blocos de alerta, saúde da frota, simulação) — sem isso ele explode em 300px */
h2 > svg, h3 > svg { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }

.chipi.sm { width: 32px; height: 32px; border-radius: 9px; }
.chipi.sm svg { width: 17px; height: 17px; }

.skeleton {
  background: linear-gradient(90deg, #e8eff7 25%, #f0f4f8 50%, #e8eff7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px; height: 16px; margin-bottom: 8px;
}
.skeleton.sk-titulo { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton.sk-linha { height: 56px; border-radius: 12px; margin-bottom: 6px; }
.skeleton.sk-kpi { height: 100px; border-radius: var(--raio); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* impressão do relatório */
@media print {
  .topo, .navbar, .lateral, .fab, .filtros, .btn, .toasts { display: none !important; }
  .conteudo { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
