:root {
    --azul: #1a56db;
    --azul-escuro: #123a91;
    --verde: #2e7d32;
    --vermelho: #e53935;
    --cinza-bg: #f4f6f9;
    --cinza-borda: #dbe1e8;
    --texto: #1f2937;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--cinza-bg);
    color: var(--texto);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Topbar */
.topbar {
    background: var(--azul-escuro);
    color: #fff;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.brand { color: #fff; font-weight: bold; font-size: 1.2em; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: #e5edff; text-decoration: none; font-size: 0.95em; }
.topbar nav a:hover { text-decoration: underline; }
.user-info { color: #b9c9f5; font-size: 0.9em; }
.btn-sair {
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 6px;
}

/* Auth */
.auth-box {
    max-width: 380px;
    margin: 40px auto;
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.auth-box h1 { margin-top: 0; text-align: center; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.9em; }

form label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 0.9em; }
form input[type=text], form input[type=email], form input[type=password] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--cinza-borda);
    border-radius: 6px;
    font-size: 1em;
}

.btn-primary {
    margin-top: 20px;
    width: 100%;
    background: var(--azul);
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
}
.btn-primary:hover { background: var(--azul-escuro); }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.92em; }
.alert-erro { background: #fdecea; color: #b71c1c; border: 1px solid #f5c6cb; }
.alert-sucesso { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.alert-info { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }

/* Cards / veículos */
.card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}
.form-actions { display: flex; align-items: flex-end; }

.tabela { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.92em; }
.tabela th, .tabela td { padding: 10px; border-bottom: 1px solid var(--cinza-borda); text-align: left; }
.tabela th { background: #f0f3f8; }
.acoes a { margin-right: 10px; color: var(--azul); text-decoration: none; }
.link-perigo { color: var(--vermelho) !important; }

.badge { padding: 3px 10px; border-radius: 12px; font-size: 0.8em; }
.badge-ativo { background: #e8f5e9; color: var(--verde); }
.badge-inativo { background: #f5f5f5; color: #757575; }

/* Mapa */
.mapa-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    height: 75vh;
}
.painel-veiculos {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    overflow-y: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.item-veiculo {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--cinza-bg);
    cursor: pointer;
    font-size: 0.9em;
}
.item-veiculo:hover { background: #e5edff; }
.item-veiculo .meta { color: #555; font-size: 0.85em; margin-top: 4px; }

/* Status online/offline */
.item-veiculo-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.status-online.online { background: #e8f5e9; color: var(--verde); }
.status-online.offline { background: #f5f5f5; color: #9e9e9e; }
.status-online .ponto {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.status-online.online .ponto {
    animation: pulso-online 1.6s infinite;
}
@keyframes pulso-online {
    0% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(46, 125, 50, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
}

.btn-historico {
    margin-top: 8px;
    width: 100%;
    background: #fff;
    border: 1px solid var(--azul);
    color: var(--azul);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.82em;
    cursor: pointer;
}
.btn-historico:hover { background: #e5edff; }

/* Modal de histórico */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-caixa {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.modal-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.modal-cabecalho h3 { margin: 0; }
.btn-fechar {
    background: none;
    border: none;
    font-size: 1.6em;
    line-height: 1;
    cursor: pointer;
    color: #777;
}
.btn-fechar:hover { color: #000; }

#mapa {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.pin-veiculo {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.footer {
    text-align: center;
    color: #888;
    font-size: 0.85em;
    padding: 20px;
}

@media (max-width: 800px) {
    .mapa-layout { grid-template-columns: 1fr; height: auto; }
    #mapa { height: 400px; }
    .painel-veiculos { max-height: 260px; }
}
