:root{
  --bg:#f5f7fb;
  --surface:#ffffff;
  --surface-soft:#f8fafc;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --yellow:#ffc400;
  --yellow-dark:#d99d00;
  --green:#16a34a;
  --red:#ef4444;
  --orange:#f59e0b;
  --blue:#2563eb;
  --purple:#8b5cf6;
  --shadow:0 14px 30px rgba(15,23,42,.08);
}

body.dark{
  --bg:#0b111a;
  --surface:#111827;
  --surface-soft:#0f172a;
  --text:#f8fafc;
  --muted:#cbd5e1;
  --border:#334155;
  --shadow:0 18px 38px rgba(0,0,0,.35);
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:Inter, Arial, Helvetica, sans-serif;
  background:var(--bg);
  color:var(--text);
}

button,input,select,textarea{
  font-family:inherit;
}

.app-shell{
  min-height:100vh;
  display:flex;
}

.sidebar{
  width:292px;
  min-height:100vh;
  position:fixed;
  left:0;
  top:0;
  background:var(--surface);
  border-right:1px solid var(--border);
  padding:18px 16px;
  display:flex;
  flex-direction:column;
  gap:18px;
  box-shadow:var(--shadow);
  z-index:20;
}

.brand{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:86px;
}

.brand-logo{
  width:240px;
  max-width:100%;
  object-fit:contain;
}

.sidebar-menu{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.nav-btn{
  display:flex;
  align-items:center;
  gap:12px;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  padding:12px 14px;
  border-radius:12px;
  font-size:14px;
  font-weight:800;
  cursor:pointer;
  text-align:left;
  box-shadow:0 8px 16px rgba(15,23,42,.04);
  position:relative;
}

.nav-btn:hover{
  border-color:var(--yellow);
  background:#fff9df;
  color:#111827;
}

body.dark .nav-btn:hover{
  background:#1f2937;
  color:#fff;
}

.nav-btn.active{
  background:linear-gradient(135deg,var(--yellow),#ffdc4a);
  color:#111827;
  border-color:#f5c400;
}

.badge,.round-badge{
  background:#ef4444;
  color:#fff;
  border-radius:999px;
  padding:3px 8px;
  margin-left:auto;
  font-size:12px;
}

.round-badge{
  position:absolute;
  right:-7px;
  top:-7px;
  min-width:21px;
  height:21px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}

.hidden{display:none!important}

.sidebar-footer{
  margin-top:auto;
  border:1px solid var(--border);
  border-radius:16px;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:8px;
  background:var(--surface-soft);
}

.sidebar-footer em{
  display:inline-block;
  width:max-content;
  background:linear-gradient(135deg,var(--yellow),#ffdf63);
  color:#111827;
  border-radius:999px;
  padding:6px 11px;
  font-style:normal;
  font-weight:800;
  font-size:12px;
}

.sidebar-footer small,.sidebar-footer span{
  color:var(--muted);
}

.main{
  margin-left:292px;
  width:calc(100% - 292px);
  padding:18px 28px 40px;
}

.topbar{
  height:62px;
  display:flex;
  align-items:center;
  gap:14px;
  margin-bottom:16px;
}

.topbar-spacer{flex:1}

.icon-btn,.whatsapp-btn,.ghost-btn,.primary-btn,.secondary-btn,.warning-btn{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  border-radius:12px;
  padding:11px 16px;
  cursor:pointer;
  font-weight:800;
  box-shadow:0 8px 16px rgba(15,23,42,.05);
  position:relative;
}

.whatsapp-btn{
  border-color:#16a34a;
  color:#15803d;
  background:#f0fdf4;
}

.primary-btn{
  background:linear-gradient(135deg,var(--yellow),#ffdf63);
  color:#111827;
  border-color:#facc15;
}

.secondary-btn{
  background:var(--surface-soft);
}

.warning-btn{
  background:#fff7ed;
  color:#9a3412;
  border-color:#fdba74;
}

.tab{display:none}
.tab.active{display:block}

.hero-card,.panel,.module,.kpi-card,.bottom-strip{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
}

.hero-card{
  min-height:176px;
  padding:28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  overflow:hidden;
  margin-bottom:18px;
  background:
    radial-gradient(circle at 82% 20%,rgba(255,196,0,.23),transparent 26%),
    var(--surface);
}

.hero-card h1{
  font-size:30px;
  margin:0 0 10px;
}

.hero-card p,.module-title p{
  margin:0 0 12px;
  color:var(--muted);
}

.connection{
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:8px 14px;
  border-radius:999px;
  font-weight:900;
}

.connection.online{
  background:#ecfdf5;
  color:#166534;
  border:1px solid #86efac;
}

.connection.offline{
  background:#fef2f2;
  color:#991b1b;
  border:1px solid #fecaca;
}

body.dark .connection.online{
  background:#052e16;
  color:#bbf7d0;
}

.kpi-grid{
  display:grid;
  grid-template-columns:repeat(6,minmax(150px,1fr));
  gap:14px;
  margin-bottom:18px;
}

.kpi-card{
  padding:18px;
  display:flex;
  gap:14px;
  align-items:center;
  min-height:112px;
}

.kpi-card span{
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.kpi-card strong{
  display:block;
  font-size:22px;
  margin:4px 0;
}

.kpi-card small{
  color:var(--muted);
}

.kpi-icon{
  width:48px;
  height:48px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  color:#fff;
  flex:0 0 auto;
}

.yellow{background:var(--yellow);color:#111827}.green{background:var(--green)}.red{background:var(--red)}.orange{background:var(--orange)}.purple{background:var(--purple)}.blue{background:var(--blue)}

.panel,.module{
  padding:20px;
  margin-bottom:18px;
}

.panel-title,.module-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:16px;
}

.panel-title h1,.panel-title h2,.module-title h1,.module-title h2{
  margin:0;
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(240px,1fr));
  gap:14px;
}

label{
  display:flex;
  flex-direction:column;
  gap:6px;
  color:var(--text);
  font-weight:800;
  font-size:13px;
}

label.wide{
  grid-column:1 / -1;
}

input,select,textarea{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  border-radius:12px;
  padding:12px;
  outline:none;
  font-size:14px;
}

textarea{min-height:90px;resize:vertical}

input:focus,select:focus,textarea:focus{
  border-color:var(--yellow);
  box-shadow:0 0 0 3px rgba(255,196,0,.16);
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:16px;
}

.table-wrap{overflow-x:auto}

table{
  width:100%;
  border-collapse:collapse;
  font-size:14px;
}

th,td{
  border-bottom:1px solid var(--border);
  padding:11px;
  text-align:left;
  vertical-align:middle;
}

th{
  color:#8a6500;
  background:#fff8db;
  text-transform:uppercase;
  font-size:12px;
}

body.dark th{
  background:#1f2937;
  color:#facc15;
}

.status{
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:900;
  display:inline-block;
}

.em-dia{background:#dcfce7;color:#166534}.em-atraso{background:#fee2e2;color:#991b1b}.alerta{background:#fff7ed;color:#9a3412}

body.dark .em-dia{background:#052e16;color:#bbf7d0}
body.dark .em-atraso{background:#3f0b0b;color:#fecaca}
body.dark .alerta{background:#451a03;color:#fed7aa}

.vehicle-dashboard-list{
  display:grid;
  grid-template-columns:1fr;
  gap:14px;
}

.vehicle-card{
  border:1px solid var(--border);
  border-left:4px solid var(--green);
  border-radius:16px;
  padding:18px;
  background:var(--surface);
}

.vehicle-card.atraso{border-left-color:var(--red)}

.vehicle-card-grid{
  display:grid;
  grid-template-columns:280px 1fr;
  gap:24px;
}

.chart-wrap{
  min-height:190px;
}

.bottom-strip{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:0;
  overflow:hidden;
  background:#fff8db;
  border-color:#f4d35e;
}

body.dark .bottom-strip{
  background:#17130a;
}

.bottom-strip div{
  padding:16px 22px;
  border-right:1px solid #f4d35e;
}

.bottom-strip div:last-child{border-right:0}

.bottom-strip b,.bottom-strip span{
  display:block;
}

.bottom-strip span{
  margin-top:5px;
  font-weight:800;
}

.alert-box{
  border:1px solid #f4d35e;
  border-left:5px solid var(--yellow);
  border-radius:14px;
  padding:14px;
  background:#fffdf3;
  margin-bottom:12px;
}

body.dark .alert-box{
  background:#17130a;
}

.contract-preview{
  border:1px dashed var(--border);
  border-radius:14px;
  padding:18px;
  margin-top:16px;
  color:var(--muted);
}

.mini-select{
  width:auto;
}

.mobile-menu{display:none}

@media(max-width:1200px){
  .kpi-grid{grid-template-columns:repeat(3,1fr)}
  .vehicle-card-grid{grid-template-columns:1fr}
}

@media(max-width:860px){
  .sidebar{
    transform:translateX(-100%);
    transition:.2s ease;
  }

  body.menu-open .sidebar{
    transform:translateX(0);
  }

  .main{
    margin-left:0;
    width:100%;
    padding:14px;
  }

  .mobile-menu{display:inline-block}
  .kpi-grid,.bottom-strip{grid-template-columns:1fr}
  .topbar{overflow-x:auto}
}

@media print{
  .sidebar,.topbar,.actions,.ghost-btn,.mobile-menu{display:none!important}
  .main{margin-left:0;width:100%}
  body{background:#fff;color:#111}
}


/* =========================================================
   V7.1 - Dashboard Premium: ajustes contra sobreposição
   ========================================================= */
.main{
  overflow-x:hidden;
}

.topbar{
  min-height:64px;
  height:auto;
  flex-wrap:wrap;
  align-items:center;
  padding:4px 0;
}

.topbar .icon-btn,
.topbar .whatsapp-btn{
  white-space:nowrap;
}

.hero-card{
  display:grid;
  grid-template-columns:minmax(0,1.25fr) minmax(260px,.75fr);
  gap:24px;
  align-items:center;
  padding:30px;
}

.hero-card > div:first-child{
  min-width:0;
}

.hero-card h1{
  font-size:clamp(24px,3vw,36px);
  line-height:1.12;
  margin-bottom:10px;
  overflow-wrap:anywhere;
}

.hero-card p{
  max-width:720px;
  line-height:1.5;
}

.hero-road{
  min-height:130px;
  border-radius:22px;
  background:
    linear-gradient(135deg,rgba(255,196,0,.28),rgba(255,255,255,0)),
    url('./Logomarca.jpeg') center/contain no-repeat;
  opacity:.98;
}

body.dark .hero-road{
  background:
    linear-gradient(135deg,rgba(255,196,0,.20),rgba(15,23,42,.4)),
    url('./Logomarca.jpeg') center/contain no-repeat;
}

.kpi-grid{
  grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
  align-items:stretch;
}

.kpi-card{
  min-width:0;
  min-height:126px;
  overflow:hidden;
}

.kpi-card > div:last-child{
  min-width:0;
}

.kpi-card span,
.kpi-card small{
  display:block;
  white-space:normal;
  overflow-wrap:anywhere;
}

.kpi-card strong{
  font-size:clamp(18px,2vw,26px);
  line-height:1.15;
  white-space:normal;
  overflow-wrap:anywhere;
}

.panel-title,
.module-title{
  flex-wrap:wrap;
  align-items:flex-start;
}

.panel-title h1,
.panel-title h2,
.module-title h1,
.module-title h2{
  line-height:1.18;
  overflow-wrap:anywhere;
}

.vehicle-dashboard-list{
  gap:18px;
}

.vehicle-card{
  overflow:hidden;
}

.vehicle-card-grid{
  grid-template-columns:minmax(260px,330px) minmax(0,1fr);
  align-items:start;
}

.vehicle-card-grid > div{
  min-width:0;
}

.vehicle-card h2{
  font-size:clamp(18px,2vw,24px);
  line-height:1.18;
  margin:0 0 10px;
  overflow-wrap:anywhere;
}

.vehicle-card p{
  line-height:1.45;
  overflow-wrap:anywhere;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-width:0;
  height:230px;
  max-height:260px;
}

.chart-wrap canvas{
  width:100% !important;
  height:100% !important;
  max-width:100%;
}

.bottom-strip{
  grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
}

.bottom-strip div{
  min-width:0;
  border-right:0;
  border-bottom:1px solid rgba(244,211,94,.55);
}

.bottom-strip b,
.bottom-strip span{
  overflow-wrap:anywhere;
  line-height:1.35;
}

.table-wrap{
  max-width:100%;
}

@media(max-width:980px){
  .hero-card{
    grid-template-columns:1fr;
  }
  .hero-road{
    min-height:100px;
    background-position:left center;
  }
  .vehicle-card-grid{
    grid-template-columns:1fr;
  }
  .chart-wrap{
    height:210px;
  }
}

@media(max-width:560px){
  .main{
    padding:12px;
  }
  .hero-card,
  .panel,
  .module{
    padding:16px;
    border-radius:14px;
  }
  .kpi-card{
    padding:14px;
    min-height:auto;
  }
  .kpi-icon{
    width:42px;
    height:42px;
  }
  .topbar{
    gap:8px;
  }
  .topbar .icon-btn,
  .topbar .whatsapp-btn{
    padding:9px 11px;
    font-size:13px;
  }
}
