/* ==========================================================================
   Rastreamento — tema escuro (central de monitoramento)
   Base: Bootstrap 5.3 com data-bs-theme="dark"; aqui ficam as variáveis da marca e os componentes.
   Pontos de quebra: celular < 768px · tablet 768–991px · computador >= 992px.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #0a1020;
  --surface: #111a2e;
  --surface-2: #17223b;
  --surface-3: #1e2c4d;
  --border: #25324f;
  --text: #e8eefc;
  --muted: #93a4c3;
  --primary: #4f8cff;
  --ok: #2fd27a;
  --off: #ff5d6c;
  --warn: #ffb020;
  --purple: #a78bfa;
  --chart-grid: #2a3860;
  --radius: 14px;
  --bar-h: 56px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg);
  --bs-body-bg-rgb: 10, 16, 32;
  --bs-body-color: var(--text);
  --bs-body-color-rgb: 232, 238, 252;
  --bs-emphasis-color: #fff;
  --bs-secondary-color: var(--muted);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-link-color: #86b3ff;
  --bs-link-hover-color: #b3d0ff;
  --bs-link-color-rgb: 134, 179, 255;
  --bs-link-hover-color-rgb: 179, 208, 255;
  --bs-primary: var(--primary);
  --bs-primary-rgb: 79, 140, 255;
  --bs-focus-ring-color: rgba(79, 140, 255, .35);
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: radial-gradient(1200px 600px at 85% -10%, rgba(79, 140, 255, .10), transparent 60%), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: .95rem;
  -webkit-tap-highlight-color: transparent;
}
h1, .h1, h2, .h2, h3, .h3, h4, .h4 { letter-spacing: -.01em; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ico { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Barra superior ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: .75rem;
  height: var(--bar-h); padding: 0 1rem;
  background: rgba(10, 16, 32, .86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -.01em; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #4f8cff, #7c5cff); box-shadow: 0 4px 14px rgba(79, 140, 255, .35); }
.brand-mark .ico { width: 20px; height: 20px; }
.app-bar-title { margin-left: auto; color: var(--muted); font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }

.top-nav { align-items: center; gap: .25rem; margin-left: 1rem; flex: 1 1 auto; }
.top-link { position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.top-link:hover { color: var(--text); background: var(--surface-2); }
.top-link.active { color: #cfe0ff; background: rgba(79, 140, 255, .16); }
.top-label { display: none; }
/* Muitos itens de menu: só mostra os nomes em telas largas (nas médias, só o item ativo tem nome) */
@media (min-width: 992px) { .top-link.active .top-label { display: inline; } }
@media (min-width: 1500px) { .top-label { display: inline; } }

.nav-badge { display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--off); color: #fff; font-size: .68rem; font-weight: 700; line-height: 1; }
.nav-badge.d-none { display: none !important; }
.top-link .nav-badge { position: absolute; top: 2px; right: 0; }
@media (min-width: 992px) { .top-link .nav-badge { position: static; } }

.app-user { align-items: center; gap: .5rem; margin: 0; }
.user-chip { color: var(--muted); font-size: .85rem; display: none; }
@media (min-width: 992px) { .user-chip { display: inline; } }
.role-tag { display: inline-block; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-3); color: #b9c7e6; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.btn-ghost { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); border: 1px solid var(--border); background: transparent; border-radius: 10px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: #34456b; }

/* ---------- Conteúdo ---------- */
.app-main { max-width: 1680px; margin: 0 auto; padding: 1rem; }
@media (min-width: 992px) { .app-main { padding: 1.25rem 1.5rem 2rem; } }
@media (max-width: 767.98px) {
  .app-main { padding: .85rem .85rem calc(var(--tab-h) + var(--safe-b) + 1.25rem); }
}

/* ---------- Barra inferior (celular) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(17, 26, 46, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.tab-ico { position: relative; display: grid; place-items: center; width: 44px; height: 28px; border-radius: 14px; transition: background .15s, color .15s; }
.tab-ico .ico { width: 1.4rem; height: 1.4rem; }
.tab-label { font-size: .68rem; font-weight: 600; letter-spacing: .01em; }
.tab.active { color: #cfe0ff; }
.tab.active .tab-ico { background: rgba(79, 140, 255, .22); color: #fff; }
.tab .nav-badge { position: absolute; top: -3px; right: 2px; }

.sheet { --bs-offcanvas-bg: var(--surface); --bs-offcanvas-border-color: var(--border); --bs-offcanvas-height: auto; border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b); }
.sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; }
.sheet-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.sheet-link { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 500; }
.sheet-link.active { border-color: var(--primary); background: rgba(79, 140, 255, .14); }
.sheet .btn-outline-danger .ico { margin-right: .25rem; vertical-align: -.25rem; }

/* ---------- Cabeçalho de página e filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.toolbar h1 { flex: 1 1 auto; margin: 0; font-size: 1.3rem; font-weight: 650; }
.toolbar > .form-control, .toolbar > .form-select { flex: 0 1 auto; }
@media (max-width: 767.98px) {
  .toolbar h1 { flex: 1 1 100%; font-size: 1.2rem; }
  .toolbar > .form-control, .toolbar > .form-select { flex: 1 1 9rem; width: auto !important; min-width: 0; }
  .toolbar > .btn { flex: 1 1 auto; }
}

/* ---------- Cartões e KPIs ---------- */
.card {
  --bs-card-bg: var(--surface); --bs-card-border-color: var(--border); --bs-card-cap-bg: var(--surface-2);
  --bs-card-border-radius: var(--radius); --bs-card-inner-border-radius: calc(var(--radius) - 1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 28px rgba(0, 0, 0, .28);
}
.card-header { font-weight: 600; border-bottom-color: var(--border); }
.card-footer { background: var(--surface-2); border-top-color: var(--border); }

.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: #475a85; }
.stat .card-body { padding: .9rem 1rem; }
.stat .stat-label { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat .stat-value { display: block; margin-top: .15rem; font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.stat .stat-value.sm { font-size: 1.3rem; }
.stat-ok::before { background: var(--ok); } .stat-ok .stat-value { color: var(--ok); }
.stat-off::before { background: var(--off); } .stat-off .stat-value { color: var(--off); }
.stat-warn::before { background: var(--warn); } .stat-warn .stat-value { color: var(--warn); }
@media (max-width: 575.98px) {
  .stat .card-body { padding: .7rem .85rem; }
  .stat .stat-value { font-size: 1.6rem; }
  .stat .stat-value.sm { font-size: 1.1rem; }
  .stat .stat-label { font-size: .66rem; }
}

/* ---------- Formulários e botões ---------- */
.form-control, .form-select { --bs-border-color: var(--border); background-color: var(--surface-2); border-color: var(--border); color: var(--text); border-radius: 10px; }
.form-control::placeholder { color: #6f82a8; }
.form-control:focus, .form-select:focus { background-color: var(--surface-2); border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(79, 140, 255, .25); color: var(--text); }
.form-control:disabled, .form-select:disabled { opacity: .6; }
.form-label { color: #b9c7e6; font-weight: 500; font-size: .85rem; }
.form-text { color: var(--muted); }
.form-control-lg { font-size: 1rem; padding: .7rem .9rem; }
.form-check-input { background-color: var(--surface-3); border-color: #3a4a70; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
input[type="date"], input[type="time"] { color-scheme: dark; }
@media (max-width: 767.98px) { .form-control, .form-select { font-size: 16px; } } /* evita zoom automático no iOS */

.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #3a78eb; --bs-btn-hover-border-color: #3a78eb; --bs-btn-active-bg: #2f68d3; --bs-btn-active-border-color: #2f68d3; --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); }
.btn-danger { --bs-btn-bg: #e5484d; --bs-btn-border-color: #e5484d; --bs-btn-hover-bg: #cf3a3f; --bs-btn-hover-border-color: #cf3a3f; }
.btn-outline-primary { --bs-btn-color: #8db6ff; --bs-btn-border-color: #2f4f8f; --bs-btn-hover-bg: #2a4a86; --bs-btn-hover-border-color: #2a4a86; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #2a4a86; --bs-btn-active-border-color: #2a4a86; }
.btn-outline-secondary { --bs-btn-color: #b9c7e6; --bs-btn-border-color: #34456b; --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: #4a5e8c; --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--surface-3); --bs-btn-active-border-color: #4a5e8c; }
.btn-outline-dark { --bs-btn-color: var(--text); --bs-btn-border-color: #3a4a70; --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: #4a5e8c; --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--surface-3); --bs-btn-active-border-color: #4a5e8c; --bs-btn-active-color: #fff; }
.btn-outline-danger { --bs-btn-color: #ff8a94; --bs-btn-border-color: #7a2f38; --bs-btn-hover-bg: #a8323d; --bs-btn-hover-border-color: #a8323d; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #a8323d; --bs-btn-active-border-color: #a8323d; }
.btn-outline-success { --bs-btn-color: #6fe0a4; --bs-btn-border-color: #1f6a47; --bs-btn-hover-bg: #1f7a50; --bs-btn-hover-border-color: #1f7a50; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1f7a50; --bs-btn-active-border-color: #1f7a50; }
.btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .7; }
@media (max-width: 575.98px) { .btn-sm { --bs-btn-padding-y: .4rem; --bs-btn-padding-x: .7rem; } }

.admin-only { display: none; }
body[data-role="admin"] .admin-only { display: inline-block; }
body[data-role="admin"] .admin-only-flex { display: flex; }
.admin-only-block { display: none; }
body[data-role="admin"] .admin-only-block { display: block; }

/* ---------- Tabelas, listas, paginação ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); --bs-table-hover-bg: rgba(79, 140, 255, .07); --bs-table-hover-color: var(--text); --bs-table-striped-bg: rgba(255, 255, 255, .02); margin-bottom: 0; }
.table thead th { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .02); }
.table td, .table th { white-space: nowrap; padding: .7rem .85rem; }
.table-sm td, .table-sm th { padding: .5rem .75rem; }
.table td.text-end { white-space: normal; }
.table td.text-end .btn { margin-bottom: .25rem; }
.table-responsive { border-radius: inherit; }

.list-group { --bs-list-group-bg: transparent; --bs-list-group-border-color: var(--border); --bs-list-group-color: var(--text); --bs-list-group-action-hover-bg: var(--surface-2); }
.pagination { --bs-pagination-bg: var(--surface-2); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text); --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-hover-color: #fff; --bs-pagination-hover-border-color: #34456b; --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-disabled-bg: var(--surface); --bs-pagination-disabled-color: #5d6f93; --bs-pagination-disabled-border-color: var(--border); --bs-pagination-focus-bg: var(--surface-3); --bs-pagination-focus-color: #fff; }
.alert { border-radius: 12px; }

/* Tabela que vira lista de cartões no celular. Os rótulos vêm do cabeçalho (data-label, preenchido em common.js). */
@media (max-width: 767.98px) {
  table.table-stack, table.table-stack tbody { display: block; width: 100%; }
  table.table-stack thead { display: none; }
  table.table-stack tr { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
  table.table-stack tbody tr:last-child { border-bottom: 0; }
  table.table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .22rem 0; border: 0; white-space: normal !important; text-align: right; min-width: 0 !important; width: auto !important; background: none; box-shadow: none; }
  table.table-stack td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; text-align: left; }
  table.table-stack td[data-label=""]::before, table.table-stack td[colspan]::before, table.table-stack td:first-child::before { display: none; }
  table.table-stack td:first-child { justify-content: flex-start; text-align: left; font-size: 1.02rem; font-weight: 650; padding-bottom: .35rem; }
  table.table-stack td[colspan] { justify-content: flex-start; text-align: left; }
  table.table-stack td.text-end { justify-content: flex-start; flex-wrap: wrap; gap: .4rem; padding-top: .55rem; text-align: left; }
  table.table-stack td.text-end::before { display: none; }
  table.table-stack td > div { text-align: right; }
}

/* ---------- Indicadores ---------- */
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .4rem; vertical-align: baseline; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 210, 122, .18); }
.dot-off { background: var(--off); box-shadow: 0 0 0 3px rgba(255, 93, 108, .18); }
.dot-none { background: #6b7a9c; }
.text-success { color: var(--ok) !important; } .text-danger { color: var(--off) !important; } .text-warning { color: var(--warn) !important; }
.badge { font-weight: 600; letter-spacing: .01em; }
.swatch { display: inline-block; width: 1.4rem; height: .35rem; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }

/* ---------- Painel ---------- */
.map-card { overflow: hidden; }
#map, #geo-map { border-radius: calc(var(--radius) - 1px); background: #dfe6ee; z-index: 0; }
#map { height: clamp(340px, 64vh, 780px); }
#geo-map { height: clamp(320px, 60vh, 700px); }
@media (max-width: 767.98px) {
  #map { height: 48vh; min-height: 320px; }
  #geo-map { height: 44vh; min-height: 300px; }
}
.map-out-btn { background: #fff; color: #1f2937; border: 0; border-radius: 8px; padding: .4rem .7rem; font-size: .8rem; font-weight: 600; box-shadow: 0 1px 6px rgba(0, 0, 0, .45); cursor: pointer; margin: 0 0 .8rem .8rem; }
.map-out-btn:hover { background: #e8eefc; }
.map-note { color: var(--muted); font-size: .78rem; margin: .5rem .15rem 0; }

.fleet-card { display: flex; flex-direction: column; }
.fleet-head { display: flex; flex-direction: column; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.fleet-title { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .8rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.chip:hover { color: var(--text); border-color: #3a4a70; }
.chip[aria-pressed="true"] { background: rgba(79, 140, 255, .18); border-color: var(--primary); color: #dce8ff; }
.chip .n { font-variant-numeric: tabular-nums; opacity: .85; }

.vehicle-list { max-height: clamp(260px, 52vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
.vehicle-item { cursor: pointer; padding: .8rem 1rem; transition: background .12s; }
.vehicle-item:hover, .vehicle-item:focus { background: var(--surface-2); outline: none; }
.vehicle-item:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.vehicle-item .vglyph { color: var(--muted); }
@media (max-width: 767.98px) { .vehicle-list { max-height: none; overflow: visible; overscroll-behavior: auto; } }

/* ---------- Marcadores do mapa ---------- */
.marker-pin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.marker-on { background: #1fae63; } .marker-off { background: #e5484d; } .marker-end { background: #3b82f6; }
/* Marcador em gota: a ponta de baixo é o ponto exato da moto. */
.vpin { position: relative; width: 38px; height: 38px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.vpin .vbody { position: absolute; inset: 0; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-sizing: border-box; background: #1fae63; }
.vpin::after { content: ""; position: absolute; left: 50%; top: 45px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: rgba(0, 0, 0, .35); filter: blur(1px); }
.pin-on .vbody, .pin-on .vlabel { background: #1fae63; } .pin-off .vbody, .pin-off .vlabel { background: #e5484d; } .pin-end .vbody, .pin-end .vlabel { background: #3b82f6; }
/* Marcador com a cor do veículo (cadastro): corpo branco, borda na cor do status (verde online / vermelha offline)
   e ícone na cor do veículo; offline fica esmaecido. Veículos de cor clara (branca, prata...) ganham fundo escuro para o ícone aparecer. */
.pin-on.pin-ign .vbody, .pin-on.pin-ign .vlabel { background: #2563eb; }   /* online com ignição ligada: azul */
.vpin.pin-colored .vbody { background: #fff; border-width: 4px; }
.vpin.pin-colored.pin-on .vbody { border-color: #1fae63; }
.vpin.pin-colored.pin-on.pin-ign .vbody { border-color: #2563eb; }
.vpin.pin-colored.pin-off .vbody { border-color: #e5484d; }
.vpin.pin-colored.pin-off .vbody { opacity: .55; }
.vpin.pin-colored.pin-off:not(.pin-light) .vglyph { opacity: .6; }
.vpin.pin-colored .vglyph { stroke-width: 2.2; }
.vpin.pin-colored.pin-light .vbody { background: #475569; }   /* veículo claro: fundo escuro para o ícone aparecer */
.vpin .vglyph { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; color: #fff; }
.vlabel { position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 1px 6px; border-radius: 4px; border: 1px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); font: 700 11px/1.3 system-ui, sans-serif; letter-spacing: .03em; color: #fff; pointer-events: none; }

.vglyph { width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vglyph .fill { fill: currentColor; }
.stop-pin { width: 16px; height: 16px; border-radius: 4px; background: #7c5cff; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.end-pin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }

/* ---------- Leaflet no tema escuro (mapa continua claro) ---------- */
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }
.leaflet-popup-content { margin: .8rem 1rem; line-height: 1.45; min-width: 190px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button:hover { color: #fff; }
.leaflet-container .leaflet-popup-content a { color: #86b3ff; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: 0 4px 14px rgba(0, 0, 0, .35) !important; }
.leaflet-bar a { background-color: var(--surface-2); color: var(--text); border-bottom-color: var(--border); }
.leaflet-bar a:hover { background-color: var(--surface-3); color: #fff; }
.leaflet-control-attribution { background: rgba(10, 16, 32, .78) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: #9bbcff !important; }
@media (max-width: 767.98px) { .leaflet-bar a { width: 36px; height: 36px; line-height: 36px; } }

/* ---------- Histórico ---------- */
#speed-chart { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); }
.range-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
@media (max-width: 767.98px) { .range-buttons .btn { flex: 1 1 auto; } }

/* ---------- Cercas ---------- */
.geo-item { cursor: pointer; }
.geo-item.active-row { background: rgba(79, 140, 255, .14); }

/* ---------- Modais ---------- */
.modal-content { --bs-modal-bg: var(--surface); --bs-modal-border-color: var(--border); --bs-modal-header-border-color: var(--border); --bs-modal-footer-border-color: var(--border); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
.modal-backdrop { --bs-backdrop-bg: #02050d; --bs-backdrop-opacity: .72; }
@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-content { border-radius: 0; }
  .modal-footer { position: sticky; bottom: 0; background: var(--surface); }
}

/* Janela de comandos */
#cmd-modal .modal-body { max-height: calc(100vh - 11rem); overflow-y: auto; }
#cmd-modal .table td, #cmd-modal .table th { white-space: normal; vertical-align: top; }
#cmd-modal .table th:nth-child(1), #cmd-modal .table td:nth-child(1) { width: 9rem; white-space: nowrap; }
#cmd-modal .table th:nth-child(2), #cmd-modal .table td:nth-child(2) { width: 11rem; }
#cmd-modal .table th:nth-child(3), #cmd-modal .table td:nth-child(3) { width: 10rem; }
#cmd-modal .table th:nth-child(5), #cmd-modal .table td:nth-child(5) { width: 5.5rem; text-align: right; }
#cmd-rows td:nth-child(4) > div:not(.small) { font: .8rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .55rem; overflow-wrap: anywhere; }
#cmd-rows td:nth-child(4) .small { margin-top: .25rem; }
#cmd-modal .alert { margin-bottom: 1rem; }
.cmd-danger { border: 1px solid #7a2f38; background: rgba(229, 72, 77, .07); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
@media (max-width: 767.98px) {
  #cmd-modal .modal-body { max-height: none; }
  #cmd-modal .d-flex.gap-2 > .btn, #cmd-modal .d-flex.gap-2 > .form-control { flex: 1 1 100%; width: 100% !important; }
  #cmd-modal .d-flex.flex-wrap.gap-2 > .btn { flex: 1 1 100%; }
  #cmd-rows td:nth-child(4) > div:not(.small) { text-align: left; }
}

/* ---------- Login e erro ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: radial-gradient(900px 500px at 50% -10%, rgba(79, 140, 255, .18), transparent 65%), var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { border-radius: 20px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); }
.auth-logo { width: 56px; height: 56px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 16px; color: #fff; background: linear-gradient(135deg, #4f8cff, #7c5cff); box-shadow: 0 8px 24px rgba(79, 140, 255, .4); }
.auth-logo .ico { width: 30px; height: 30px; }

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Botão de tema ---------- */
.theme-toggle { padding: .3rem .5rem; line-height: 1; }
.theme-toggle .ico-sun { display: none; }
[data-bs-theme="light"] .theme-toggle .ico-moon { display: none; }
[data-bs-theme="light"] .theme-toggle .ico-sun { display: inline-block; }
.auth-theme { position: fixed; top: .75rem; right: .75rem; z-index: 10; }

/* ==========================================================================
   Tema claro — mesmas variáveis, valores claros. Escolha salva no navegador (theme.js).
   ========================================================================== */
[data-bs-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #e8eef8;
  --border: #d9e1ee;
  --text: #17223b;
  --muted: #5d6b86;
  --primary: #2f6bf0;
  --ok: #17a05a;
  --off: #e5484d;
  --warn: #d98a00;
  --purple: #6f4be0;
  --chart-grid: #dde5f2;
  --bs-body-bg: var(--bg);
  --bs-body-bg-rgb: 243, 246, 251;
  --bs-body-color: var(--text);
  --bs-body-color-rgb: 23, 34, 59;
  --bs-emphasis-color: #0b1226;
  --bs-secondary-color: var(--muted);
  --bs-secondary-bg: var(--surface-3);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-link-color: #2457d6;
  --bs-link-hover-color: #1b43a8;
  --bs-link-color-rgb: 36, 87, 214;
  --bs-link-hover-color-rgb: 27, 67, 168;
  --bs-primary: var(--primary);
  --bs-primary-rgb: 47, 107, 240;
  --bs-focus-ring-color: rgba(47, 107, 240, .25);
}
[data-bs-theme="light"] body { background: radial-gradient(1200px 600px at 85% -10%, rgba(47, 107, 240, .08), transparent 60%), var(--bg); }
[data-bs-theme="light"] .app-bar { background: rgba(255, 255, 255, .88); }
[data-bs-theme="light"] .bottom-nav { background: rgba(255, 255, 255, .95); }
[data-bs-theme="light"] .brand:hover { color: #0b1226; }
[data-bs-theme="light"] .top-link.active, [data-bs-theme="light"] .tab.active { color: #1b43a8; }
[data-bs-theme="light"] .top-link.active { background: rgba(47, 107, 240, .12); }
[data-bs-theme="light"] .tab.active .tab-ico { background: rgba(47, 107, 240, .14); color: #1b43a8; }
[data-bs-theme="light"] .role-tag { background: var(--surface-3); color: #3d4c6b; }
[data-bs-theme="light"] .btn-ghost:hover { border-color: #b8c5dd; }
[data-bs-theme="light"] .card { box-shadow: 0 1px 2px rgba(23, 34, 59, .05), 0 6px 18px rgba(23, 34, 59, .06); }
[data-bs-theme="light"] .stat::before { background: #a9b6d0; }
[data-bs-theme="light"] .form-control::placeholder { color: #8c99b3; }
[data-bs-theme="light"] .form-control:focus, [data-bs-theme="light"] .form-select:focus { background-color: #fff; box-shadow: 0 0 0 .2rem rgba(47, 107, 240, .2); }
[data-bs-theme="light"] .form-label { color: #3d4c6b; }
[data-bs-theme="light"] .form-check-input { background-color: #fff; border-color: #b8c5dd; }
[data-bs-theme="light"] .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
[data-bs-theme="light"] .btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #2358cc; --bs-btn-hover-border-color: #2358cc; --bs-btn-active-bg: #1d4cb4; --bs-btn-active-border-color: #1d4cb4; --bs-btn-color: #fff; --bs-btn-hover-color: #fff; }
[data-bs-theme="light"] .btn-outline-primary { --bs-btn-color: #2457d6; --bs-btn-border-color: #9db8f2; --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--primary); --bs-btn-active-border-color: var(--primary); }
[data-bs-theme="light"] .btn-outline-secondary { --bs-btn-color: #3d4c6b; --bs-btn-border-color: #c4cfe3; --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: #a9b6d0; --bs-btn-hover-color: #17223b; --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: #17223b; }
[data-bs-theme="light"] .btn-outline-dark { --bs-btn-color: var(--text); --bs-btn-border-color: #b8c5dd; --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: #a9b6d0; --bs-btn-hover-color: #17223b; --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: #17223b; }
[data-bs-theme="light"] .btn-outline-danger { --bs-btn-color: #c62f3a; --bs-btn-border-color: #efb0b5; --bs-btn-hover-bg: #d93a45; --bs-btn-hover-border-color: #d93a45; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #d93a45; --bs-btn-active-color: #fff; }
[data-bs-theme="light"] .btn-outline-success { --bs-btn-color: #11793f; --bs-btn-border-color: #a6dcbc; --bs-btn-hover-bg: #17a05a; --bs-btn-hover-border-color: #17a05a; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #17a05a; --bs-btn-active-color: #fff; }
[data-bs-theme="light"] .table { --bs-table-hover-bg: rgba(47, 107, 240, .05); --bs-table-striped-bg: rgba(23, 34, 59, .02); }
[data-bs-theme="light"] .table thead th { background: var(--surface-2); }
[data-bs-theme="light"] .pagination { --bs-pagination-hover-color: #17223b; --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-hover-border-color: #b8c5dd; --bs-pagination-active-color: #fff; --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-disabled-color: #9aa7c0; }
[data-bs-theme="light"] .dot-none { background: #9aa7c0; }
[data-bs-theme="light"] .chip:hover { border-color: #b8c5dd; }
[data-bs-theme="light"] .chip[aria-pressed="true"] { background: rgba(47, 107, 240, .12); color: #1b43a8; }
[data-bs-theme="light"] .geo-item.active-row, [data-bs-theme="light"] .sheet-link.active { background: rgba(47, 107, 240, .1); }
[data-bs-theme="light"] .leaflet-popup-content-wrapper { box-shadow: 0 10px 30px rgba(23, 34, 59, .22); }
[data-bs-theme="light"] .leaflet-container a.leaflet-popup-close-button:hover { color: var(--text); }
[data-bs-theme="light"] .leaflet-container .leaflet-popup-content a { color: #2457d6; }
[data-bs-theme="light"] .leaflet-bar { box-shadow: 0 4px 14px rgba(23, 34, 59, .18) !important; }
[data-bs-theme="light"] .leaflet-bar a:hover { color: var(--text); }
[data-bs-theme="light"] .leaflet-control-attribution { background: rgba(255, 255, 255, .85) !important; }
[data-bs-theme="light"] .leaflet-control-attribution a { color: #2457d6 !important; }
[data-bs-theme="light"] .modal-content { box-shadow: 0 24px 60px rgba(23, 34, 59, .3); }
[data-bs-theme="light"] .modal-backdrop { --bs-backdrop-bg: #0b1226; --bs-backdrop-opacity: .5; }
[data-bs-theme="light"] .cmd-danger { border-color: #efb0b5; background: rgba(229, 72, 77, .06); }
[data-bs-theme="light"] .auth-body { background: radial-gradient(900px 500px at 50% -10%, rgba(47, 107, 240, .14), transparent 65%), var(--bg); }
[data-bs-theme="light"] .auth-card { box-shadow: 0 20px 50px rgba(23, 34, 59, .14); }
[data-bs-theme="light"] input[type="date"], [data-bs-theme="light"] input[type="time"] { color-scheme: light; }

/* ---------- Detalhe da moto ---------- */
.toolbar h1 { display: flex; align-items: center; gap: .6rem; }
.v-glyph .vglyph { width: 1.7rem; height: 1.7rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.v-glyph .vglyph .fill { fill: currentColor; }
.vd-top { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.vd-speed { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-radius: var(--radius); background: #1b2236; border: 1px solid var(--border); color: #fff; }
.vd-speed .ico { width: 2.2rem; height: 2.2rem; color: var(--warn); stroke-width: 1.6; }
.vd-label { font-size: .75rem; color: #b9c7e6; }
.vd-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.vd-value small { font-size: .8rem; font-weight: 500; color: #b9c7e6; }
.vd-history { display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 650; border-radius: var(--radius); }
.vd-list { display: grid; grid-template-columns: minmax(7rem, 38%) 1fr; margin: 0; padding: .35rem 1rem .6rem; }
.vd-list dt { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: .5rem 0; border-bottom: 1px solid var(--border); align-self: stretch; display: flex; align-items: center; }
.vd-list dd { margin: 0; padding: .5rem 0 .5rem .75rem; border-bottom: 1px solid var(--border); text-align: right; overflow-wrap: anywhere; }
.vd-list dt:last-of-type, .vd-list dd:last-of-type { border-bottom: 0; }
.vd-coords { font-variant-numeric: tabular-nums; }
@media (max-width: 991.98px) { #map { height: 46vh; min-height: 300px; } }
.plate-link { color: inherit; text-decoration: none; } .plate-link:hover strong { text-decoration: underline; }
.leaflet-bar a.follow-btn { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; text-decoration: none; cursor: pointer; }
.leaflet-bar a.follow-btn.on { background-color: var(--primary); color: #fff; }
.vlabel.vlabel-up { bottom: calc(100% + 24px); }

/* ---------- Seletor de mapa (ruas/satélite) ---------- */
.leaflet-control-layers { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: 10px !important; box-shadow: 0 4px 14px rgba(0, 0, 0, .3) !important; }
.leaflet-control-layers-toggle { width: 36px !important; height: 36px !important; }
.leaflet-control-layers-expanded { padding: .5rem .75rem !important; }
.leaflet-control-layers label { margin: .15rem 0; font-size: .85rem; }
.leaflet-control-layers-separator { border-top-color: var(--border) !important; }
[data-bs-theme="dark"] .leaflet-control-layers-toggle { filter: invert(.85); }

/* ---------- Minha conta ---------- */
a.user-chip { text-decoration: none; }
a.user-chip:hover { color: var(--text); }

/* ---------- Coluna "Local" (endereço + coordenadas) ---------- */
.loc { min-width: 12rem; }
.loc-addr { white-space: normal; max-width: 26rem; line-height: 1.3; }
.loc-coords { display: block; font-size: .76rem; color: var(--muted); }

/* Lista de seleção (motos do usuário, usuários da moto) */
.pick-list { max-height: 45vh; overflow-y: auto; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 10px; }
.pick-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; cursor: pointer; border-bottom: 1px solid var(--border, rgba(127,127,127,.2)); margin: 0; }
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--surface-2, rgba(127,127,127,.12)); }
.msg-pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2, rgba(127,127,127,.12)); border-radius: 10px; padding: .75rem; margin-bottom: .5rem; font-family: inherit; }
.auth-or{display:flex;align-items:center;gap:.75rem}.auth-or::before,.auth-or::after{content:'';flex:1;border-top:1px solid var(--bs-border-color)}

/* ---- Marca EFA Track */
.brand-logo { display: block; width: 34px; height: 34px; object-fit: contain; }
.brand-name { font-style: italic; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.brand-efa { color: var(--text); }
.brand-track { color: #19c7d8; }
.auth-brand { margin: 0 auto 1rem; max-width: 290px; }
.auth-brand img { display: block; width: 100%; height: auto; }
.logo-for-dark { display: none !important; }
[data-bs-theme="dark"] .logo-for-light { display: none !important; }
[data-bs-theme="dark"] .logo-for-dark { display: block !important; }
@media (max-width: 380px) { .brand-name { font-size: .95rem; } }

/* Clientes (contas) */
.company-switch { flex: 0 1 10rem; width: auto; min-width: 6rem; max-width: 10rem; margin-left: auto; margin-right: .5rem; }
.company-switch.is-acting { border-color: var(--bs-warning); box-shadow: 0 0 0 .15rem rgba(255, 193, 7, .35); }
.acting-banner { background: var(--bs-warning-bg-subtle, #fff3cd); color: var(--bs-warning-text-emphasis, #664d03); border-bottom: 1px solid var(--bs-warning-border-subtle, #ffe69c); padding: .4rem 1rem; font-size: .9rem; display: flex; align-items: center; flex-wrap: wrap; }
tr.company-group > td { background: var(--bs-tertiary-bg, #f1f3f5); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.quota-bar { height: .45rem; min-width: 5rem; }

/* Ajuda */
.help-toc { position: sticky; top: 4.5rem; gap: .15rem; }
.help-toc a { padding: .25rem .4rem; border-radius: .35rem; color: var(--bs-body-color); text-decoration: none; }
.help-toc a:hover { background: var(--border); }
.help-sec h2 { font-size: 1.1rem; font-weight: 650; margin-bottom: .75rem; }
.help-sec { scroll-margin-top: 4.5rem; }
.help-sec ul, .help-sec ol { padding-left: 1.25rem; }
.help-sec li { margin-bottom: .3rem; }
.help-faq dt { font-weight: 600; margin-top: .6rem; }
.help-faq dd { margin: 0 0 .2rem; color: var(--muted); }
.help-tabs .nav-link { padding: .4rem .9rem; }


/* Lista resumida (cartões) x detalhada (tabela) em Veículos e Rastreadores */
#list-wrap[data-view="compact"] .list-full { display: none; }
#list-wrap[data-view="full"] .list-compact { display: none; }
.view-toggle .btn.active { background: var(--surface-3); color: var(--text); border-color: var(--primary); }
.compact-group { padding: .9rem .25rem .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.compact-item { display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding-right: .6rem; }
.compact-item:hover { border-color: #34456b; }
.ci-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .8rem; padding: .8rem .6rem .8rem .9rem; color: inherit; text-decoration: none; background: none; border: 0; text-align: left; font: inherit; }
button.ci-main { cursor: pointer; }
.ci-ico { flex: 0 0 auto; width: 2.7rem; height: 2.7rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.ci-ico .vglyph { width: 1.5rem; height: 1.5rem; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ci-ico .vglyph .fill { fill: currentColor; }
.ci-ico.tone-on { background: rgba(47, 210, 122, .14); color: var(--ok); }
.ci-ico.tone-off { background: rgba(255, 93, 108, .14); color: var(--off); }
.ci-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.ci-title { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.ci-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.ci-chip { font-size: .72rem; padding: .08rem .5rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.ci-chip.chip-on { color: var(--ok); border-color: rgba(47, 210, 122, .4); }
.ci-chip.chip-off { color: var(--off); border-color: rgba(255, 93, 108, .4); }
.ci-chip.chip-warn { color: var(--warn); border-color: rgba(255, 176, 32, .4); }
.ci-when { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: .1rem; }
.ci-ago { font-weight: 600; font-size: .85rem; color: var(--primary); }
.ci-date { font-size: .72rem; color: var(--muted); }
.ci-menu .btn { padding: .15rem .6rem; font-size: 1.1rem; line-height: 1; }
@media (max-width: 575.98px) {
  .ci-main { gap: .6rem; padding: .7rem .4rem .7rem .7rem; }
  .ci-ico { width: 2.4rem; height: 2.4rem; }
  .ci-title { font-size: .92rem; }
  .ci-when { max-width: 5.2rem; }
  .ci-date { display: none; }
}

/* Histórico: viagem em destaque no mapa */
tr.trip-row { cursor: pointer; }
tr.trip-row:hover td, tr.trip-row:focus td { background: var(--surface-2, rgba(127, 127, 127, .14)); }
tr.trip-row:focus { outline: none; }
tr.trip-row:focus-visible td { box-shadow: inset 0 0 0 2px var(--primary); }
tr.trip-row.active td { background: rgba(111, 66, 193, .22); }
.trip-pin { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .8rem; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .55); }
.trip-pin.sm { width: 20px; height: 20px; font-size: .68rem; border-width: 1.5px; vertical-align: middle; }
.trip-pin-a { background: #1fae63; } .trip-pin-b { background: #e5484d; } .trip-pin-via { background: #6f42c1; } .trip-pin-stop { background: #7c5cff; border-radius: 5px; }
.trip-arrow { width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.trip-facts { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-bottom: .6rem; color: var(--muted); }
.trip-steps { display: grid; gap: .45rem; }
.map-card { scroll-margin-top: 72px; }
.history-list { max-height: 420px; overflow-y: auto; }
@media (min-width: 1200px) {
  .history-sticky { position: sticky; top: 72px; }
  .history-split #map { height: clamp(300px, 40vh, 480px); }
  .history-sticky #trip-body { max-height: 24vh; overflow-y: auto; }
}
@media (max-width: 767.98px) { .history-list { max-height: none; overflow: visible; overscroll-behavior: auto; } }

/* ==========================================================================
   Tema claro — destaques no azul escuro da marca (menu, barra inferior, cabeçalhos de cartões e tabelas).
   O restante continua claro; só as áreas de navegação e títulos ganham o azul.
   ========================================================================== */
[data-bs-theme="light"] {
  --navy: #0f1a33;
  --navy-2: #17264a;
  --navy-text: #e8eefc;
  --navy-muted: #9fb0d0;
}
[data-bs-theme="light"] .app-bar { background: linear-gradient(180deg, #14213f, var(--navy)); border-bottom: 1px solid #0a1224; box-shadow: 0 2px 10px rgba(15, 26, 51, .25); }
[data-bs-theme="light"] .app-bar .brand, [data-bs-theme="light"] .app-bar .brand-efa { color: #fff; }
[data-bs-theme="light"] .app-bar .brand:hover { color: #fff; }
[data-bs-theme="light"] .app-bar .brand-track { color: #2fd0e0; }
[data-bs-theme="light"] .app-bar .top-link { color: var(--navy-muted); }
[data-bs-theme="light"] .app-bar .top-link:hover { color: #fff; background: rgba(255, 255, 255, .09); }
[data-bs-theme="light"] .app-bar .top-link.active { color: #fff; background: rgba(79, 140, 255, .28); box-shadow: inset 0 -2px 0 #4f8cff; }
[data-bs-theme="light"] .app-bar .user-chip, [data-bs-theme="light"] .app-bar .app-bar-title { color: var(--navy-text); }
[data-bs-theme="light"] .app-bar .role-tag { background: rgba(79, 140, 255, .25); color: #cfe0ff; }
[data-bs-theme="light"] .app-bar .btn-ghost, [data-bs-theme="light"] .app-bar .btn-outline-secondary { color: var(--navy-muted); border-color: rgba(255, 255, 255, .18); background: transparent; --bs-btn-color: var(--navy-muted); --bs-btn-border-color: rgba(255, 255, 255, .18); --bs-btn-hover-bg: rgba(255, 255, 255, .1); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: rgba(255, 255, 255, .3); }
[data-bs-theme="light"] .app-bar .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .3); }
[data-bs-theme="light"] .app-bar .form-select { background-color: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); color: var(--navy-text); --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cfe0ff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
[data-bs-theme="light"] .app-bar .form-select option { color: #17223b; background: #fff; }

[data-bs-theme="light"] .bottom-nav { background: linear-gradient(180deg, #14213f, var(--navy)); border-top-color: #0a1224; box-shadow: 0 -2px 10px rgba(15, 26, 51, .25); }
[data-bs-theme="light"] .bottom-nav .tab { color: var(--navy-muted); }
[data-bs-theme="light"] .bottom-nav .tab.active { color: #fff; }
[data-bs-theme="light"] .bottom-nav .tab.active .tab-ico { background: rgba(79, 140, 255, .3); color: #fff; }

/* Cabeçalho dos cartões e das tabelas em azul escuro: dá estrutura ao conteúdo claro. */
[data-bs-theme="light"] .card-header { background: var(--navy); color: var(--navy-text); border-bottom: 0; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
[data-bs-theme="light"] .card-header .text-secondary, [data-bs-theme="light"] .card-header .text-muted, [data-bs-theme="light"] .card-header .small { color: var(--navy-muted) !important; }
[data-bs-theme="light"] .card-header .btn-outline-secondary, [data-bs-theme="light"] .card-header .btn-ghost { --bs-btn-color: var(--navy-muted); --bs-btn-border-color: rgba(255, 255, 255, .22); --bs-btn-hover-bg: rgba(255, 255, 255, .12); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: rgba(255, 255, 255, .35); color: var(--navy-muted); border-color: rgba(255, 255, 255, .22); }
[data-bs-theme="light"] .card-header .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, .12); }
[data-bs-theme="light"] .card-header .btn-outline-primary { --bs-btn-color: #9cc0ff; --bs-btn-border-color: rgba(156, 192, 255, .45); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-color: #fff; }
[data-bs-theme="light"] .card-header .form-control, [data-bs-theme="light"] .card-header .form-select { background-color: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: var(--navy-text); }
[data-bs-theme="light"] .table thead th { background: var(--navy-2); color: #dbe6ff; border-bottom-color: var(--navy-2); }
[data-bs-theme="light"] .stat::before { background: var(--navy); }
[data-bs-theme="light"] .stat-ok::before { background: var(--ok); } [data-bs-theme="light"] .stat-off::before { background: var(--off); } [data-bs-theme="light"] .stat-warn::before { background: var(--warn); }
[data-bs-theme="light"] .fleet-head { background: var(--navy); border-bottom: 0; color: var(--navy-text); }
[data-bs-theme="light"] .fleet-head .form-control { background-color: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: var(--navy-text); }
[data-bs-theme="light"] .fleet-head .form-control::placeholder { color: var(--navy-muted); }
[data-bs-theme="light"] .fleet-head .chip { background: transparent; color: var(--navy-muted); border-color: rgba(255, 255, 255, .25); }
[data-bs-theme="light"] .fleet-head .chip[aria-pressed="true"] { background: rgba(79, 140, 255, .3); color: #fff; border-color: #4f8cff; }

/* Partida bloqueada: cadeado no canto do pino */
.vlock { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%; background: #b42318; border: 1.5px solid #fff; font-size: 10px; line-height: 15px; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); pointer-events: none; }
.block-badge { font-weight: 600; }

/* ---------- Celular: início enxuto (mapa cheio + gaveta) ---------- */
.m-top { display: flex; gap: .5rem; margin-bottom: .6rem; }
.m-count { flex: 1 1 0; display: flex; align-items: baseline; justify-content: center; gap: .35rem; padding: .5rem .4rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .8rem; font-weight: 600; text-decoration: none; }
.m-count b { font-size: 1.25rem; color: var(--text); font-variant-numeric: tabular-nums; }
.m-ok b { color: #34c27a; } .m-off b { color: #ef6a6e; } .m-warn b { color: #f5b942; }
.m-top.has-alerts .m-warn { border-color: #f5b942; background: rgba(245, 185, 66, .12); }
.sheet-handle { display: none; }
.vgroup { display: flex; justify-content: space-between; align-items: center; padding: .4rem 1rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); color: var(--muted); }
.vgroup .n { font-variant-numeric: tabular-nums; }
.vgroup.g-alert { color: #f5b942; } .vgroup.g-on { color: #34c27a; } .vgroup.g-off { color: #ef6a6e; }
.badges-row { display: flex; flex-wrap: wrap; gap: .3rem; margin: .15rem 0; }
.badges-row:empty { display: none; }
.vcard .vc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .6rem; }
.vc-stat { padding: .55rem .6rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.vc-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.vc-value { font-weight: 650; overflow-wrap: anywhere; }
.vc-addr { color: var(--muted); margin-bottom: .6rem; }
.vc-alert { display: block; margin-bottom: .6rem; color: #f5b942; }
.vc-actions { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.vc-act { min-height: 48px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
@media (max-width: 767.98px) {
  .dash-grid { --m-top-h: 3.4rem; margin: 0; }
  #stats { display: none; }
  .dash-grid .map-note { display: none; }
  .dash-grid #map { height: calc(100dvh - var(--bar-h) - var(--tab-h) - var(--safe-b) - var(--m-top-h) - 1.9rem); min-height: 280px; }
  #fleet.fleet-card {
    position: fixed; left: 0; right: 0; z-index: 1020; margin: 0;
    bottom: calc(var(--tab-h) + var(--safe-b));
    border-radius: 18px 18px 0 0; border-bottom: 0;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .35);
    transition: height .22s ease;
  }
  #fleet[data-state="peek"] { height: 92px; }
  #fleet[data-state="half"] { height: 44dvh; }
  #fleet[data-state="full"] { height: calc(100dvh - var(--bar-h) - var(--tab-h) - var(--safe-b) - 8px); }
  #fleet .sheet-handle { display: block; width: 100%; padding: 8px 0 4px; border: 0; background: var(--surface-2); border-radius: 18px 18px 0 0; }
  #fleet .sheet-handle span { display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto; }
  #fleet .fleet-head { border-radius: 0; padding-top: .3rem; }
  #fleet[data-state="peek"] .fleet-head > :not(.fleet-title) { display: none; }
  #fleet .vehicle-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
  #fleet[data-state="peek"] .vehicle-list { display: none; }
  .vc-actions { grid-template-columns: 1fr 1fr; }
  .vc-actions .vc-act:first-child { grid-column: 1 / -1; }
}
[data-bs-theme="light"] .m-count { background: #fff; }
[data-bs-theme="light"] #fleet .sheet-handle, [data-bs-theme="light"] .vgroup { background: #eef2f8; }

@media (max-width: 767.98px) {
  #fleet .sheet-handle, #fleet .fleet-head { touch-action: none; }
  #fleet .vehicle-list { touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: auto; }
  #fleet[data-state="peek"] { height: 64px; }
  #fleet[data-state="peek"] .fleet-head { padding-bottom: .5rem; border-bottom: 0; }
}

.vi-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.vi-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vi-head .badge, .vi-head .status-badge { flex: none; white-space: nowrap; }
.vehicle-item { padding: .65rem 1rem; }
