/* app.css — identidade visual espelhando o app (AppColors) */

:root {
    --primary:        #07275A;
    --primary-dark:   #0F2554;
    --secondary:      #499C2A;
    --bg:             #F5F7FA;
    --surface:        #FFFFFF;
    --surface-variant:#F0F2F5;
    --error:          #E53935;
    --text:           #1A202C;
    --text-muted:     #718096;
    --orange:         #FF9800;
    --teal:           #042D3D;
    --divider:        #E2E8F0;
    --radius:         16px;
    --shadow:         0 2px 10px rgba(7, 39, 90, .08);
}

/* ---------- Tema escuro — mesma paleta do app nativo (ui/Theme.kt,
   AppColorsDark), pra ficar visualmente igual entre appweb e nativo.
   Ativado via [data-theme="dark"] no <html> (ver assets/js/tema.js). ---------- */
:root[data-theme="dark"] {
    --primary:        #5B8DEF;
    --primary-dark:   #3D6BC4;
    --secondary:      #66D944;
    --bg:             #121212;
    --surface:        #1E1E1E;
    --surface-variant:#252525;
    --error:          #FF7070;
    --text:           #ECECEC;
    --text-muted:     #9E9E9E;
    --orange:         #FFB74D;
    --teal:           #80DEEA;
    --divider:        #333333;
    --shadow:         0 2px 10px rgba(0, 0, 0, .3);
}

/* Componentes com cor "fundo do card" fixa em #fff (deveriam ter usado
   var(--surface) desde o início) — sem isso ficam brancos em cima de página
   escura. Login fica de fora de propósito: sem sessão ainda, não tem o botão
   de tema, então sempre abre no claro. */
:root[data-theme="dark"] .campo-input,
:root[data-theme="dark"] .campo-select,
:root[data-theme="dark"] .campo-textarea,
:root[data-theme="dark"] .campo-label,
:root[data-theme="dark"] .tipo-pneu-select {
    /* #2A2A2A é o fundo de input do nativo no escuro (ui/Theme.kt,
       darkTextFieldColors()/surfaceVariant) — diferente do --surface geral
       (#1E1E1E), que é só pra cards. */
    background: #2A2A2A;
}
:root[data-theme="dark"] .campo-input,
:root[data-theme="dark"] .campo-select,
:root[data-theme="dark"] .campo-textarea,
:root[data-theme="dark"] .tipo-pneu-select {
    border-color: #555555; /* darkTextFieldColors().unfocusedBorderColor */
}
:root[data-theme="dark"] .status-vazia { background: var(--surface-variant); }
:root[data-theme="dark"] .status-ico-vazia { color: var(--text-muted); }
:root[data-theme="dark"] .status-vazia-sub { color: var(--text-muted); }

/* Topbar e barra inferior: no nativo, no escuro, NÃO seguem a paleta geral
   (não viram um gradiente azul/verde claro) — usam essa cor de "chrome"
   fixa, igual DashboardScreen.kt e DashboardBottomBar.kt. */
:root[data-theme="dark"] .app-topbar {
    background: #1A1A2E;
}
:root[data-theme="dark"] .bottom-nav {
    background: #1A1A2E;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Desliga o "puxar pra atualizar" nativo do navegador/PWA. Sem internet
       (ou com internet ruim), esse gesto só recarrega e trava a tela — não
       tem substituto próprio nosso nem confiança nenhuma em quando ele existe. */
    overscroll-behavior-y: contain;
}

.container-narrow {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Barra superior ---------- */
.app-topbar {
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    padding: 14px 0;
    box-shadow: 0 2px 12px rgba(7, 39, 90, .25);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-greeting { font-size: 1.05rem; font-weight: 600; }
.topbar-title    { font-size: 1.05rem; font-weight: 600; }
.topbar-btn {
    color: #fff;
    width: 48px; height: 48px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1.5rem;
    background: none; border: none;
    -webkit-tap-highlight-color: transparent;
}
/* Sem fundo fixo, igual ao app (só o ícone) — feedback rápido só ao tocar/clicar */
.topbar-btn:active { background: rgba(255, 255, 255, .15); color: #fff; }
@media (hover: hover) {
    .topbar-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
}
/* Traço mais grosso no ícone (sem aumentar o tamanho) — Bootstrap Icons só tem
   um peso, então "engordamos" o glifo com um contorno fino da própria cor. */
.topbar-btn i { -webkit-text-stroke: .6px currentColor; }
.topbar-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--warning, #E6A100); color: #fff;
    border-radius: 8px; font-size: .62rem; font-weight: 700; line-height: 16px;
    display: inline-flex; align-items: center; justify-content: center;
}
#topbar-sync-icon.girando { animation: trakvia-spin .9s linear infinite; }
@keyframes trakvia-spin { to { transform: rotate(360deg); } }

/* ---------- Aviso "logado como administrador" (impersonação a partir do admin) ---------- */
.impersonando-bar {
    background: var(--orange);
    color: #fff;
    font-size: .84rem;
    font-weight: 600;
    padding: 9px 0;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.impersonando-voltar {
    display: inline-flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    background: rgba(255,255,255,.18);
    padding: 4px 12px;
    border-radius: 20px;
    transition: background .15s;
    flex-shrink: 0;
}
.impersonando-voltar:active,
.impersonando-voltar:hover { background: rgba(255,255,255,.3); color: #fff; }

.app-main   { flex: 1 0 auto; padding: 20px 16px 32px; }
.app-footer { padding: 16px 0; color: var(--text-muted); font-size: .8rem; }

/* ---------- Botões de menu (cards) ---------- */
.menu-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 18px;
    margin-bottom: 14px;
    text-decoration: none;
    color: var(--text);
    width: 100%;
    transition: transform .12s ease, box-shadow .12s ease;
}
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(7, 39, 90, .14); color: var(--text); }
.menu-card .ico {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.menu-card .label { font-weight: 600; font-size: 1.02rem; }
.menu-card .bi-chevron-right { margin-left: auto; color: var(--text-muted); }

/* CTA destaque (Iniciar Viagem) */
.cta-card {
    background: linear-gradient(135deg, var(--secondary) 0%, #3C8222 100%);
    color: #fff;
}
.cta-card .label, .cta-card .bi-chevron-right { color: #fff; }
.cta-card .ico { background: rgba(255, 255, 255, .2); }

/* ---------- Login (idêntico ao app) ---------- */
.login-body { background: var(--primary); }
.login-screen {
    min-height: 100vh; min-height: 100dvh;
    background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex; flex-direction: column;
}
.login-col {
    flex: 1 0 auto;
    width: 100%; max-width: 460px; margin: 0 auto;
    display: flex; flex-direction: column; align-items: center;
    padding: 24px;
}
.login-header {
    color: rgba(255, 255, 255, .85);
    font-size: 1rem;
    margin: 64px 0 32px;
}
.login-card {
    width: 100%;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    padding: 24px;
}
.login-card-title {
    font-size: 1.25rem; font-weight: 600; color: var(--text);
    text-align: center; margin-bottom: 22px;
}
.login-rodape {
    color: rgba(255, 255, 255, .6);
    font-size: .75rem;
    margin-top: auto; padding-top: 24px;
}

/* Campos com ícone à esquerda */
.input-icon .input-group-text {
    background: #fff; border-right: none;
    color: var(--primary);
}
.input-icon .form-control {
    border-left: none; padding-left: 4px;
}
.input-icon .form-control:focus {
    box-shadow: none; border-color: #ced4da;
}
.input-icon:focus-within .input-group-text,
.input-icon:focus-within .form-control {
    border-color: var(--primary);
}
.input-icon .check-cnpj { background: #fff; border-left: none; color: var(--secondary); }
.input-icon .toggle-senha { background: #fff; border-left: none; color: var(--text-muted); cursor: pointer; }
.input-group.input-icon { border-radius: 12px; }
.input-icon .input-group-text:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.input-icon .form-control:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

/* Botão ENTRAR */
.btn-entrar {
    background: var(--primary); color: #fff;
    border: none; border-radius: 12px;
    height: 52px; font-weight: 700; font-size: 1rem; letter-spacing: .04em;
}
.btn-entrar:hover { background: var(--primary-dark); color: #fff; }
.btn-entrar:disabled { opacity: .7; }

.form-label { font-weight: 600; font-size: .85rem; color: var(--text); }
.form-control { border-radius: 12px; padding: 12px 14px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(7, 39, 90, .15); }

.btn-primary {
    background: var(--primary); border-color: var(--primary);
    border-radius: 12px; padding: 12px; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.alert { border-radius: 12px; }

/* ---------- Estado "em construção" ---------- */
.em-construcao {
    text-align: center; color: var(--text-muted);
    padding: 48px 16px;
}
.em-construcao .bi { font-size: 3rem; color: var(--divider); display: block; margin-bottom: 12px; }

/* ---------- Autocomplete de empresa no login ---------- */
#resultados {
    position: absolute;
    left: 0; right: 0;
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
    border-radius: 12px;
}
#resultados .list-group-item-action { cursor: pointer; }

/* ---------- Lista de viagens (cartão com editar/excluir/ações, igual ao app) ---------- */
.trip-card {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    color: var(--text);
    border-left: 4px solid var(--primary);
}
.trip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trip-dest { font-weight: 600; }
.trip-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: .85rem; margin-top: 6px; }
.trip-frete { margin-top: 8px; font-weight: 700; color: var(--secondary); }

.trip-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 10px; }
.trip-field-label { font-size: .72rem; color: var(--text-muted); }
.trip-field-value { font-weight: 600; font-size: .92rem; }
.trip-field-value.destaque { color: var(--orange); }

.trip-divider { border: none; border-top: 1px solid var(--divider); margin: 14px 0; }

/* Botões de ação do cartão — estilo próprio (não depende do .btn do Bootstrap) */
.trip-actions { display: flex; gap: 8px; }
.trip-actions form { flex: 1; margin: 0; display: flex; }
.btn-card-acao {
    width: 100%;
    height: 45px;
    border: none; border-radius: 10px;
    font-weight: 700; font-size: .9rem;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: filter .12s ease;
}
.btn-card-acao:hover { filter: brightness(1.08); }
.btn-card-acao:active { filter: brightness(.95); }
.btn-editar  { background: var(--primary); color: #fff; }
.btn-excluir { background: var(--error);   color: #fff; }
.btn-acoes {
    width: 100%; margin-top: 8px; height: 50px;
    background: #8B5CF6; color: #fff;
}
.btn-acoes:hover { filter: brightness(1.08); color: #fff; }

.badge { font-weight: 600; font-size: .72rem; padding: .35em .6em; border-radius: 8px; }
.badge-ok        { background: rgba(73,156,42,.15); color: #357a1c; }
.badge-andamento { background: rgba(255,152,0,.18);  color: #b46e00; }

/* ---------- Blocos de detalhe ---------- */
.card-bloco {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.bloco-titulo { font-weight: 700; color: var(--primary); }
.dl-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--divider); }
.dl-row:last-child { border-bottom: none; }
.dl-k { color: var(--text-muted); font-size: .9rem; }
.dl-v { font-weight: 600; text-align: right; }
.dl-v-alerta { color: #C0392B; }
.dl-saldo { border-top: 2px solid var(--divider); border-bottom: none; margin-top: 4px; padding-top: 8px; }
.dl-saldo .dl-k, .dl-saldo .dl-v { font-size: 1.05rem; color: var(--secondary); font-weight: 700; }
.dl-saldo.dl-saldo-negativo .dl-k, .dl-saldo.dl-saldo-negativo .dl-v { color: var(--error); }

/* ---------- Grade de ações ---------- */
.acoes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.acao {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
    padding: 14px 6px; text-decoration: none; color: var(--text);
    font-size: .78rem; font-weight: 600; text-align: center;
    transition: transform .12s ease;
}
.acao:hover { transform: translateY(-2px); color: var(--primary); }
.acao i { font-size: 1.5rem; color: var(--primary); }
@media (max-width: 360px) { .acoes-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Viagem em andamento (bloqueio) ---------- */
.andamento-card { border-top: 4px solid var(--orange); }

/* ---------- Avisos do Dashboard (CNH vencendo, manutenção programada) ---------- */
.aviso-card {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface-variant);
    border-left: 4px solid var(--orange);
}
.aviso-card.aviso-erro { border-left-color: var(--error); }
.aviso-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: .92rem;
    color: var(--orange);
}
.aviso-card.aviso-erro .aviso-card-head { color: var(--error); }
.aviso-card-linha { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }
.aviso-card-mais { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.andamento-ico { font-size: 3rem; color: var(--orange); }
.andamento-titulo { color: var(--orange); font-weight: 700; font-size: 1.35rem; margin-top: 8px; }
.andamento-info {
    background: var(--surface-variant);
    border-radius: 12px; padding: 14px; margin-top: 8px;
}

/* ---------- Upload de foto ---------- */
.foto-area {
    border: 2px dashed var(--divider);
    border-radius: 14px;
    background: var(--surface-variant);
    cursor: pointer;
    overflow: hidden;
    min-height: 150px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .15s ease;
}
.foto-area:hover { border-color: var(--primary); }
.foto-placeholder {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    color: var(--primary); font-weight: 600; padding: 24px;
}
.foto-placeholder i { font-size: 2.6rem; }
.foto-preview { width: 100%; max-height: 320px; object-fit: contain; display: block; }

/* ---------- Card de status da viagem (dashboard) ---------- */
.status-card {
    display: block;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    text-decoration: none;
    color: var(--text);
}
.status-ativa {
    background: rgba(73,156,42,.10);
    border: 1px solid rgba(73,156,42,.25);
    transition: transform .12s ease;
}
.status-ativa:hover { transform: translateY(-2px); color: var(--text); }
.status-ico { font-size: 1.5rem; color: var(--secondary); }
.status-label { font-size: .8rem; color: var(--text-muted); }
.status-dest { font-weight: 700; color: var(--secondary); font-size: 1.05rem; }
.status-id { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.status-extra { margin-top: 8px; color: var(--text-muted); font-size: .8rem; }

/* Viagem iniciada offline, ainda não sincronizada — mesmo cartão de "em
   andamento", mas não é um link (não existe id real pra abrir viagem.php
   ainda) e ganha um aviso de que está aguardando conexão. */
.status-offline-pendente { cursor: default; }
.status-offline-pendente:hover { transform: none; }
.status-offline-pendente .status-extra { color: #b46e00; }

.status-vazia { background: #FAFAFA; border: 1px dashed var(--divider); padding: 22px 16px; }
.status-ico-vazia { font-size: 2.4rem; color: #CBD5E0; }
.status-vazia-titulo { font-weight: 600; color: var(--text-muted); margin-top: 8px; }
.status-vazia-sub { font-size: .8rem; color: #BDBDBD; }

/* ---------- Botões de opção (tipo de pagamento) ---------- */
.opcoes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opcao-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border: 2px solid var(--divider); background: var(--surface);
    border-radius: 12px; padding: 12px; font-weight: 600; color: var(--text);
    cursor: pointer; transition: all .12s ease;
}
.opcao-btn.ativo { border-color: var(--primary); background: rgba(7,39,90,.06); color: var(--primary); }
.opcao-btn i { font-size: 1.1rem; }

/* ---------- Barra de navegação inferior (só na tela inicial) ---------- */
.app-main.com-bottom-nav { padding-bottom: 88px; }   /* espaço para a barra fixa */

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 64px;
    background: var(--primary);
    box-shadow: 0 -2px 12px rgba(0,0,0,.18);
    display: flex;
    z-index: 200;
    max-width: 520px; margin: 0 auto;
}
.bn-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    background: none; border: none;
    color: rgba(255,255,255,.7);
    font-size: .69rem; font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    padding: 6px 2px;
    transition: color .12s ease;
}
.bn-item i { font-size: 1.5rem; }
.bn-item.ativo { color: #fff; }
.bn-item.ativo i {
    background: rgba(255,255,255,.2);
    border-radius: 14px;
    padding: 2px 14px;
}
.bn-item:active { color: #fff; }

/* Menu de despesas (dropup) */
.desp-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.35);
    z-index: 210;
}
.desp-menu {
    position: fixed; left: 0; right: 0; bottom: 64px;
    max-width: 520px; margin: 0 auto;
    background: var(--surface);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    box-shadow: 0 -6px 24px rgba(7,39,90,.18);
    z-index: 220;
    padding: 8px 0;
    animation: slideUp .18s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.desp-menu a {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 22px;
    color: var(--text); text-decoration: none; font-weight: 600;
}
.desp-menu a:hover { background: var(--surface-variant); }
.desp-menu a i { font-size: 1.3rem; color: var(--primary); width: 24px; text-align: center; }

/* ---------- Toggle de campos opcionais ---------- */
.toggle-extra {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-variant);
    border: 1px solid var(--divider);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--primary); font-weight: 600;
    cursor: pointer;
}
.toggle-chevron { transition: transform .2s ease; }
.toggle-chevron.aberto { transform: rotate(180deg); }

.form-switch .form-check-input { width: 2.6em; height: 1.4em; cursor: pointer; }
.form-check-input:checked { background-color: var(--secondary); border-color: var(--secondary); }

/* ---------- Lista de despesas ---------- */
.grupo-titulo {
    font-weight: 700; color: var(--primary);
    font-size: .82rem; text-transform: uppercase; letter-spacing: .03em;
    margin: 16px 2px 8px;
}
.desp-item {
    display: flex; flex-direction: column;
    background: var(--surface); border-radius: 12px;
    box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 8px;
}
.desp-item-row { display: flex; align-items: center; gap: 10px; }
.desp-item-info { flex: 1; min-width: 0; }
.desp-item-titulo { font-weight: 600; }
.desp-item-sub { font-size: .8rem; color: var(--text-muted); }
.desp-item-valor { font-weight: 700; color: var(--text); white-space: nowrap; }

/* Editar/Excluir por lançamento — só quando a viagem está em andamento, igual ao app */
.desp-item-acoes {
    display: flex; justify-content: flex-end; gap: 18px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--divider);
}
.desp-item-acoes form { margin: 0; }
.desp-acao {
    display: inline-flex; align-items: center; gap: 5px;
    background: none; border: none; padding: 4px;
    font-weight: 600; font-size: .85rem;
    text-decoration: none; cursor: pointer;
}
.desp-acao.editar  { color: var(--primary); }
.desp-acao.excluir { color: var(--error); }

/* ---------- Checklist ---------- */
.check-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 2px; border-bottom: 1px solid var(--divider);
    cursor: pointer; margin: 0;
}
.check-row:last-child { border-bottom: none; }
.check-row span { font-size: .95rem; }
.check-row .form-check-input { width: 1.5em; height: 1.5em; margin: 0; flex-shrink: 0; }

/* ---------- Relatório ---------- */
.rel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.rel-cell { background: var(--surface-variant); border-radius: 12px; padding: 14px 6px; }
.rel-num { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.rel-lbl { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ====================================================================
   Campo de formulário igual ao app (ícone + label flutuante + outline)
   ==================================================================== */
.campo { position: relative; margin-bottom: 16px; }
.campo-ico {
    position: absolute; left: 14px; top: 27px; transform: translateY(-50%);
    color: var(--primary); font-size: 1.15rem; z-index: 2; pointer-events: none;
}
.campo-input, .campo-select, .campo-textarea {
    width: 100%;
    border: 1.5px solid var(--divider);
    border-radius: 12px;
    background: #fff; color: var(--text);
    font-size: 1rem; line-height: 1.3;
    padding: 16px 14px 16px 44px;
    outline: none;
    transition: border-color .15s ease;
    -webkit-appearance: none; appearance: none;
}
.campo-textarea { min-height: 88px; resize: vertical; }
.campo-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.campo-input:focus, .campo-select:focus, .campo-textarea:focus { border-color: var(--primary); }
.campo-input:focus ~ .campo-ico, .campo-select:focus ~ .campo-ico, .campo-textarea:focus ~ .campo-ico { color: var(--primary); }

.campo-label {
    position: absolute; left: 40px; top: 27px; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1rem;
    background: #fff; padding: 0 5px;
    pointer-events: none; z-index: 1;
    transition: top .15s ease, left .15s ease, font-size .15s ease, color .15s ease;
    max-width: calc(100% - 56px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Flutua quando focado ou preenchido (texto) */
.campo-input:focus ~ .campo-label,
.campo-input:not(:placeholder-shown) ~ .campo-label,
.campo-textarea:focus ~ .campo-label,
.campo-textarea:not(:placeholder-shown) ~ .campo-label {
    top: 0; left: 38px; font-size: .76rem; color: var(--primary);
}
/* Select e date: label sempre flutuada (não têm placeholder-shown) */
.campo.up .campo-label { top: 0; left: 38px; font-size: .76rem; }
.campo.up .campo-input:focus ~ .campo-label,
.campo.up .campo-select:focus ~ .campo-label { color: var(--primary); }
/* Textarea: ícone no topo */
.campo.area .campo-ico { top: 22px; }
.campo.area .campo-label { top: 22px; }
.campo.area .campo-textarea:focus ~ .campo-label,
.campo.area .campo-textarea:not(:placeholder-shown) ~ .campo-label { top: 0; }

/* ===== Camada offline: badge de pendências + avisos ===== */
.offline-badge {
    position: fixed;
    right: 16px;
    bottom: 80px;
    z-index: 1080;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    background: #07275A;
    box-shadow: 0 6px 18px rgba(7, 39, 90, .35);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: badge-in .25s ease;
}
.offline-badge.tem-erro { background: #E53935; box-shadow: 0 6px 18px rgba(229, 57, 53, .35); }
.offline-badge .spinner-border { width: 1rem; height: 1rem; }
@keyframes badge-in { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.offline-toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translate(-50%, 20px);
    z-index: 1090;
    max-width: 90vw;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 500;
    color: #fff;
    background: #1A202C;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    text-align: center;
}
.offline-toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline-toast.ok { background: #499C2A; }
.offline-toast.erro { background: #E53935; }

/* ===== Modal de mensagem (sucesso/erro) — igual ao AlertDialog do app nativo ===== */
.tk-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1300;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    animation: tk-modal-fade .15s ease;
}
@keyframes tk-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.tk-modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px 24px 20px;
    max-width: 340px; width: 100%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
    animation: tk-modal-pop .18s ease;
}
@keyframes tk-modal-pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tk-modal-icon { font-size: 2.5rem; margin-bottom: 8px; }
.tk-modal-titulo { font-weight: 700; font-size: 1.15rem; margin-bottom: 10px; }
.tk-modal-mensagem { color: var(--text); font-size: .95rem; line-height: 1.45; margin-bottom: 20px; white-space: pre-line; }
.tk-modal-botoes { display: flex; flex-direction: column; gap: 10px; }
.tk-modal-ok {
    width: 100%; border: none; border-radius: 8px;
    padding: 12px; font-weight: 700; color: #fff; font-size: .95rem;
    cursor: pointer;
}
.tk-modal-secundario {
    width: 100%; border-radius: 8px; padding: 11px;
    font-weight: 700; font-size: .95rem; cursor: pointer;
    background: none; border: 1.5px solid var(--divider); color: var(--text);
}

/* ---------- Modal de pendências (fila offline) ---------- */
.tk-pend-modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    max-width: 420px; width: 100%;
    max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
    animation: tk-modal-pop .18s ease;
}
.tk-pend-titulo { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
.tk-pend-sub { color: var(--text-muted); font-size: .82rem; margin-bottom: 14px; }
.tk-pend-lista { overflow-y: auto; flex: 1; margin-bottom: 14px; }
.tk-pend-vazio { text-align: center; color: var(--text-muted); font-size: .88rem; padding: 24px 0; }
.tk-pend-item {
    border: 1px solid var(--divider);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.tk-pend-item.erro { border-color: var(--error); background: rgba(229, 57, 53, .06); }
.tk-pend-item-topo { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tk-pend-tipo { font-weight: 700; font-size: .88rem; }
.tk-pend-badge {
    font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
    background: var(--surface-variant); color: var(--text-muted);
}
.tk-pend-item.erro .tk-pend-badge { background: var(--error); color: #fff; }
.tk-pend-data { color: var(--text-muted); font-size: .76rem; margin-top: 2px; }
.tk-pend-erro-msg { color: var(--error); font-size: .78rem; margin-top: 6px; }
.tk-pend-descartar {
    border: none; background: none; color: var(--error);
    font-size: .78rem; font-weight: 700; padding: 6px 0 0; cursor: pointer;
}
.tk-pend-botoes { display: flex; flex-direction: column; gap: 10px; }

/* ===== Diagrama de chassi para troca de pneu (igual ao app) ===== */
.chassi-wrap {
    background: #111827;
    border-radius: 16px;
    padding: 18px 10px;
    display: flex; flex-direction: column; align-items: center;
}
.eixo-label { color: #9CA3AF; font-size: .72rem; margin-bottom: 4px; }
.eixo-separador { color: #9CA3AF; font-size: .68rem; margin: 4px 0; }
.eixo { display: flex; align-items: center; width: 100%; max-width: 280px; justify-content: space-between; }
.eixo-simples { padding: 0 12px; }
.eixo-barra { flex: 1; height: 12px; margin: 0 6px; background: #4B5563; border-radius: 6px; }
.eixo-conexao { width: 8px; height: 18px; background: #374151; }
.pneu-par { display: flex; gap: 4px; }
.pneu {
    width: 32px; height: 50px;
    border-radius: 8px;
    background: #1F2937; border: 2px solid #374151; color: #fff;
    font-size: .72rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: background .12s ease, border-color .12s ease;
}
.pneu.selecionado { background: #3B82F6; border-color: #1D4ED8; }

.tipo-pneu-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tipo-pneu-label { width: 68px; flex-shrink: 0; font-weight: 600; font-size: .9rem; color: var(--text); }
.tipo-pneu-select {
    flex: 1; border: 1.5px solid var(--divider); border-radius: 10px;
    padding: 10px 12px; font-size: .95rem; background: #fff; color: var(--text);
}
.tipo-pneu-select:focus { border-color: var(--primary); outline: none; }
