/* ══════════════════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════════════════ */
:root {
  --ui: 'Inter';
  --mo: 'inter';
  --t-fast: .15s cubic-bezier(.4,0,.2,1);
  --t-med:  .3s cubic-bezier(.4,0,.2,1);
  --t-slow: .5s cubic-bezier(.4,0,.2,1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
}

/* ── DARK THEME (default) ── */
[data-theme="dark"] {
  --cl-blue:    #3b82f6;
  --cl-blue-dk: #2563eb;
  --cl-blue-lt: rgba(59,130,246,.12);
  --cl-blue-md: rgba(59,130,246,.25);
  --cl-glow:    rgba(59,130,246,.4);
  --cl-orange:  #FFA500;
  --cl-grey: #4A4A4A;
  --bg:         #0a0e1a;
  --bg2:        #111827;
  --bg3:        #1a2035;
  --card:       rgba(17,24,39,.85);
  --card-solid: #111827;
  --card2:      rgba(26,32,53,.6);
  --glass:      rgba(17,24,39,.7);
  --bdr:        rgba(255,255,255,.06);
  --bdr2:       rgba(255,255,255,.1);
  --bdr-focus:  var(--cl-blue);
  --tx:         #f1f5f9;
  --tx2:        #cbd5e1;
  --mt:         #64748b;
  --mt2:        #475569;
  --gr:   #10b981; --grl: rgba(16,185,129,.1); --grb: rgba(16,185,129,.3);
  --rd:   #ef4444; --rdl: rgba(239,68,68,.1); --rdb: rgba(239,68,68,.3);
  --am:   #f59e0b; --aml: rgba(245,158,11,.1); --amb: rgba(245,158,11,.3);
  --vl:   #8b5cf6; --vll: rgba(139,92,246,.1); --vlb: rgba(139,92,246,.3);
  --cy:   #06b6d4; --cyl: rgba(6,182,212,.1); --cyb: rgba(6,182,212,.3);
  --rs:   #f43f5e; --rsl: rgba(244,63,94,.1); --rsb: rgba(244,63,94,.3);
  --sh-sm: 0 1px 3px rgba(0,0,0,.4);
  --sh-md: 0 4px 16px rgba(0,0,0,.4);
  --sh-lg: 0 8px 32px rgba(0,0,0,.5);
  --sh-xl: 0 20px 60px rgba(0,0,0,.6);
  --sh-glow: 0 0 30px rgba(59,130,246,.15);
  --overlay: rgba(0,0,0,.6);
  --scrollbar: rgba(255,255,255,.08);
  --scrollbar-h: rgba(255,255,255,.15);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --cl-blue:    #2563eb;
  --cl-blue-dk: #1d4ed8;
  --cl-blue-lt: rgba(37,99,235,.06);
  --cl-blue-md: rgba(37,99,235,.15);
  --cl-orange:  #FFA500;  
  --cl-grey: #4A4A4A;
  --cl-glow:    rgba(37,99,235,.2);
  --bg:         #f0f2f7;
  --bg2:        #e5e7ef;
  --bg3:        #dde0ea;
  --card:       rgba(255,255,255,.92);
  --card-solid: #ffffff;
  --card2:      rgba(248,249,252,.8);
  --glass:      rgba(255,255,255,.75);
  --bdr:        rgba(0,0,0,.06);
  --bdr2:       rgba(0,0,0,.1);
  --bdr-focus:  var(--cl-blue);
  --tx:         #0f172a;
  --tx2:        #334155;
  --mt:         #64748b;
  --mt2:        #94a3b8;
  --gr:   #059669; --grl: rgba(5,150,105,.08); --grb: rgba(5,150,105,.25);
  --rd:   #dc2626; --rdl: rgba(220,38,38,.07); --rdb: rgba(220,38,38,.2);
  --am:   #d97706; --aml: rgba(217,119,6,.07); --amb: rgba(217,119,6,.2);
  --vl:   #7c3aed; --vll: rgba(124,58,237,.07); --vlb: rgba(124,58,237,.2);
  --cy:   #0891b2; --cyl: rgba(8,145,178,.07); --cyb: rgba(8,145,178,.2);
  --rs:   #e11d48; --rsl: rgba(225,29,72,.07); --rsb: rgba(225,29,72,.2);
  --sh-sm: 0 1px 4px rgba(0,0,0,.06);
  --sh-md: 0 4px 16px rgba(0,0,0,.08);
  --sh-lg: 0 8px 32px rgba(0,0,0,.1);
  --sh-xl: 0 20px 60px rgba(0,0,0,.14);
  --sh-glow: 0 0 30px rgba(37,99,235,.08);
  --overlay: rgba(15,23,42,.4);
  --scrollbar: rgba(0,0,0,.06);
  --scrollbar-h: rgba(0,0,0,.12);
  --surface: #ffffff;
  --text: #0f172a;
  --mt: #64748b;

}

/* ══════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med), color var(--t-med);
  overflow-x: hidden;
}

/* Scrollbar global */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-h); }

/* Background mesh */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--cl-blue-lt) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, var(--vll) 0%, transparent 50%);
  pointer-events: none;
  transition: opacity var(--t-med);
}

/* ══════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 300;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--bdr);
  height: 60px;
  display: flex; align-items: center;
  padding: 0 20px; gap: 6px;
  transition: background var(--t-med);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  margin-right: 4px; flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(59,130,246,.4);
  flex-shrink: 0;
  transition: transform var(--t-fast);
}
.brand-logo:hover { transform: scale(1.08) rotate(-3deg); }
.brand-logo svg { width: 20px; height: 20px; }
.brand-name {
  font-size: 17px; font-weight: 900;
  color: var(--tx); letter-spacing: -.5px;
  transition: color var(--t-med);
}
.brand-name span { 
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-tag {
  font-family: var(--mo); font-size: 8px; font-weight: 600;
  color: var(--cl-blue); background: var(--cl-blue-lt);
  border: 1px solid var(--cl-blue-md);
  border-radius: 4px; padding: 2px 7px; letter-spacing: 1.5px;
}

.tb-div { width: 1px; height: 28px; background: var(--bdr2); flex-shrink: 0; }

/* Server input */
.srv-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--bdr);
  border-radius: var(--radius-xs); padding: 5px 10px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.srv-box:focus-within { border-color: var(--cl-blue); box-shadow: 0 0 0 3px var(--cl-blue-lt); }
.srv-box label { font-family: var(--mo); font-size: 9px; color: var(--mt); white-space: nowrap; }
.srv-box input {
  background: none; border: none; outline: none;
  font-family: var(--mo); font-size: 10px; color: var(--tx);
  width: 170px; transition: color var(--t-med);
}
.srv-box button {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none; border-radius: 5px;
  font-family: var(--ui); font-size: 10px; font-weight: 700; color: #fff;
  padding: 5px 12px; cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.srv-box button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.4); }
.srv-box button:active { transform: none; }

/* Connection badge */
.conn-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px;
  font-family: var(--mo); font-size: 9px; font-weight: 700;
  border: 1px solid; transition: all var(--t-med); flex-shrink: 0;
  cursor: default;
}
.conn-badge.ok   { background: var(--grl); border-color: var(--grb); color: var(--gr); }
.conn-badge.wait { background: var(--aml); border-color: var(--amb); color: var(--am); }
.conn-badge.err  { background: var(--rdl); border-color: var(--rdb); color: var(--rd); }
.conn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.25;transform:scale(.7)} }

/* Client select */
.client-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--bdr);
  border-radius: var(--radius-xs); padding: 5px 10px;
  transition: border-color var(--t-fast);
}
.client-box:focus-within { border-color: var(--cl-blue); }
.client-box label { font-family: var(--mo); font-size: 9px; color: var(--mt); white-space: nowrap; }
.client-box select {
  background: none; border: none; outline: none;
  font-family: var(--mo); font-size: 10px; font-weight: 600; color: var(--tx);
  cursor: pointer; transition: color var(--t-med);
}
.client-box select option { background: var(--card-solid); color: var(--tx); }

/* Topbar right */
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tb-clock { font-family: var(--mo); font-size: 14px; color: var(--tx2); letter-spacing: .5px; font-weight: 500; }
.tb-sync  { font-family: var(--mo); font-size: 9px; color: var(--mt2); }
.tb-sync b { color: var(--tx2); }

/* Theme toggle */
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t-fast); color: var(--mt);
  font-size: 16px; position: relative; overflow: hidden;
}
.theme-toggle:hover { background: var(--cl-blue-lt); border-color: var(--cl-blue-md); color: var(--cl-blue); transform: rotate(15deg); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { 
  position: absolute; transition: all var(--t-med);
}
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: rotate(0); }

/* Fullscreen toggle */
.tb-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t-fast); color: var(--mt);
  font-size: 14px;
}
.tb-btn:hover { background: var(--cl-blue-lt); border-color: var(--cl-blue-md); color: var(--cl-blue); }

/* ══════════════════════════════════════════════════════
   NAVIGATION TABS
══════════════════════════════════════════════════════ */
.nav-tabs {
  position: sticky; top: 60px; z-index: 290;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--bdr);
  padding: 0 20px;
  display: flex; gap: 0; align-items: stretch;
  transition: background var(--t-med);
  overflow-x: auto;
}
.nav-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 0 18px; height: 46px;
  font-size: 12px; font-weight: 600; color: var(--mt);
  cursor: pointer; border-bottom: 2.5px solid transparent;
  transition: all var(--t-fast); white-space: nowrap;
  position: relative;
}
.nav-tab:hover { color: var(--tx); }
.nav-tab.active { 
  color: var(--cl-blue); 
  border-bottom-color: var(--cl-blue);
}
.nav-tab.active::after {
  content: '';
  position: absolute; bottom: -1px; left: 20%; right: 20%;
  height: 2px; border-radius: 2px;
  background: var(--cl-blue);
  filter: blur(6px);
  opacity: .7;
}
.nav-tab-icon { font-size: 15px; }
.nav-badge {
  font-family: var(--mo); font-size: 9px;
  background: var(--rdl); color: var(--rd);
  border-radius: 20px; padding: 1px 7px; font-weight: 700;
  display: none; border: 1px solid var(--rdb);
}
.nav-badge.show { display: inline-block; animation: badge-pop .3s ease; }
@keyframes badge-pop { 0%{transform:scale(.5)} 50%{transform:scale(1.2)} 100%{transform:scale(1)} }

/* Period buttons */
.period-group {
  margin-left: auto; display: flex; gap: 3px;
  align-items: center; padding: 6px 0;
}
.period-btn {
  padding: 5px 12px; border-radius: var(--radius-xs);
  font-size: 10px; font-weight: 600; color: var(--mt);
  cursor: pointer; transition: all var(--t-fast);
}
.period-btn:hover { color: var(--tx); background: var(--bg2); }
.period-btn.active { background: var(--cl-blue-lt); color: var(--cl-blue); border: 1px solid var(--cl-blue-md); }

/* ══════════════════════════════════════════════════════
   PAGE CONTENT
══════════════════════════════════════════════════════ */
.page { padding: 20px 20px 80px; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fade-in .35s ease; }
@keyframes fade-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ══════════════════════════════════════════════════════
   KPI GRID
══════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kcard {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sh-sm);
  cursor: default;
  transition: all var(--t-med);
}
.kcard:hover {
  box-shadow: var(--sh-md), var(--sh-glow);
  transform: translateY(-3px);
  border-color: var(--bdr2);
}
.kcard-accent {
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: var(--radius) var(--radius) 0 0;
}
/* Glow effect under accent */
.kcard-accent::after {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%;
  height: 20px; filter: blur(12px); opacity: .4;
  background: inherit; border-radius: 50%;
}
.kcard-icon { font-size: 22px; margin-bottom: 10px; display: block; }
.kcard-label {
  font-size: 10px; font-weight: 700; color: var(--mt);
  letter-spacing: .8px; text-transform: uppercase; margin-bottom: 4px;
}
.kcard-value {
  font-family: var(--mo); font-size: 32px; font-weight: 700;
  line-height: 1; margin-bottom: 3px;
  transition: all .3s ease;
}
.kcard-unit { font-family: var(--mo); font-size: 9px; color: var(--mt2); margin-bottom: 10px; }
.kcard-spark { width: 100%; height: 32px; display: block; margin-bottom: 10px; }
.kcard-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 9px; border-top: 1px solid var(--bdr);
  font-size: 10px;
}
.kcard-footer-label { color: var(--mt); }
.kcard-footer-val { font-family: var(--mo); font-size: 10px; font-weight: 700; }
.txt-gr { color: var(--gr); } .txt-rd { color: var(--rd); }
.txt-am { color: var(--am); } .txt-bl { color: var(--cl-blue); }
.txt-vl { color: var(--vl); } .txt-mt { color: var(--mt); }

@keyframes val-flash { 0% { opacity:.1; transform:scale(.95) } 60% { opacity:1; transform:scale(1) } }
.flashing { animation: val-flash .4s ease; }

/* ══════════════════════════════════════════════════════
   LAYOUT MAIN
══════════════════════════════════════════════════════ */
.main-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.col-main { display: flex; flex-direction: column; gap: 16px; }
.col-side { display: flex; flex-direction: column; gap: 16px; }

/* ══════════════════════════════════════════════════════
   CARD PANEL
══════════════════════════════════════════════════════ */
.panel {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bdr);
  border-radius: var(--radius);
  box-shadow: var(--sh-sm);
  /* overflow: hidden; -- removido para tabelas */
  transition: all var(--t-med);
}
.panel:hover { box-shadow: var(--sh-md); }
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title {
  font-size: 12px; font-weight: 800;
  color: var(--tx); letter-spacing: -.1px;
  display: flex; align-items: center; gap: 8px;
}
.panel-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.panel-body { padding: 16px 18px; }
.panel-badge {
  font-family: var(--mo); font-size: 9px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; border: 1px solid;
  white-space: nowrap;
}
.pb-gr { background: var(--grl); border-color: var(--grb); color: var(--gr); }
.pb-rd { background: var(--rdl); border-color: var(--rdb); color: var(--rd); }
.pb-bl { background: var(--cl-blue-lt); border-color: var(--cl-blue-md); color: var(--cl-blue); }
.pb-am { background: var(--aml); border-color: var(--amb); color: var(--am); }
.pb-vl { background: var(--vll); border-color: var(--vlb); color: var(--vl); }

/* ══════════════════════════════════════════════════════
   VEHICLE TABLE
══════════════════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; max-height: 600px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card2);
  backdrop-filter: blur(8px);
  padding: 10px 12px;
  font-size: 9px; font-weight: 700; color: var(--mt);
  letter-spacing: .8px; text-transform: uppercase;
  border-bottom: 1px solid var(--bdr);
  text-align: right; white-space: nowrap;
}
thead th:first-child { text-align: left; }
tbody td {
  padding: 10px 12px;
  font-family: var(--mo); font-size: 11px;
  border-bottom: 1px solid var(--bdr);
  text-align: right; white-space: nowrap;
  transition: background var(--t-fast);
  color: var(--tx2);
}
tbody td:first-child { font-family: var(--ui); font-size: 11px; font-weight: 700; text-align: left; color: var(--tx); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cl-blue-lt); cursor: pointer; }
tbody tr.row-alert td { background: var(--rdl); }
@keyframes row-new { from { background: var(--cl-blue-lt); } to { background: transparent; } }
.row-new { animation: row-new .7s ease; }

/* pill */
.pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 20px; border: 1px solid;
  font-family: var(--ui); font-size: 9px; font-weight: 700;
}
.pill-gr { background: var(--grl); border-color: var(--grb); color: var(--gr); }
.pill-rd { background: var(--rdl); border-color: var(--rdb); color: var(--rd); }
.pill-am { background: var(--aml); border-color: var(--amb); color: var(--am); }
.pill-bl { background: var(--cl-blue-lt); border-color: var(--cl-blue-md); color: var(--cl-blue); }
.pill-mt { background: var(--bg2); border-color: var(--bdr2); color: var(--mt); }
.pill-vl { background: var(--vll); border-color: var(--vlb); color: var(--vl); }

/* ══════════════════════════════════════════════════════
   STAT ITEMS
══════════════════════════════════════════════════════ */
.stat-list { display: flex; flex-direction: column; gap: 8px; }
.stat-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}
.stat-item:hover { border-color: var(--bdr2); box-shadow: var(--sh-sm); transform: translateX(3px); }
.stat-lhs { display: flex; flex-direction: column; gap: 2px; }
.stat-name { font-size: 11px; font-weight: 700; color: var(--tx2); }
.stat-sub  { font-family: var(--mo); font-size: 9px; color: var(--mt); }
.stat-val  { font-family: var(--mo); font-size: 24px; font-weight: 700; transition: all .25s; }
.stat-unit { font-family: var(--mo); font-size: 9px; color: var(--mt); margin-left: 2px; }

/* ══════════════════════════════════════════════════════
   ALERT FEED
══════════════════════════════════════════════════════ */
.alert-feed { display: flex; flex-direction: column; gap: 2px; max-height: 440px; overflow-y: auto; }

.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--t-fast);
}
.alert-item:hover { background: var(--bg2); transform: translateX(2px); }
@keyframes alert-in { from { opacity:0; transform:translateX(-10px); } to { opacity:1; transform:none; } }
.alert-item.new { animation: alert-in .3s ease; }
.alert-bar { width: 3px; min-height: 34px; border-radius: 2px; flex-shrink: 0; margin-top: 2px; }
.alert-icon { font-size: 15px; flex-shrink: 0; margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-name { font-size: 11px; font-weight: 800; color: var(--tx); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-desc { font-family: var(--mo); font-size: 9px; color: var(--mt); margin-bottom: 2px; }
.alert-loc  { font-size: 9px; color: var(--mt2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.alert-time { font-family: var(--mo); font-size: 9px; color: var(--mt); }
.alert-vel  { font-family: var(--mo); font-size: 11px; font-weight: 700; }

/* ══════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card-solid); border-radius: 20px;
  border: 1px solid var(--bdr);
  box-shadow: var(--sh-xl);
  width: 100%; max-width: 580px;
  transform: scale(.94) translateY(10px);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-head {
  padding: 20px 24px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 900; color: var(--tx); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg2); border: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: var(--mt);
  transition: all var(--t-fast); flex-shrink: 0;
}
.modal-close:hover { background: var(--rdl); color: var(--rd); border-color: var(--rdb); transform: rotate(90deg); }
.modal-body { padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 14px; height:auto; width:auto;}
.modal-alert-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700;
}
.modal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.modal-field {
  background: var(--bg2); border: 1px solid var(--bdr);
  border-radius: var(--radius-sm); padding: 12px 14px;
  transition: border-color var(--t-fast);
}
.modal-field:hover { border-color: var(--bdr2); }
.modal-field-label { font-size: 9px; font-weight: 700; color: var(--mt); letter-spacing: .6px; text-transform: uppercase; margin-bottom: 4px; }
.modal-field-val { font-family: var(--mo); font-size: 14px; font-weight: 600; color: var(--tx); }
.modal-field-val.big { font-size: 22px; }
.modal-map-link {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius-sm);
  background: var(--cl-blue-lt); border: 1px solid var(--cl-blue-md);
  color: var(--cl-blue); font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all var(--t-fast); text-decoration: none;
}
.modal-map-link:hover { background: var(--cl-blue); color: #fff; }

/* ══════════════════════════════════════════════════════
   SPEED DISTRIBUTION
══════════════════════════════════════════════════════ */
.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dist-label { font-size: 10px; color: var(--mt); width: 90px; flex-shrink: 0; font-family: var(--mo); }
.dist-track { flex: 1; height: 10px; background: var(--bg2); border-radius: 5px; overflow: hidden; border: 1px solid var(--bdr); }
.dist-fill { height: 100%; border-radius: 5px; transition: width 1s cubic-bezier(.4,0,.2,1); }
.dist-val { font-family: var(--mo); font-size: 12px; font-weight: 700; width: 28px; text-align: right; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   TIMELINE
══════════════════════════════════════════════════════ */
.tl-header { display: flex; margin-left: 88px; margin-bottom: 6px; }
.tl-tick { flex: 1; font-family: var(--mo); font-size: 8px; color: var(--mt2); }
.tl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tl-name { width: 80px; flex-shrink: 0; font-family: var(--mo); font-size: 9px; color: var(--mt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { flex: 1; height: 16px; background: var(--bg2); border-radius: 5px; position: relative; overflow: hidden; border: 1px solid var(--bdr); }
.tl-seg { position: absolute; top: 0; height: 100%; border-radius: 4px; transition: width .5s; }
.tl-seg.mv { background: var(--cl-blue); opacity: .85; }
.tl-seg.id { background: var(--am); opacity: .75; }
.tl-seg.oh { background: var(--rd); opacity: .85; }
.tl-seg.off { background: var(--mt2); opacity: .4; }

/* Timeline melhorias */
.tl-scroll { max-height: 320px; overflow-y: auto; }
.tl-row { cursor: pointer; }
.tl-row:hover .tl-track { border-color: var(--bdr2); }
.tl-row:hover .tl-name { color: var(--tx); }
.tl-tooltip {
  position: fixed; z-index: 999;
  background: var(--card-solid); border: 1px solid var(--bdr2);
  border-radius: var(--radius-xs); padding: 8px 12px;
  font-family: var(--mo); font-size: 10px; color: var(--tx);
  box-shadow: var(--sh-md); pointer-events: none;
  white-space: nowrap;
}
.tl-expand {
  text-align: center; padding: 8px;
  font-size: 10px; font-weight: 700; color: var(--cl-blue);
  cursor: pointer; transition: all var(--t-fast);
}
.tl-expand:hover { color: var(--tx); }

/* ══════════════════════════════════════════════════════
   VEHICLE RANKING
══════════════════════════════════════════════════════ */
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--bdr);
  transition: all var(--t-fast);
}
.rank-row:hover { transform: translateX(3px); }
.rank-row:last-child { border-bottom: none; }
.rank-pos {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--bg2); border: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: var(--mt);
  flex-shrink: 0;
}
.rank-pos.gold   { background: rgba(251,191,36,.15); border-color: rgba(251,191,36,.4); color: #fbbf24; }
.rank-pos.silver { background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.3); color: #94a3b8; }
.rank-pos.bronze { background: rgba(217,119,6,.12); border-color: rgba(217,119,6,.3); color: #d97706; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 11px; font-weight: 700; color: var(--tx2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub  { font-family: var(--mo); font-size: 9px; color: var(--mt); }
.rank-val  { font-family: var(--mo); font-size: 16px; font-weight: 700; text-align: right; flex-shrink: 0; }
.rank-delta { font-family: var(--mo); font-size: 9px; text-align: right; flex-shrink: 0; min-width: 40px; }
.rank-bar-wrap { width: 80px; flex-shrink: 0; }
.rank-bar-track { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 4px; transition: width .9s cubic-bezier(.4,0,.2,1); }

/* ══════════════════════════════════════════════════════
   CHART AREA
══════════════════════════════════════════════════════ */
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--mt); }
.leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leg-line { width: 14px; height: 2px; border-radius: 1px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   SETTINGS MODAL
══════════════════════════════════════════════════════ */
.settings-modal .modal { max-width: 72vw; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 15px; font-weight: 700; color: var(--mt2); letter-spacing: .4px; }
.field-input {
  background: var(--bg2); border: 1px solid var(--bdr);
  border-radius: var(--radius-xs); padding: 9px 12px;
  font-family: var(--mo); font-size: 14px; color: var(--tx);
  outline: none; transition: all var(--t-fast);
  width: 100%;
}
.field-input:focus { border-color: var(--cl-blue); box-shadow: 0 0 0 3px var(--cl-blue-lt); }
.field-desc { font-size: 12px; color: var(--mt2); }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; border: none; border-radius: var(--radius-xs);
  padding: 10px 20px;
  font-family: var(--ui); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all var(--t-fast);
  box-shadow: 0 4px 14px rgba(59,130,246,.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59,130,246,.4); }

/* ══════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════ */
.empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 48px 20px;
  color: var(--mt);
}
.empty-icon { font-size: 36px; opacity: .3; }
.empty-title { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.empty-sub { font-family: var(--mo); font-size: 9px; text-align: center; line-height: 1.7; color: var(--mt2); }

/* ══════════════════════════════════════════════════════
   STATUS BAR
══════════════════════════════════════════════════════ */
.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 280;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-top: 1px solid var(--bdr);
  padding: 7px 20px;
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mo); font-size: 9px; color: var(--mt);
  transition: background var(--t-med);
}
.sb-sep { color: var(--bdr2); }
.sb-val { color: var(--tx2); font-weight: 600; }
.sb-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

/* ══════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════ */
@keyframes slide-up { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }
.slide-up { animation: slide-up .4s cubic-bezier(.4,0,.2,1) both; }
.slide-up:nth-child(1) { animation-delay:.03s }
.slide-up:nth-child(2) { animation-delay:.06s }
.slide-up:nth-child(3) { animation-delay:.09s }
.slide-up:nth-child(4) { animation-delay:.12s }
.slide-up:nth-child(5) { animation-delay:.15s }
.slide-up:nth-child(6) { animation-delay:.18s }

canvas { display: block; }
/* Smooth transitions */
.kcard-value { transition: all .4s ease; }
.vel-bar-fill { transition: width .5s cubic-bezier(.4,0,.2,1) !important; }
.vel-bar-row { transition: all .3s ease; }
.vel-bar-row[style*="border-left"] { animation: fresh-pulse .6s ease; }
@keyframes fresh-pulse { 0%{background:var(--grl)} 100%{background:transparent} }
.dist-fill { transition: width .8s cubic-bezier(.4,0,.2,1) !important; }
.stat-val { transition: all .3s ease; }

/* Smooth transitions */
.kcard-value { transition: all .4s ease; }
.vel-bar-fill { transition: width .5s cubic-bezier(.4,0,.2,1) !important; }
.vel-bar-row { transition: all .3s ease; }
.vel-bar-row[style*="border-left"] { animation: fresh-pulse .6s ease; }
@keyframes fresh-pulse { 0%{background:var(--grl)} 100%{background:transparent} }
.dist-fill { transition: width .8s cubic-bezier(.4,0,.2,1) !important; }
.stat-val { transition: all .3s ease; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Map inline modal */
#modalMap { width:100%; height:220px; border-radius:var(--radius-sm); border:1px solid var(--bdr); overflow:hidden; }
#modalMap iframe { width:100%; height:100%; border:none; }

/* Offline */
#k-of { cursor:pointer; text-decoration:underline dotted; }
.offline-list { display:flex; flex-direction:column; gap:6px; max-height:320px; overflow-y:auto; }
.offline-item { display:flex; align-items:center; gap:10px; padding:9px 14px; background:var(--bg2); border:1px solid var(--bdr); border-radius:var(--radius-sm); transition: all var(--t-fast); }
.offline-item:hover { border-color: var(--bdr2); transform: translateX(2px); }
.offline-name { font-size:11px; font-weight:700; flex:1; color: var(--tx); }
.offline-sub  { font-family:var(--mo); font-size:9px; color:var(--mt); }


/* Vel bars */
.vel-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--bdr);
  transition: all var(--t-fast); position: relative;
}
.vel-bar-row:last-child { border-bottom: none; }
.vel-bar-row:hover { transform: translateX(2px); }
.vel-bar-pos {
  width: 18px; font-family: var(--mo); font-size: 9px;
  font-weight: 800; color: var(--mt); text-align: center; flex-shrink: 0;
}
.vel-bar-name {
  width: 90px; flex-shrink: 0; font-size: 10px; font-weight: 700;
  color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vel-bar-track {
  flex: 1; height: 20px; background: var(--bg2);
  border-radius: 5px; overflow: hidden; border: 1px solid var(--bdr);
  position: relative;
}
.vel-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.vel-bar-dot {
  position: absolute; right: -1px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff; border: 2px solid;
  animation: vel-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 6px currentColor;
}
@keyframes vel-pulse { 0%,100%{opacity:1;transform:translateY(-50%) scale(1)} 50%{opacity:.6;transform:translateY(-50%) scale(1.3)} }
.vel-bar-val {
  width: 65px; flex-shrink: 0; text-align: right;
  font-family: var(--mo); font-size: 11px; font-weight: 700;
}
.vel-bar-sub {
  font-family: var(--mo); font-size: 8px; color: var(--mt);
  width: 50px; flex-shrink: 0; text-align: right;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .main-layout { grid-template-columns: 1fr 300px; }
}
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
  .col-side { order: -1; }
  .srv-box { display: none; }
  .brand-tag { display: none; }
}
@media (max-width: 768px) {
  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .nav-tabs { padding: 0 12px; top: 52px; }
  .page { padding: 12px 12px 80px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kcard { padding: 14px; }
  .kcard-value { font-size: 26px; }
  .brand-name { font-size: 15px; }
  .brand-logo { width: 32px; height: 32px; }
  .tb-clock { display: none; }
  .tb-sync { display: none; }
  .tb-div { display: none; }
  .panel-body { padding: 12px; }
  .conn-badge span { display: none; }
  .conn-badge { padding: 6px 8px; }
  .statusbar { padding: 6px 12px; gap: 8px; font-size: 8px; }
  .statusbar .sb-sep:nth-child(n+4) { display: none; }
  .statusbar span:nth-child(n+7) { display: none; }
  .nav-tab { padding: 0 12px; font-size: 11px; }
  .nav-tab-icon { font-size: 13px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kcard-value { font-size: 28px; }
  .client-box { display: none; }
  .modal { max-width: 100%; border-radius: 14px; }
  .modal-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════
   NOTIFICATION TOAST
══════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; top: 70px; right: 20px; z-index: 600;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card-solid); border: 1px solid var(--bdr2);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--sh-lg);
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 600; color: var(--tx);
  pointer-events: all; cursor: pointer;
  animation: toast-in .3s ease;
  max-width: 320px;
  backdrop-filter: blur(12px);
}
.toast.hide { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity:0; transform:translateX(30px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(30px); } }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 11px; font-weight: 800; }
.toast-msg { font-size: 10px; color: var(--mt); font-weight: 400; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════
   SEARCH BOX (novo)
══════════════════════════════════════════════════════ */
.search-box {
  position: relative;
}
.search-box input {
  background: var(--bg2); border: 1px solid var(--bdr);
  border-radius: var(--radius-xs); padding: 7px 12px 7px 30px;
  font-family: var(--ui); font-size: 11px; color: var(--tx);
  outline: none; width: 100%; transition: all var(--t-fast);
}
.search-box input:focus { border-color: var(--cl-blue); box-shadow: 0 0 0 3px var(--cl-blue-lt); }
.search-box input::placeholder { color: var(--mt2); }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--mt2); font-size: 12px; pointer-events: none;
}

/* BACKGROUND ANIMADO LOGIN */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #000;
  overflow: hidden;
}

/* container */
.login-screen {
  position: relative;
  overflow: hidden;
}

/* fundo animado */
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;

  background: linear-gradient(
    120deg,
    #0b1220,
    #0f1b33,
    #1b2a4a,
    #16235c,
    #163ca3
  );

  background-size: 300% 300%;
  animation: loginFlow 7s ease-out infinite;
}

/* glow */
.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;

  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0,180,255,0.06), transparent 45%);

  animation: loginGlow 7s ease-out infinite;
}

/* conteúdo */
.login-screen > * {
  position: relative;
  z-index: 1;
}

/* 👇 movimento contínuo SEM corte visível */
@keyframes loginFlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* glow */
@keyframes loginGlow {
  0%   { transform: translate3d(0,0,0); }
  50%  { transform: translate3d(-2%, 2%, 0); }
  100% { transform: translate3d(0,0,0); }
}

/* ── Aba Desempenho: tabela responsiva ── */
#tab-desempenho .tbl-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
}
#tab-desempenho table {
  min-width: 900px;
  table-layout: fixed;
}
#tab-desempenho thead th {
  font-size: 8px;
  padding: 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tab-desempenho tbody td {
  font-size: 10px;
  padding: 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Larguras fixas por coluna */
#tab-desempenho table th:nth-child(1),
#tab-desempenho table td:nth-child(1) { width: 130px; min-width: 100px; } /* Veículo */
#tab-desempenho table th:nth-child(2),
#tab-desempenho table td:nth-child(2) { width: 100px; min-width: 80px; } /* Cliente */
#tab-desempenho table th:nth-child(3),
#tab-desempenho table td:nth-child(3) { width: 62px; } /* F.Verde */
#tab-desempenho table th:nth-child(4),
#tab-desempenho table td:nth-child(4) { width: 52px; } /* Acel */
#tab-desempenho table th:nth-child(5),
#tab-desempenho table td:nth-child(5) { width: 55px; } /* Ocioso */
#tab-desempenho table th:nth-child(6),
#tab-desempenho table td:nth-child(6) { width: 58px; } /* RPM */
#tab-desempenho table th:nth-child(7),
#tab-desempenho table td:nth-child(7) { width: 52px; } /* Temp */
#tab-desempenho table th:nth-child(8),
#tab-desempenho table td:nth-child(8) { width: 58px; } /* Vel */
#tab-desempenho table th:nth-child(9),
#tab-desempenho table td:nth-child(9) { width: 52px; } /* L/h */
#tab-desempenho table th:nth-child(10),
#tab-desempenho table td:nth-child(10) { width: 48px; } /* Freios */
#tab-desempenho table th:nth-child(11),
#tab-desempenho table td:nth-child(11) { width: 52px; } /* Inf.RPM */
#tab-desempenho table th:nth-child(12),
#tab-desempenho table td:nth-child(12) { width: 46px; } /* Emb */
#tab-desempenho table th:nth-child(13),
#tab-desempenho table td:nth-child(13) { width: 52px; } /* Fr.Alta */
#tab-desempenho table th:nth-child(14),
#tab-desempenho table td:nth-child(14) { width: 52px; } /* /100km */
#tab-desempenho table th:nth-child(15),
#tab-desempenho table td:nth-child(15) { width: 52px; } /* Horo */
#tab-desempenho table th:nth-child(16),
#tab-desempenho table td:nth-child(16) { width: 70px; } /* Odom */
#tab-desempenho table th:nth-child(17),
#tab-desempenho table td:nth-child(17) { width: 48px; } /* Freio% */
#tab-desempenho table th:nth-child(18),
#tab-desempenho table td:nth-child(18) { width: 70px; } /* Status */

/* KPI grids da aba desempenho */
#tab-desempenho .kpi-grid {
  display: grid;
  gap: 10px;
}
#tab-desempenho .main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
}
@media (max-width: 1400px) {
  #tab-desempenho .main-layout {
    grid-template-columns: 1fr 260px;
  }
}
@media (max-width: 1100px) {
  #tab-desempenho .main-layout {
    grid-template-columns: 1fr;
  }
  #tab-desempenho .col-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}
/* Período controls */
#tab-desempenho .dp-controls {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 14px;
  background: var(--card); border: 1px solid var(--bdr);
  border-radius: var(--radius-sm); padding: 10px 14px;
}

/* ══════════════════════════════════════════════════════
   ABA MOTORISTAS
══════════════════════════════════════════════════════ */
#tab-motoristas .main-layout,
#tab-manutencao .main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 1200px) {
  #tab-motoristas .main-layout,
  #tab-manutencao .main-layout {
    grid-template-columns: 1fr;
  }
  #tab-motoristas .col-side,
  #tab-manutencao .col-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}
/* Score pill animado */
@keyframes score-pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
#motBody tr td:nth-child(5) span {
  animation: score-pop .25s ease both;
}
/* Row hover nos rankings */
#motBody tr:hover,
#manBody tr:hover {
  background: var(--cl-blue-lt) !important;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════
   MELHORIAS VISUAIS GERAIS
══════════════════════════════════════════════════════ */

/* KCard — hover lift aprimorado */
.kcard {
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.kcard:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg), 0 0 0 1px var(--bdr2);
}

/* Nav tab — underline animado */
.nav-tab {
  position: relative;
  overflow: hidden;
}
.nav-tab::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  width: 0; height: 2px;
  background: var(--cl-blue);
  border-radius: 2px;
  transition: width .2s ease, left .2s ease;
}
.nav-tab.active::after {
  width: 80%;
  left: 10%;
}
.nav-tab:not(.active):hover::after {
  width: 40%;
  left: 30%;
}

/* Badge de manutenção — cor âmbar */
.nav-badge[style*="--am"] {
  background: var(--am) !important;
}

/* Panel — borda esquerda no hover */
.panel {
  transition: box-shadow var(--t-fast);
}
.panel:hover {
  box-shadow: var(--sh-md);
}

/* Tabela — zebra sutil */
table tbody tr:nth-child(even) {
  background: rgba(255,255,255,.018);
}
[data-theme="light"] table tbody tr:nth-child(even) {
  background: rgba(0,0,0,.02);
}

/* dist-fill — transição suave */
.dist-fill {
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* Settings grid — 2 colunas default */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 600px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* Tooltip simples via title */
[title] { cursor: help; }
button[title], .tb-btn[title] { cursor: pointer; }

/* Modal manutenção — textarea */
#man-obs {
  font-family: var(--mo);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-xs);
  color: var(--tx);
  padding: 8px;
  outline: none;
  transition: border-color var(--t-fast);
}
#man-obs:focus { border-color: var(--cl-blue); }

/* Stat cards no modal de motorista */
#motDetalheBody > div:last-child {
  border-radius: var(--radius-xs);
}

/* ══════════════════════════════════════════════════════
   ITINERÁRIO — SUB-NAV
══════════════════════════════════════════════════════ */
.itin-subnav {
  flex: 1; padding: 7px 12px; background: transparent; border: none;
  border-radius: var(--radius-xs); font-family: var(--ui); font-size: 11px;
  font-weight: 600; color: var(--mt); cursor: pointer;
  transition: all var(--t-fast);
}
.itin-subnav:hover { background: var(--bg3); color: var(--tx); }
.itin-subnav.active {
  background: var(--cl-blue); color: #fff; font-weight: 700;
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
}
/* ── MARIA BUBBLE & PANEL ── */
#maria-bubble {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  cursor: pointer;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: maria-pulse 3s ease-in-out infinite;
  border: none; outline: none;
}
#maria-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 8px rgba(99,102,241,0.25), 0 8px 32px rgba(0,0,0,0.5);
  animation: none;
}
#maria-bubble.open {
  animation: none;
  transform: scale(0.92);
}
#maria-bubble svg { width: 22px; height: 22px; transition: transform 0.3s; pointer-events: none; }
#maria-bubble.open svg { transform: rotate(45deg); }
#maria-notif {
  position: absolute; top: 1px; right: 1px;
  width: 11px; height: 11px;
  background: #10b981; border-radius: 50%;
  border: 2px solid var(--bg, #0a0e1a);
  animation: maria-blink 2s ease-in-out infinite;
}
@keyframes maria-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4), 0 8px 24px rgba(0,0,0,0.5); }
  50%      { box-shadow: 0 0 0 10px transparent, 0 8px 24px rgba(0,0,0,0.5); }
}
@keyframes maria-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.2; }
}
 
#maria-panel {
  position: fixed;
  bottom: 90px;
  right: 28px;

  width: min(420px, 92vw);
  height: min(640px, 82vh);

  background: color-mix(in srgb, var(--surface) 85%, transparent);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  border: 1px solid var(--border);
  border-radius: 20px;

  z-index: 9998;

  display: flex;
  flex-direction: column;

  box-shadow: 
    0 30px 90px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.05);

  transform: translateY(18px) scale(0.96);
  opacity: 0;
  pointer-events: none;

  transition: 
    transform 0.3s cubic-bezier(.34,1.56,.64,1),
    opacity 0.22s ease;

  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

#maria-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
} 
/* header */
.maria-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(129,140,248,0.04));
  flex-shrink: 0;
}
.maria-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 800; font-size: 13px; color: #fff;
  letter-spacing: -0.5px;
}
.maria-info { flex: 1; min-width: 0; }
.maria-name { font-size: 13px; font-weight: 700; color: var(--text, #e2e8f0); }
.maria-status { font-size: 10px; color: #10b981; display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.maria-status::before { content:''; width:5px; height:5px; border-radius:50%; background:#10b981; display:inline-block; animation: maria-blink 2s infinite; }
.maria-hbtns { display: flex; gap: 5px; align-items: center; }
.maria-hbtn {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--mt, #64748b);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.maria-hbtn:hover { background: rgba(99,102,241,0.15); color: #818cf8; border-color: rgba(99,102,241,0.3); }
.maria-hbtn svg { width: 12px; height: 12px; }
 
/* tts pill */
.maria-tts {
  font-size: 10px; padding: 3px 8px; border-radius: 20px;
  background: rgba(16,185,129,0.1); color: #10b981;
  border: 1px solid rgba(16,185,129,0.2);
  cursor: pointer; display: flex; align-items: center; gap: 3px;
  font-weight: 600; transition: all 0.15s; white-space: nowrap;
}
.maria-tts:hover { background: rgba(16,185,129,0.2); }
.maria-tts.muted { background: rgba(100,116,139,0.08); color: var(--mt,#64748b); border-color: rgba(255,255,255,0.07); }
 
/* context bar */
.maria-ctx {
  padding: 7px 13px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  background: rgba(6,182,212,0.03);
  flex-shrink: 0;
}
.maria-ctx-label { font-size: 10px; color: var(--mt,#64748b); text-transform: uppercase; letter-spacing: 0.4px; }
.maria-tag {
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: rgba(59,130,246,0.1); color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.18);
  font-family: 'Inter';
  white-space: nowrap;
}
.maria-tag.g { background: rgba(16,185,129,0.08); color: #34d399; border-color: rgba(16,185,129,0.18); }
.maria-tag.r { background: rgba(239,68,68,0.08); color: #f87171; border-color: rgba(239,68,68,0.18); }
.maria-tag.o { background: rgba(245,158,11,0.08); color: #fbbf24; border-color: rgba(245,158,11,0.18); }
 
/* messages */
.maria-msgs {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.maria-msgs::-webkit-scrollbar { width: 3px; }
.maria-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
 
.maria-msg { display: flex; gap: 7px; max-width: 100%; }
.maria-msg.user { flex-direction: row-reverse; }
.maria-msg-av {
  width: 24px; height: 24px; border-radius: 50%;
  flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800;
}
.maria-msg.ai   .maria-msg-av { background: linear-gradient(135deg,#6366f1,#818cf8); color:#fff; }
.maria-msg.user .maria-msg-av { background: rgba(255,255,255,0.07); color: var(--mt,#64748b); border: 1px solid rgba(255,255,255,0.07); }
.maria-bubble-msg {
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 12.5px; line-height: 1.55;
  max-width: 84%;
}
.maria-msg.ai   .maria-bubble-msg { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.07); border-bottom-left-radius: 4px; color: var(--text,#e2e8f0); }
.maria-msg.user .maria-bubble-msg { background: linear-gradient(135deg,#6366f1,#818cf8); border-bottom-right-radius: 4px; color: #fff; }
 
/* insight card dentro do bubble */
.maria-icard {
  margin-top: 7px;
  background: rgba(99,102,241,0.07);
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 9px; padding: 9px 11px;
  font-size: 11.5px;
}
.maria-icard-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #818cf8; font-weight: 700; margin-bottom: 5px; }
.maria-irow { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.maria-irow:last-child { border: none; }
.maria-irow .irl { color: var(--mt,#64748b); }
.maria-irow .irv { font-family: 'Inter'; font-size: 11px; color: var(--text,#e2e8f0); }
.maria-irow .irv.ok  { color: #34d399; }
.maria-irow .irv.warn{ color: #fbbf24; }
.maria-irow .irv.bad { color: #f87171; }
 
/* typing */
.maria-typing {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 13px; border-bottom-left-radius: 4px;
  width: fit-content;
}
.maria-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #6366f1; opacity: 0.4;
  animation: maria-typing-anim 1.2s ease-in-out infinite;
}
.maria-dot:nth-child(2) { animation-delay: 0.2s; }
.maria-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes maria-typing-anim {
  0%,100% { opacity:0.4; transform:translateY(0); }
  50%      { opacity:1;   transform:translateY(-3px); }
}
 
/* quick prompts */
.maria-quick {
  padding: 7px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; gap: 5px; flex-wrap: wrap;
  flex-shrink: 0;
}
.maria-qbtn {
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--mt,#64748b); cursor: pointer;
  transition: all 0.15s;
  font-family: 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
}
.maria-qbtn:hover { background: rgba(99,102,241,0.12); color: var(--text,#e2e8f0); border-color: rgba(99,102,241,0.3); }
 
/* input area */
.maria-input-area {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; gap: 7px; align-items: flex-end;
  flex-shrink: 0;
}
.maria-textarea {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 11px;
  padding: 8px 11px;
  color: var(--text, #e2e8f0);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px; resize: none;
  min-height: 36px; max-height: 90px;
  outline: none; line-height: 1.4;
  transition: border-color 0.2s;
}
.maria-textarea:focus { border-color: rgba(99,102,241,0.4); }
.maria-textarea::placeholder { color: var(--mt,#64748b); }
.maria-send, .maria-mic {
  width: 36px; height: 36px; border-radius: 9px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.maria-send {
  background: linear-gradient(135deg,#6366f1,#818cf8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.maria-send:hover { transform: scale(1.05); }
.maria-mic {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--mt,#64748b);
}
.maria-mic:hover { background: rgba(16,185,129,0.1); color: #34d399; border-color: rgba(16,185,129,0.25); }
.maria-mic.rec {
  background: rgba(239,68,68,0.1); color: #f87171;
  border-color: rgba(239,68,68,0.3);
  animation: maria-pulse 1s ease-in-out infinite;
}
.maria-send svg, .maria-mic svg { width: 14px; height: 14px; }

#maria-live-btn {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--mt,#64748b); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
#maria-live-btn:hover { background: rgba(99,102,241,0.15); color: #818cf8; }
#maria-live-btn.live-on {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border-color: rgba(239,68,68,0.4);
  animation: maria-pulse 1.5s ease-in-out infinite;
}
#maria-live-btn svg { width: 14px; height: 14px; }

/* ══════════════════════════════════════════════════════
   UI PATCH — tabelas premium, heatmap, eficiência semanal
   Compatível com dash.css + theme_v2.css
   Usa !important apenas onde theme_v2 sobrescreve
══════════════════════════════════════════════════════ */

/* ── Heatmap atividade por hora ── */
.hora-heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 3px;
  font-size: 9px;
}
.hora-heatmap .hm-header {
  padding: 2px 1px;
  color: var(--mt);
  font-weight: 600;
  text-align: center;
  font-family: var(--mo);
  font-size: 8px;
}
.hora-heatmap .hm-label {
  padding: 4px 4px;
  color: var(--mt);
  font-weight: 600;
  font-size: 9px;
  display: flex;
  align-items: center;
}
.hora-heatmap .hm-cell {
  aspect-ratio: 1.1;
  border-radius: 3px;
  background: rgba(59,130,246,.08);
  cursor: pointer;
  transition: transform .1s;
  position: relative;
}
.hora-heatmap .hm-cell:hover {
  transform: scale(1.3);
  z-index: 2;
}
.hm-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg3, #141b27);
  border: 1px solid var(--bdr2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tx);
  pointer-events: none;
  box-shadow: var(--sh-md);
  white-space: nowrap;
  display: none;
}

/* ── Tabela Infrações premium ── */
.tbl-premium {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tbl-premium thead th {
  padding: 10px 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--mt);
  border-bottom: 1px solid var(--bdr2);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-align: left;
}
.tbl-premium thead th:hover { color: var(--tx); }
.tbl-premium tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bdr);
  color: var(--tx2);
  vertical-align: middle;
  text-align: left;
}
.tbl-premium tbody tr {
  transition: background .12s ease;
  cursor: pointer;
}
.tbl-premium tbody tr:hover { background: var(--cl-blue-lt); }
.tbl-premium tbody tr.row-danger {
  background: var(--rdl);
  border-left: 3px solid var(--rd);
}
.tbl-premium tbody tr.row-danger:hover { background: rgba(239,68,68,.14); }
.tbl-premium .col-mono { font-family: var(--mo); font-weight: 600; }
.tbl-premium .col-num  { font-family: var(--mo); font-weight: 700; text-align: right; }

/* badge tipo infração */
.inf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.inf-badge.speed    { background: var(--rdl); color: var(--rd); border: 1px solid var(--rdb); }
.inf-badge.rpm      { background: var(--vll); color: var(--vl); border: 1px solid var(--vlb); }
.inf-badge.offhours { background: var(--aml); color: var(--am); border: 1px solid var(--amb); }
.inf-badge.fuel     { background: var(--cl-blue-lt); color: var(--cl-blue); border: 1px solid var(--cl-blue-md); }

/* chip excesso velocidade */
.excess-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--mo);
  font-size: 11px;
  font-weight: 800;
  background: var(--rdl);
  color: var(--rd);
}

/* ── Tabela Motoristas premium ── */
.tbl-motor {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tbl-motor thead th {
  padding: 10px 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--mt);
  border-bottom: 1px solid var(--bdr2);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-align: left;
}
.tbl-motor thead th:hover { color: var(--tx); }
.tbl-motor tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--bdr);
  color: var(--tx2);
  vertical-align: middle;
}
.tbl-motor tbody tr { cursor: pointer; transition: background .12s; }
.tbl-motor tbody tr:hover { background: var(--cl-blue-lt); }

/* avatar iniciais */
.mot-av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--vl, #8b5cf6), var(--cl-blue, #3b82f6));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 11px;
  flex-shrink: 0;
}

/* badge score */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--mo);
  font-weight: 800;
  font-size: 13px;
  min-width: 44px;
}

/* mini barra KM inline */
.inline-bar-track {
  height: 5px;
  border-radius: 99px;
  background: var(--bdr2);
  overflow: hidden;
  flex-shrink: 0;
}
.inline-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Select sort eficiência ── */
#efSort {
  background: var(--bg2);
  border: 1px solid var(--bdr2);
  border-radius: var(--radius-xs, 6px);
  padding: 5px 8px;
  font-family: var(--mo);
  font-size: 10px;
  color: var(--tx);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
#efSort:focus { border-color: var(--cl-blue); }

/* ── Container gráfico Eficiência Semanal ── */
#efSemanalChart {
  width: 100% !important;
  display: block;
}
.ef-semanal-wrap {
  position: relative;
  height: 130px;
}
.ef-semanal-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--bdr);
}
.ef-semanal-kpis > div {
  text-align: center;
}
.ef-semanal-kpis .ek-label {
  font-size: 8px;
  color: var(--mt);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.ef-semanal-kpis .ek-val {
  font-family: var(--mo);
  font-size: 16px;
  font-weight: 800;
}
.ef-semanal-kpis .ek-unit {
  font-size: 9px;
  color: var(--mt);
}

/* ── Div horaHeatmap (onde o heatmap é renderizado) ── */
#horaHeatmap {
  padding: 4px 0;
  overflow-x: auto;
}

/* ── Garantir que theme_v2 não quebre as tabelas premium ── */
.tbl-premium tbody tr:nth-child(even),
.tbl-motor   tbody tr:nth-child(even) {
  background: transparent;
}
[data-theme="dark"]  .tbl-premium tbody tr:nth-child(even),
[data-theme="dark"]  .tbl-motor   tbody tr:nth-child(even) {
  background: transparent;
}
