/* =====================================================================
   ULTRA EXPRESS — CONTROLE DE FROTA
   Design system: pista noturna. Fundo grafite-azulado, quase-preto,
   como o asfalto visto pelos faróis; o laranja e o verde da marca
   (o "S" entrelaçado do logotipo) aparecem só onde algo precisa de
   decisão — ação primária, alerta, status. O resto fica quieto.
   ===================================================================== */

/* ---------- tokens ---------- */
:root{
  /* superfícies */
  --bg:           #10131a;
  --bg-soft:      #0c0e13;
  --surface-1:    #171b23;   /* sidebar, topbar */
  --surface-2:    #1b202a;   /* painéis, cards, tabelas */
  --surface-3:    #232a35;   /* inputs, hover */
  --surface-4:    #2b3341;   /* hover mais forte / bordas de foco */
  --border:       #2a3140;
  --border-soft:  #1f2530;

  /* texto */
  --ink:          #eef1f6;
  --muted:        #9aa4b6;
  --muted-2:      #677185;
  --muted-on-dark:#7c8698;

  /* marca */
  --brand-orange:      #fc3800;
  --brand-orange-ink:  #ff9a7a;
  --brand-orange-soft: rgba(252,56,0,.14);
  --brand-orange-line: rgba(252,56,0,.35);
  --brand-green:       #4cc21c;
  --brand-green-soft:  rgba(76,194,28,.14);

  /* estados semânticos */
  --ok:        #4cc21c;
  --ok-soft:   rgba(76,194,28,.14);
  --warn:      #f2a93c;
  --warn-soft: rgba(242,169,60,.14);
  --danger:    #f0473f;
  --danger-soft: rgba(240,71,63,.14);
  --info:      #3d9bf5;
  --info-soft: rgba(61,155,245,.14);
  --grey-soft: rgba(154,164,182,.14);

  /* tipografia */
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius-sm: 7px;
  --radius:    11px;
  --radius-lg: 16px;
  --shadow-pop: 0 20px 48px -16px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.35);

  --sidebar-w: 258px;
  --topbar-h: 64px;
}

/* ---------- reset ---------- */
*, *::before, *::after{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  background: radial-gradient(1200px 640px at 14% -8%, #171d29 0%, var(--bg) 46%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4{ font-family: var(--font-display); font-weight:600; margin:0; color:var(--ink); letter-spacing:-.01em; }
p{ margin:0 0 .6em; }
a{ color: var(--brand-orange-ink); }
button, input, select, textarea{ font-family: inherit; font-size: inherit; color: inherit; }
button{ cursor:pointer; }
svg{ display:block; }
::selection{ background: var(--brand-orange-soft); color:#fff; }

/* barra de rolagem */
*{ scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
*::-webkit-scrollbar{ width:9px; height:9px; }
*::-webkit-scrollbar-track{ background:transparent; }
*::-webkit-scrollbar-thumb{ background: var(--surface-4); border-radius:99px; border:2px solid transparent; background-clip:content-box; }
*::-webkit-scrollbar-thumb:hover{ background: #38424f; background-clip:content-box; }

/* foco visível, sempre */
:focus-visible{ outline: 2px solid var(--brand-orange); outline-offset: 2px; border-radius:4px; }
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app{
  display:grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height:100vh;
}

/* ---------- sidebar ---------- */
.sidebar{
  background: linear-gradient(185deg, var(--surface-1) 0%, #12151c 100%);
  border-right: 1px solid var(--border-soft);
  display:flex;
  flex-direction:column;
  position:sticky;
  top:0;
  height:100vh;
  z-index:40;
}
.brand{
  display:flex; align-items:center;
  padding: 20px 18px 16px;
  background:none; border:none; border-bottom:1px solid var(--border-soft);
  text-align:left; width:100%;
  transition: background .15s ease;
}
.brand:hover{ background: rgba(255,255,255,.02); }
.brand-logo{ width:100%; max-width:196px; height:auto; display:block; }

.nav{ flex:1; overflow-y:auto; padding: 14px 12px 10px; }
.nav-group-label{
  font-family: var(--font-display);
  font-size:11px;
  font-weight:600;
  letter-spacing:.06em;
  color: var(--muted-2);
  padding: 16px 10px 6px;
}
.nav-group-label:first-child{ padding-top:4px; }
.nav-item{
  width:100%;
  display:flex; align-items:center; gap:10px;
  background:none; border:none;
  padding: 9px 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size:13.5px;
  font-weight:500;
  text-align:left;
  position:relative;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg{ width:17px; height:17px; flex:none; stroke:currentColor; opacity:.85; }
.nav-item span{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-item:hover{ background: var(--surface-3); color: var(--ink); }
.nav-item.active{
  background: var(--brand-orange-soft);
  color: #fff;
}
.nav-item.active svg{ opacity:1; color: var(--brand-orange-ink); stroke: var(--brand-orange-ink); }
.nav-item.active::before{
  content:'';
  position:absolute; left:-12px; top:8px; bottom:8px; width:3px;
  background: var(--brand-orange);
  border-radius:0 3px 3px 0;
}
.nav-count{
  font-family: var(--font-mono);
  font-size:11px;
  font-weight:600;
  background: var(--surface-3);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 99px;
  min-width:20px;
  text-align:center;
}
.nav-item.active .nav-count{ background: rgba(255,255,255,.14); color:#fff; }
.nav-item.danger-count .nav-count{ background: var(--danger-soft); color: #ff8a83; }

.sidebar-foot{ padding: 12px; border-top:1px solid var(--border-soft); }
.sync-pill{
  display:flex; align-items:center; gap:8px;
  font-size:12px; color:var(--muted);
  padding:8px 10px;
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: 99px;
}
.dot{ width:7px; height:7px; border-radius:50%; flex:none; background:var(--muted-2); box-shadow:0 0 0 3px rgba(255,255,255,.04); }
.dot--ok{ background: var(--ok); box-shadow:0 0 0 3px var(--ok-soft); }
.dot--warn{ background: var(--warn); box-shadow:0 0 0 3px var(--warn-soft); animation: pulse-dot 1.8s ease-in-out infinite; }
.dot--danger{ background: var(--danger); box-shadow:0 0 0 3px var(--danger-soft); }
@keyframes pulse-dot{ 0%,100%{ opacity:1; } 50%{ opacity:.45; } }

.scrim{
  display:none;
  position:fixed; inset:0; z-index:39;
  background: rgba(6,7,10,.6);
  backdrop-filter: blur(2px);
}
.scrim.open{ display:block; }

/* ---------- main / topbar ---------- */
.main{ display:flex; flex-direction:column; min-width:0; }
.topbar{
  height: var(--topbar-h);
  display:flex; align-items:center; gap:14px;
  padding: 0 22px;
  background: rgba(23,27,35,.82);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom:1px solid var(--border-soft);
  position:sticky; top:0; z-index:30;
}
.topbar-mark{ display:none; height:30px; width:auto; }
.icon-btn{
  display:flex; align-items:center; justify-content:center;
  width:36px; height:36px; flex:none;
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
  position:relative;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover{ background: var(--surface-3); color: var(--ink); border-color: var(--border); }
.icon-btn svg{ stroke: currentColor; }
.icon-btn#trackBtn:hover{ color: var(--brand-green); }
.badge{
  position:absolute; top:-5px; right:-5px;
  min-width:17px; height:17px; padding:0 4px;
  border-radius:99px;
  background: var(--brand-orange);
  color:#fff;
  font-family: var(--font-mono);
  font-size:10px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  border:2px solid var(--surface-1);
}
.badge.hidden{ display:none; }

.search{
  flex:1; max-width:420px;
  display:flex; align-items:center; gap:9px;
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: 99px;
  padding: 0 14px;
  height:38px;
  color: var(--muted-2);
  transition: border-color .15s ease, background .15s ease;
}
.search:focus-within{ border-color: var(--brand-orange-line); background: var(--surface-3); }
.search input{
  flex:1; background:none; border:none; outline:none;
  color: var(--ink); height:100%;
}
.search input::placeholder{ color: var(--muted-2); }

.topbar-actions{ display:flex; gap:10px; flex:none; }

.content{ flex:1; padding: 26px 30px 60px; max-width:1360px; width:100%; margin:0 auto; outline:none; }

/* menu mobile escondido no desktop */
.only-mobile{ display:none; }

/* ============================================================
   PAGE HEAD
   ============================================================ */
.page-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:16px;
  margin-bottom:22px;
  flex-wrap:wrap;
}
.page-head h1{ font-size:23px; }
.page-head .sub{ margin-top:4px; font-size:13px; color:var(--muted); }
.sub{ font-size:13px; color:var(--muted); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn{
  display:inline-flex; align-items:center; gap:7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-weight:600;
  font-size:13.5px;
  white-space:nowrap;
  transition: background .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
.btn:hover{ background: var(--surface-3); border-color:#38414f; }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }

.btn-accent{
  background: linear-gradient(180deg, #ff4b12, var(--brand-orange));
  border-color: #d33000;
  color:#fff;
  box-shadow: 0 8px 20px -8px rgba(252,56,0,.55);
}
.btn-accent:hover{ background: linear-gradient(180deg, #ff5c26, #e64000); box-shadow: 0 10px 24px -8px rgba(252,56,0,.7); }

.btn-danger{
  background: var(--danger-soft);
  border-color: rgba(240,71,63,.35);
  color:#ff9d97;
}
.btn-danger:hover{ background: rgba(240,71,63,.24); color:#ffb5b0; }

.btn-ghost{
  background:transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover{ background: var(--surface-3); color: var(--ink); border-color: var(--border-soft); }

.btn-sm{ padding: 5px 11px; font-size:12.5px; }

/* ============================================================
   KPIs
   ============================================================ */
.kpi-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap:12px;
  margin-bottom:22px;
}
.kpi-grid--destaque{ margin-bottom:8px; }
.kpi{
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px 16px;
  position:relative;
  overflow:hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.kpi::before{
  content:'';
  position:absolute; left:0; top:0; bottom:0; width:3px;
  background: var(--surface-4);
}
.kpi--ok::before{ background: var(--ok); }
.kpi--warn::before{ background: var(--warn); }
.kpi--danger::before{ background: var(--danger); }
.kpi--link, .kpi[data-nav]{ cursor:pointer; }
.kpi--link:hover, .kpi[data-nav]:hover{ border-color: var(--border); transform: translateY(-1px); }
.kpi-label{ font-size:12px; color: var(--muted); font-weight:500; margin-bottom:8px; }
.kpi-value{
  font-family: var(--font-display);
  font-size:25px;
  font-weight:700;
  letter-spacing:-.01em;
  color: var(--ink);
}
.kpi--ok .kpi-value{ color: #7fe157; }
.kpi--warn .kpi-value{ color: var(--warn); }
.kpi--danger .kpi-value{ color: #ff7a72; }
.kpi-sub{ margin-top:6px; font-size:11.5px; color: var(--muted-2); }

/* ============================================================
   DASHBOARD GRID / PAINÉIS
   ============================================================ */
.dash-section-title{
  font-family: var(--font-display);
  font-size:13px;
  font-weight:600;
  color: var(--muted);
  text-transform: none;
  letter-spacing:.01em;
  margin: 30px 0 12px;
  padding-bottom:8px;
  border-bottom:1px solid var(--border-soft);
  display:flex; align-items:baseline; gap:8px;
}
.dash-section-title:first-child{ margin-top:0; }
.dash-section-title span{ font-weight:400; color: var(--muted-2); font-size:12px; }

.dash-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:16px;
  margin-bottom:16px;
}
.dash-grid--wide{ grid-template-columns: 1.3fr 1fr; }

.panel{
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  min-width:0;
}
.panel h3{
  font-size:14.5px;
  font-weight:600;
  margin-bottom:14px;
  display:flex; flex-wrap:wrap; align-items:baseline; gap:8px;
}
.panel h3 small{
  font-family: var(--font-body);
  font-weight:400;
  font-size:12px;
  color: var(--muted-2);
}

/* ============================================================
   TOOLBAR (filtros de topo de página)
   ============================================================ */
.toolbar{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  margin-bottom:18px;
}
.count-tag{
  font-size:12.5px;
  color: var(--muted);
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  padding: 7px 12px;
  border-radius: 99px;
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap{
  background: var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow-x:auto;
  overflow-y:hidden;
}
table{ width:100%; border-collapse:collapse; min-width:560px; }
thead th{
  text-align:left;
  font-size:11px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.05em;
  color: var(--muted-2);
  background: rgba(255,255,255,.02);
  padding: 12px 16px;
  border-bottom:1px solid var(--border-soft);
  white-space:nowrap;
}
tbody td{
  padding: 12px 16px;
  border-bottom:1px solid var(--border-soft);
  font-size:13.5px;
  color: var(--ink);
  vertical-align:middle;
}
tbody tr:last-child td{ border-bottom:none; }
tbody tr{ transition: background .12s ease; }
tbody tr:hover{ background: rgba(255,255,255,.025); }
td .mono, .mono{ font-family: var(--font-mono); font-size:12.5px; letter-spacing:-.02em; }
td.wrap, .wrap{ white-space:normal; max-width:280px; color: var(--muted); }

.row-actions{ display:flex; gap:6px; justify-content:flex-end; flex-wrap:nowrap; }

/* ============================================================
   PILLS / STATUS
   ============================================================ */
.pill{
  display:inline-flex; align-items:center;
  font-size:11.5px; font-weight:600;
  padding: 3px 10px;
  border-radius: 99px;
  white-space:nowrap;
  border:1px solid transparent;
}
.pill--green{ background: var(--ok-soft); color:#7fe157; border-color:rgba(76,194,28,.3); }
.pill--blue{  background: var(--info-soft); color:#7cbcfb; border-color:rgba(61,155,245,.3); }
.pill--amber{ background: var(--warn-soft); color:var(--warn); border-color:rgba(242,169,60,.3); }
.pill--red{   background: var(--danger-soft); color:#ff8a83; border-color:rgba(240,71,63,.3); }
.pill--grey{  background: var(--grey-soft); color: var(--muted); border-color: var(--border); }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert-row{
  display:flex; align-items:center; gap:10px;
  width:100%;
  padding: 11px 6px;
  border-bottom:1px solid var(--border-soft);
  background:none; border-left:none; border-right:none; border-top:none;
  text-align:left;
  color: var(--ink);
  font-size:13px;
}
.alert-row:last-child{ border-bottom:none; }
.alert-row--link{ cursor:pointer; border-radius: var(--radius-sm); transition: background .12s ease; }
.alert-row--link:hover{ background: var(--surface-3); }
.sev-dot{ width:8px; height:8px; border-radius:50%; flex:none; background: var(--muted-2); }
.sev-dot.warn{ background: var(--warn); box-shadow:0 0 0 3px var(--warn-soft); }
.sev-dot.danger{ background: var(--danger); box-shadow:0 0 0 3px var(--danger-soft); }
.alert-txt{ flex:1; color: var(--ink); }
.alert-tag{
  font-size:11px; font-weight:600; color: var(--muted);
  background: var(--surface-3);
  padding: 3px 9px;
  border-radius: 99px;
  flex:none;
}
.alert-go{ color: var(--muted-2); font-size:17px; flex:none; }
.alert-row--link:hover .alert-go{ color: var(--brand-orange-ink); }

/* ============================================================
   TIMELINE (histórico do veículo)
   ============================================================ */
.timeline{ position:relative; padding-left:22px; }
.timeline::before{
  content:'';
  position:absolute; left:5px; top:6px; bottom:6px; width:2px;
  background: var(--border);
}
.tl-item{ position:relative; padding: 0 0 20px; }
.tl-item::before{
  content:'';
  position:absolute; left:-22px; top:3px;
  width:11px; height:11px; border-radius:50%;
  background: var(--surface-2);
  border:2px solid var(--brand-orange);
}
.tl-item:last-child{ padding-bottom:0; }
.tl-date{ font-family: var(--font-mono); font-size:11.5px; color: var(--muted-2); margin-bottom:3px; }
.tl-title{ font-weight:600; font-size:14px; margin-bottom:2px; }
.tl-meta{ font-size:12.5px; color: var(--muted); }

/* ============================================================
   ESTADO VAZIO
   ============================================================ */
.empty-state{
  padding: 46px 24px;
  text-align:center;
  color: var(--muted);
}
.empty-state svg{ margin:0 auto 14px; opacity:.5; width:38px; height:38px; stroke:currentColor; }
.empty-state h3{ font-size:15px; color: var(--ink); margin-bottom:6px; }
.empty-state p{ font-size:13px; max-width:360px; margin:0 auto; }

/* ============================================================
   FORMULÁRIO / MODAL
   ============================================================ */
.modal-backdrop{
  display:none;
  position:fixed; inset:0; z-index:60;
  background: rgba(6,7,10,.68);
  backdrop-filter: blur(3px);
  align-items:center; justify-content:center;
  padding:20px;
}
.modal-backdrop.open{ display:flex; }
.modal{
  width:100%; max-width:640px;
  max-height:88vh;
  display:flex; flex-direction:column;
  background: var(--surface-2);
  border:1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: modal-in .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes modal-in{ from{ opacity:0; transform: translateY(8px) scale(.98); } to{ opacity:1; transform:none; } }
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 22px;
  border-bottom:1px solid var(--border-soft);
  flex:none;
}
.modal-head h2{ font-size:16.5px; }
.modal-body{ padding: 20px 22px 22px; overflow-y:auto; }

.field-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px 12px;
}
.field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.field.full{ grid-column: 1 / -1; }
.field label{ font-size:12.5px; font-weight:600; color: var(--muted); }

input, select, textarea{
  background: var(--surface-3);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--ink);
  outline:none;
  width:100%;
  transition: border-color .15s ease, background .15s ease;
}
input:hover, select:hover, textarea:hover{ border-color:#3a4351; }
input:focus, select:focus, textarea:focus{
  border-color: var(--brand-orange);
  background: var(--surface-4);
  box-shadow: 0 0 0 3px var(--brand-orange-soft);
}
textarea{ min-height:78px; resize:vertical; }
select{ appearance:none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa4b6' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position: right 11px center;
  padding-right: 32px;
}
::placeholder{ color: var(--muted-2); }

.form-actions{
  display:flex; justify-content:flex-end; gap:10px;
  margin-top:20px;
  padding-top:16px;
  border-top:1px solid var(--border-soft);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast{
  position:fixed; left:50%; bottom:26px; z-index:80;
  transform: translate(-50%, 14px);
  background: #1a1e27;
  color: var(--ink);
  border:1px solid var(--border);
  padding: 12px 20px;
  border-radius: 99px;
  font-size:13px; font-weight:500;
  box-shadow: var(--shadow-pop);
  opacity:0; pointer-events:none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show{ opacity:1; transform: translate(-50%, 0); pointer-events:auto; }

/* ============================================================
   GRÁFICOS (charts.js)
   ============================================================ */
.chart{ width:100%; }
.chart-top{
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; gap:10px;
  margin-bottom:12px;
}
.chart-legend{ display:flex; flex-wrap:wrap; gap:6px; }
.ch-leg{
  display:inline-flex; align-items:center; gap:6px;
  background: var(--surface-3);
  border:1px solid var(--border-soft);
  border-radius: 99px;
  padding: 5px 11px;
  font-size:11.5px; font-weight:500;
  color: var(--muted);
  transition: opacity .15s ease, border-color .15s ease;
}
.ch-leg i{ width:9px; height:9px; border-radius:3px; flex:none; }
.ch-leg i.ln{ border-radius:99px; height:3px; width:12px; }
.ch-leg:hover{ border-color: var(--border); color: var(--ink); }
.ch-leg.off{ opacity:.4; text-decoration: line-through; }

.ch-segs{
  display:inline-flex; background: var(--surface-3); border:1px solid var(--border-soft);
  border-radius: 99px; padding:2px; gap:2px;
}
.ch-seg{
  border:none; background:none; color: var(--muted);
  font-size:11.5px; font-weight:600;
  padding: 5px 11px; border-radius:99px;
  transition: background .15s ease, color .15s ease;
}
.ch-seg.on{ background: var(--brand-orange); color:#fff; }
.ch-seg:not(.on):hover{ color: var(--ink); }

.chart-plot{ position:relative; }
.chart-empty{
  display:flex; align-items:center; justify-content:center;
  color: var(--muted-2); font-size:13px;
  border:1px dashed var(--border);
  border-radius: var(--radius);
  min-height:160px;
}

/* --- gráfico cartesiano (barras + linha) --- */
.ch-svg{ width:100%; height:auto; overflow:visible; }
.ch-svg text{ fill: var(--muted-2); font-size:10.5px; font-family: var(--font-mono); }
.ch-xl--now{ fill: var(--ink) !important; font-weight:600; }
.ch-grid{ stroke: var(--border-soft); stroke-width:1; }
.ch-grid--base{ stroke: var(--border); }
.ch-b{ transition: opacity .15s ease; }
.ch-guide{ fill: transparent; }
.ch-hit{ fill: transparent; }
.ch-hit.is-click{ cursor:pointer; }
.ch-hit:hover + .ch-guide, .ch-guide:has(+ .ch-hit:hover){ fill: rgba(255,255,255,.03); }
.chart-plot:has(.ch-hit:hover) .ch-guide{ fill: rgba(255,255,255,.025); }
.ch-line{ fill:none; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round; }
.ch-dot{ stroke: var(--surface-2); stroke-width:2; }
.ch-enter .ch-b{ animation: bar-in .4s ease both; }
.ch-enter .ch-line{ stroke-dasharray:1; stroke-dashoffset:1; animation: line-in .6s ease .1s both; }
@keyframes bar-in{ from{ opacity:0; transform: scaleY(.85); transform-origin: bottom; } to{ opacity:1; transform:none; } }
@keyframes line-in{ to{ stroke-dashoffset:0; } }

/* --- rosca (donut) --- */
.dn{ display:flex; align-items:center; gap:22px; flex-wrap:wrap; }
.dn-wrap{ position:relative; width:190px; height:190px; flex:none; }
.dn-wrap svg{ width:100%; height:100%; }
.ch-slice{ transition: filter .15s ease, transform .15s ease; transform-origin:center; }
.ch-slice.is-click{ cursor:pointer; }
.ch-slice:hover{ filter:brightness(1.14); transform: translate(var(--dx), var(--dy)); }
.dn-center{
  position:absolute; inset:0;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; pointer-events:none;
}
.dn-t{ font-size:11.5px; color: var(--muted); max-width:100px; }
.dn-v{ font-family: var(--font-display); font-size:22px; font-weight:700; color: var(--ink); margin:2px 0; }
.dn-s{ font-size:11px; color: var(--muted-2); }
.dn-legend{ flex:1; min-width:160px; display:flex; flex-direction:column; gap:2px; }
.dl-row{
  display:grid; grid-template-columns:9px 1fr auto var(--vw,44px);
  align-items:center; gap:9px;
  background:none; border:none; border-radius: var(--radius-sm);
  padding: 7px 8px; text-align:left;
  transition: background .12s ease, opacity .15s ease;
}
.dl-row i{ width:9px; height:9px; border-radius:3px; }
.dl-row:hover{ background: var(--surface-3); }
.dl-row.off{ opacity:.4; }
.dl-row.is-click{ cursor:pointer; }
.dl-n{ font-size:13px; color: var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dl-v{ font-family: var(--font-mono); font-size:12.5px; color: var(--muted); text-align:right; }
.dl-p{ font-family: var(--font-mono); font-size:11px; color: var(--muted-2); text-align:right; min-width:34px; }

/* --- barras horizontais (ranking) --- */
.hb{ display:flex; flex-direction:column; gap:10px; }
.hb-row{
  display:grid; grid-template-columns: 116px 1fr auto;
  align-items:center; gap:12px;
  background:none; border:none; border-radius: var(--radius-sm);
  padding: 4px 6px; text-align:left;
  transition: background .12s ease;
}
.hb-row:hover{ background: var(--surface-3); }
.hb-row.is-click{ cursor:pointer; }
.hb-label{ overflow:hidden; }
.hb-label b{ display:block; font-size:13px; font-weight:600; color: var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hb-label small{ display:block; font-family: var(--font-mono); font-size:10.5px; color: var(--muted-2); margin-top:1px; }
.hb-track{
  position:relative; height:14px;
  background: var(--surface-3);
  border-radius: 5px;
  overflow:hidden;
  display:flex;
}
.hb-fill{ display:flex; height:100%; border-radius:5px; overflow:hidden; transition: width .5s cubic-bezier(.2,.8,.3,1); }
.hb-seg{ height:100%; }
.hb-mark{ position:absolute; top:-3px; bottom:-3px; width:2px; background: var(--brand-orange-ink); }
.hb-val{ font-family: var(--font-mono); font-size:12.5px; color: var(--ink); text-align:right; min-width:70px; }
.hb-note{ margin-top:6px; font-size:11.5px; color: var(--muted-2); display:flex; align-items:center; gap:6px; }
.hb-mk{ display:inline-block; width:8px; height:2px; background: var(--brand-orange-ink); }

/* --- tooltip compartilhado --- */
.chart-tip{
  position:fixed; z-index:70;
  background: #1a1e27;
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size:12.5px;
  box-shadow: var(--shadow-pop);
  pointer-events:none;
  max-width:240px;
  opacity:0; visibility:hidden;
  transition: opacity .1s ease;
}
.chart-tip.show{ opacity:1; visibility:visible; }
.ct-title{ font-weight:600; color: var(--ink); margin-bottom:6px; font-size:12.5px; }
.ct-sub{ font-weight:400; color: var(--muted-2); font-size:11px; }
.ct-row{ display:flex; align-items:center; gap:7px; padding:2px 0; color: var(--muted); }
.ct-row i{ width:8px; height:8px; border-radius:2px; flex:none; }
.ct-row i.ln{ border-radius:99px; }
.ct-row span{ flex:1; }
.ct-row b{ color: var(--ink); font-family: var(--font-mono); font-weight:600; }
.ct-total{ display:flex; justify-content:space-between; margin-top:5px; padding-top:5px; border-top:1px solid var(--border-soft); font-size:12px; color: var(--muted); }
.ct-total b{ color: var(--ink); font-family: var(--font-mono); }
.ct-hint{ margin-top:6px; font-size:11px; color: var(--muted-2); font-style:italic; }

/* ============================================================
   MAPA (Leaflet — rastreamento)
   ============================================================ */
.leaflet-container{ background: var(--surface-2); border-radius: var(--radius); font-family: var(--font-body); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip{ background: var(--surface-3); color: var(--ink); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1080px){
  .dash-grid--wide{ grid-template-columns: 1fr; }
  .field-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 880px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{
    position:fixed; left:0; top:0; bottom:0;
    width: min(80vw, 290px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open{ transform:none; }
  .only-mobile{ display:flex; }
  .topbar-mark{ display:block; }
  .topbar{ padding: 0 14px; gap:10px; }
  .content{ padding: 18px 16px 48px; }
  .search{ max-width:none; }
  .search input::placeholder{ font-size:12.5px; }
  .kpi-grid{ grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); }
  .hb-row{ grid-template-columns: 88px 1fr auto; gap:8px; }
  .dn{ justify-content:center; }
  .page-head{ flex-direction:column; align-items:stretch; }
  .page-head .btn{ align-self:flex-start; }
}

@media (max-width: 560px){
  .kpi-grid{ grid-template-columns: repeat(2, 1fr); }
  .modal{ max-height:94vh; }
  .field-grid{ gap:12px; }
  .table-wrap table{ min-width:520px; }
}