:root{
  --bg:#0b1220;
  --card:#0f1a2e;
  --card-2:#162338;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --blue:#2563eb;
  --blue-soft:#1e3a8a;
  --red:#ef4444;
  --line:rgba(255,255,255,.08);
  --shadow:0 10px 25px rgba(0,0,0,.35);
  --radius:16px;
  --font:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  -webkit-text-size-adjust:100%;
  overflow-x:hidden;
}

a{color:inherit;text-decoration:none}

/* ================= CONTAINER ================= */
.container{
  max-width:1200px;
  margin:0 auto;
  padding:18px;
}

/* ================= NAV ================= */
.nav{
  background:rgba(11,18,32,.85);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
  max-width:100%;
}
.nav-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 18px;
  flex-wrap:wrap;
  max-width:100%;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  min-width:0;
}
.brand .dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--blue);
  box-shadow:0 0 0 6px rgba(37,99,235,.15);
}

/* ================= LAYOUT ================= */
.grid{
  display:grid;
  grid-template-columns:260px 1fr;
  gap:16px;
  max-width:100%;
}
.row{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  max-width:100%;
}
.flex{
  display:flex;
  gap:10px;
  align-items:center;
  max-width:100%;
}
.right{margin-left:auto}

/* ================= CARD ================= */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  max-width:100%;
}
.card h3{
  margin:0 0 8px 0;
  font-size:14px;
  color:var(--muted);
}
.kpi{
  font-size:26px;
  font-weight:900;
}
.muted{color:var(--muted)}
hr.sep{
  border:none;
  border-top:1px solid var(--line);
  margin:16px 0;
}

/* ================= BADGES ================= */
.badge{
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  color:var(--muted);
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.badge.blue{
  background:rgba(37,99,235,.14);
  border-color:rgba(37,99,235,.30);
  color:#c7d2fe;
}
.badge.red{
  background:rgba(239,68,68,.10);
  border-color:rgba(239,68,68,.30);
  color:#fecaca;
}

/* ================= BUTTONS ================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  cursor:pointer;
  font-weight:700;
  transition:.15s;
  color:#ffffff !important;
  max-width:100%;
}
.btn:hover{background:rgba(255,255,255,.10)}
.btn.primary{
  background:linear-gradient(135deg,#2563eb,#1d4ed8);
  border-color:#2563eb;
}
.btn.danger{
  background:linear-gradient(135deg,#ef4444,#dc2626);
  border-color:#ef4444;
}

/* ================= INPUTS ================= */
.input, select{
  width:100%;
  max-width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.15);
  background:var(--card-2);
  color:#f1f5f9;
  font-weight:600;
  outline:none;
  appearance:none;
}
select option{
  background:#0f1a2e;
  color:#f1f5f9;
}
select option:checked{
  background:var(--blue-soft);
  color:#ffffff;
}

/* ================= TABLE ================= */
.table-wrap{
  overflow:auto;
  border-radius:var(--radius);
  border:1px solid var(--line);
  max-width:100%;
}
table{
  width:100%;
  border-collapse:collapse;
  min-width:820px;
}
th, td{
  padding:12px;
  border-bottom:1px solid var(--line);
  font-size:13px;
}
th{
  background:rgba(255,255,255,.05);
  text-align:left;
  font-weight:700;
}
tr:nth-child(even) td{background:rgba(255,255,255,.02)}

/* ================= SIDEBAR ================= */
.sidebar{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:14px;
  max-width:100%;
}
.menu a{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid transparent;
  font-weight:600;
}
.menu a:hover{background:rgba(255,255,255,.06)}
.menu a.active{
  background:rgba(37,99,235,.12);
  border-color:rgba(37,99,235,.30);
}

/* ================= MOBILE ================= */
.mobile-list{display:none}
.overlay{display:none}

@media(max-width:980px){
  .container{padding:12px;}
  .grid{grid-template-columns:1fr}

  /* NAV: evita estourar largura */
  .nav-inner{padding:12px;}
  .brand{font-size:18px;}
  .right{margin-left:0}

  /* Drawer */
  .sidebar{
    position:fixed;
    left:12px;
    top:12px;
    bottom:calc(12px + env(safe-area-inset-bottom));
    width:min(88vw,320px);
    z-index:100;
    transform:translateX(-110%);
    transition:.2s;
    overflow:hidden;
    display:flex;
    flex-direction:column;
    padding:14px;
    border-radius:22px;
    box-shadow:0 24px 60px rgba(0,0,0,.55);
  }
  .menu{
    flex:1 1 auto;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    padding-right:6px;
  }
  body.sidebar-open .sidebar{transform:translateX(0)}

  .overlay{
    display:block;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.55);
    opacity:0;
    pointer-events:none;
    transition:.2s;
    z-index:90;
  }
  body.sidebar-open .overlay{
    opacity:1;
    pointer-events:auto;
  }

  /* mobile usa cards */
  .table-wrap{display:none}
  .mobile-list{
    display:flex;
    flex-direction:column;
    gap:14px;
  }

  /* =====================================================
     RANKING MOBILE – FORÇA ORGANIZAÇÃO
     Funciona tanto no ranking antigo (texto) quanto no novo
  ====================================================== */

  /* melhora card */
  .mobile-list .mcard{
    border:1px solid rgba(255,255,255,.10);
    background:linear-gradient(180deg, rgba(255,255,255,.04), transparent 35%), var(--card);
    border-radius:18px;
    padding:14px;
    box-shadow:0 16px 40px rgba(0,0,0,.45);
    max-width:100%;
  }

  .mobile-list .mcard .top{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:10px;
    min-width:0;
  }

  .mobile-list .mcard .title{
    font-size:16px;
    font-weight:950;
    line-height:1.15;
  }

  .mobile-list .mcard .sub{
    font-size:12px;
    color:var(--muted);
    margin-top:4px;
  }

  /* Total como pill */
  .mobile-list .mcard .badge.blue{
    white-space:nowrap;
    padding:8px 10px;
    border-radius:14px;
    font-weight:950;
  }

  /* Se o ranking antigo estiver imprimindo "Carros/Peças..." em texto,
     escondemos essas linhas no mobile para não bagunçar */
  .mobile-list .mcard > div:not(.top):not(.mgrid):not(.mactions){
    display:none !important;
  }

  /* Grid 2x2 (caso exista) */
  .mobile-list .mgrid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-top:10px;
    max-width:100%;
  }
  .mobile-list .mkv{
    padding:12px;
    border-radius:14px;
    border:1px solid rgba(255,255,255,.08);
    background:rgba(255,255,255,.03);
    min-width:0;
  }
  .mobile-list .mkv .k{
    font-size:11px;
    color:var(--muted);
    text-transform:uppercase;
    letter-spacing:.25px;
  }
  .mobile-list .mkv .v{
    margin-top:4px;
    font-size:15px;
    font-weight:950;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  /* botão full */
  .mobile-list .mactions{
    margin-top:12px;
  }
  .mobile-list .mactions .btn{
    width:100%;
    height:46px;
    border-radius:16px;
  }

  img,canvas,svg,video{max-width:100%}
}

@media(max-width:420px){
  .container{padding:10px}
  .nav-inner{padding:12px}
}