:root{
  --blue:#2f6fed; --blue-d:#2557c4; --ink:#1f2733; --muted:#6b7785;
  --line:#e3e8ef; --surf:#ffffff; --page:#eef1f5; --soft:#eaf0fe;
  --ok-bg:#e8f5ee; --ok:#1f7a46; --warn-bg:#fdf0d9; --warn:#8a5a00;
  --danger-bg:#fbeaea; --danger:#b33636;
}
*{ box-sizing:border-box; }
body{ margin:0; font-family:'Inter',system-ui,-apple-system,Segoe UI,Arial,sans-serif;
  color:var(--ink); background:var(--page); font-size:14px; }
a{ color:var(--blue); text-decoration:none; }
h1,h2,h3{ font-weight:600; margin:0; }

/* Login */
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card{ width:340px; background:var(--surf); border:1px solid var(--line); border-radius:14px;
  padding:30px 28px; box-shadow:0 10px 34px rgba(20,33,58,.08); }
.brand{ display:flex; align-items:center; justify-content:center; gap:8px; font-size:22px; font-weight:700; }
.brand b{ color:var(--blue); font-weight:700; }
.brand-sub{ text-align:center; color:var(--muted); margin:4px 0 22px; }

/* App shell */
.app{ display:flex; min-height:100vh; }
.side{ width:210px; background:var(--surf); border-right:1px solid var(--line); padding:12px; flex-shrink:0; }
.side .logo{ font-size:22px; font-weight:700; padding:10px; margin-bottom:10px; display:flex; align-items:center; gap:0; color:var(--ink); text-decoration:none; border-radius:9px; cursor:pointer; transition:background .12s; }
.side .logo b{ color:var(--blue); }
.side .logo:hover{ background:var(--page); color:var(--ink); }
.nav{ display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:9px;
  color:var(--muted); cursor:pointer; margin-bottom:3px; }
.nav:hover{ background:var(--page); color:var(--ink); }
.nav.on{ background:var(--soft); color:var(--blue); font-weight:500; }
.nav .badge-alerta{ margin-left:auto; background:var(--danger); color:#fff; font-size:11px; font-weight:700; min-width:18px; height:18px; padding:0 5px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center; }
.push-toast{ position:fixed; right:20px; bottom:20px; width:330px; max-width:calc(100vw - 40px); background:var(--surf); border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,.18); z-index:9999; opacity:0; transform:translateY(12px); pointer-events:none; transition:opacity .2s, transform .2s; }
.push-toast.on{ opacity:1; transform:translateY(0); pointer-events:auto; }
.push-head{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--line); font-weight:700; }
.push-x{ border:none; background:none; font-size:20px; line-height:1; cursor:pointer; color:var(--muted); padding:0 2px; }
.push-body{ padding:6px 14px 10px; max-height:260px; overflow:auto; }
.push-row{ display:flex; align-items:flex-start; gap:9px; padding:8px 0; }
.push-dot{ width:9px; height:9px; border-radius:50%; margin-top:5px; flex-shrink:0; }
.push-txt{ display:flex; flex-direction:column; min-width:0; }
.push-txt b{ font-size:14px; }
.push-txt span{ font-size:12px; color:var(--muted); }
.push-more{ font-size:12px; color:var(--muted); padding:4px 0 2px; }
.push-foot{ display:block; padding:11px 14px; border-top:1px solid var(--line); color:var(--blue); font-weight:500; font-size:14px; text-decoration:none; }
.push-foot:hover{ background:var(--page); }
.rel-ctrls{ display:flex; gap:22px; flex-wrap:wrap; align-items:center; font-size:13px; color:var(--muted); }
.rel-ctrl{ display:inline-flex; align-items:center; gap:8px; }
.togglegrp{ display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.togglegrp > a, .togglegrp > button{ padding:7px 14px; font-size:13px; background:var(--surf); color:var(--muted); border:none; border-left:1px solid var(--line); cursor:pointer; text-decoration:none; line-height:1; }
.togglegrp > a:first-child, .togglegrp > button:first-child{ border-left:none; }
.togglegrp > a.on, .togglegrp > button.on{ background:var(--blue); color:#fff; font-weight:600; }
.vsel-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:2px 16px; max-height:240px; overflow:auto; margin-top:12px; border-top:1px solid var(--line); padding-top:10px; }
.vsel-grid label{ display:flex; align-items:center; gap:7px; font-size:13px; padding:3px 0; cursor:pointer; min-width:0; }
.vsel-grid label b{ font-weight:600; white-space:nowrap; }
.vsel-grid label span{ color:var(--muted); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.legend{ display:flex; gap:18px; flex-wrap:wrap; margin:16px 0 12px; font-size:13px; color:var(--muted); }
.legend i{ width:10px; height:10px; border-radius:50%; display:inline-block; margin-right:6px; vertical-align:middle; }
.vrow{ display:flex; align-items:center; gap:14px; padding:9px 0; }
.vrow + .vrow{ border-top:1px solid var(--line); }
.vrow-lbl{ width:180px; flex-shrink:0; }
.vrow-lbl b{ display:block; font-size:13px; }
.vrow-lbl span{ color:var(--muted); font-size:11px; }
.vrow-track{ flex:1; background:var(--page); border-radius:5px; height:22px; }
.vrow-bar{ height:100%; display:flex; border-radius:5px; overflow:hidden; min-width:2px; }
.vrow-seg{ height:100%; }
.vrow-val{ width:140px; text-align:right; font-size:13px; font-weight:500; flex-shrink:0; }
.vgrp-head{ display:flex; align-items:baseline; gap:10px; padding:12px 0 6px; margin-top:6px; border-bottom:2px solid var(--line); }
.vgrp-head:first-child{ margin-top:0; }
.vgrp-head > b{ font-size:14px; color:var(--blue); }
.vgrp-sub{ font-size:12px; }
.grp{ font-size:11px; color:#9aa4b1; padding:14px 12px 6px; letter-spacing:.04em; }
.content{ flex:1; min-width:0; }
.topbar{ background:var(--surf); border-bottom:1px solid var(--line); padding:12px 22px;
  display:flex; align-items:center; gap:12px; }
.topbar .tag{ background:var(--soft); color:var(--blue); font-size:12px; padding:3px 11px; border-radius:20px; }
.topbar .spacer{ flex:1; }
.main{ padding:22px 26px; }

/* Pieces */
.head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.metrics{ display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:14px; margin-bottom:20px; }
.metric{ background:var(--surf); border:1px solid var(--line); border-radius:11px; padding:14px 16px; }
.metric .l{ color:var(--muted); font-size:13px; }
.metric .v{ font-size:24px; font-weight:600; margin-top:4px; }
.card{ background:var(--surf); border:1px solid var(--line); border-radius:12px; }
.card-pad{ padding:18px 20px; }
.alert{ display:flex; align-items:center; gap:11px; padding:12px 0; border-bottom:1px solid var(--line); }
.alert:last-child{ border-bottom:none; }

/* Tables */
table{ width:100%; border-collapse:collapse; }
th{ text-align:left; color:var(--muted); font-weight:500; padding:11px 18px; border-bottom:1px solid var(--line); font-size:13px; }
td{ padding:13px 18px; border-bottom:1px solid var(--line); }
tr:last-child td{ border-bottom:none; }

/* Pills */
.pill{ font-size:12px; padding:3px 11px; border-radius:20px; }
.pill.ok{ background:var(--ok-bg); color:var(--ok); }
.pill.warn{ background:var(--warn-bg); color:var(--warn); }
.pill.danger{ background:var(--danger-bg); color:var(--danger); }
.pill.blue{ background:var(--soft); color:var(--blue); }

/* Forms */
label{ display:block; font-size:13px; color:var(--muted); margin-bottom:6px; }
.field{ margin-bottom:14px; }
input,select,textarea{ width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:9px;
  font-size:14px; font-family:inherit; color:var(--ink); background:#fff; }
input:focus,select:focus,textarea:focus{ outline:none; border-color:var(--blue); box-shadow:0 0 0 3px rgba(47,111,237,.14); }
.btn{ display:inline-flex; align-items:center; gap:7px; background:var(--blue); color:#fff; border:none;
  border-radius:9px; padding:10px 16px; font-size:14px; font-weight:500; cursor:pointer; font-family:inherit; }
.btn:hover{ background:var(--blue-d); }
.btn-ghost{ background:transparent; border:1px solid var(--line); color:var(--ink); }
.btn-ghost:hover{ background:var(--page); }
.erro{ background:var(--danger-bg); border:1px solid #f1c9c9; color:var(--danger);
  padding:10px 12px; border-radius:9px; margin-bottom:14px; font-size:14px; }
.muted{ color:var(--muted); }
.link{ color:var(--blue); cursor:pointer; background:none; border:none; font-size:14px; font-family:inherit; padding:0; }

.ok-flash{ background:var(--ok-bg); color:var(--ok); padding:11px 14px; border-radius:9px; margin-bottom:16px; }
.section-title{ font-size:13px; color:var(--muted); font-weight:500; margin:20px 0 12px; padding-bottom:7px; border-bottom:1px solid var(--line); }
.grid2{ display:flex; gap:14px; flex-wrap:wrap; } .grid2 .field{ flex:1; min-width:170px; }
.modgrid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; }
.moditem{ display:flex; align-items:center; gap:9px; padding:10px 12px; border:1px solid var(--line); border-radius:9px; cursor:pointer; font-size:14px; }
.moditem input{ width:auto; }
.toolbar{ display:flex; gap:10px; margin-bottom:16px; align-items:center; flex-wrap:wrap; }
.actions{ white-space:nowrap; }
.actions a, .actions form{ display:inline; margin-left:14px; }
.right{ text-align:right; }
.with-btn{ display:flex; gap:8px; }
.with-btn input{ flex:1; }

.usebar{ height:8px; background:var(--line); border-radius:6px; overflow:hidden; min-width:90px; }
.usebar > i{ display:block; height:100%; }
.tiremap{ display:flex; flex-direction:column; gap:8px; padding:12px; border:1px solid var(--line); border-radius:10px; max-width:460px; background:var(--page); }
.tiremap .axle{ display:flex; align-items:center; gap:6px; }
.tiremap .axlelbl{ width:88px; font-size:12px; color:var(--muted); }
.tiremap .tire{ width:44px; height:30px; border:1px solid var(--line); border-radius:6px; background:#fff; cursor:pointer; font-size:12px; color:var(--ink); font-family:inherit; }
.tiremap .tire:hover{ border-color:var(--blue); }
.tiremap .tire.on{ background:var(--blue); color:#fff; border-color:var(--blue); }
.tiremap .gap{ width:26px; }
.modal-ov{ position:fixed; inset:0; background:rgba(20,30,50,.45); display:none; align-items:center; justify-content:center; z-index:50; padding:20px; }
.modal-ov.on{ display:flex; }
.modal{ background:#fff; border-radius:12px; padding:20px 22px; max-width:540px; width:100%; max-height:85vh; overflow:auto; box-shadow:0 12px 40px rgba(20,33,58,.2); }
.subtabs{ display:flex; gap:2px; border-bottom:1px solid var(--line); margin:0 0 20px; flex-wrap:wrap; }
.subtabs a{ padding:9px 15px; color:var(--muted); font-weight:500; font-size:14px; border-bottom:2px solid transparent; }
.subtabs a.on{ color:var(--blue); border-bottom-color:var(--blue); }
.filtros{ display:flex; gap:14px; align-items:flex-end; flex-wrap:wrap; background:var(--surf); border:1px solid var(--line); border-radius:12px; padding:14px 16px; margin-bottom:18px; }
.filtros .field{ margin:0; min-width:150px; }
.barchart{ display:flex; flex-direction:column; gap:9px; }
.bargrp{ font-size:12px; font-weight:700; color:var(--blue); background:var(--soft); border-radius:6px; padding:5px 10px; margin-top:6px; }
.bargrp:first-child{ margin-top:0; }
.barrow{ display:grid; grid-template-columns:165px 1fr auto; align-items:center; gap:12px; font-size:13px; }
.barrow .lbl{ color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.barrow .track{ background:#eef2f7; border-radius:6px; height:18px; overflow:hidden; }
.barrow .fill{ display:block; height:100%; border-radius:6px; min-width:3px; }
.barrow .val{ font-weight:600; white-space:nowrap; }
.placa-label{ background:#fff; border:1px solid var(--line); border-radius:4px; padding:1px 5px; font-size:11px; font-weight:700; color:var(--ink); box-shadow:0 1px 3px rgba(20,30,50,.2); }
.leaflet-tooltip.placa-label::before{ display:none; }
.map-resize{ height:18px; background:var(--surf); border-top:1px solid var(--line); cursor:ns-resize; display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:12px; letter-spacing:3px; user-select:none; }
.map-resize:hover{ background:var(--page); color:var(--ink); }
.metric{ position:relative; }
.metric .v{ margin-top:2px; }
.metric .s{ color:var(--muted); font-size:12px; margin-top:3px; }
.msel{ position:relative; }
.msel-btn{ width:100%; text-align:left; background:var(--surf); border:1px solid var(--line); border-radius:9px; padding:10px 12px; font:inherit; font-size:14px; color:var(--ink); cursor:pointer; display:flex; justify-content:space-between; gap:8px; align-items:center; }
.msel-panel{ display:none; position:absolute; z-index:30; top:calc(100% + 4px); left:0; min-width:250px; max-height:320px; overflow:auto; background:var(--surf); border:1px solid var(--line); border-radius:10px; box-shadow:0 8px 30px rgba(20,33,58,.16); padding:6px; }
.msel-panel.on{ display:block; }
.msel-item{ display:flex; align-items:flex-start; gap:9px; padding:7px 9px; border-radius:7px; cursor:pointer; font-size:14px; margin:0; }
.msel-item:hover{ background:var(--page); }
.msel-item input{ width:auto; margin:3px 0 0; }
