:root {
    --navy: #0b1f3a;
    --navy-2: #123056;
    --ink: #0f172a;
    --paper: #e8eef6;
    --accent: #2563eb;
    --accent-2: #0ea5e9;
    --danger: #dc2626;
    --ok: #059669;
    --warn: #d97706;
    --font-display: "Outfit", "Segoe UI", sans-serif;
    --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

html, body {
    min-height: 100%;
    background:
        radial-gradient(900px 420px at 0% 0%, rgba(37, 99, 235, 0.12), transparent 55%),
        radial-gradient(700px 380px at 100% 0%, rgba(14, 165, 233, 0.10), transparent 50%),
        var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
}

.frota-top {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: linear-gradient(90deg, #071526 0%, var(--navy) 45%, #0a2748 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 0;
    z-index: 200;
    overflow: visible;
}
.frota-top__bar {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 8px 18px;
}
.frota-top__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 0 0 auto;
}
.frota-top__brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.frota-top__logo {
    display: block;
    max-height: 40px;
    max-width: 160px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.frota-top__brand i { font-size: 1.4rem; color: #7dd3fc; }
.frota-top__brand small {
    display: block;
    opacity: 0.72;
    font-size: 0.72rem;
}
@media (max-width: 1280px) {
    .frota-top__brand small,
    .frota-top__user-name {
        display: none !important;
    }
}
.frota-top__nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 18px;
    overflow: visible;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(0, 0, 0, 0.12);
}
.frota-top__link {
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    font-family: var(--font-display);
    white-space: nowrap;
    flex: 0 0 auto;
}
.frota-top__link:hover, .frota-top__link.is-active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.frota-top__dropdown {
    position: relative;
    flex: 0 0 auto;
    z-index: 210;
}
.frota-top__dropdown > .frota-top__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.frota-top__caret {
    font-size: 0.65rem;
    opacity: 0.75;
}
.frota-top__cascade {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 5000;
    min-width: 12rem;
    padding: 6px;
    border-radius: 10px;
    background: #0f2744;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255,255,255,0.12);
    flex-direction: column;
    gap: 4px;
}
.frota-top__dropdown.is-open > .frota-top__cascade,
.frota-top__cascade.is-open {
    display: flex;
}
.frota-top__cascade-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 9px 11px;
    border-radius: 8px;
    white-space: nowrap;
    font-family: var(--font-display);
    background: transparent;
}
.frota-top__cascade-link:hover,
.frota-top__cascade-link.is-active {
    background: rgba(255,255,255,0.14);
    color: #fff;
}
.header-app__sistemas {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 2px;
    margin-left: 0;
    padding: 2px;
    border-radius: 999px;
    background: #f4f7fc;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-app__sistemas::-webkit-scrollbar { display: none; }
.header-app__sistema-btn {
    border: 0;
    background: transparent;
    color: #0b3d91;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    line-height: 1.2;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
}
.header-app__sistema-btn.is-active {
    background: #d6e4fb;
    color: #0b3d91;
}
a.header-app__sistema-btn:hover {
    background: #dbe7fb;
    color: #082f73;
}
.frota-top__user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    flex: 0 0 auto;
}
.frota-top__user-name {
    text-align: right;
    line-height: 1.15;
}
.frota-top__user-name small {
    display: block;
    color: rgba(255,255,255,0.55);
    font-size: 0.72rem;
}
.frota-main { padding-bottom: 40px; }

.kpi {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(11, 31, 58, 0.06);
}
.kpi strong { font-size: 1.7rem; font-family: var(--font-display); }
.kpi span { color: #64748b; font-size: 0.85rem; }
.kpi.alert-kpi { border-left: 4px solid var(--danger); }

.card-frota {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(11, 31, 58, 0.05);
}
.badge-status-em_viagem { background: #2563eb; }
.badge-status-disponivel { background: #059669; }
.badge-status-manutencao { background: #d97706; }
.badge-status-inativo { background: #64748b; }
.badge-brudam {
    background: #0f766e;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.alerta-row {
    border-left: 4px solid var(--danger);
    animation: pulse-red 1.6s ease-in-out infinite;
}
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.pneu-grid {
    display: grid;
    grid-template-columns: 1fr 70px 1fr;
    gap: 8px;
    max-width: 420px;
    margin: 0 auto;
}
.pneu-slot {
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    background: #f8fafc;
    min-height: 72px;
}
.pneu-slot.critico { border-color: var(--danger); background: #fef2f2; }
.pneu-slot .pos { font-weight: 700; font-size: 0.78rem; color: #64748b; }

.foto-ficha {
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
}
.foto-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: middle;
}

.cal-cell {
    min-height: 118px;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 6px 8px;
    vertical-align: top;
    width: 14.285%;
}
.cal-cell.hoje { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell.fora { background: #f1f5f9; opacity: 0.7; }
.cal-day { display: block; margin-bottom: 4px; }
.agenda-page { width: 100%; max-width: 100%; }
.agenda-cal-wrap { width: 100%; }
.agenda-cal {
    width: 100%;
    table-layout: fixed;
    margin-bottom: 0;
}
.agenda-cal th {
    text-align: center;
    width: 14.285%;
    background: #f8fafc;
}
.ev-chip {
    display: block;
    font-size: 0.72rem;
    border-radius: 6px;
    padding: 2px 6px;
    margin-top: 4px;
    color: #fff;
    text-decoration: none;
}
.ev-preventiva { background: #2563eb; }
.ev-preditiva { background: #7c3aed; }
.ev-corretiva { background: #dc2626; }
.ev-legal { background: #0f766e; }

.km-cronometro {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 18px;
    background: #f8fafc;
    text-align: center;
}
.km-cronometro-ok { border-left: 5px solid #16a34a; }
.km-cronometro-atencao { border-left: 5px solid #d97706; background: #fffbeb; }
.km-cronometro-critica,
.km-cronometro-vencida { border-left: 5px solid #dc2626; background: #fef2f2; }
.km-cronometro-label { font-size: 0.9rem; margin-bottom: 4px; }
.km-cronometro-valor {
    font-family: var(--font-display);
    font-size: 2.4rem;
    line-height: 1.1;
    font-weight: 700;
}
.km-cronometro-unidade { color: #64748b; font-size: 0.9rem; }
.km-cronometro dl { text-align: left; }

.contrato-time {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 18px;
    background: #f8fafc;
    text-align: center;
    margin-bottom: 1rem;
}
.contrato-time-compact { padding: 12px 14px; margin-bottom: 1rem; }
.contrato-time-ok { border-left: 5px solid #16a34a; }
.contrato-time-atencao { border-left: 5px solid #d97706; background: #fffbeb; }
.contrato-time-critica,
.contrato-time-vencido { border-left: 5px solid #dc2626; background: #fef2f2; }
.contrato-time-aguardando { border-left: 5px solid #2563eb; background: #eff6ff; }
.contrato-time-sem_contrato { border-left: 5px solid #94a3b8; }
.contrato-time-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 2px;
}
.contrato-time-valor {
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1.15;
    font-weight: 700;
}
.contrato-time-compact .contrato-time-valor { font-size: 1.45rem; }
.contrato-time-unidade { color: #64748b; font-size: 0.9rem; }
.contrato-time dl { text-align: left; margin-top: 8px; }

body.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #071526 0%, #123056 50%, #0b3a6a 100%);
}
.login-card {
    width: min(440px, 92vw);
    background: #fff;
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}
.login-card h1 { font-family: var(--font-display); font-size: 1.45rem; }

#mapa-torre { height: 480px; border-radius: 14px; }
.mapa-torre-wrap { position: relative; }
.consulta-placa input { width: 10.5rem; }
.consulta-placa-card {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 500;
    width: min(320px, calc(100% - 24px));
    background: rgba(255,255,255,0.96);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px 16px;
    box-shadow: 0 12px 28px rgba(15,23,42,0.16);
}
.consulta-placa-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 2px;
}
.consulta-placa-placa {
    display: block;
    font-family: var(--font-display);
    font-size: 1.45rem;
    letter-spacing: 0.08em;
    color: #0b1f3a;
}
.consulta-placa-dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin: 12px 0;
}
.consulta-placa-dl dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0;
}
.consulta-placa-dl dd { margin: 0; font-weight: 600; }
.consulta-placa-end {
    border-top: 1px solid #e2e8f0;
    margin-top: 4px;
    padding-top: 10px;
}
.consulta-placa-fechar {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: transparent;
    font-size: 1.3rem;
    line-height: 1;
    color: #64748b;
}
#tabelaFrota tr.is-consulta {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
    background: #eff6ff;
}
.veiculo-marker.is-foco .veiculo-marker__placa {
    background: #1d4ed8;
    color: #fff;
}

.veiculo-icon {
    background: none !important;
    border: none !important;
}
.veiculo-marker {
    position: relative;
    width: 48px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}
.veiculo-marker__halo {
    position: absolute;
    top: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.35);
    box-shadow: 0 0 16px 6px rgba(56, 189, 248, 0.45);
    opacity: 0;
}
.veiculo-marker.is-vivo .veiculo-marker__halo {
    opacity: 1;
    animation: veiculo-halo 1.8s ease-in-out infinite;
}
.veiculo-marker.is-movimento .veiculo-marker__halo {
    background: rgba(52, 211, 153, 0.4);
    box-shadow: 0 0 18px 7px rgba(52, 211, 153, 0.5);
}
.veiculo-marker__spin {
    width: 28px;
    height: 44px;
    transform-origin: 50% 58%;
    transition: transform 0.6s ease;
    filter: drop-shadow(0 3px 3px rgba(15, 23, 42, 0.45));
}
.veiculo-marker__bob { width: 28px; height: 44px; }
.veiculo-marker.is-movimento .veiculo-marker__bob {
    animation: veiculo-bob 0.7s ease-in-out infinite;
}
.veiculo-marker__spin svg { width: 28px; height: 44px; display: block; }
.veiculo-marker__placa {
    margin-top: 1px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #0f172a;
    background: rgba(255,255,255,0.92);
    border-radius: 4px;
    padding: 0 4px;
    line-height: 1.3;
    box-shadow: 0 1px 3px rgba(15,23,42,0.2);
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@keyframes veiculo-halo {
    0%, 100% { transform: scale(0.75); opacity: 0.7; }
    50% { transform: scale(1.35); opacity: 0.15; }
}
@keyframes veiculo-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

.table thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; }

.campo-wrap { max-width: 640px; }
.campo-qr-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 32px;
}
.campo-qr-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(90deg, #071526 0%, var(--navy) 100%);
    color: #fff;
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 16px;
}
.campo-qr-kicker {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    opacity: 0.75;
    margin-bottom: 2px;
}
.campo-chk-grid {
    display: grid;
    gap: 10px;
}
.campo-chk-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    min-height: 56px;
}
.campo-chk-item.is-critico { border-color: #fecaca; background: #fff7f7; }
.campo-chk-item .form-check-input {
    width: 1.4rem;
    height: 1.4rem;
    margin-top: 0.15rem;
}
.campo-chk-item .btn-group .btn { font-weight: 600; }
.campo-chk-item .btn-check:checked + .btn-outline-success { background: #059669; color: #fff; }
.campo-chk-item .btn-check:checked + .btn-outline-danger { background: #dc2626; color: #fff; }

body.campo-page.device-phone .frota-top,
body.campo-page.device-tablet .frota-top__nav {
    display: none;
}
@media (max-width: 767.98px) {
    body.campo-page .frota-top { display: none !important; }
    body.campo-page .frota-main { padding-bottom: 24px; }
    .campo-qr-shell { padding: 12px 12px 28px; }
    .form-control-lg, .form-select-lg, .btn-lg { min-height: 48px; }
}
@media (min-width: 768px) {
    body.device-tablet .campo-chk-grid,
    body.device-desktop .campo-chk-grid { grid-template-columns: 1fr 1fr; }
    .campo-qr-shell { max-width: 960px; padding-top: 24px; }
}
body.login-page.device-phone .login-card,
body.login-page.device-tablet .login-card {
    max-width: 100%;
    margin: 16px;
    box-shadow: none;
}
.km-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
}
.km-tile span { display: block; font-size: 0.78rem; color: #64748b; }
.km-tile strong { font-size: 1.35rem; font-family: var(--font-display); }
.km-tile-patio { border-color: #7dd3fc; background: #f0f9ff; }
.km-tile-patio strong { color: #0369a1; }
.qr-pin-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    max-width: 240px;
}
.qr-ficha {
    width: 148px;
    height: 148px;
}
.qr-ficha svg {
    width: 140px;
    height: 140px;
    display: block;
}
.qr-pin-digitos {
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.28em;
    display: block;
    color: #0b1f3a;
}
.qr-pin-input {
    font-size: 2rem;
    letter-spacing: 0.4em;
    font-family: var(--font-display);
}
.campo-qr-escolha {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 42vh;
    padding: 8px 0 24px;
}
.campo-qr-escolha .btn {
    width: min(100%, 420px);
    min-height: 72px;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 16px;
}
.campo-camera-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.campo-camera-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}
.km-foto {
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}
.status-ok { color: var(--ok); }
.status-atencao { color: var(--warn); }
.status-critica, .status-vencida { color: var(--danger); font-weight: 700; }
.btn-navy {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.btn-navy:hover { background: var(--navy-2); color: #fff; }

.doc-arquivo-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.doc-arquivo-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.82rem;
}
.doc-arquivo-link:hover .doc-arquivo-pdf {
    background: #fee2e2;
}
body.doc-viewer-open {
    overflow: hidden;
}
.doc-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #071018;
    display: flex;
    flex-direction: column;
}
.doc-viewer[hidden] {
    display: none !important;
}
.doc-viewer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #0b1f3a;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.doc-viewer__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}
.doc-viewer__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.doc-viewer__stage {
    flex: 1;
    min-height: 0;
    background: #111827;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.doc-viewer__stage iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}
.doc-viewer__stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: auto;
}
@media print {
    body.doc-viewer-open .frota-top,
    body.doc-viewer-open .frota-main,
    body.doc-viewer-open .doc-viewer__bar {
        display: none !important;
    }
    body.doc-viewer-open .doc-viewer {
        position: static;
        background: #fff;
    }
    body.doc-viewer-open .doc-viewer__stage {
        height: 100vh;
        background: #fff;
    }
}

/* Entrada dual + portal motorista */
.entrada-shell {
  max-width: 52rem;
  margin: 3rem auto;
  padding: 0 1rem;
  text-align: center;
}
.entrada-card {
  display: block;
  text-align: left;
  text-decoration: none;
  color: inherit;
  padding: 1.5rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: linear-gradient(160deg, #f8fafc 0%, #eef2ff 100%);
  transition: transform .15s ease, box-shadow .15s ease;
  min-height: 10rem;
}
.entrada-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
  color: inherit;
}
.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}
.portal-nav a {
  text-decoration: none;
  color: #475569;
  font-weight: 600;
  padding: .35rem 0;
}
.portal-nav a.is-active,
.portal-nav a:hover {
  color: #0f172a;
}
.portal-tile {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-height: 8.5rem;
}
.portal-tile i {
  font-size: 1.4rem;
  color: #2563eb;
}
.portal-tile strong { font-size: 1.05rem; }
.portal-tile span { color: #64748b; font-size: .9rem; }
.portal-tile:hover {
  border-color: #93c5fd;
  color: inherit;
}
