:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel2: #1a2234;
  --line: #232c40;
  --txt: #e7ecf5;
  --muted: #8b97ad;
  --brand: #ffd23f;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Marca */
.marca { display: flex; align-items: center; gap: 9px; }
.marca h1, .marca strong { margin: 0; font-size: 20px; letter-spacing: -0.5px; }
.marca span { color: var(--brand); }
.marca-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 14px var(--brand);
}

/* Login */
.tela-login {
  display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px;
}
.card-login {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 32px 26px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.card-login .marca { justify-content: center; }
.card-login h1 { font-size: 28px; }
.card-login .sub { text-align: center; color: var(--muted); margin: -6px 0 8px; }
.card-login input, .card-login button {
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 16px; width: 100%;
}
.card-login input { background: var(--panel2); color: var(--txt); }
.card-login button {
  background: var(--brand); color: #1a1400; border: none; font-weight: 700; cursor: pointer;
}
.card-login .erro { color: var(--red); text-align: center; margin: 0; }

/* App */
#app { display: flex; flex-direction: column; height: 100dvh; }
.topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  padding-top: max(12px, env(safe-area-inset-top));
}
.topo-info { display: flex; align-items: center; gap: 10px; }
#apelido { color: var(--muted); font-size: 14px; }
.badge {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-transform: uppercase;
}
.badge.on { background: rgba(34,197,94,.15); color: var(--green); }
.badge.off { background: rgba(148,163,184,.15); color: var(--muted); }

#mapa { flex: 1; min-height: 240px; background: #0d1320; }

/* Painel inferior */
.painel {
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; text-align: center;
}
.stat label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat b { display: block; font-size: 18px; margin-top: 2px; }
.stat small { color: var(--muted); font-size: 11px; }

.endereco {
  font-size: 13px; color: var(--muted); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; line-height: 1.4;
}

.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--txt); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.ghost.ativo { border-color: var(--brand); color: var(--brand); }
.btn.perigo { background: var(--red); border: none; color: #fff; }
.btn.ok { background: var(--green); border: none; color: #04240f; }

.estado-bloqueio { text-align: center; font-weight: 700; font-size: 15px; min-height: 0; }
.estado-bloqueio.bloqueado { color: var(--red); }
.estado-bloqueio.liberado { color: var(--green); }

.eventos { font-size: 13px; }
.eventos summary { color: var(--muted); cursor: pointer; padding: 4px 0; }
.eventos ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 160px; overflow: auto; }
.eventos li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.eventos li span { color: var(--muted); margin-right: 6px; }

/* Pino do carro no mapa */
.carro-pin {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(34,197,94,.18); border: 2px solid var(--c, var(--green));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 4px rgba(34,197,94,.12);
}
.carro-seta { color: var(--c, var(--green)); font-size: 18px; line-height: 1; transition: transform .4s ease; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 9999;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px;
}
.modal-card h2 { margin: 0 0 10px; font-size: 19px; }
.modal-card p { color: var(--txt); line-height: 1.5; margin: 0 0 18px; }
.modal-acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Telas maiores: mapa e painel lado a lado */
@media (min-width: 860px) {
  #app { flex-direction: row; }
  .topo { position: fixed; top: 0; left: 0; right: 0; z-index: 500; }
  #mapa { margin-top: 56px; }
  .painel {
    width: 380px; margin-top: 56px; border-top: none; border-left: 1px solid var(--line);
    overflow: auto;
  }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
