/* RastreiaFrota — UI premium, responsiva e acessível */
:root {
  --rf-primary: #2563eb;
  --rf-primary-strong: #1d4ed8;
  --rf-primary-soft: rgba(37, 99, 235, .12);
  --rf-success: #16a34a;
  --rf-danger: #dc2626;
  --rf-warning: #d97706;
  --rf-info: #0891b2;
  --rf-bg: #f4f7fb;
  --rf-surface: #ffffff;
  --rf-surface-2: #f8fafc;
  --rf-border: #e5eaf1;
  --rf-text: #0f172a;
  --rf-muted: #64748b;
  --rf-sidebar: #0b1220;
  --rf-sidebar-2: #111c31;
  --rf-sidebar-fg: #cbd5e1;
  --rf-shadow-sm: 0 2px 10px rgba(15, 23, 42, .05);
  --rf-shadow: 0 14px 40px rgba(15, 23, 42, .09);
  --rf-radius: 18px;
  --rf-radius-sm: 12px;
  --rf-sidebar-width: 276px;
}
[data-bs-theme="dark"] {
  --rf-bg: #08111f;
  --rf-surface: #101b2d;
  --rf-surface-2: #0d1727;
  --rf-border: #22314a;
  --rf-text: #e5edf8;
  --rf-muted: #94a3b8;
  --rf-shadow-sm: 0 2px 10px rgba(0, 0, 0, .18);
  --rf-shadow: 0 14px 40px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { color: var(--rf-text); background: var(--rf-bg); }
body, button, input, select, textarea { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { text-underline-offset: 3px; }
.rf-body { min-height: 100vh; }
.rf-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.rf-sidebar {
  width: var(--rf-sidebar-width); background: linear-gradient(180deg, var(--rf-sidebar) 0%, var(--rf-sidebar-2) 100%);
  color: var(--rf-sidebar-fg); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
  z-index: 1045; transition: transform .25s ease; box-shadow: 14px 0 40px rgba(2, 6, 23, .12);
}
.rf-brand { display: flex; align-items: center; gap: .8rem; padding: 1.25rem 1.15rem 1rem; color: #fff; text-decoration: none; }
.rf-brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 10px 24px rgba(37, 99, 235, .35); font-size: 1.2rem;
}
.rf-brand-copy { min-width: 0; }
.rf-brand-title { display: block; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-brand-subtitle { display: block; font-size: .72rem; color: #94a3b8; margin-top: .08rem; }
.rf-workspace { margin: 0 .9rem .75rem; padding: .75rem .85rem; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(255,255,255,.045); }
.rf-workspace small { color: #94a3b8; display: block; }
.rf-workspace strong { color: #f8fafc; font-size: .85rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-nav { flex: 1; overflow-y: auto; padding: .25rem .7rem 1rem; scrollbar-width: thin; }
.rf-nav-section { color: #64748b; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; padding: .95rem .7rem .4rem; }
.rf-nav-link {
  display: flex; align-items: center; gap: .8rem; min-height: 44px; padding: .64rem .75rem; margin: .12rem 0;
  color: var(--rf-sidebar-fg); text-decoration: none; font-size: .9rem; font-weight: 600; border-radius: 12px; transition: .18s ease;
}
.rf-nav-link i { width: 22px; text-align: center; font-size: 1.05rem; }
.rf-nav-link:hover { color: #fff; background: rgba(255,255,255,.075); transform: translateX(2px); }
.rf-nav-link.active { color: #fff; background: linear-gradient(135deg, rgba(59,130,246,.28), rgba(37,99,235,.14)); box-shadow: inset 0 0 0 1px rgba(96,165,250,.16); }
.rf-sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding: .65rem .7rem .9rem; }
.rf-sidebar-footer form { margin: 0; }
.rf-sidebar-footer button { border: 0; width: 100%; background: transparent; }
.rf-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(2, 6, 23, .58); backdrop-filter: blur(2px); z-index: 1040; }

/* Main/topbar */
.rf-main { flex: 1; margin-left: var(--rf-sidebar-width); min-width: 0; display: flex; flex-direction: column; }
.rf-topbar {
  height: 76px; display: flex; align-items: center; gap: .8rem; padding: .75rem 1.5rem;
  background: color-mix(in srgb, var(--rf-surface) 94%, transparent); border-bottom: 1px solid var(--rf-border);
  position: sticky; top: 0; z-index: 1030; backdrop-filter: blur(16px);
}
.rf-page-heading { min-width: 0; }
.rf-page-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-page-kicker { color: var(--rf-muted); font-size: .75rem; margin-top: .12rem; }
.rf-icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid var(--rf-border);
  color: var(--rf-text); background: var(--rf-surface); border-radius: 12px; transition: .18s ease;
}
.rf-icon-btn:hover { color: var(--rf-primary); border-color: rgba(37,99,235,.35); background: var(--rf-primary-soft); transform: translateY(-1px); }
.rf-user-btn { border: 1px solid var(--rf-border); background: var(--rf-surface); color: var(--rf-text); border-radius: 14px; padding: .42rem .65rem .42rem .45rem; }
.rf-avatar { width: 32px; height: 32px; border-radius: 10px; display: inline-grid; place-items: center; color: #fff; font-weight: 800; background: linear-gradient(135deg,#3b82f6,#7c3aed); }
.rf-content { padding: 1.45rem; width: 100%; }
.rf-content-inner { max-width: 1680px; margin: 0 auto; }
.rf-impersonation { border: 0; border-radius: 0; margin: 0; padding: .55rem 1.5rem; background: linear-gradient(90deg,#f59e0b,#f97316); color: #fff; }

/* Cards, tables, forms */
.card { background: var(--rf-surface); border: 1px solid var(--rf-border); border-radius: var(--rf-radius); box-shadow: var(--rf-shadow-sm); }
.card-header { background: transparent; border-color: var(--rf-border); }
.rf-card-hover { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.rf-card-hover:hover { transform: translateY(-3px); box-shadow: var(--rf-shadow); border-color: rgba(37,99,235,.22); }
.rf-section-title { font-size: .98rem; font-weight: 800; letter-spacing: -.01em; margin: 0; }
.rf-section-subtitle { color: var(--rf-muted); font-size: .78rem; margin-top: .15rem; }
.rf-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; margin-bottom: 1rem; }
.rf-stat { display: flex; align-items: center; gap: .9rem; min-height: 64px; }
.rf-stat .icon { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 1.25rem; flex: 0 0 auto; }
.rf-stat .value { font-size: 1.5rem; font-weight: 850; line-height: 1.05; letter-spacing: -.035em; }
.rf-stat .label { color: var(--rf-muted); font-size: .76rem; font-weight: 650; margin-top: .2rem; }
.rf-stat .trend { font-size: .7rem; color: var(--rf-muted); }
.table-responsive { border-radius: 14px; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--rf-text); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .78rem .78rem; border-bottom-color: var(--rf-border); vertical-align: middle; }
.table thead th { color: var(--rf-muted); font-size: .71rem; text-transform: uppercase; letter-spacing: .055em; font-weight: 800; white-space: nowrap; background: var(--rf-surface-2); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: color-mix(in srgb, var(--rf-primary-soft) 45%, transparent); }
.form-control, .form-select, .input-group-text {
  color: var(--rf-text); background-color: var(--rf-surface); border-color: var(--rf-border); border-radius: 11px;
}
.form-control:focus, .form-select:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 .22rem rgba(37,99,235,.11); background: var(--rf-surface); color: var(--rf-text); }
.input-group > .form-control:not(:first-child), .input-group > .form-select:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group-text { color: var(--rf-muted); }
.form-label { font-size: .78rem; font-weight: 750; color: color-mix(in srgb, var(--rf-text) 82%, var(--rf-muted)); margin-bottom: .35rem; }
.btn { border-radius: 11px; font-weight: 700; }
.btn-primary { background: linear-gradient(135deg, var(--rf-primary), var(--rf-primary-strong)); border-color: transparent; box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.btn-primary:hover { border-color: transparent; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(37,99,235,.25); }
.btn-outline-primary { border-color: rgba(37,99,235,.35); }
.badge { border-radius: 999px; padding: .42em .68em; font-weight: 750; }
.modal-content { background: var(--rf-surface); color: var(--rf-text); border: 1px solid var(--rf-border); border-radius: 20px; box-shadow: var(--rf-shadow); }
.modal-header, .modal-footer { border-color: var(--rf-border); }
.dropdown-menu { background: var(--rf-surface); color: var(--rf-text); border-color: var(--rf-border); border-radius: 14px; box-shadow: var(--rf-shadow); padding: .5rem; }
.dropdown-item { color: var(--rf-text); border-radius: 9px; }
.dropdown-item:hover { background: var(--rf-primary-soft); color: var(--rf-primary); }
.pagination .page-link { color: var(--rf-text); background: var(--rf-surface); border-color: var(--rf-border); }
.pagination .active > .page-link { background: var(--rf-primary); border-color: var(--rf-primary); color: #fff; }

/* Map and fleet */
#map, #histMap, #cercaMap, #shareMap { width: 100%; height: calc(100vh - 185px); min-height: 440px; border-radius: var(--rf-radius); z-index: 1; border: 1px solid var(--rf-border); box-shadow: var(--rf-shadow-sm); }
.rf-map-shell { position: relative; }
.rf-map-floating { position: absolute; z-index: 500; top: 12px; right: 12px; display: flex; gap: .4rem; }
.rf-vehicle-list { max-height: calc(100vh - 285px); overflow-y: auto; }
.rf-vehicle-item { cursor: pointer; border: 1px solid transparent !important; border-left-width: 4px !important; margin-bottom: .45rem; border-radius: 12px !important; background: var(--rf-surface-2); }
.rf-vehicle-item:hover { background: var(--rf-primary-soft); border-color: rgba(37,99,235,.15) !important; }
.rf-vehicle-item.moving { border-left-color: var(--rf-success) !important; }
.rf-vehicle-item.stopped { border-left-color: var(--rf-primary) !important; }
.rf-vehicle-item.offline { border-left-color: var(--rf-danger) !important; }
.rf-vehicle-item.alert { border-left-color: #eab308 !important; }
.rf-vehicle-item.gray { border-left-color: #94a3b8 !important; }
.rf-marker-dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.35); position: relative; }
.rf-marker-dot::after { content: ''; position: absolute; top: -7px; left: 6px; border-left: 2px solid transparent; border-right: 2px solid transparent; border-bottom: 6px solid currentColor; }
.rf-route-stat { display:flex; flex-direction:column; min-width:108px; padding:.65rem .8rem; border:1px solid var(--rf-border); border-radius:12px; background:var(--rf-surface-2); }
.rf-route-stat strong { color:var(--rf-text); font-size:.96rem; }
.rf-route-stat span { font-size:.72rem; }
.rf-route-legend { display:inline-block; width:22px; height:5px; border-radius:999px; margin:0 .25rem 2px .55rem; }
.rf-route-legend.slow { background:#22c55e; }
.rf-route-legend.normal { background:#2563eb; }
.rf-route-legend.fast { background:#f97316; }

/* Criação de cercas com mapa sempre utilizável, mesmo após abrir o formulário. */
.rf-geofence-map-shell { position:sticky; top:calc(var(--rf-topbar-height) + 1rem); min-height:520px; }
.rf-geofence-map-shell #cercaMap { height:calc(100vh - 125px); min-height:520px; }
.rf-geofence-toolbar { position:absolute; z-index:500; top:12px; left:50px; right:12px; display:flex; justify-content:flex-end; gap:.45rem; flex-wrap:wrap; pointer-events:none; }
.rf-geofence-toolbar .btn { pointer-events:auto; box-shadow:0 5px 18px rgba(15,23,42,.18); }
.rf-geofence-status { position:absolute; z-index:500; left:14px; bottom:14px; max-width:min(620px,calc(100% - 28px)); padding:.62rem .85rem; border:1px solid rgba(255,255,255,.65); border-radius:12px; background:rgba(15,23,42,.88); color:#fff; font-size:.78rem; font-weight:700; box-shadow:0 8px 24px rgba(15,23,42,.22); backdrop-filter:blur(8px); pointer-events:none; }
.rf-map-drawing { cursor:crosshair !important; }
.rf-geofence-list { max-height:310px; overflow:auto; }
.rf-geofence-list .list-group-item { background:transparent; border-color:var(--rf-border); }

/* Notifications */
.rf-notif-menu { width: min(390px, calc(100vw - 24px)); max-height: 520px; overflow: hidden; }
.rf-notif-list { max-height: 390px; overflow-y: auto; }
.rf-notif-item { display: flex; gap: .75rem; padding: .75rem; border-radius: 12px; text-decoration: none; color: var(--rf-text); }
.rf-notif-item:hover { background: var(--rf-primary-soft); }
.rf-notif-item.unread { background: color-mix(in srgb, var(--rf-primary-soft) 58%, transparent); }
.rf-notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rf-primary); margin-top: .38rem; flex: 0 0 auto; }
.rf-notif-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; display: none; place-items: center; padding: 0 4px; font-size: .63rem; border-radius: 999px; background: var(--rf-danger); color: #fff; border: 2px solid var(--rf-surface); }

/* States and utilities */
.rf-skeleton { background: linear-gradient(90deg, var(--rf-border) 25%, var(--rf-surface-2) 50%, var(--rf-border) 75%); background-size: 200% 100%; animation: rfSk 1.2s infinite; border-radius: 10px; min-height: 1rem; }
@keyframes rfSk { to { background-position: -200% 0; } }
.rf-empty { text-align: center; padding: 2.5rem 1rem; color: var(--rf-muted); }
.rf-empty i { font-size: 2rem; display: block; margin-bottom: .55rem; opacity: .65; }
.rf-status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: .35rem; }
.rf-live-pulse { position: relative; }
.rf-live-pulse::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid currentColor; opacity: .45; animation: pulse 1.7s infinite; }
@keyframes pulse { 70%,100% { transform: scale(1.8); opacity: 0; } }
.text-muted { color: var(--rf-muted) !important; }
.bg-body-tertiary { background-color: var(--rf-surface-2) !important; }

/* Auth/public */
.rf-guest-body { min-height: 100vh; background: radial-gradient(circle at 15% 15%, rgba(37,99,235,.38), transparent 34%), radial-gradient(circle at 85% 8%, rgba(124,58,237,.28), transparent 30%), linear-gradient(145deg,#07101f,#111c32); padding: 1rem; }
.rf-login-card { max-width: 440px; margin: 7vh auto; border: 1px solid rgba(255,255,255,.13); box-shadow: 0 30px 90px rgba(0,0,0,.32); }
.rf-login-logo { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 1rem; color: #fff; font-size: 1.6rem; background: linear-gradient(135deg,#3b82f6,#7c3aed); box-shadow: 0 14px 32px rgba(37,99,235,.35); }

@media (max-width: 1199px) { :root { --rf-sidebar-width: 250px; } }
@media (max-width: 991.98px) {
  .rf-sidebar { transform: translateX(-105%); width: min(88vw, 310px); }
  .rf-sidebar.open { transform: translateX(0); }
  .rf-sidebar-overlay.show { display: block; }
  .rf-main { margin-left: 0; }
  .rf-content { padding: 1rem; }
  .rf-topbar { height: 68px; padding: .65rem 1rem; }
  #map, #histMap, #cercaMap, #shareMap { height: 62vh; min-height: 390px; }
  .rf-vehicle-list { max-height: 360px; }
  .rf-geofence-map-shell { position:relative; top:auto; min-height:430px; }
  .rf-geofence-map-shell #cercaMap { height:60vh; min-height:430px; }
}
@media (max-width: 575.98px) {
  .rf-content { padding: .75rem; }
  .rf-topbar { padding: .6rem .75rem; }
  .rf-page-kicker, .rf-user-copy { display: none !important; }
  .card { border-radius: 15px; }
  .table > :not(caption) > * > * { padding: .67rem .55rem; }
  .rf-stat .value { font-size: 1.28rem; }
  .rf-geofence-toolbar { left:10px; justify-content:flex-start; }
  .rf-geofence-toolbar .btn span { display:none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; } }

/* Experiência premium 2.0 */
.rf-hero-panel {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  min-height: 154px; padding: 1.55rem 1.7rem; color: #fff; border-radius: 24px;
  background: radial-gradient(circle at 88% 18%, rgba(96,165,250,.42), transparent 23%), linear-gradient(125deg,#0b1730 0%,#172d55 46%,#1d4ed8 100%);
  box-shadow: 0 20px 52px rgba(15, 48, 102, .22);
}
.rf-hero-panel::after { content:""; position:absolute; width:220px; height:220px; border:1px solid rgba(255,255,255,.11); border-radius:50%; right:-72px; bottom:-138px; box-shadow:0 0 0 35px rgba(255,255,255,.03),0 0 0 72px rgba(255,255,255,.025); pointer-events:none; }
.rf-hero-panel > * { position: relative; z-index: 1; }
.rf-hero-panel h2 { margin:.35rem 0 .4rem; font-size:clamp(1.35rem,2.4vw,2.15rem); font-weight:850; letter-spacing:-.04em; }
.rf-hero-panel p { max-width:760px; color:rgba(255,255,255,.75); margin:0; font-size:.92rem; }
.rf-eyebrow { display:inline-flex; align-items:center; gap:.45rem; font-size:.7rem; font-weight:850; letter-spacing:.1em; text-transform:uppercase; color:#bfdbfe; }
.rf-hero-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:.65rem; flex:0 0 auto; }
.rf-hero-panel .btn-outline-light { border-color:rgba(255,255,255,.32); }
.rf-chart-wrap { position:relative; height:310px; }
.rf-chart-wrap-sm { height:285px; }
.rf-chart-wrap-md { height:280px; }
.rf-truncate-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; max-width:320px; }
.rf-alert-card { height:100%; display:flex; gap:.8rem; padding:.9rem; color:var(--rf-text); background:var(--rf-surface-2); border:1px solid var(--rf-border); border-radius:14px; transition:.18s ease; }
.rf-alert-card:hover { border-color:rgba(37,99,235,.28); transform:translateY(-2px); box-shadow:var(--rf-shadow-sm); }
.rf-alert-icon { width:40px; height:40px; flex:0 0 auto; display:grid; place-items:center; border-radius:12px; }
.rf-alert-card strong,.rf-alert-card small,.rf-alert-card span span { display:block; }
.rf-alert-card small { color:var(--rf-muted); margin:.12rem 0 .3rem; }
.rf-alert-card span span { color:var(--rf-muted); font-size:.76rem; line-height:1.4; }
.rf-info-list { display:flex; flex-direction:column; }
.rf-info-row { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.82rem .15rem; color:var(--rf-text); border-bottom:1px solid var(--rf-border); }
.rf-info-row:last-child { border-bottom:0; }
.rf-info-row > span { min-width:0; }
.rf-info-row strong,.rf-info-row small { display:block; }
.rf-info-row small { color:var(--rf-muted); font-size:.72rem; margin-top:.16rem; }
.rf-live-dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:.4rem; background:#94a3b8; box-shadow:0 0 0 4px rgba(148,163,184,.13); }
.rf-live-dot.moving { background:#16a34a; box-shadow:0 0 0 4px rgba(22,163,74,.13); }
.rf-live-dot.stopped { background:#2563eb; box-shadow:0 0 0 4px rgba(37,99,235,.13); }
.rf-live-dot.offline { background:#dc2626; box-shadow:0 0 0 4px rgba(220,38,38,.13); }
.rf-live-dot.stale { background:#b45309; box-shadow:0 0 0 4px rgba(180,83,9,.16); }
.rf-live-dot.alert { background:#f59e0b; box-shadow:0 0 0 4px rgba(245,158,11,.14); }
.rf-map-stale { color:#b45309 !important; font-weight:700; }
.rf-empty { min-height:140px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.55rem; color:var(--rf-muted); text-align:center; padding:1.5rem; }
.rf-empty i { font-size:1.75rem; opacity:.55; }
.rf-health-check { display:flex; align-items:center; gap:.75rem; height:100%; min-height:76px; padding:.85rem; border:1px solid var(--rf-border); border-radius:14px; background:var(--rf-surface-2); }
.rf-health-icon { width:34px; height:34px; border-radius:11px; display:grid; place-items:center; flex:0 0 auto; }
.rf-health-check.ok .rf-health-icon { color:#15803d; background:rgba(22,163,74,.12); }
.rf-health-check.fail .rf-health-icon { color:#dc2626; background:rgba(220,38,38,.12); }
.rf-health-check strong,.rf-health-check small { display:block; }
.rf-health-check small { color:var(--rf-muted); font-size:.72rem; margin-top:.12rem; word-break:break-word; }

/* Mapa ao vivo */
.rf-hero-map { min-height:128px; }
.rf-map-summary { display:flex; align-items:center; gap:.65rem; }
.rf-map-summary > span { min-width:92px; padding:.75rem .9rem; text-align:center; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.08); backdrop-filter:blur(8px); border-radius:15px; }
.rf-map-summary strong,.rf-map-summary small { display:block; }
.rf-map-summary strong { font-size:1.3rem; line-height:1; }
.rf-map-summary small { color:rgba(255,255,255,.7); font-size:.67rem; margin-top:.3rem; }
.rf-live-layout { display:grid; grid-template-columns:minmax(300px,360px) minmax(0,1fr); gap:1rem; }
.rf-live-sidebar { height:calc(100vh - 280px); min-height:540px; overflow:hidden; }
.rf-live-sidebar .rf-vehicle-list { flex:1; min-height:0; max-height:none; overflow:auto; padding-right:.2rem; }
.rf-live-sidebar { display:flex; flex-direction:column; }
.rf-live-meta { color:var(--rf-muted); font-size:.7rem; }
.rf-segmented { display:grid; grid-template-columns:repeat(4,1fr); padding:.25rem; border-radius:12px; background:var(--rf-surface-2); border:1px solid var(--rf-border); }
.rf-segmented button { display:flex; align-items:center; justify-content:center; gap:.18rem; min-height:34px; border:0; border-radius:9px; background:transparent; color:var(--rf-muted); font-size:.68rem; font-weight:750; }
.rf-segmented button.active { color:var(--rf-primary); background:var(--rf-surface); box-shadow:var(--rf-shadow-sm); }
.rf-segmented .rf-live-dot { width:7px; height:7px; margin-right:.1rem; box-shadow:none; }
.rf-fleet-list-item { width:100%; display:grid; grid-template-columns:42px minmax(0,1fr) auto; gap:.7rem; align-items:center; padding:.75rem .55rem; margin-bottom:.45rem; text-align:left; color:var(--rf-text); background:var(--rf-surface-2); border:1px solid transparent; border-radius:14px; transition:.18s ease; }
.rf-fleet-list-item:hover,.rf-fleet-list-item.selected { border-color:rgba(37,99,235,.25); background:var(--rf-primary-soft); transform:translateX(2px); }
.rf-fleet-icon { position:relative; width:40px; height:40px; display:grid; place-items:center; color:var(--rf-primary); background:var(--rf-surface); border:1px solid var(--rf-border); border-radius:12px; font-size:1.05rem; }
.rf-fleet-icon .rf-live-dot { position:absolute; right:-2px; bottom:-2px; margin:0; width:9px; height:9px; border:2px solid var(--rf-surface); box-shadow:none; }
.rf-fleet-copy,.rf-fleet-copy strong,.rf-fleet-copy span,.rf-fleet-copy small { display:block; min-width:0; }
.rf-fleet-copy strong { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:.84rem; }
.rf-fleet-copy strong small { display:inline; font-weight:500; color:var(--rf-muted); }
.rf-fleet-copy span,.rf-fleet-copy small { color:var(--rf-muted); font-size:.69rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:.1rem; }
.rf-fleet-metrics { text-align:right; }
.rf-fleet-metrics strong,.rf-fleet-metrics span { display:block; white-space:nowrap; }
.rf-fleet-metrics strong { font-size:.9rem; }
.rf-fleet-metrics strong small,.rf-fleet-metrics span { color:var(--rf-muted); font-size:.64rem; }
.rf-fleet-metrics em { display:inline-grid; place-items:center; min-width:18px; height:18px; margin-top:.25rem; padding:0 .25rem; border-radius:999px; background:#dc2626; color:#fff; font-size:.62rem; font-style:normal; font-weight:800; }
.rf-map-shell #map { height:calc(100vh - 280px); min-height:540px; }
.rf-map-btn { width:42px; height:42px; display:grid; place-items:center; border:1px solid rgba(15,23,42,.12); border-radius:13px; background:rgba(255,255,255,.94); color:#0f172a; box-shadow:0 8px 24px rgba(15,23,42,.14); backdrop-filter:blur(10px); }
.rf-map-btn:hover { color:#2563eb; transform:translateY(-1px); }
.rf-map-btn.spinning i { animation:rf-spin .8s linear infinite; }
.rf-map-connection { position:absolute; z-index:500; left:12px; bottom:12px; display:flex; align-items:center; padding:.55rem .75rem; border-radius:999px; color:#166534; background:rgba(240,253,244,.94); border:1px solid rgba(22,163,74,.18); box-shadow:var(--rf-shadow-sm); font-size:.7rem; font-weight:750; }
.rf-map-connection.offline { color:#991b1b; background:rgba(254,242,242,.94); border-color:rgba(220,38,38,.18); }
.rf-marker-wrap { position:relative; }
.rf-marker-pin { position:absolute; inset:4px; display:grid; place-items:center; color:#fff; border:3px solid #fff; border-radius:13px 13px 13px 4px; transform:rotate(45deg); box-shadow:0 5px 14px rgba(15,23,42,.3); }
.rf-marker-pin i { font-size:.72rem; transform:rotate(calc(-45deg + var(--bearing))); }
.rf-marker-pin.moving { background:#16a34a; }.rf-marker-pin.stopped{background:#2563eb}.rf-marker-pin.offline{background:#dc2626}.rf-marker-pin.stale{background:#b45309}.rf-marker-pin.alert{background:#f59e0b}.rf-marker-pin.gray{background:#94a3b8}
.rf-marker-pulse { position:absolute; inset:0; border-radius:50%; animation:rf-map-pulse 2s infinite; }
.rf-marker-pulse.moving{background:rgba(22,163,74,.2)}.rf-marker-pulse.stopped{background:rgba(37,99,235,.18)}.rf-marker-pulse.offline{background:rgba(220,38,38,.16)}.rf-marker-pulse.stale{background:rgba(180,83,9,.18)}.rf-marker-pulse.alert{background:rgba(245,158,11,.22)}
.rf-marker-alert { position:absolute; top:-5px; right:-5px; z-index:2; display:grid; place-items:center; width:17px; height:17px; border-radius:50%; background:#dc2626; color:#fff; border:2px solid #fff; font-size:.55rem; font-weight:900; }
.rf-map-popup header { display:flex; align-items:center; gap:.5rem; padding-bottom:.65rem; border-bottom:1px solid #e5e7eb; }
.rf-map-popup header strong,.rf-map-popup header small { display:block; }.rf-map-popup header small{color:#64748b;font-size:.7rem}
.rf-map-popup-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:.45rem; margin:.7rem 0; }
.rf-map-popup-grid span { padding:.55rem; border-radius:10px; background:#f8fafc; }.rf-map-popup-grid i{color:#2563eb;margin-right:.3rem}.rf-map-popup-grid strong,.rf-map-popup-grid small{display:block}.rf-map-popup-grid small{color:#64748b;font-size:.62rem;margin-top:.1rem}
.rf-map-popup p { margin:.35rem 0; color:#475569; font-size:.74rem; }.rf-map-popup p i{width:20px;color:#2563eb}.rf-map-popup footer{display:flex;gap:.4rem;margin-top:.75rem}
.leaflet-control-layers { border:1px solid rgba(15,23,42,.12) !important; border-radius:12px !important; box-shadow:0 8px 24px rgba(15,23,42,.14) !important; font-size:.75rem; }
.leaflet-control-layers label { margin:.2rem .1rem; cursor:pointer; }
[data-bs-theme="dark"] .leaflet-control-layers { color:#e2e8f0; background:#111827; border-color:rgba(255,255,255,.16) !important; }
[data-bs-theme="dark"] .leaflet-control-layers-separator { border-color:rgba(255,255,255,.16); }
@keyframes rf-map-pulse { 0%,100%{transform:scale(.85);opacity:.8}50%{transform:scale(1.18);opacity:.18} }
@keyframes rf-spin { to { transform:rotate(360deg); } }

@media (max-width:1199.98px) {
  .rf-live-layout { grid-template-columns:310px minmax(0,1fr); }
  .rf-hero-panel { align-items:flex-start; }
}
@media (max-width:991.98px) {
  .rf-hero-panel { flex-direction:column; padding:1.3rem; min-height:auto; }
  .rf-hero-actions { justify-content:flex-start; }
  .rf-map-summary { width:100%; overflow:auto; }
  .rf-map-summary > span { flex:1; min-width:85px; }
  .rf-live-layout { display:flex; flex-direction:column-reverse; }
  .rf-live-sidebar { height:auto; min-height:0; }
  .rf-live-sidebar .rf-vehicle-list { max-height:430px; }
  .rf-map-shell #map { height:58vh; min-height:430px; }
}
@media (max-width:575.98px) {
  .rf-hero-panel h2 { font-size:1.35rem; }
  .rf-hero-actions,.rf-hero-actions .btn { width:100%; }
  .rf-hero-actions .btn { justify-content:center; }
  .rf-segmented { grid-template-columns:repeat(2,1fr); gap:.2rem; }
  .rf-map-shell #map { height:54vh; min-height:390px; border-radius:15px; }
  .rf-map-floating { top:8px; right:8px; }
  .rf-map-btn { width:38px; height:38px; }
  .rf-chart-wrap { height:250px; }
}

/* Correções Premium 2.1 — contexto da empresa e modais longos */
.rf-workspace-user {
  display: flex;
  align-items: center;
  gap: .38rem;
  margin-top: .42rem;
  color: #94a3b8;
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rf-workspace-user i { flex: 0 0 auto; }

.rf-entity-modal .modal-dialog {
  width: min(1120px, calc(100vw - 2rem));
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
}
.rf-entity-modal .modal-content {
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}
.rf-modal-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 2rem);
}
.rf-modal-header {
  flex: 0 0 auto;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, var(--rf-surface), color-mix(in srgb, var(--rf-surface-2) 72%, var(--rf-surface)));
}
.rf-modal-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  color: #fff;
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--rf-primary), #7c3aed);
  box-shadow: 0 10px 24px rgba(37,99,235,.22);
}
.rf-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.15rem 1.25rem 1.35rem;
  overscroll-behavior: contain;
}
.rf-modal-footer {
  flex: 0 0 auto;
  padding: .85rem 1.25rem;
  background: color-mix(in srgb, var(--rf-surface) 94%, var(--rf-surface-2));
  box-shadow: 0 -10px 26px rgba(15,23,42,.045);
}
.rf-context-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--rf-primary) 20%, var(--rf-border));
  border-radius: 15px;
  background: linear-gradient(135deg, var(--rf-primary-soft), color-mix(in srgb, var(--rf-surface) 90%, transparent));
}
.rf-context-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: var(--rf-primary);
  background: var(--rf-surface);
  border: 1px solid color-mix(in srgb, var(--rf-primary) 18%, var(--rf-border));
}
.rf-form-section {
  padding: 1rem;
  border: 1px solid var(--rf-border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--rf-surface-2) 58%, var(--rf-surface));
}
.rf-form-section-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .85rem;
  color: var(--rf-text);
  font-size: .84rem;
  font-weight: 850;
  letter-spacing: -.01em;
}
.rf-form-section-title i { color: var(--rf-primary); font-size: 1rem; }

@media (max-width: 767.98px) {
  .rf-entity-modal .modal-dialog {
    width: auto;
    max-width: none;
    min-height: calc(100% - 1rem);
    margin: .5rem;
  }
  .rf-entity-modal .modal-content,
  .rf-modal-form { max-height: calc(100vh - 1rem); }
  .rf-modal-header, .rf-modal-body, .rf-modal-footer { padding-left: .9rem; padding-right: .9rem; }
  .rf-modal-header p { display: none; }
  .rf-modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .rf-modal-footer .btn { width: 100%; }
  .rf-context-card { align-items: flex-start; flex-wrap: wrap; }
  .rf-context-card .badge { margin-left: 3.2rem; }
  .rf-form-section { padding: .85rem; }
}

/* Proteção por Áudio — painel premium */
.rf-audio-hero { position:relative; overflow:hidden; display:flex; align-items:center; justify-content:space-between; gap:1.5rem; min-height:190px; padding:2rem 2.2rem; border-radius:26px; color:#fff; background:linear-gradient(135deg,#0f172a 0%,#1e3a8a 56%,#2563eb 100%); box-shadow:0 20px 50px rgba(15,23,42,.16); }
.rf-audio-hero:after { content:""; position:absolute; width:270px; height:270px; right:-70px; bottom:-150px; border:38px solid rgba(255,255,255,.07); border-radius:50%; }
.rf-audio-hero h2 { margin:.45rem 0 .55rem; font-size:clamp(1.75rem,3vw,2.5rem); font-weight:850; letter-spacing:-.04em; }
.rf-audio-hero p { max-width:680px; margin:0; color:#dbeafe; }
.rf-audio-eyebrow { display:inline-flex; align-items:center; gap:.45rem; padding:.38rem .7rem; border:1px solid rgba(255,255,255,.18); border-radius:999px; background:rgba(255,255,255,.1); font-size:.72rem; font-weight:800; letter-spacing:.06em; text-transform:uppercase; }
.rf-audio-hero-icon { position:relative; z-index:1; width:88px; height:88px; display:grid; place-items:center; flex:0 0 auto; border-radius:26px; font-size:2rem; background:rgba(255,255,255,.13); border:1px solid rgba(255,255,255,.18); backdrop-filter:blur(8px); }
.rf-lock-icon { width:72px; height:72px; display:grid; place-items:center; border-radius:22px; color:var(--rf-primary); background:var(--rf-primary-soft); font-size:1.65rem; }
.rf-stat-card { position:relative; overflow:hidden; min-height:124px; padding:1.15rem 1.2rem; border:1px solid var(--rf-border); border-radius:20px; background:var(--rf-surface); box-shadow:var(--rf-shadow-sm); }
.rf-stat-card span { display:block; color:var(--rf-muted); font-size:.77rem; font-weight:750; text-transform:uppercase; letter-spacing:.04em; }
.rf-stat-card strong { display:block; margin-top:.45rem; color:var(--rf-text); font-size:1.75rem; line-height:1; }
.rf-stat-card i { position:absolute; right:1rem; bottom:.85rem; color:color-mix(in srgb,var(--rf-primary) 26%,transparent); font-size:2.2rem; }
.rf-stat-danger i { color:rgba(220,38,38,.25); }
.rf-audio-player { width:100%; max-width:340px; height:38px; vertical-align:middle; }
@media (max-width:767.98px) { .rf-audio-hero { min-height:auto; padding:1.45rem; border-radius:20px; } .rf-audio-hero-icon { display:none; } .rf-audio-player { min-width:220px; } }


/* O badge de status do mapa fica no canto inferior esquerdo; sem esta folga o
   controle de camadas do Leaflet ficava por baixo dele e a opcao "Satelite"
   nao dava para clicar. */
.leaflet-bottom.leaflet-left .leaflet-control-layers { margin-bottom: 46px; }
@media (max-width: 575.98px) {
  .leaflet-bottom.leaflet-left .leaflet-control-layers { margin-bottom: 54px; }
}

/* Foco visivel nos componentes proprios (nao herdam o anel do Bootstrap). */
.rf-nav-link:focus-visible,
.rf-icon-btn:focus-visible,
.rf-map-btn:focus-visible,
.rf-user-btn:focus-visible,
.rf-fleet-list-item:focus-visible,
.rf-segmented button:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Impressao de relatorio: sai so o conteudo. */
@media print {
  .rf-sidebar, .rf-topbar, .rf-toolbar, .rf-hero-panel, #rfToasts,
  .rf-sidebar-backdrop, .btn, .leaflet-control-container { display: none !important; }
  .rf-main { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; color: #000 !important; }
}
