:root{
  /* Base */
  --bg:#050b10;
  --panel:#07141a;
  --card:#071820;
  --line:rgba(255,255,255,.08);
  --muted:rgba(255,255,255,.65);
  --text:rgba(255,255,255,.92);

  /* Paleta Roxa (INTACTA) */
  --p1:#791a77;
  --p2:#90448f;
  --p3:#a465a3;
  --p4:#b681b3;
  --p5:#c198c1;
  --p6:#ccaccd;
  --p7:#ecdeeb;

  /* Marca */
  --brand: var(--p3);
  --brand2: var(--p4);

  /* Status */
  --ok:#22c55e;
  --warn:#facc15;
  --bad:#ef4444;

  /* Shape / FX */
  --shadow: 0 18px 40px rgba(0,0,0,.45);
  --radius:16px;
  --radius2:22px;

  /* Espaçamentos (apenas padronização) */
  --gap:12px;
  --pad:20px;
}

*{box-sizing:border-box}
html, body{height:100%}

body{
  margin:0;
  font-family: Arial, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(164,101,163,.18), transparent 55%),
    radial-gradient(900px 600px at 90% 10%, rgba(182,129,179,.14), transparent 55%),
    var(--bg);
  color:var(--text);
}

/* =========================
   Layout
========================= */
.container{
  display:flex;
  min-height:100vh;
  width:100%;
}

.main{
  flex:1;
  padding:var(--pad) calc(var(--pad) + 2px);
  min-width:0; /* evita overflow em grids/tabelas */
}

/* =========================
   Sidebar
========================= */
.sidebar{
  width:280px;
  background: linear-gradient(180deg, rgba(7,20,26,.96), rgba(5,11,16,.98));
  border-right:1px solid var(--line);
  padding:18px 16px;
  position:sticky;
  top:0;
  height:100vh;
}

/* Brand */
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:14px;
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

.brand h1{font-size:16px;margin:0;letter-spacing:.6px}
.brand small{
  display:block;
  color:var(--muted);
  margin-top:2px;
  font-size:12px;
}

.logoDot{
  width:14px;
  height:14px;
  border-radius:50%;
  background: radial-gradient(circle at 30% 30%, var(--brand2), var(--brand));
  box-shadow: 0 0 0 4px rgba(182,129,179,.18);
}

/* Nav */
.nav{
  margin-top:16px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.nav a{
  text-decoration:none;
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid transparent;
  color:rgba(255,255,255,.86);
  background:rgba(255,255,255,.02);
}

.nav a:hover{
  border-color: rgba(182,129,179,.35);
  background: rgba(182,129,179,.14);
}

.nav a.active{
  border-color: rgba(182,129,179,.55);
  background: rgba(182,129,179,.24);
}

/* =========================
   Topbar
========================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:16px;
  flex-wrap:wrap; /* melhora em telas menores sem mudar visual */
}

.title{min-width:0}
.title h2{margin:0;font-size:20px}
.title p{margin:6px 0 0 0;color:var(--muted);font-size:13px}

/* =========================
   Grid
========================= */
.grid{
  display:grid;
  grid-template-columns:repeat(12, 1fr);
  gap:var(--gap);
  min-width:0;
}

/* =========================
   Cards
========================= */
.card{
  grid-column: span 3;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border:1px solid var(--line);
  border-radius: var(--radius2);
  padding:14px 14px;
  box-shadow: var(--shadow);
  position:relative;
  overflow:hidden;
  min-width:0;
}

.card:before{
  content:"";
  position:absolute;
  inset:-1px;
  background: radial-gradient(600px 220px at 20% 0%, rgba(182,129,179,.22), transparent 60%);
  pointer-events:none;
}

.card h3{
  margin:0;
  font-size:13px;
  color:var(--muted);
  font-weight:700;
  letter-spacing:.6px;
  text-transform:uppercase;
}

.card .num{margin-top:10px;font-size:28px;font-weight:800}
.card .tag{margin-top:6px;color:var(--muted);font-size:12px}

/* =========================
   Panels
========================= */
.panel{
  grid-column: span 12;
  background: rgba(255,255,255,.02);
  border:1px solid var(--line);
  border-radius: var(--radius2);
  padding:14px;
  box-shadow: var(--shadow);
  min-width:0;
}

/* =========================
   Table
========================= */
.table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
  border-radius:14px;
}

.table th,
.table td{
  padding:12px 10px;
  border-bottom:1px solid rgba(255,255,255,.06);
  text-align:left;
  font-size:13px;
}

.table th{
  color:rgba(255,255,255,.75);
  font-weight:800;
  background:rgba(255,255,255,.03);
}

.table tr:hover td{background:rgba(182,129,179,.10)}

/* =========================
   Badges
========================= */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  font-weight:800;
  font-size:12px;
  white-space:nowrap;
}

.badge.ok{border-color:rgba(34,197,94,.35);background:rgba(34,197,94,.12);color:#fff}
.badge.warn{border-color:rgba(250,204,21,.35);background:rgba(250,204,21,.12);color:#fff}
.badge.bad{border-color:rgba(239,68,68,.35);background:rgba(239,68,68,.12);color:#fff}
.badge.neutral{border-color:rgba(255,255,255,.12);background:rgba(255,255,255,.06);color:#fff}

/* =========================
   Buttons
========================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:10px 14px;
  border-radius:14px;
  border:1px solid transparent;
  background:rgba(255,255,255,.04);
  color:#fff;
  text-decoration:none;
  font-weight:800;
  font-size:13px;
  white-space:nowrap;
}

.btn:hover{
  border-color: rgba(182,129,179,.35);
  background: rgba(182,129,179,.18);
}

.btn.primary{
  background:linear-gradient(180deg, var(--brand2), var(--brand));
  border-color: rgba(182,129,179,.55);
  color:#100613;
}

/* =========================
   Inputs
========================= */
.input,
select,
textarea,
input{
  width:100%;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(7,20,26,.80);
  color:rgba(255,255,255,.92);
  outline:none;
}

select:focus,
textarea:focus,
input:focus{
  border-color: rgba(182,129,179,.55);
  box-shadow: 0 0 0 4px rgba(182,129,179,.18);
  background: linear-gradient(180deg, rgba(182,129,179,.16), rgba(7,20,26,.80));
  transform: translateY(-1px);
}

/* Labels */
label{
  display:block;
  margin:10px 0 6px;
  color:rgba(255,255,255,.75);
  font-weight:800;
  font-size:12px;
  letter-spacing:.4px;
  text-transform:uppercase;
}

.row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:var(--gap);
  min-width:0;
}

hr{
  border:0;
  border-top:1px solid rgba(255,255,255,.08);
  margin:14px 0;
}

/* ====== SELECT: fechado escuro / dropdown claro ====== */
/* Select fechado */
select{
  color: rgba(255,255,255,.92);
  background-color: rgba(7,20,26,.80);
}

/* Options (dropdown aberto) */
select option{
  background:#ffffff;
  color:#0b1220;
}

select option:checked{
  background:#efe6f2;
  color:#0b1220;
}

select option[disabled]{
  color:#475569;
}

/* Date/Month com ícone branco */
input[type="date"],
input[type="month"]{
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator{
  filter: invert(1);
  opacity:.75;
}

/* =========================
   Auth
========================= */
.center{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}

.authBox{
  width:380px;
  max-width:100%;
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow: var(--shadow);
  padding:18px;
}

/* =========================
   Responsivo (melhorado)
========================= */
@media (max-width: 1100px){
  .card{grid-column: span 4}
}

@media (max-width: 980px){
  .sidebar{display:none}
  .main{padding:18px}
  .card{grid-column: span 6}
  .row{grid-template-columns:1fr}
}

@media (max-width: 720px){
  .topbar{align-items:flex-start}
  .btn{width:100%}
  .panel{padding:12px}
  .table{display:block; overflow-x:auto; -webkit-overflow-scrolling:touch}
  .table th, .table td{white-space:nowrap}
}

@media (max-width: 520px){
  .main{padding:16px}
  .card{grid-column: span 12}
}

/* =========================
   FIX: Calendário (date) estourando no tablet/mobile
========================= */
.filtersGrid > * { min-width: 0; }
.field { min-width: 0; }

.kmFilters input,
.kmFilters select{
  max-width: 100%;
  min-width: 0;
}

.kmFilters input[type="date"]{
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  font-size: 16px;
}

.kmFilters input[type="date"]::-webkit-calendar-picker-indicator{
  margin: 0;
  padding: 0;
  cursor: pointer;
}

@media (max-width: 900px){
  .filtersGrid{ grid-template-columns: 1fr; }
  .filtersActions{ grid-column: 1 / -1; }
}
