/* =====================================================================
   GalviTracks: rastreamento de motoboys com a identidade visual Galvitech
   1. Tokens (tema claro / escuro)   5. Painel lateral e cartões
   2. Base                           6. Mapa, marcadores e controles
   3. Layout                         7. Diálogos, toasts e tabelas
   4. Componentes                    8. Responsivo e acessibilidade
   ===================================================================== */

/* 1. TOKENS ------------------------------------------------------------ */
/* Identidade visual Galvitech: mesmos tokens do ERP de oficinas (sistema-mecanica,
   shadcn/ui): roxo Galvi #401F71, lavanda, magenta, cinzas neutros e Inter.
   O tema escuro segue o galvi-controle, que mantém o roxo da marca. */
:root {
  --fonte: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --bg: #ffffff;                 /* background */
  --sup: #ffffff;                /* card / popover */
  --sup-2: #fafafa;              /* sidebar */
  --sup-3: #f5f5f5;              /* muted / accent */
  --borda: #e5e5e5;              /* border / input */
  --borda-forte: #d4d4d4;
  --txt: #0a0a0a;                /* foreground */
  --txt-2: #3f3f46;              /* sidebar-foreground */
  --txt-3: #737373;              /* muted-foreground */

  --pri: #401f71;                /* primary (roxo Galvi) */
  --pri-hover: #53357f;          /* primary/90 */
  --pri-suave: #efeaf6;
  --pri-txt: #e3d7f4;            /* primary-foreground */
  --sec: #ceb7f0;                /* secondary (lavanda) */
  --sec-txt: #6f2dd2;            /* secondary-foreground */
  --terc: #cd37be;               /* tertiary (magenta) */
  --nav-ativo-bg: #f4f4f5;       /* sidebar-accent */
  --nav-ativo-txt: #7340bf;      /* sidebar-accent-foreground */

  --ok: #16a34a;                 /* botão "aprovar" do ERP (green-600) */
  --ok-hover: #15803d;
  --ok-suave: #e8f6ec;
  --aviso: #d97706;
  --aviso-suave: #fef3dc;
  --perigo: #ef4444;             /* botão "destrutivo" do ERP (red-500) */
  --perigo-hover: #b91c1c;
  --perigo-suave: #fdecec;
  --sobre-cor: #ffffff;          /* texto sobre ok/perigo */
  --replay: #eb6834;             /* viz-series-2 do ERP */
  --replay-hover: #d95926;

  --mapa-fundo: #f5f5f5;
  --sombra-1: 0 1px 2px 0 rgb(0 0 0 / .05);
  --sombra-2: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --sombra-3: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --anel: #0a0a0a;               /* ring */
  --anel-foco: 0 0 0 2px var(--sup), 0 0 0 4px var(--anel);

  --r-1: 4px;                    /* radius - 4px */
  --r-2: 6px;                    /* radius - 2px (md) */
  --r-3: 8px;                    /* radius 0.5rem (lg) */
  --r-4: 8px;
  --e-1: 4px;
  --e-2: 8px;
  --e-3: 12px;
  --e-4: 16px;
  --e-5: 24px;
  --t-rapida: 150ms cubic-bezier(.4, 0, .2, 1);
  --t-media: 200ms cubic-bezier(.4, 0, .2, 1);

  --topo-h: 64px;                /* h-16 do cabeçalho do ERP */
  --nav-w: 16rem;                /* SIDEBAR_WIDTH */
  --nav-w-ic: 3rem;              /* SIDEBAR_WIDTH_ICON */
  --painel-w: 384px;
  color-scheme: light;
}

:root[data-tema="escuro"] {
  --bg: #0e0b14;
  --sup: #17131f;
  --sup-2: #120e19;
  --sup-3: #241e30;
  --borda: #2a2436;
  --borda-forte: #332c42;
  --txt: #f1edf7;
  --txt-2: #d6cfe2;
  --txt-3: #a39bb2;

  --pri: #b99af0;
  --pri-hover: #c8aff4;
  --pri-suave: #2a2140;
  --pri-txt: #16101f;
  --sec: #241e30;
  --sec-txt: #f1edf7;
  --terc: #e058d2;
  --nav-ativo-bg: #221b2e;
  --nav-ativo-txt: #f1edf7;

  --ok: #6fd18a;
  --ok-hover: #8bdca1;
  --ok-suave: #173022;
  --aviso: #f0c060;
  --aviso-suave: #352a12;
  --perigo: #ff8a80;
  --perigo-hover: #ffa69e;
  --perigo-suave: #3a1b19;
  --sobre-cor: #16101f;
  --replay: #f08a5d;
  --replay-hover: #f4a07b;

  --mapa-fundo: #0e0b14;
  --sombra-1: 0 1px 2px rgb(0 0 0 / .4);
  --sombra-2: 0 6px 16px rgb(0 0 0 / .45);
  --sombra-3: 0 24px 60px rgb(0 0 0 / .6);
  --anel: #e058d2;
  color-scheme: dark;
}

/* 2. BASE -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--fonte);
  font-size: 14px;
  line-height: 1.43;
  color: var(--txt);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mudo { color: var(--txt-3); }
.nowrap { white-space: nowrap; }
.ic { width: 16px; height: 16px; flex-shrink: 0; }
:focus-visible { outline: none; box-shadow: var(--anel-foco); }
::selection { background: color-mix(in srgb, var(--pri) 22%, transparent); }
/* Barra de rolagem fina, como a custom-scrollbar do ERP */
* { scrollbar-width: thin; scrollbar-color: var(--borda-forte) transparent; }

/* 3. LAYOUT ------------------------------------------------------------ */
/* Mesmo esqueleto do ERP: menu lateral recolhível + área principal com cabeçalho */
#app { display: flex; height: 100vh; height: 100dvh; }

.nav {
  width: var(--nav-w); flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--sup-2); border-right: 1px solid var(--borda); color: var(--txt-2);
  position: relative; z-index: 1200; overflow: hidden;
  transition: width var(--t-media);
}
:root.nav-recolhida .nav { width: var(--nav-w-ic); }
.nav-cab { display: flex; align-items: center; gap: 8px; height: var(--topo-h); padding: 0 8px; flex-shrink: 0; }
.nav-logo { width: 32px; height: 32px; border-radius: var(--r-3); flex-shrink: 0; }
.nav-marca { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.nav-marca strong { font-size: 14px; font-weight: 600; color: var(--txt); white-space: nowrap; }
.nav-marca span { font-size: 12px; color: var(--txt-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-conteudo { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.nav-grupo { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.nav-rotulo {
  display: flex; align-items: center; height: 32px; padding: 0 8px; flex-shrink: 0;
  font-size: 12px; font-weight: 500; color: color-mix(in srgb, var(--txt-2) 70%, transparent);
  white-space: nowrap; transition: margin var(--t-media), opacity var(--t-media);
}
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 8px;
  border: 0; border-radius: var(--r-2); background: transparent; color: var(--pri);
  font-size: 14px; text-align: left; white-space: nowrap; overflow: hidden;
  transition: background var(--t-rapida), color var(--t-rapida), width var(--t-media);
}
.nav-item > span { display: inline-flex; }
.nav-item .rotulo { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover, .nav-item.ativo { background: var(--nav-ativo-bg); color: var(--nav-ativo-txt); }
.nav-item.ativo { font-weight: 500; }
.nav-rodape { padding: 8px; flex-shrink: 0; }
.nav-usuario { display: flex; align-items: center; gap: 8px; height: 48px; padding: 8px; border-radius: var(--r-2); overflow: hidden; font: inherit; }
.nav-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-3); flex-shrink: 0;
  background: var(--sup-3); color: var(--pri); font-size: 13px; font-weight: 500;
}
.nav-usuario-txt { display: grid; min-width: 0; line-height: 1.25; }
.nav-usuario-txt strong { font-size: 14px; font-weight: 600; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-usuario-txt span { font-size: 12px; color: var(--txt-3); white-space: nowrap; }
/* Menu recolhido: só os ícones, como o collapsible="icon" do ERP */
:root.nav-recolhida .nav-marca, :root.nav-recolhida .nav-usuario-txt, :root.nav-recolhida .nav-item .rotulo { display: none; }
:root.nav-recolhida .nav-rotulo { margin-top: -32px; opacity: 0; pointer-events: none; }
:root.nav-recolhida .nav-item { width: 32px; }
:root.nav-recolhida .nav-usuario { padding: 0; width: 32px; height: 32px; }
.nav-fundo { display: none; }

.inset { flex: 1; min-width: 0; display: grid; grid-template-rows: var(--topo-h) 1fr; background: var(--bg); }

.topo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--borda);
  position: relative; z-index: 1100; min-width: 0;
}
.btn-gatilho { width: 28px; height: 28px; margin-left: -4px; }
.topo-sep { width: 1px; height: 16px; background: var(--borda); margin: 0 8px 0 4px; flex-shrink: 0; }
.trilha { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; color: var(--txt-3); white-space: nowrap; }
.trilha-atual { color: var(--txt); }
.trilha-sep { width: 7px; height: 7px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); opacity: .8; }

.resumo { display: flex; gap: 6px; margin: 0 0 0 auto; padding: 0; list-style: none; min-width: 0; }
.r-item {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--borda); background: var(--sup-3); color: var(--txt-3); white-space: nowrap;
}
.r-valor { font-size: 13px; font-weight: 600; color: var(--txt); font-variant-numeric: tabular-nums; }
.r-rotulo { font-size: 12px; font-weight: 500; }
.r-rota { background: color-mix(in srgb, var(--pri) 10%, var(--bg)); border-color: color-mix(in srgb, var(--pri) 25%, transparent); }
.r-rota .r-valor, .r-rota .r-rotulo { color: var(--pri); }
.r-livre { background: color-mix(in srgb, var(--ok) 10%, var(--bg)); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.r-livre .r-valor, .r-livre .r-rotulo { color: var(--ok); }
.r-alerta.ativo { background: var(--perigo-suave); border-color: color-mix(in srgb, var(--perigo) 30%, transparent); }
.r-alerta.ativo .r-valor, .r-alerta.ativo .r-rotulo { color: var(--perigo); }

.topo-acoes { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.resumo + .topo-acoes { margin-left: 8px; }

.corpo {
  display: grid; grid-template-columns: var(--painel-w) 1fr; min-height: 0;
  transition: grid-template-columns var(--t-media);
}
body.painel-recolhido .corpo { grid-template-columns: 0 1fr; }
body.painel-recolhido .painel { visibility: hidden; }

.painel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--sup); border-right: 1px solid var(--borda);
  position: relative; z-index: 900;
}
.painel-alca { display: none; }
.painel-rolagem { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.painel-rodape {
  padding: var(--e-4); border-top: 1px solid var(--borda); background: var(--sup);
  display: flex; flex-direction: column; gap: var(--e-3);
}
.painel-rodape:empty { display: none; }

.mapa-area { position: relative; min-width: 0; min-height: 0; }
#mapa { position: absolute; inset: 0; z-index: 0; background: var(--mapa-fundo); }

/* 4. COMPONENTES ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-2);
  border: 1px solid transparent; font-weight: 500; font-size: 14px; white-space: nowrap;
  text-decoration: none; user-select: none;
  transition: background var(--t-rapida), border-color var(--t-rapida), color var(--t-rapida), transform var(--t-rapida), box-shadow var(--t-rapida);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--pri); color: var(--pri-txt); }
.btn-primario:hover:not(:disabled) { background: var(--pri-hover); }
.btn-sucesso { background: var(--ok); color: var(--sobre-cor); }
.btn-sucesso:hover:not(:disabled) { background: var(--ok-hover); }
.btn-perigo { background: var(--perigo); color: var(--sobre-cor); }
.btn-perigo:hover:not(:disabled) { background: var(--perigo-hover); }
.btn-sec { background: var(--bg); border-color: var(--borda); color: var(--txt); }
.btn-sec:hover:not(:disabled) { background: var(--sup-3); }
.btn-fantasma { background: transparent; color: var(--pri); }
.btn-fantasma:hover:not(:disabled) { background: var(--sup-3); }
.btn-p { height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--r-2); }
.btn-p .ic { width: 15px; height: 15px; }
.btn-g { height: 44px; font-size: 14px; border-radius: var(--r-2); width: 100%; }
.btn-g .ic { width: 20px; height: 20px; }

.btn-icone {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--r-2); border: 0; background: transparent; color: var(--pri);
  transition: background var(--t-rapida), color var(--t-rapida);
}
.btn-icone:hover { background: var(--sup-3); color: var(--pri); }
.btn-icone.perigo:hover { background: var(--perigo-suave); color: var(--perigo); }
.btn-icone[aria-pressed="true"] { color: var(--pri); background: var(--pri-suave); }
.btn-mini { width: 32px; height: 32px; border-radius: var(--r-2); }
.btn-mini .ic { width: 16px; height: 16px; }

.btn-topo {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 0; border-radius: var(--r-2); background: transparent; color: var(--txt-2); font-weight: 600;
  transition: background var(--t-rapida), color var(--t-rapida);
}
.btn-topo:hover { background: var(--sup-3); color: var(--txt); }
.btn-topo span { display: inline-flex; }

.inp, .inp-cor {
  width: 100%; height: 40px; padding: 0 12px; font-size: 14px;
  border: 1px solid var(--borda); border-radius: var(--r-2);
  background: var(--bg); color: var(--txt);
  transition: border-color var(--t-rapida), box-shadow var(--t-rapida);
}
.inp::placeholder { color: var(--txt-3); }
.inp:focus { outline: none; box-shadow: var(--anel-foco); }
.inp[aria-invalid="true"] { border-color: var(--perigo); box-shadow: 0 0 0 3px var(--perigo-suave); }
.inp-p { height: 36px; font-size: 14px; padding: 0 10px; width: auto; }
.inp-cor { padding: 4px; height: 40px; cursor: pointer; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.inp-ic { position: relative; display: block; flex: 1; }
.inp-ic > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--pri); pointer-events: none; width: 16px; height: 16px; }
.inp-ic > .inp { padding-left: 38px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; border: 1px solid transparent; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-livre { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.pill-rota { background: color-mix(in srgb, var(--pri) 10%, transparent); border-color: color-mix(in srgb, var(--pri) 25%, transparent); color: var(--pri); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--borda);
  background: var(--bg); color: var(--txt-2); font-weight: 500; font-size: 13px;
  transition: all var(--t-rapida);
}
.chip:hover { background: var(--sup-3); color: var(--txt); }
.chip.ativo { background: var(--pri); color: var(--pri-txt); border-color: var(--pri); }
.chip-p { height: 28px; padding: 0 10px; font-size: 12px; }

.contador:empty { display: none; }
.contador {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 999px; background: var(--sec); color: var(--sec-txt); font-size: 12px; font-weight: 600;
}

.avatar {
  --cor: var(--pri);
  position: relative; display: grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--r-3);
  background: var(--cor); color: #fff; font-weight: 600; font-size: 14px;
}
.avatar-g { width: 48px; height: 48px; border-radius: var(--r-3); font-size: 17px; }
.avatar-status {
  position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%;
  border: 2.5px solid var(--sup); background: var(--txt-3);
}
.avatar-status.on { background: var(--ok); }
.avatar-status.off { background: var(--perigo); }

.spinner {
  width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex-shrink: 0;
  border: 2px solid var(--borda-forte); border-top-color: var(--pri); animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.skeleton {
  display: inline-block; height: 14px; width: 70%; min-width: 48px; border-radius: 6px;
  background: linear-gradient(90deg, var(--sup-3) 25%, var(--sup-2) 50%, var(--sup-3) 75%);
  background-size: 200% 100%; animation: brilho 1.2s ease-in-out infinite;
}
@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.vazio { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; color: var(--txt-3); text-align: center; }
.vazio-ic { width: 32px; height: 32px; opacity: .7; }
.vazio-ic-wrap {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-3);
  background: var(--pri-suave); color: var(--pri);
}
.vazio-ic-wrap.ok { background: var(--ok-suave); color: var(--ok); }

.aviso {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-2);
  font-weight: 600; font-size: 13px; border: 1px solid transparent;
}
.aviso-critico { background: var(--perigo-suave); color: var(--perigo); border-color: color-mix(in srgb, var(--perigo) 25%, transparent); }
.aviso-alerta { background: var(--aviso-suave); color: var(--aviso); border-color: color-mix(in srgb, var(--aviso) 25%, transparent); }
.aviso-aviso { background: var(--sup-3); color: var(--txt-2); }

/* Conexão */
.conexao {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; margin-right: 4px;
  border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--sup-3); border: 1px solid var(--borda); color: var(--txt-3);
}
.conexao-ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--txt-3); position: relative; }
.conexao-ao-vivo .conexao-ponto, .conexao-polling .conexao-ponto { background: var(--ok); }
.conexao-ao-vivo .conexao-ponto::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); animation: onda 1.8s ease-out infinite;
}
.conexao-ao-vivo { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.conexao-offline { color: var(--perigo); background: var(--perigo-suave); border-color: transparent; }
.conexao-offline .conexao-ponto { background: var(--perigo); }
@keyframes onda { from { transform: scale(1); opacity: .7; } to { transform: scale(3); opacity: 0; } }

/* Central de alertas */
.notif { position: relative; }
#btn-alertas { position: relative; }
#btn-alertas.tem-critico { color: var(--perigo); }
#btn-alertas.tem-critico .ic { animation: balanco 2.4s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes balanco { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(14deg); } 90% { transform: rotate(-12deg); } 95% { transform: rotate(6deg); } }
.badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 999px; border: 2px solid var(--bg);
  background: var(--txt-3); color: #fff; font-size: 10.5px; font-weight: 600;
}
.badge-critico { background: var(--perigo); }
.badge-alerta { background: var(--aviso); }
.notif-painel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: min(480px, 70vh);
  display: flex; flex-direction: column;
  background: var(--sup); border: 1px solid var(--borda); border-radius: var(--r-3); box-shadow: var(--sombra-3);
  overflow: hidden; animation: surgir var(--t-media);
}
@keyframes surgir { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.notif-cab { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--borda); }
.notif-cab strong { font-size: 14px; font-weight: 600; }
.notif-cab .btn-icone { margin-left: auto; }
.notif-lista { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.notif-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; text-align: left;
  border: 0; border-radius: var(--r-2); background: transparent; transition: background var(--t-rapida);
}
.notif-item:hover { background: var(--sup-3); }
.notif-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-3); flex-shrink: 0; background: var(--pri-suave); color: var(--pri); }
.notif-item.nivel-critico .notif-ic { background: var(--perigo-suave); color: var(--perigo); }
.notif-item.nivel-alerta .notif-ic { background: var(--aviso-suave); color: var(--aviso); }
.notif-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.notif-txt strong { font-size: 13.5px; }
.notif-txt span { font-size: 12.5px; color: var(--txt-2); }
.notif-ver { font-size: 12px; font-weight: 600; color: var(--pri); }
.notif-vazio { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--txt-2); }
.notif-vazio span:last-child { font-size: 13px; color: var(--txt-3); }

/* 5. PAINEL LATERAL ---------------------------------------------------- */
.secao { padding: var(--e-4); }
.secao + .secao { border-top: 1px solid var(--borda); }
.secao-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.secao-cab h2 { font-size: 12px; font-weight: 500; color: color-mix(in srgb, var(--txt-2) 70%, transparent); }
.secao-cab .btn { margin-left: auto; }
.secao-dica { margin-left: auto; font-size: 11.5px; color: var(--txt-3); }

.frota { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cartao {
  --cor: var(--pri);
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px;
  border-radius: var(--r-3); border: 1px solid var(--borda); background: var(--sup); box-shadow: var(--sombra-1);
  cursor: pointer; transition: border-color var(--t-rapida), background var(--t-rapida), box-shadow var(--t-rapida), transform var(--t-rapida);
}
.cartao:hover { background: var(--sup-3); }
.cartao.sel {
  border-color: var(--cor);
  background: color-mix(in srgb, var(--cor) 6%, var(--sup));
  box-shadow: 0 0 0 1px var(--cor);
}
.cartao.offline .avatar { filter: grayscale(.7); opacity: .7; }
.cartao.nivel-critico::before, .cartao.nivel-alerta::before {
  content: ''; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--perigo);
}
.cartao.nivel-alerta::before { background: var(--aviso); }
.cartao .avatar { --cor: inherit; }
.cartao-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cartao-l1 { display: flex; align-items: center; gap: 8px; }
.cartao-nome { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartao-l1 .pill { margin-left: auto; }
.cartao-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12.5px; color: var(--txt-2); font-variant-numeric: tabular-nums; }
.cartao-meta span { display: inline-flex; align-items: center; gap: 4px; }
.cartao-meta .ic { width: 14px; height: 14px; color: var(--pri); }
.cartao-meta .meta-vel { font-weight: 600; color: var(--txt); }
.cartao-meta .meta-ruim, .cartao-meta .meta-ruim .ic { color: var(--perigo); font-weight: 600; }
.cartao-alerta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: var(--perigo); }
.cartao.nivel-alerta .cartao-alerta { color: var(--aviso); }
.cartao.nivel-aviso .cartao-alerta { color: var(--txt-2); }
.cartao-alerta .ic { width: 15px; height: 15px; }
.cartao-tecla {
  position: absolute; right: 10px; bottom: 9px; font: 600 10.5px var(--fonte); color: var(--txt-3);
  border: 1px solid var(--borda); border-radius: 5px; padding: 0 5px; line-height: 16px; opacity: 0; transition: opacity var(--t-rapida);
}
.cartao:hover .cartao-tecla { opacity: 1; }

.detalhe { display: flex; flex-direction: column; gap: var(--e-3); }
.detalhe .secao-cab { margin: 6px 0 0; }
.det-cab { display: flex; align-items: center; gap: 14px; }
.det-titulo { flex: 1; min-width: 0; }
.det-titulo h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.det-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12.5px; color: var(--txt-2); }
.det-sub span { display: inline-flex; align-items: center; gap: 4px; }
.det-sub .ic { width: 14px; height: 14px; }
.det-botoes { display: flex; gap: 2px; }
.det-alertas { display: flex; flex-direction: column; gap: 6px; }
.det-alertas:empty { display: none; }

.busca { position: relative; }
.busca-lista {
  list-style: none; margin: 6px 0 0; padding: 6px; max-height: 300px; overflow-y: auto;
  background: var(--sup); border: 1px solid var(--borda); border-radius: var(--r-2); box-shadow: var(--sombra-2);
  animation: surgir var(--t-rapida);
}
.busca-grupo { padding: 6px 8px; font-size: 12px; font-weight: 500; color: var(--txt-3); }
.busca-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-1); cursor: pointer; }
.busca-item.ativo { background: var(--sup-3); }
.busca-cor { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px var(--sup), 0 0 0 3px var(--borda-forte); }
.busca-ic { color: var(--pri); display: inline-flex; }
.busca-txt { display: flex; flex-direction: column; min-width: 0; }
.busca-txt strong { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busca-txt small { font-size: 12px; color: var(--txt-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busca-info { display: flex; align-items: center; gap: 8px; padding: 10px; font-size: 13px; color: var(--txt-3); }

.paradas { list-style: none; margin: 0; padding: 0; position: relative; }
.parada-item {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 4px 4px 4px 0;
}
.parada-item:not(:last-child)::after {
  content: ''; position: absolute; left: 13px; top: 34px; bottom: -10px; width: 2px;
  background: repeating-linear-gradient(to bottom, var(--cor-sel, var(--pri)) 0 4px, transparent 4px 8px); opacity: .45;
}
.parada-num {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  background: var(--cor-sel, var(--pri)); color: #fff; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 0 0 3px var(--sup);
}
.parada-num .ic { width: 15px; height: 15px; }
.parada-loja .parada-num { background: var(--sup-3); color: var(--txt-2); }
.parada-loja .parada-nome { color: var(--txt-3); font-size: 12.5px; }
.parada-nome { flex: 1; min-width: 0; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parada-item .btn-mini { opacity: .55; }
.parada-item:hover .btn-mini, .parada-item .btn-mini:focus-visible { opacity: 1; }
.paradas-vazio {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 16px; text-align: center;
  border: 1.5px dashed var(--borda-forte); border-radius: var(--r-3); color: var(--txt-3); font-size: 13px;
}
.paradas-vazio strong { color: var(--txt-2); font-size: 14px; }

.estimativa {
  display: flex; align-items: center; gap: var(--e-4); padding: 10px 14px; border-radius: var(--r-3);
  background: var(--sup-2); border: 1px solid var(--borda);
}
.est-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.est-item small { font-size: 11.5px; color: var(--txt-3); font-weight: 500; }
.est-item strong { font-size: 17px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.est-fonte { margin-left: auto; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); color: var(--ok); white-space: nowrap; }
.est-fonte.offline { background: var(--aviso-suave); color: var(--aviso); border-color: color-mix(in srgb, var(--aviso) 30%, transparent); }
.est-erro { display: flex; align-items: center; gap: 8px; color: var(--aviso); font-weight: 600; font-size: 13px; }

.acoes-rota { display: flex; flex-direction: column; gap: 10px; }
.campo-nota { display: flex; flex-direction: column; gap: 4px; }
.inp-nota { height: 44px; font-weight: 500; letter-spacing: .02em; }
.em-rota-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.em-rota-info > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-2); background: var(--sup-2); border: 1px solid var(--borda); min-width: 0; }
.em-rota-info small { font-size: 11px; color: var(--txt-3); }
.em-rota-info strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

/* 6. MAPA -------------------------------------------------------------- */
.leaflet-container { font-family: var(--fonte); background: var(--mapa-fundo); }
.leaflet-tile-pane { filter: saturate(.72) contrast(.96) brightness(1.02); }
:root[data-tema="escuro"] .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.92) contrast(.88) saturate(.45); }
.leaflet-control-zoom.leaflet-bar { border: 1px solid var(--borda); box-shadow: var(--sombra-1); border-radius: var(--r-2); overflow: hidden; }
.leaflet-control-zoom a, .leaflet-control-zoom a:hover {
  width: 40px !important; height: 40px !important; line-height: 38px !important;
  background: var(--sup); color: var(--pri); border-color: var(--borda) !important; font-weight: 500;
}
.leaflet-control-zoom a:hover { background: var(--sup-3); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--sup) 80%, transparent) !important; color: var(--txt-3); font-size: 10.5px; border-radius: 6px 0 0 0; }
.leaflet-control-attribution a { color: var(--txt-2); }
.leaflet-tooltip {
  background: var(--pri); color: var(--pri-txt); border: 0; border-radius: var(--r-2);
  box-shadow: none; padding: 6px 12px; font-size: 12px; font-weight: 500;
}
.leaflet-tooltip-right::before { border-right-color: var(--pri); }
.leaflet-tooltip-left::before { border-left-color: var(--pri); }
.leaflet-tooltip-top::before { border-top-color: var(--pri); }
.leaflet-tooltip-bottom::before { border-bottom-color: var(--pri); }
.popup-radar .leaflet-popup-content-wrapper { background: var(--sup); color: var(--txt); border: 1px solid var(--borda); border-radius: var(--r-2); box-shadow: var(--sombra-2); padding: 0; }
.popup-radar .leaflet-popup-content { margin: 14px; }
.popup-radar .leaflet-popup-tip { background: var(--sup); }
.pop { display: flex; flex-direction: column; gap: 10px; }
.pop-cab { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.pop-cor { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; box-shadow: 0 0 0 2px var(--sup), 0 0 0 3px var(--borda-forte); }
.pop-tel { display: inline-flex; align-items: center; gap: 6px; color: var(--txt-2); text-decoration: none; font-size: 13px; }
.pop-tel .ic { width: 14px; height: 14px; }
.pop-acoes { display: flex; align-items: center; gap: 4px; }
.pop-acoes .btn { flex: 1; }
.pop-acoes .btn-icone { width: 32px; height: 32px; }

/* Marcador do motoboy */
.moto-marcador { background: none; border: 0; }
.moto {
  --cor: var(--pri);
  position: absolute; left: 0; top: 0;
  transform: translateX(var(--dx, 0px));
  transition: transform 300ms ease;
  font-family: var(--fonte);
}
.moto-puck {
  position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--cor) 70%, #fff), var(--cor) 60%);
  border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .35), 0 0 0 1px rgba(15, 23, 42, .12);
  transition: width var(--t-media), height var(--t-media), left var(--t-media), top var(--t-media), filter var(--t-media), opacity var(--t-media);
}
.moto-ini { font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.moto-seta { position: absolute; inset: 0; display: none; place-items: center; transition: transform 450ms cubic-bezier(.3, .7, .3, 1); }
.moto-seta svg { width: 19px; height: 19px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.moto.com-rumo .moto-seta { display: grid; }
.moto.com-rumo .moto-ini { display: none; }
.moto-rotulo {
  position: absolute; left: 0; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--sup); color: var(--txt); border: 1px solid var(--borda);
  font-size: 11.5px; font-weight: 600; box-shadow: var(--sombra-2);
  transition: bottom var(--t-media), background var(--t-media), color var(--t-media);
}
.moto-rotulo::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--cor); }
.moto-bat { color: var(--perigo); font-weight: 800; }
.moto-vel {
  position: absolute; left: 0; top: 23px; transform: translateX(-50%);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--pri); color: #fff; font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .3);
}
:root[data-tema="escuro"] .moto-vel { background: var(--pri); color: var(--pri-txt); }
.moto.sel .moto-puck { left: -23px; top: -23px; width: 46px; height: 46px; box-shadow: 0 0 0 6px color-mix(in srgb, var(--cor) 30%, transparent), 0 6px 16px rgba(15, 23, 42, .4); }
.moto.sel .moto-rotulo { bottom: 30px; background: var(--cor); color: #fff; border-color: transparent; }
.moto.sel .moto-rotulo::before { background: #fff; }
.moto.sel .moto-vel { top: 28px; }
.moto.sel .moto-seta svg { width: 23px; height: 23px; }
.moto.na-loja:not(.sel) .moto-rotulo { display: none; }
.moto.na-loja:not(.sel):hover .moto-rotulo { display: flex; }
.moto.offline .moto-puck { filter: grayscale(.85); opacity: .7; }
.moto.offline .moto-rotulo { opacity: .8; }
.moto.offline .moto-vel { background: var(--perigo); color: #fff; }
.moto-pulso { position: absolute; inset: -4px; border-radius: 50%; display: none; pointer-events: none; }
.moto.nivel-critico .moto-pulso { display: block; border: 3px solid var(--perigo); animation: pulso 1.6s ease-out infinite; }
.moto.nivel-alerta .moto-pulso { display: block; border: 3px solid var(--aviso); animation: pulso 2.2s ease-out infinite; }
@keyframes pulso { from { transform: scale(1); opacity: .9; } to { transform: scale(2.1); opacity: 0; } }
.replay-moto .moto-puck { --cor: var(--replay); }

/* Pinos */
.pino-loja, .pino-cliente, .pino-parada { background: none; border: 0; }
.loja {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: #401f71; color: #fff; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(15, 23, 42, .35);
  transform: rotate(45deg);
}
.loja .ic { transform: rotate(-45deg); width: 18px; height: 18px; }
:root[data-tema="escuro"] .loja { background: #b99af0; color: #16101f; border-color: #16101f; }
.pino-cliente svg { filter: drop-shadow(0 2px 3px rgba(15, 23, 42, .35)); transition: transform var(--t-rapida); transform-origin: 50% 100%; }
.pino-cliente:hover svg { transform: scale(1.12); }
.parada {
  position: absolute; left: 1px; top: 0; width: 28px; height: 28px;
  border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: var(--cor); border: 2.5px solid #fff; box-shadow: 0 3px 8px rgba(15, 23, 42, .35);
  display: grid; place-items: center;
}
.parada span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 12px; font-family: var(--fonte); }

/* Controles sobre o mapa */
.mapa-ctrl { position: absolute; top: 14px; right: 14px; z-index: 10; display: flex; flex-direction: column; gap: 10px; }
.ctrl-grupo { display: flex; flex-direction: column; background: var(--sup); border-radius: var(--r-2); box-shadow: var(--sombra-1); overflow: hidden; border: 1px solid var(--borda); }
.ctrl-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: transparent; color: var(--pri);
  transition: background var(--t-rapida), color var(--t-rapida);
}
.ctrl-btn + .ctrl-btn { border-top: 1px solid var(--borda); }
.ctrl-btn:hover { background: var(--sup-3); }
.ctrl-btn.ativo { background: var(--pri); color: var(--pri-txt); }

body.modo-mira #mapa, body.modo-mira #mapa .leaflet-interactive { cursor: crosshair !important; }
.mira-aviso {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; max-width: calc(100% - 100px);
  background: var(--pri); color: var(--pri-txt); border-radius: 999px; box-shadow: var(--sombra-2);
  font-size: 13.5px; animation: surgir var(--t-media);
}
.mira-aviso .btn-sec { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--pri-txt) 35%, transparent); }
.mira-aviso .btn-sec:hover { background: color-mix(in srgb, var(--pri-txt) 15%, transparent); }
.mira-ic { display: inline-flex; animation: girar 4s linear infinite; }

/* Replay */
.replay {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  width: min(760px, calc(100% - 32px)); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--sup); border: 1px solid var(--borda); border-radius: var(--r-3); box-shadow: var(--sombra-3);
  animation: surgir var(--t-media);
}
.replay-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.replay-titulo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-right: auto; }
.replay-titulo .ic { color: var(--replay); }
.replay-ctrl { display: flex; align-items: center; gap: 14px; }
.btn-play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; flex-shrink: 0; display: grid; place-items: center;
  background: var(--replay); color: #fff; box-shadow: var(--sombra-2);
  transition: transform var(--t-rapida), background var(--t-rapida);
}
.btn-play:hover:not(:disabled) { background: var(--replay-hover); }
.btn-play:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-play .ic { width: 20px; height: 20px; fill: currentColor; }
.replay-linha { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.replay-slider { width: 100%; accent-color: var(--replay); height: 20px; cursor: pointer; }
.replay-tempos { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.replay-hora { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.replay-info { font-size: 12px; text-align: right; }
.replay-legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--txt-2); }
.replay-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.replay-legenda i { width: 16px; height: 4px; border-radius: 2px; }

/* 7. DIÁLOGOS, TOASTS E TABELAS --------------------------------------- */
.dlg-fundo {
  position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px;
  /* coluna limitada à tela: tabelas largas rolam dentro do diálogo em vez de alargá-lo */
  grid-template-columns: minmax(0, 1fr);
  background: rgb(0 0 0 / .8);
  opacity: 0; transition: opacity var(--t-media);
}
.dlg-fundo.aberto { opacity: 1; }
.dlg {
  width: 100%; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--sup); border: 1px solid var(--borda); border-radius: var(--r-3); box-shadow: var(--sombra-3);
  transform: translateY(10px) scale(.98); transition: transform var(--t-media);
}
.dlg-fundo.aberto .dlg { transform: none; }
.dlg:focus { outline: none; box-shadow: var(--sombra-3); }
.dlg-sm { max-width: 440px; }
.dlg-md { max-width: 560px; }
.dlg-lg { max-width: 760px; }
.dlg-xl { max-width: 1080px; }
.dlg-cab { display: flex; align-items: flex-start; gap: 12px; padding: 20px 16px 6px 24px; }
.dlg-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-3); flex-shrink: 0; background: var(--pri-suave); color: var(--pri); }
.dlg-titulos { flex: 1; min-width: 0; padding-top: 1px; }
.dlg-titulos h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.dlg-titulos p { font-size: 14px; color: var(--txt-3); margin-top: 4px; }
.dlg-corpo { padding: 12px 24px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.dlg-corpo > * { min-width: 0; }
.dlg-texto { color: var(--txt-2); font-size: 14.5px; }
.dlg-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--borda); background: var(--sup); border-radius: 0 0 var(--r-3) var(--r-3); }

.form { display: flex; flex-direction: column; gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo-rotulo { font-size: 14px; font-weight: 500; color: var(--txt); }
.campo-rotulo em { color: var(--perigo); font-style: normal; }
.campo-erro { font-size: 12.5px; color: var(--perigo); font-weight: 500; min-height: 0; }
.campo-erro:empty { display: none; }
.campo-dica { font-size: 12px; color: var(--txt-3); }

.barra-filtros { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.barra-filtros .inp-ic { min-width: 220px; }
.datas { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.datas .inp { width: 156px; height: 36px; }
.totais { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.totais > div { display: flex; flex-direction: column-reverse; gap: 6px; padding: 14px 16px; border-radius: var(--r-3); background: var(--sup); border: 1px solid var(--borda); box-shadow: var(--sombra-1); }
.totais strong { font-size: 24px; font-weight: 600; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.totais span { font-size: 14px; font-weight: 500; color: var(--txt-3); }
.totais span::first-letter { text-transform: uppercase; }
.tabela-rolagem { overflow: auto; border: 1px solid var(--borda); border-radius: var(--r-2); max-height: 56vh; }
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th {
  position: sticky; top: 0; z-index: 1; text-align: left; height: 48px; padding: 0 16px; white-space: nowrap;
  background: var(--sup); color: var(--txt-3); font-size: 14px; font-weight: 500;
  border-bottom: 1px solid var(--borda);
}
.tabela td { padding: 12px 16px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover td { background: color-mix(in srgb, var(--sup-3) 50%, transparent); }
.tabela .col-acoes { width: 1%; white-space: nowrap; text-align: right; }
.tabela .col-acoes .btn-icone { width: 32px; height: 32px; }
.tabela .col-destinos { min-width: 240px; color: var(--txt-2); }
.tag-nota { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--pri) 25%, transparent); background: color-mix(in srgb, var(--pri) 10%, transparent); color: var(--pri); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.cel-cliente { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.linha-skeleton td { background: transparent !important; }
/* Indicadores por motoboy (histórico) */
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela th.num { text-align: right; }
.tabela tfoot th {
  position: sticky; bottom: 0; height: 48px; padding: 0 16px; background: var(--sup);
  border-top: 1px solid var(--borda); color: var(--txt); font-weight: 600; font-size: 14px;
}
.tabela tfoot th:first-child { text-align: left; }
.ind-viagens { display: inline-flex; align-items: center; justify-content: flex-end; gap: 10px; }
.ind-viagens > span:first-child { min-width: 3ch; text-align: right; }
.ind-barra { display: block; width: 72px; height: 6px; border-radius: 999px; background: var(--sup-3); overflow: hidden; }
.ind-barra i { display: block; height: 100%; border-radius: inherit; background: var(--pri); }
.ind-nota { margin: 0; font-size: 13px; }

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 4000; width: min(380px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px 12px 14px;
  background: var(--sup); color: var(--txt); border: 1px solid var(--borda); border-radius: var(--r-2); box-shadow: var(--sombra-3);
  opacity: 0; transform: translateY(8px) scale(.98); transition: opacity var(--t-media), transform var(--t-media);
}
.toast.visivel { opacity: 1; transform: none; }
.toast-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; background: var(--pri-suave); color: var(--pri); }
.toast-ic .ic { width: 16px; height: 16px; }
.toast-sucesso .toast-ic { background: var(--ok-suave); color: var(--ok); }
.toast-erro .toast-ic, .toast-critico .toast-ic { background: var(--perigo-suave); color: var(--perigo); }
.toast-aviso .toast-ic { background: var(--aviso-suave); color: var(--aviso); }
.toast-critico { border-color: color-mix(in srgb, var(--perigo) 40%, var(--borda)); }
.toast-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding-top: 4px; font-size: 13.5px; }
.toast-txt strong { font-size: 14px; font-weight: 600; }
.toast-txt span { color: var(--txt-2); }
.toast-acao { border: 1px solid var(--borda); background: transparent; color: var(--txt); font-weight: 500; padding: 5px 10px; border-radius: var(--r-2); }
.toast-acao:hover { background: var(--sup-3); }
.toast-x { border: 0; background: transparent; color: var(--txt-3); width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; }
.toast-x:hover { background: var(--sup-3); color: var(--txt); }
.toast-x .ic { width: 15px; height: 15px; }

/* Menu do usuário (rodapé do menu lateral), como o NavUser do ERP */
.nav-usuario { width: 100%; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; transition: background var(--t-rapida); }
.nav-usuario:hover, .nav-usuario[aria-expanded="true"] { background: var(--nav-ativo-bg); }
.nav-usuario-seta { margin-left: auto; display: inline-flex; color: var(--txt-3); }
.nav-usuario-seta .ic { width: 14px; height: 14px; }
:root.nav-recolhida .nav-usuario-seta { display: none; }
.menu-usuario {
  position: fixed; z-index: 3600; min-width: 224px; padding: 4px;
  background: var(--sup); color: var(--txt); border: 1px solid var(--borda); border-radius: var(--r-2); box-shadow: var(--sombra-2);
  animation: surgir var(--t-rapida);
}
.menu-usuario-cab { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.menu-usuario-cab div { display: grid; line-height: 1.25; min-width: 0; }
.menu-usuario-cab strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-usuario-cab span { font-size: 12px; color: var(--txt-3); }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--borda); }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-1);
  background: transparent; color: var(--txt); font-size: 14px; text-align: left;
}
.menu-item .ic { color: var(--pri); }
.menu-item:hover, .menu-item:focus-visible { background: var(--sup-3); box-shadow: none; }
.perfil { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--borda); background: var(--sup-3); color: var(--txt-3); }
.perfil-gestor { border-color: color-mix(in srgb, var(--pri) 25%, transparent); background: color-mix(in srgb, var(--pri) 10%, transparent); color: var(--pri); }
.campo-select { appearance: auto; }

/* Tela de login (mesmo layout do login do ERP) */
body.pagina-login { overflow: auto; background: var(--sup-3); }
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-caixa { width: 100%; max-width: 384px; display: flex; flex-direction: column; gap: 24px; }
.login-cartao { display: grid; overflow: hidden; background: var(--sup); border: 1px solid var(--borda); border-radius: var(--r-3); box-shadow: var(--sombra-1); }
.login-form { display: flex; flex-direction: column; gap: 20px; padding: 24px; }
.login-titulo { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-bottom: 4px; }
.login-titulo h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.login-titulo p { color: var(--txt-3); text-wrap: balance; }
.login-botao { width: 100%; }
.login-dica { font-size: 13px; color: var(--txt-3); text-align: center; }
.login-arte { display: none; align-items: center; justify-content: center; background: var(--pri-txt); }
.login-arte img { width: 50%; height: auto; }
:root[data-tema="escuro"] .login-arte { background: var(--sec); }
:root[data-tema="escuro"] .login-arte img { filter: brightness(.6) grayscale(.3); }
.login-rodape { font-size: 12px; color: var(--txt-3); text-align: center; text-wrap: balance; }
@media (min-width: 768px) {
  .login { padding: 40px; }
  .login-caixa { max-width: 768px; }
  .login-cartao { grid-template-columns: 1fr 1fr; }
  .login-form { padding: 32px; }
  .login-arte { display: flex; }
}

/* 8. RESPONSIVO E ACESSIBILIDADE ---------------------------------------- */
@media (max-width: 1440px) {
  .r-item:nth-child(n+4) { display: none; }
}
@media (max-width: 1180px) {
  .resumo { display: none; }
}

@media (max-width: 768px) {
  :root { --topo-h: 56px; }
  .so-desktop { display: none !important; }
  .topo { gap: 6px; padding: 0 8px 0 12px; }
  .trilha-pai, .trilha-sep { display: none; }
  /* Menu lateral vira gaveta sobre a tela, como o Sheet do ERP no celular */
  .nav, :root.nav-recolhida .nav {
    position: fixed; left: 0; top: 0; bottom: 0; width: 18rem; z-index: 3500;
    transform: translateX(-100%); transition: transform var(--t-media); box-shadow: var(--sombra-3);
  }
  :root.nav-aberta .nav { transform: none; }
  :root.nav-recolhida .nav-marca, :root.nav-recolhida .nav-usuario-txt { display: grid; }
  :root.nav-recolhida .nav-item .rotulo { display: inline; }
  :root.nav-recolhida .nav-rotulo { margin-top: 0; opacity: 1; }
  :root.nav-recolhida .nav-item { width: 100%; }
  :root.nav-recolhida .nav-usuario { padding: 8px; width: auto; height: 48px; }
  :root.nav-aberta .nav-fundo { display: block; position: fixed; inset: 0; z-index: 3400; background: rgb(0 0 0 / .8); }
  .conexao { padding: 0 9px; margin-right: 0; }
  .conexao .rotulo { display: none; }
  .topo-acoes { gap: 0; }
  .notif-painel { position: fixed; left: 8px; right: 8px; top: calc(var(--topo-h) + 6px); width: auto; }

  .corpo { display: block; position: relative; }
  .mapa-area { position: absolute; inset: 0; }
  .painel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: var(--folha-h, 104px);
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / .15);
    transition: height var(--t-media);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .painel.arrastando { transition: none; }
  .painel-alca { display: flex; justify-content: center; align-items: center; height: 24px; flex-shrink: 0; cursor: grab; touch-action: none; }
  .painel-alca span { width: 40px; height: 5px; border-radius: 3px; background: var(--borda-forte); }
  .painel[data-folha="min"] .painel-rodape { display: none; }
  .secao { padding: 4px 14px 14px; }
  .secao-dica, .cartao-tecla { display: none; }
  .frota { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; gap: 8px; }
  .cartao { flex: 0 0 min(280px, 82vw); scroll-snap-align: start; }
  .btn-icone, .ctrl-btn { width: 44px; height: 44px; }
  .btn-mini { width: 36px; height: 36px; }
  .mapa-ctrl { top: 10px; right: 10px; }
  .leaflet-bottom.leaflet-right { bottom: 112px; }
  .leaflet-control-attribution { display: none; }
  .replay { bottom: 116px; width: calc(100% - 16px); padding: 10px; }
  .replay-cab .inp-p { flex: 1; min-width: 0; }
  .toasts { top: calc(var(--topo-h) + 8px); bottom: auto; right: 8px; left: 8px; width: auto; }
  .mira-aviso { top: auto; bottom: 120px; max-width: calc(100% - 16px); }
  .dlg-fundo { place-items: end center; padding: 0; }
  .dlg { border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .dlg-rodape { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-rodape .btn { flex: 1; height: 44px; }
  .datas { margin-left: 0; width: 100%; }
  .datas .inp { flex: 1; width: auto; min-width: 0; }
  .totais strong { font-size: 17px; }
  .inp { height: 44px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
