/* ============================================================
   SGR-Condo Dashboard - Dark + Green Theme (Uber-like)
   ============================================================ */

/* ---- Reset ------------------------------------------------ */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Variaveis -------------------------------------------- */
:root {
    --primary:         #39B560;
    --primary-light:   #34D399;
    --primary-soft:    rgba(0, 200, 83, 0.12);
    --primary-dark:    #39B560;

    --secondary:       #3B82F6;
    --secondary-soft:  rgba(59, 130, 246, 0.10);

    /* Cores SEMANTICAS de badge/status — TEMA CLARO (default).
       Texto escuro o suficiente para bom contraste sobre os fundos translucidos.
       O tema escuro re-mapeia para tons mais claros/neon em [data-theme="dark"]. */
    --badge-success-fg: #1E7E40;   /* verde escuro (Ativa, Online, Movendo) */
    --badge-warning-fg: #92600A;   /* ambar escuro (Parado, Bateria baixa) */
    --badge-danger-fg:  #C0392B;   /* vermelho escuro (Critico, 0%, Offline grave) */
    --badge-info-fg:    #2563EB;   /* azul (Em trajeto) */
    --badge-neutral-fg: #475569;   /* cinza-azulado (Inativa, Desconhecido) */

    /* Sidebar / header — valores do TEMA CLARO (default).
       O tema escuro re-mapeia tudo em [data-theme="dark"]. */
    --sidebar-bg:      #FFFFFF;
    --sidebar-text:    #1A2634;          /* texto/icone do item */
    --sidebar-text-strong: #0F1A2A;      /* item em hover/ativo */
    --sidebar-muted:   #6C7A8A;          /* titulos de secao */
    --sidebar-hover:   rgba(15,26,42,0.05);
    --sidebar-active:  rgba(57,181,96,0.12);
    --sidebar-border:  #E9EDF2;

    --header-bg:       #FFFFFF;
    --header-text:     #1A2634;
    --header-border:   #E9EDF2;

    /* light canvas */
    --neutral-100:     #FFFFFF;
    --neutral-200:     #F5F7FA;
    --neutral-300:     #E9EDF2;
    --neutral-400:     #CAD1D9;
    --neutral-500:     #8B93A1;
    --neutral-600:     #6C7A8A;
    --neutral-700:     #4A5568;
    --neutral-800:     #1A2634;
    --neutral-900:     #0F1A2A;

    /* overlays dark */
    --dark-card:       #232323;
    --dark-card-soft:  #1A1F26;

    --shadow-sm:       0 1px 2px rgba(15,17,21,0.06);
    --shadow-md:       0 4px 12px rgba(15,17,21,0.08);
    --shadow-lg:       0 20px 40px -12px rgba(15,17,21,0.15);
    --shadow-focus:    0 0 0 3px var(--primary-soft);

    --radius-sm:       8px;
    --radius-md:       10px;
    --radius-lg:       16px;
    --transition:      all 0.15s ease;
}

/* ---- Base ------------------------------------------------- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--neutral-200);
    min-height: 100vh;
    color: var(--neutral-900);
    line-height: 1.5;
}

/* ---- Scrollbar ------------------------------------------- */
html { scrollbar-gutter: stable; }
html, body, .sidebar {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar { width: 8px; height: 8px; }
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 999px;
    transition: background-color 0.22s ease-in-out;
}
html:hover::-webkit-scrollbar-thumb,
body:hover::-webkit-scrollbar-thumb {
    background-color: var(--neutral-400);
}
.sidebar:hover::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.25);
}

h1, h2, h3 { font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif; }
h1 { font-weight: 700; font-size: 1.75rem; letter-spacing: -0.02em; color: var(--neutral-900); margin-bottom: 0.4rem; }
h2 { font-weight: 700; font-size: 1.4rem;  letter-spacing: -0.02em; color: var(--neutral-900); margin-bottom: 0.4rem; }
h3 { font-weight: 600; font-size: 1.15rem; color: var(--neutral-900); }

/* ---- Utilities -------------------------------------------- */
.text-center            { text-align: center; }
.d-flex                 { display: flex; }
.justify-content-center { justify-content: center; }
.align-items-center     { align-items: center; }
.gap-3  { gap: 1rem; }
.mt-3   { margin-top: 1rem; }
.mb-3   { margin-bottom: 1rem; }
.mb-4   { margin-bottom: 1.5rem; }
.w-100  { width: 100%; }
.hidden { display: none !important; }

/* ---- Animation -------------------------------------------- */
.fade-in { animation: fadeSlideIn 0.35s ease forwards; }
@keyframes fadeSlideIn {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ---- Inputs ----------------------------------------------- */
.input-premium {
    border: 1.5px solid var(--neutral-300);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    font-size: 0.92rem;
    min-height: 38px;
    background: #fff;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.02);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    color: var(--neutral-900);
}
.input-premium:hover { border-color: var(--neutral-400); }
.input-premium:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}
.input-premium::placeholder { color: var(--neutral-500); font-weight: 400; }

/* ---- Buttons ---------------------------------------------- */
.btn-modern {
    border-radius: var(--radius-md);
    padding: 0.6rem 1.05rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #fff;
    color: var(--neutral-800);
    border: 1px solid var(--neutral-300);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-decoration: none;
}
.btn-modern i { font-size: 1rem; display: inline-block; }
.btn-modern:hover {
    transform: translateY(-1px);
    border-color: var(--neutral-400);
    color: var(--neutral-900);
    text-decoration: none;
}
.btn-modern:disabled,
.btn-modern[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}
.btn-primary-modern {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;
}
.btn-primary-modern:hover { background: #2e9c50; border-color: #2e9c50; color: #fff; transform: translateY(-1px); }
.btn-secondary-modern { background: var(--secondary); border: 1px solid var(--secondary); color: #fff; }
.btn-secondary-modern:hover { background: #2563eb; border-color: #2563eb; color: #fff; transform: translateY(-1px); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-danger-modern { background: #dc3545; border: 1px solid #dc3545; color: #fff; }
.btn-danger-modern:hover { background: #c82333; border-color: #c82333; color: #fff; transform: translateY(-1px); }

/* Botao-icone (acoes de tabela): transparente, redondo, sem borda */
.btn-icon, .data-table .actions .btn-modern.btn-icon {
    background: transparent;
    border: 0;
    padding: 0.5rem;
    border-radius: 50%;
    box-shadow: none;
    color: var(--neutral-600);
}
.btn-icon:hover {
    background: var(--neutral-200);
    border: 0;
    color: var(--primary);
    transform: none;
}

/* ---- Alerts ----------------------------------------------- */
.alert-danger { background: #fee2e2; color: #991b1b; padding: 0.75rem 1.1rem; border-radius: 10px; border: 1px solid #fecaca; }

/* ---- Form label ------------------------------------------- */
.form-label { font-weight: 500; color: var(--neutral-800); margin-bottom: 0.4rem; display: block; font-size: 0.85rem; }

/* ---- Layout ----------------------------------------------- */
#app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--neutral-200);
}

/* ---- Top Header (DARK) ------------------------------------ */
.top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    /* Acima do bloqueio de etapa (.setup-lock=1050) para que o dropdown do
       usuario/notificacoes (filhos do header, presos no stacking context dele)
       fiquem por cima do overlay. Abaixo dos modais (2000), que devem cobrir
       tudo. O header ocupa só os 60px do topo, entao nao atrapalha o conteudo. */
    z-index: 1200;
    gap: 1rem;
    color: var(--header-text);
}
.top-header .brand {
    font-weight: 700;
    font-size: 1.18rem;
    letter-spacing: -0.02em;
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.top-header .brand::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
}
.top-header .brand:hover { text-decoration: none; color: var(--primary); }
.top-header .spacer { flex: 1; }

.notif-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--header-text);
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
    opacity: 0.85;
}
.notif-btn:hover { background: var(--sidebar-hover); color: var(--primary); opacity: 1; }
.notif-badge {
    position: absolute;
    top: 0; right: 0;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 30px;
    transition: var(--transition);
    border: 1.5px solid transparent;
    user-select: none;
}
.user-menu:hover { background: var(--sidebar-hover); border-color: var(--sidebar-border); }
.user-menu .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.82rem;
    flex-shrink: 0;
    overflow: hidden;
}
.user-menu .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-menu .user-info { line-height: 1.2; }
.user-menu .user-info .uname { font-weight: 600; font-size: 0.85rem; color: var(--header-text); }
.user-menu .user-info .urole { font-size: 0.7rem; color: var(--sidebar-muted); }
/* Trigger "ativo" quando aberto: conectado ao popup logo abaixo (sem gap). */
.user-menu.open {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-border);
}
.user-menu .fa-chevron-down { color: var(--sidebar-muted); transition: transform 0.15s; }
.user-menu.open .fa-chevron-down { transform: rotate(180deg); color: var(--primary); }

/* Dropdown "saindo do header": encostado na base do header (top = altura do
   header), sem gap, borda/sombra coerentes com o trigger ativo. */
.user-dropdown {
    position: fixed;
    top: 60px;
    right: 1rem;
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 250px;
    z-index: 1100;
    padding: 0.4rem;
    animation: dropdownIn 0.15s ease;
}
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Cabecalho do dropdown: avatar + nome + cargo (SEM email). */
.user-dropdown-header {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.7rem 0.7rem;
}
.user-dropdown-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem; flex-shrink: 0; overflow: hidden;
}
.user-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-dropdown-meta { display: flex; flex-direction: column; min-width: 0; }
.user-dropdown-meta strong { font-size: 0.9rem; color: var(--neutral-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown-meta small { font-size: 0.75rem; color: var(--neutral-600); text-transform: capitalize; }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--neutral-800);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}
.user-dropdown-item:hover { background: var(--neutral-200); text-decoration: none; }
.user-dropdown-item i { width: 16px; text-align: center; color: var(--neutral-600); }
.user-dropdown-item--danger { color: #dc3545; }
.user-dropdown-item--danger i { color: #dc3545; }
.user-dropdown-item--danger:hover { background: #fff0f1; color: #dc3545; }
.user-dropdown-divider { height: 1px; background: var(--neutral-300); margin: 0.3rem 0; }

/* ---- Seletor de tema (controle segmentado Claro | Escuro) --- */
.theme-row { gap: 0.6rem; }
.theme-seg {
    display: flex;
    flex: 1;
    gap: 0.25rem;
    padding: 0.2rem;
    background: var(--neutral-200);
    border: 1px solid var(--neutral-300);
    border-radius: 999px;
}
.theme-seg-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--neutral-600);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.theme-seg-btn i { width: auto; color: inherit; }
.theme-seg-btn:hover { color: var(--neutral-900); }
.theme-seg-btn.is-active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.theme-seg-btn.is-active:hover { color: #fff; }
html[data-theme="dark"] .theme-seg { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
html[data-theme="dark"] .theme-seg-btn { color: rgba(255,255,255,0.6); }
html[data-theme="dark"] .theme-seg-btn:hover { color: #fff; }
html[data-theme="dark"] .theme-seg-btn.is-active { background: var(--primary); color: #fff; }

/* ---- Meu perfil (estilo pipedip: foto + form em grid) ------ */
.profile-card { max-width: 760px; }
.profile-body {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}
.profile-avatar-col {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.6rem; flex-shrink: 0; width: 160px;
}
.profile-avatar-preview {
    width: 96px; height: 96px;
    border-radius: 50%;
    background: var(--primary);
    border: 1.5px solid var(--neutral-300);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar-initials {
    color: #fff; font-weight: 700; font-size: 2rem; line-height: 1;
    text-transform: uppercase; letter-spacing: 0.02em;
}
.profile-avatar-actions { display: flex; flex-direction: column; gap: 0.4rem; width: 100%; }
.profile-avatar-actions .btn-modern { justify-content: center; }
.profile-avatar-hint { font-size: 0.72rem; color: var(--neutral-600); text-align: center; }

/* Form em GRID de 2 colunas quando ha largura (nao empilhar tudo alto). */
.profile-form-grid {
    flex: 1; min-width: 280px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.2rem;
    align-content: start;
}
.profile-form-grid .form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.profile-form-grid .form-label { font-size: 0.82rem; font-weight: 600; color: var(--neutral-700); }
.profile-form-grid .form-hint { font-size: 0.72rem; color: var(--neutral-600); }
.profile-role-tag {
    display: inline-flex; align-items: center; align-self: flex-start;
    padding: 0.35rem 0.7rem;
    background: var(--primary-soft); color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 600; text-transform: capitalize;
}
.profile-form-actions {
    grid-column: 1 / -1;
    display: flex; justify-content: flex-end; gap: 0.6rem;
    margin-top: 0.4rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--neutral-300);
}
.profile-form-grid input[disabled],
.profile-form-grid input[readonly] {
    background: var(--neutral-200);
    color: var(--neutral-600);
    cursor: not-allowed;
}
@media (max-width: 600px) {
    .profile-form-grid { grid-template-columns: 1fr; }
}

/* ---- Notifications dropdown ------------------------------- */
.notif-dropdown {
    position: fixed;
    top: 60px;
    right: 4.5rem;
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 360px;
    max-width: calc(100vw - 2rem);
    z-index: 1100;
    overflow: hidden;
    animation: dropdownIn 0.15s ease;
    display: flex; flex-direction: column;
    max-height: 70vh;
}
.notif-head {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--neutral-300);
    font-size: 0.95rem;
    color: var(--neutral-900);
}
.notif-head > strong { flex: 0 0 auto; }
/* Badge do contador de alertas abertos: mesmo estilo dos badges de status
   (fundo tingido suave + texto colorido, sem halo/sombra). Vazio = neutro;
   com itens = tom de aviso/perigo. */
.notif-head-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px;
    padding: 0 0.45rem; box-sizing: border-box;
    background: var(--neutral-200);
    color: var(--neutral-600);
    font-size: 0.72rem; font-weight: 600; line-height: 1;
    border-radius: 30px;
    transition: background .15s, color .15s;
}
.notif-head-count.has-items {
    background: rgba(220,53,69,0.12);
    color: var(--badge-danger-fg);
}
.notif-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; max-height: 420px; }
.notif-empty { padding: 1.4rem 1rem; text-align: center; color: var(--neutral-500); font-size: 0.85rem; }
/* Linha da notificacao: corpo clicavel (link) + botao de marcar lido. */
.notif-item {
    display: flex; align-items: stretch;
    border-bottom: 1px solid var(--neutral-200);
    transition: background 0.15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--neutral-100); }
.notif-item-link {
    display: flex; gap: 0.7rem; padding: 0.7rem 0.4rem 0.7rem 1rem;
    flex: 1 1 auto; min-width: 0;
    cursor: pointer; text-decoration: none; color: inherit;
}
.notif-item-link:hover { text-decoration: none; }
/* Botao "marcar lido" (check) */
/* Lixeira de "dispensar alerta": botao-icone limpo (sem caixa), hover vermelho. */
.notif-item-read {
    flex: 0 0 auto;
    align-self: center;
    width: 30px; height: 30px; margin: 0 0.5rem 0 0.2rem;
    border: 0; border-radius: 8px;
    background: transparent; color: var(--neutral-500);
    cursor: pointer; font-size: 0.85rem;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
}
.notif-item-read:hover { background: rgba(220,53,69,0.12); color: #dc3545; }
html[data-theme="dark"] .notif-item-read { color: rgba(255,255,255,0.5); }
html[data-theme="dark"] .notif-item-read:hover { background: rgba(248,113,113,0.16); color: #f87171; }
/* "Marcar todas como lidas" no cabecalho */
.notif-markall {
    border: 0; background: transparent; cursor: pointer;
    color: var(--primary); font-size: 0.74rem; font-weight: 600; font-family: inherit;
    padding: 0.15rem 0.3rem; border-radius: 6px; margin-left: auto;
}
.notif-markall:hover { text-decoration: underline; }
.notif-markall:disabled { color: var(--neutral-400); cursor: default; text-decoration: none; }
.notif-item-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0; margin-top: 0.45rem;
    background: var(--neutral-400);
}
.notif-item-dot.critical { background: #dc2626; box-shadow: 0 0 0 3px #fee2e2; }
.notif-item-dot.warning  { background: #ea580c; box-shadow: 0 0 0 3px #ffedd5; }
.notif-item-dot.info     { background: #2563eb; box-shadow: 0 0 0 3px #dbeafe; }
/* Icone das notificacoes de mencao (@) — circulo verde com a arroba. */
.notif-item-icon {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--success, #16a34a); color: #fff; font-size: 0.72rem;
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-weight: 600; font-size: 0.86rem; color: var(--neutral-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-meta  { font-size: 0.75rem; color: var(--neutral-500); margin-top: 0.15rem; }
.notif-item-meta strong { color: var(--neutral-700); font-weight: 600; }
.notif-foot {
    display: block;
    padding: 0.7rem 1rem;
    text-align: center;
    background: var(--neutral-100);
    border-top: 1px solid var(--neutral-300);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}
.notif-foot:hover { background: var(--neutral-200); text-decoration: none; }
@keyframes notifBlink {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.25); }
}
.notif-badge.bump { animation: notifBlink 0.4s ease; }

/* ---- Analytics page --------------------------------------- */
.ana-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.ana-kpi {
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    box-shadow: var(--shadow-sm);
}
.ana-kpi-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.ana-kpi-body { min-width: 0; flex: 1; }
.ana-kpi-label { font-size: 0.75rem; color: var(--neutral-600); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.ana-kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--neutral-900); margin-top: 0.15rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ana-kpi-sub   { font-size: 0.78rem; color: var(--neutral-500); margin-top: 0.1rem; }

.ana-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Heatmap hora x dia da semana */
.ana-heatgrid {
    display: grid;
    grid-template-columns: 36px repeat(24, 1fr);
    /* 1 linha de cabecalho (horas) + 7 linhas de dias que ESTICAM (1fr) para a
       grade preencher a altura do card em vez de ficar com celulas minusculas
       no topo e espaco vazio embaixo. */
    grid-template-rows: auto repeat(7, 1fr);
    gap: 3px;
    font-size: 0.7rem;
    height: 100%;
    min-height: 300px;
}
.ana-heatgrid .hh-day, .ana-heatgrid .hh-hour {
    color: var(--neutral-500);
    text-align: center;
    padding: 0.2rem 0;
    font-weight: 600;
}
.ana-heatgrid .hh-day { text-align: right; padding-right: 0.4rem; align-self: center; }
.ana-heatgrid .hh-cell {
    border-radius: 4px;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    transition: transform 0.1s;
    cursor: default;
    position: relative;
    min-height: 22px;
}
/* Celula com cor (ocorrencias > 0): a cor vem inline; remove a borda clara para
   o bloco ficar cheio e legivel. O JS define bordas so nas vazias via fundo. */
.ana-heatgrid .hh-cell[data-tooltip] { border-color: transparent; }
.ana-heatgrid .hh-cell:hover { transform: scale(1.5); z-index: 2; box-shadow: var(--shadow-md); }
.ana-heatgrid .hh-cell[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #1A1A1A;
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 3;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}
html[data-theme="dark"] .ana-heatgrid .hh-cell[data-tooltip]:hover::after {
    background: #2A2A2A;
    border-color: rgba(255,255,255,0.12);
}

@media (max-width: 1100px) {
    .ana-kpis { grid-template-columns: repeat(2, 1fr); }
    .ana-row-2col { grid-template-columns: 1fr; }
}

/* ---- Audit page ------------------------------------------- */
.audit-changes { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.audit-diff {
    display: inline-block;
    background: var(--neutral-100);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    color: var(--neutral-700);
    border: 1px solid var(--neutral-300);
}
.audit-diff strong { color: var(--neutral-900); font-weight: 600; }

.sidebar-toggle {
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: var(--header-text);
    padding: 6px; border-radius: 8px;
    transition: var(--transition);
    opacity: 0.85;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--primary); opacity: 1; }

/* ---- Sidebar (DARK) --------------------------------------- */
.sidebar {
    position: fixed;
    top: 60px; left: 0; bottom: 0;
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    transition: transform 0.25s ease, width 0.25s ease;
    z-index: 90;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    color: var(--sidebar-text);
}
.sidebar.collapsed { width: 60px; overflow: visible; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.75rem; }

.nav-section-title {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--sidebar-muted);
    padding: 1rem 1.2rem 0.4rem;
    display: block;
}
/* Com varias categorias, o 1o titulo (ou o 1o visivel apos os ocultos) nao
   precisa do respiro grande de topo. */
.nav-section-title:first-of-type { padding-top: 0.6rem; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.2rem;
    cursor: pointer;
    border-radius: 10px;
    margin: 0 0.5rem;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
    position: relative;
}
.nav-item i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.nav-item:hover i { opacity: 1; }
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--primary);
    border-left-color: var(--primary);
}
.nav-item.active i { opacity: 1; color: var(--primary); }

/* ---- Main Content ----------------------------------------- */
.main-content {
    margin-top: 60px;
    margin-left: 240px;
    padding: 1.5rem;
    transition: margin-left 0.25s ease;
    min-height: calc(100vh - 60px);
    /* overflow-x: clip (e nao hidden) contem o estouro horizontal SEM virar
       container de scroll — `hidden` quebraria `position: sticky` dos filhos
       (ex.: painel de variaveis em Configuracoes > Notificacoes). */
    overflow-x: clip;
}
.main-content.sidebar-collapsed { margin-left: 60px; }

/* ===== MODO TV / KIOSK do dashboard ====================================
   Esconde TODO o HUD (sidebar, header do app, cabecalho da pagina) e expande
   o conteudo para a tela inteira — visao limpa para colocar numa TV. */
.dash-kiosk .top-header,
.dash-kiosk .sidebar,
.dash-kiosk #page-dashboard .page-header { display: none !important; }
.dash-kiosk .main-content {
    margin: 0 !important;
    padding: 0.6rem !important;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}
/* So o dashboard fica visivel (as outras paginas ja sao .hidden, mas garante). */
.dash-kiosk .page-shell:not(#page-dashboard) { display: none !important; }
/* O dashboard preenche a altura total da TV. */
.dash-kiosk #page-dashboard { height: 100%; display: flex; flex-direction: column; }
/* Grid ESTICA para ocupar toda a tela: as linhas crescem (1fr) em vez de manter
   a altura fixa de 92px, eliminando o espaco vazio embaixo. A faixa de KPIs tem
   altura propria menor (--dash-h pequeno) e os demais blocos dividem o resto. */
.dash-kiosk #page-dashboard .dash-grid-12 {
    flex: 1 1 auto;
    min-height: 0;
    grid-auto-rows: minmax(0, 1fr);
    align-content: stretch;
}

/* Botao flutuante de SAIR do modo TV: invisivel fora do kiosk; aparece no canto
   superior direito quando em kiosk (com leve atenuacao ate o hover/foco). */
.dash-kiosk-exit { display: none; }
.dash-kiosk .dash-kiosk-exit {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 14px; right: 14px; z-index: 1200;
    width: 42px; height: 42px; border-radius: 50%;
    border: 1px solid var(--neutral-300);
    background: var(--neutral-100); color: var(--neutral-700);
    font-size: 1rem; cursor: pointer; opacity: 0.45;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.dash-kiosk .dash-kiosk-exit:hover,
.dash-kiosk .dash-kiosk-exit:focus { opacity: 1; background: var(--primary); color: #fff; border-color: var(--primary); }

/* Botao fantasma (icone) usado no header do card do mapa. */
.btn-icon-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid transparent; background: transparent;
    color: var(--neutral-600); cursor: pointer; font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.btn-icon-ghost:hover { background: var(--neutral-200); color: var(--neutral-900); }

/* ===== TELA CHEIA SO DO MAPA ===========================================
   O card do mapa cobre a viewport inteira; o resto do dashboard fica atras. */
.dash-map-full #dash-map-card {
    position: fixed; inset: 0; z-index: 1300;
    border-radius: 0; border: none; margin: 0;
    display: flex; flex-direction: column;
}
.dash-map-full #dash-map-card .content-card-body { flex: 1 1 auto; min-height: 0; }
.dash-map-full #dash-map-card #map { height: 100%; min-height: 0; }
/* Evita rolagem do fundo enquanto o mapa esta em tela cheia. */
.dash-map-full { overflow: hidden; }

/* ---- Page Header ------------------------------------------ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.page-header h2 { margin-bottom: 0; }

/* ---- Stat Cards ------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0;
}
/* KPIs da TAG (Distância/Duração/Vel./Bateria/Sinal): cards mais largos para o
   valor (ex.: "109.40 km") nao quebrar em duas linhas. */
#tag-detail-stats {
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}
#tag-detail-stats .stat-value { white-space: nowrap; }
.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 0.8rem 0.9rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--neutral-300);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary-light); }
.stat-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-icon.orange  { background: var(--primary-soft);    color: var(--primary); }
.stat-icon.blue    { background: var(--secondary-soft);  color: var(--secondary); }
.stat-icon.green   { background: var(--primary-soft);    color: var(--primary); }
.stat-icon.red     { background: rgba(220,53,69,0.10);   color: #dc3545; }
.stat-icon.yellow  { background: rgba(255,193,7,0.12);   color: #c79500; }
.stat-icon.purple  { background: rgba(111,66,193,0.10);  color: #6f42c1; }
.stat-value { font-weight: 700; font-size: 1.4rem; color: var(--neutral-900); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--neutral-600); margin-top: 2px; }
.stat-sub   { font-size: 0.72rem; color: var(--neutral-500); margin-top: 2px; }

/* ---- Content Card ----------------------------------------- */
.content-card {
    background: var(--neutral-100);
    border-radius: var(--radius-md);
    border: 1px solid var(--neutral-300);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.content-card-header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--neutral-300);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.content-card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.content-card-body { padding: 1rem; }

/* ---- Dashboard Grid --------------------------------------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0; }
.dash-grid .span-2 { grid-column: span 2; }
.dash-col-8-4 { display: grid; grid-template-columns: 2fr 1fr; gap: 0.75rem; margin-bottom: 0; }

/* ---- Table ------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    scrollbar-width: none;
}
.table-wrap::-webkit-scrollbar { height: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.table-wrap:hover::-webkit-scrollbar-thumb { background: var(--neutral-300); }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table thead th {
    padding: 0.6rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--neutral-600);
    background: var(--neutral-200);
    border-bottom: 1px solid var(--neutral-300);
    white-space: nowrap;
}
.data-table tbody tr {
    border-bottom: 1px solid var(--neutral-300);
    transition: background 0.15s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--neutral-200); }
.data-table td {
    padding: 0.55rem 1rem;
    color: var(--neutral-800);
    vertical-align: middle;
}
/* Gutter das colunas das pontas: o conteudo (e o cabecalho) nao encosta na
   borda do card. th e td recebem o MESMO recuo, mantendo titulo e dado
   alinhados na mesma coluna. Vale para todas as tabelas (.data-table). */
.data-table thead th:first-child,
.data-table tbody td:first-child { padding-left: 1.25rem; }
.data-table thead th:last-child,
.data-table tbody td:last-child { padding-right: 1.25rem; }
.data-table .actions { display: flex; gap: 0.3rem; justify-content: flex-end; }
/* O cabecalho da coluna "Ações" alinha a DIREITA para bater com os botoes
   (.actions sao right-aligned). Sem isso o titulo fica a esquerda e os botoes
   a direita na mesma coluna larga — parece "torto". Vale p/ todas as tabelas. */
.data-table thead th[data-i18n="th_acoes"] { text-align: right; }

/* ---- Badges ----------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;             /* espaco entre icone e texto */
    padding: 0.2rem 0.65rem;
    border-radius: 30px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-speed_violation    { background: rgba(220,53,69,0.12);   color: var(--badge-danger-fg); }
.badge-stop_detected      { background: rgba(240,193,75,0.16);  color: var(--badge-warning-fg); }
.badge-geofence_violation { background: rgba(111,66,193,0.12);  color: #7C4DCC; }
.badge-offline            { background: rgba(108,117,125,0.16); color: var(--badge-neutral-fg); }
.badge-low_battery        { background: rgba(240,193,75,0.16);  color: var(--badge-warning-fg); }
.badge-system             { background: rgba(108,117,125,0.16); color: var(--badge-neutral-fg); }
.badge-info           { background: var(--secondary-soft);  color: var(--badge-info-fg); }

/* Badge do plano atual (dropdown do usuario) — empurrado para a direita do item. */
.plan-badge {
    margin-left: auto;
    padding: 0.12rem 0.55rem;
    border-radius: 30px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.plan-badge--ok     { background: var(--primary-soft);      color: var(--badge-success-fg); }
.plan-badge--trial  { background: rgba(240,193,75,0.18);    color: var(--badge-warning-fg); }
.plan-badge--danger { background: rgba(220,53,69,0.14);     color: var(--badge-danger-fg); }

/* ---- Matriz de permissões (cargos + override por usuário) -------------
   "ver" = portão do recurso (linha destacada). "gerenciar" = ações que
   dependem do ver (indentadas; ficam esmaecidas/travadas quando o ver
   está desmarcado). Componente: public/assets/js/perm-matrix.js */
.perm-matrix {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.6rem;
}
.perm-card {
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: var(--neutral-100);
    padding: 0.6rem 0.7rem;
}
.perm-card-title {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--neutral-900);
    padding-bottom: 0.45rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--neutral-300);
}
.perm-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.28rem 0.15rem;
    font-size: 0.84rem;
    color: var(--neutral-800);
    cursor: pointer;
    border-radius: 6px;
}
.perm-row:hover { background: var(--neutral-200); }
.perm-row input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
/* Ações de gestão ficam indentadas sob o "ver". */
.perm-row--action { padding-left: 0.8rem; }
.perm-label { line-height: 1.25; }
/* Etiqueta ver / gerenciar */
.perm-kind {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.05rem 0.4rem;
    border-radius: 30px;
    flex-shrink: 0;
}
.perm-kind--view   { background: var(--secondary-soft); color: var(--badge-info-fg); }
.perm-kind--manage { background: var(--primary-soft);   color: var(--badge-success-fg); }
/* Ação travada porque o "ver" do recurso está desmarcado. */
.perm-row--disabled { opacity: 0.45; cursor: not-allowed; }
.perm-row--disabled:hover { background: transparent; }
.perm-row--disabled input,
.perm-row--disabled .perm-label { cursor: not-allowed; }

html[data-theme="dark"] .perm-card { background: var(--dark-card-soft); border-color: var(--neutral-300); }
html[data-theme="dark"] .perm-row:hover { background: rgba(255,255,255,0.05); }
.badge-warning        { background: rgba(240,193,75,0.16);  color: var(--badge-warning-fg); }
.badge-critical       { background: rgba(220,53,69,0.12);   color: var(--badge-danger-fg); }
.badge-moving         { background: var(--primary-soft);    color: var(--badge-success-fg); }
.badge-stopped        { background: rgba(240,193,75,0.16);  color: var(--badge-warning-fg); }
.badge-unknown        { background: rgba(108,117,125,0.16); color: var(--badge-neutral-fg); }
.badge-online         { background: var(--primary-soft);    color: var(--badge-success-fg); }
.badge-success        { background: var(--primary-soft);    color: var(--badge-success-fg); }
.badge-primary        { background: var(--secondary-soft);  color: var(--badge-info-fg); }
.badge-danger         { background: rgba(220,53,69,0.12);   color: var(--badge-danger-fg); }
.badge-secondary      { background: rgba(108,117,125,0.16); color: var(--badge-neutral-fg); }
.badge-active         { background: var(--primary-soft);    color: var(--badge-success-fg); }
.badge-inactive       { background: rgba(108,117,125,0.16); color: var(--badge-neutral-fg); }
/* TAG livre (disponivel, sem visita ativa): tom positivo discreto. */
.badge-free           { background: var(--primary-soft);    color: var(--badge-success-fg); gap: 0.3rem; }
.badge-free i         { font-size: 0.7rem; }

/* ---- Empty / Loading -------------------------------------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--neutral-600); }
.empty-state i { font-size: 3rem; opacity: 0.25; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: 0.95rem; }

.spinner {
    display: inline-block;
    width: 28px; height: 28px;
    border: 3px solid var(--neutral-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 2rem; }

/* ---- Skeleton loading (shimmer sutil estilo pipedip) ------------------- */
.skeleton {
    display: block;
    border-radius: 6px;
    background: var(--neutral-200);
    background-image: linear-gradient(
        90deg,
        var(--neutral-200) 0%,
        var(--neutral-300) 50%,
        var(--neutral-200) 100%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.2s ease-in-out infinite;
}
.skeleton-line {
    height: 0.85rem;
    width: 100%;
}
/* linha de tabela: cada td recebe uma barra .skeleton */
.skeleton-row td { padding: 0.55rem 1rem; border-bottom: 1px solid var(--neutral-300); }
.skeleton-block { height: 2.4rem; width: 100%; margin-bottom: 0.5rem; }
@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
html[data-theme="dark"] .skeleton {
    background: var(--neutral-200);
    background-image: linear-gradient(
        90deg,
        var(--neutral-200) 0%,
        var(--neutral-300) 50%,
        var(--neutral-200) 100%
    );
}
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

/* ---- Page shell ------------------------------------------- */
/* Sem `forwards`: o estado final da animacao (opacity:1; translateY(0)) e' igual
   ao default, entao apos rodar o elemento volta ao normal SEM `transform`
   residual. Isso e' importante porque um transform persistente cria containing
   block e quebra `position: sticky` dos filhos (ex.: painel de variaveis em
   Configuracoes > Notificacoes). */
.page-shell { display: flex; flex-direction: column; gap: 0.6rem; animation: fadeSlideIn 0.15s ease; }

/* ---- Activity Feed ---------------------------------------- */
/* Barra de filtro de alertas (quando um veiculo do tracker esta selecionado). */
.alerts-filter-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.4rem 0.6rem; margin-bottom: 0.4rem;
    background: var(--primary-soft); border: 1px solid var(--primary);
    border-radius: 8px; font-size: 0.76rem; color: var(--primary-dark, var(--primary)); font-weight: 600;
}
.alerts-filter-bar > span { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alerts-filter-clear {
    flex: none; background: none; border: none; cursor: pointer;
    color: var(--primary); font-weight: 700; font-size: 0.74rem; text-decoration: underline;
}
.activity-item { display: flex; gap: 0.75rem; padding: 0.7rem 0; border-bottom: 1px solid var(--neutral-300); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.activity-dot.critical { background: #dc3545; }
.activity-dot.warning  { background: #c79500; }
.activity-dot.info     { background: var(--secondary); }
.activity-info { flex: 1; }
.activity-action { font-weight: 600; font-size: 0.85rem; color: var(--neutral-800); }
.activity-meta   { font-size: 0.76rem; color: var(--neutral-600); margin-top: 2px; }

/* ---- Filter bar ------------------------------------------- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
    align-items: center;
}

/* ---- Modal ------------------------------------------------ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    /* ACIMA do Leaflet: as panes do mapa (.leaflet-pane=400) e os controles
       (.leaflet-control=1000) ficavam por cima do modal quando aberto sobre uma
       pagina com mapa (ex.: wizard sobre Vias internas). 2000 cobre tudo. */
    z-index: 2000;
    padding: 1rem;
    animation: fadeSlideIn 0.15s ease;
}
.modal-box {
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow: hidden;
    display: flex; flex-direction: column;
}
/* Modais densos (muitos campos): mais largura para distribuir em colunas */
.modal-box.modal-lg  { max-width: 760px; }
.modal-box.modal-xl  { max-width: 860px; }
.modal-box > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* Linha de formulario em grade: 2+ colunas em telas largas, 1 no mobile.
   Largura primeiro, altura depois (evita modais verticalmente longos). */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.85rem 1rem;
    align-items: start;
}
.form-row > .form-col-span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}
.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.1rem;
}
.modal-footer {
    flex-shrink: 0;
    padding: 0.85rem 1.1rem;
    border-top: 1px solid var(--neutral-300);
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}
.modal-footer .modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---- Toast ------------------------------------------------ */
#toast-container {
    position: fixed;
    top: 1.5rem; right: 1.5rem;
    z-index: 2100;   /* acima dos modais (2000) p/ toasts sempre visiveis */
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    /* Cor FIXA (nao usar --neutral-900: no tema escuro ele vira quase branco,
       deixando o toast 'info' branco-no-branco). Toast e overlay -> sempre escuro. */
    background: #1e2530;
    color: #fff;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    max-width: 320px;
    box-shadow: var(--shadow-md);
    animation: toastSlideIn 0.3s ease;
    display: flex; align-items: center; gap: 0.5rem;
}
/* Entrada deslizando de cima (combina com o ancoramento no topo direito). */
@keyframes toastSlideIn {
    0%   { opacity: 0; transform: translateY(-8px); }
    100% { opacity: 1; transform: translateY(0); }
}
/* Em telas estreitas, ocupa a largura disponivel sem encostar nas bordas. */
@media (max-width: 600px) {
    #toast-container { top: 1rem; right: 0.75rem; left: 0.75rem; }
    .toast { max-width: none; }
}
.toast.success { background: var(--primary); }
.toast.error   { background: #dc3545; }
.toast.warning { background: #c79500; }
.toast.info    { background: #1e2530; border-left: 3px solid var(--secondary); }

/* ---- Login Page (dark with green accent) ------------------ */
#login-screen, #signup-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem 1rem;
    background: radial-gradient(ellipse at top, #1A1F26 0%, #0B0D10 60%);
}
.login-card {
    max-width: 420px;
    width: 100%;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    animation: loginCardIn 0.3s ease both;
}
@keyframes loginCardIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .brand-name {
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.03em;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.login-logo .brand-name::before {
    content: '';
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--primary);
}
.login-logo p { color: var(--neutral-600); font-size: 0.95rem; margin-top: 0.4rem; }

/* Chip do condominio na tela de login (quando o slug vem da URL #/login/<slug>).
   Substitui o campo de digitacao: mostra qual condominio e um link "trocar". */
.login-tenant-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--neutral-300);
    border-radius: 12px;
    background: var(--neutral-100);
    font-size: 0.92rem;
    color: var(--neutral-700);
}
.login-tenant-chip > i { color: var(--primary); }
.login-tenant-chip-label { color: var(--neutral-500); }
.login-tenant-chip strong { color: var(--neutral-900); font-weight: 700; }
.login-tenant-switch {
    margin-left: auto;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.82rem;
    text-decoration: none;
    cursor: pointer;
}
.login-tenant-switch:hover { text-decoration: underline; }

/* ---- Form controls (app.css style) ------------------------ */
.form-control-app {
    width: 100%;
    border: 1.5px solid var(--neutral-300);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    font-size: 0.92rem;
    font-family: inherit;
    min-height: 38px;
    background: #fff;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.02);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    color: var(--neutral-800);
}
.form-control-app:hover { border-color: var(--neutral-400); }
.form-control-app:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); outline: none; }
.form-control-app::placeholder { color: var(--neutral-500); font-weight: 400; }
textarea.form-control-app { min-height: 80px; resize: vertical; }

/* Select nativo com seta SVG custom a direita (estilo pipedip) */
select.form-control-app {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238B93A1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}

/* ---- Parâmetros operacionais: layout em grade que usa a largura ---- */
.cfg-op-card { max-width: 920px; }
.cfg-op-form { display: flex; flex-direction: column; gap: 1.1rem; }
.cfg-op-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.85rem 1.1rem;
    align-items: start;
}
.cfg-op-grid--sep {
    border-top: 1px dashed var(--neutral-300);
    padding-top: 1rem;
}
.cfg-op-field { display: flex; flex-direction: column; min-width: 0; }
.cfg-op-field--wide { grid-column: 1 / -1; }
/* Inputs compactos nesta tela (menos altura morta na vertical). */
#page-settings-operacional .form-control-app { min-height: 34px; padding: 0.4rem 0.7rem; }
.cfg-op-hint {
    color: var(--neutral-500);
    font-size: 0.74rem;
    line-height: 1.35;
    margin-top: 0.3rem;
}

/* ---- Premium UI kit --------------------------------------- */
.premium-title-sub { font-size: 0.85rem; color: var(--neutral-500); font-weight: 400; }

.premium-search-shell {
    margin-bottom: 0.85rem;
    padding: 0.55rem;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: var(--neutral-100);
    box-shadow: var(--shadow-sm);
}
.premium-table-shell {
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.premium-table-shell .data-table thead th {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--neutral-600);
    background: #FAFBFD;
    border-bottom: 1px solid var(--neutral-300);
}
.premium-table-shell .data-table tbody tr:nth-child(odd) td { background-color: #FCFDFF; }
.premium-table-shell .data-table tbody tr:hover td { background-color: #F3F7FB; }

/* Botão X limpo dos modais (sem caixa em volta). */
.modal-x {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--neutral-600);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.05rem;
    line-height: 1;
    transition: background .15s, color .15s;
}
.modal-x:hover { background: var(--neutral-200); color: var(--neutral-900); }

/* Seletor de idioma no dropdown do usuario: compacto (nao usar .form-control-app,
   que e alto demais para o dropdown). */
.lang-select {
    flex: 1;
    margin-left: 0.5rem;
    min-height: 30px;
    padding: 0.25rem 1.8rem 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--neutral-800);
    background-color: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-sm);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.premium-date-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--neutral-300);
    background: var(--neutral-100);
    color: var(--neutral-700);
    font-size: 0.74rem;
    font-weight: 600;
}
/* Tema escuro: fundo grafite + texto claro para leitura nitida (antes ficava
   branco lavado com texto cinza). */
html[data-theme="dark"] .premium-date-pill {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.14);
    color: #e7e9ec;
}

/* ---- Map markers ------------------------------------------ */
.veh-marker {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}
.veh-marker.moving     { background: var(--primary); }
.veh-marker.stopped    { background: #3b82f6; }
.veh-marker.offline    { background: #6c757d; }
.veh-marker.unknown    { background: var(--secondary); }
.veh-marker.no_checkin { background: #9aa3ad; opacity: 0.85; border-style: dashed; }
.marker-overlay.no_checkin {
    background: #9aa3ad; color: #fff; padding: 2px 7px; border-radius: 12px;
    font-size: 0.65rem; font-weight: 700; white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: none; transform: none;   /* posicao so pelo wrapper (centrado sob o dot) */
}

/* ---- Pagination ------------------------------------------- */
.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--neutral-300);
    background: #fff;
    color: var(--neutral-800);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    padding: 0 0.55rem;
    cursor: pointer;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; pointer-events: none; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-ellipsis { padding: 0 0.3rem; color: var(--neutral-400); align-self: center; }
.pagination-summary {
    text-align: center;
    margin-top: 0.55rem;
    font-size: 0.8rem;
    color: var(--neutral-600);
}

/* ============================================================
   SweetAlert2 — overrides para combinar com tema dark+green
   ============================================================ */
/* O container do SweetAlert (toast e confirm) tem z-index 1060 por padrao —
   ABAIXO dos modais do sistema (.modal-overlay = 2000). Isso fazia o confirm
   (ex.: "Editar o sentido das ruas?") aparecer ATRAS de um modal aberto.
   Forca acima de tudo para que confirmacoes/toasts sempre fiquem por cima. */
.swal2-container { z-index: 100000 !important; }
.sgr-swal-popup {
    border-radius: var(--radius-lg) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    box-shadow: 0 30px 80px rgba(0,0,0,0.55) !important;
    font-family: 'Inter', system-ui, sans-serif !important;
}
.sgr-swal-title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 1.15rem !important;
}
.sgr-swal-html {
    color: rgba(255,255,255,0.78) !important;
    font-size: 0.92rem !important;
}
.sgr-swal-confirm,
.sgr-swal-cancel {
    border-radius: var(--radius-md) !important;
    padding: 0.6rem 1.05rem !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    border: 1px solid transparent !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
}
.sgr-swal-confirm:hover,
.sgr-swal-cancel:hover { transform: translateY(-1px); }
.sgr-swal-cancel {
    background: rgba(255,255,255,0.06) !important;
    color: rgba(255,255,255,0.85) !important;
    border-color: rgba(255,255,255,0.12) !important;
}
.swal2-icon.swal2-question     { border-color: var(--primary) !important; color: var(--primary) !important; }
.swal2-icon.swal2-warning      { border-color: #fbbf24 !important; color: #fbbf24 !important; }
.swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--primary) !important; }
.swal2-icon.swal2-success .swal2-success-ring { border-color: rgba(57,181,96,0.35) !important; }
.swal2-icon.swal2-error        { border-color: #dc3545 !important; color: #dc3545 !important; }
.swal2-icon.swal2-error [class^=swal2-x-mark-line] { background-color: #dc3545 !important; }
.swal2-icon.swal2-info         { border-color: var(--secondary) !important; color: var(--secondary) !important; }

/* ============================================================
   DASHBOARD — Vehicle list panel + map overlays
   ============================================================ */
/* === Grid fluido de 12 colunas (estilo pipedip) ===========================
   Cada bloco e' um filho direto e ocupa --dash-w colunas (1..12) por --dash-h
   unidades de linha. grid-auto-flow:dense faz os blocos refluirem p/ preencher
   buracos — entao ocultar/encolher um faz os demais (ex.: o mapa) crescerem,
   em vez de deixar espaco vazio. Cada bloco define seu span via variaveis CSS
   (setadas pelo JS a partir do layout salvo). */
.dash-grid-12 {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: var(--dash-row, 92px);
    grid-auto-flow: row dense;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 0;
}
.dash-grid-12 > .dash-block {
    grid-column: span var(--dash-w, 12);
    grid-row: span var(--dash-h, 4);
    min-width: 0; min-height: 0;
}
/* Blocos com conteudo rolavel: a lista/alertas rolam internamente (a PAGINA
   nao rola). */
.dash-grid-12 .vehicle-list-card .vlc-body,
.dash-grid-12 .dash-side-alerts .content-card-body { overflow-y: auto; }
.dash-grid-12 > .dash-side-alerts { display: flex; flex-direction: column; }
.dash-grid-12 > .dash-side-alerts .content-card-body { flex: 1; min-height: 0; }

.vehicle-list-card {
    background: var(--dark-card);
    color: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--sidebar-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    max-height: 348px;
}
.vehicle-list-card .vlc-header {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.7);
}
.vehicle-list-card .vlc-header .vlc-count {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}
.vehicle-list-card .vlc-body {
    overflow-y: auto;
    padding: 0.4rem;
    flex: 1;
}
.vehicle-list-card .vlc-body::-webkit-scrollbar { width: 6px; }
.vehicle-list-card .vlc-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }

.veh-card {
    display: flex;
    gap: 0.7rem;
    padding: 0.6rem 0.7rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    /* Estado NORMAL (nao selecionado): superficie sutil e legivel — nao "apagada".
       Fica claramente visivel sobre o painel escuro do tracker. */
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-left: 3px solid transparent;
    margin-bottom: 0.3rem;
}
.veh-card:hover {
    background: rgba(255,255,255,0.09);
    transform: translateX(2px);
}
/* SELECIONADO: destaque forte (mais claro + realce na cor primaria) para
   diferenciar bem do estado normal. */
.veh-card.active {
    background: rgba(57,181,96,0.16);
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-bottom-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}
.veh-card.alert-state-moving    { border-left-color: var(--primary); }
.veh-card.alert-state-stopped   { border-left-color: #c79500; }
.veh-card.alert-state-speeding  { border-left-color: #dc3545; }
.veh-card.alert-state-off_route { border-left-color: #fbbf24; }
.veh-card.alert-state-offline   { border-left-color: #6c757d; opacity: 0.7; }
.veh-card.alert-state-idle_out_zone { border-left-color: #dc2626; animation: idleCardBlink 1.4s ease-in-out infinite; }
@keyframes idleCardBlink {
    0%, 100% { background: transparent; }
    50%      { background: rgba(220,38,38,0.12); }
}

.veh-card .vc-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.veh-card.alert-state-moving    .vc-icon { background: rgba(0,200,83,0.2);  color: #34D399; }
.veh-card.alert-state-stopped   .vc-icon { background: rgba(255,193,7,0.2); color: #fbbf24; }
.veh-card.alert-state-speeding  .vc-icon { background: rgba(220,53,69,0.2); color: #ff6b6b; }
.veh-card.alert-state-off_route .vc-icon { background: rgba(251,191,36,0.2);color: #fbbf24; }
.veh-card.alert-state-offline   .vc-icon { background: rgba(108,117,125,0.2);color:#9ca3af; }
.veh-card.alert-state-idle_out_zone .vc-icon { background: rgba(220,38,38,0.22); color: #f87171; }

.veh-card .vc-info { flex: 1; min-width: 0; line-height: 1.3; }
.veh-card .vc-name {
    font-weight: 700;
    color: #fff;
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.veh-card .vc-plate {
    font-size: 0.74rem;
    color: rgba(255,255,255,0.55);
}
.veh-card .vc-meta {
    margin-top: 0.22rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}
.veh-card .vc-state-pill {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}
.veh-card.alert-state-moving    .vc-state-pill { background: rgba(0,200,83,0.18);  color: #34D399; }
.veh-card.alert-state-stopped   .vc-state-pill { background: rgba(255,193,7,0.18); color: #fbbf24; }
.veh-card.alert-state-speeding  .vc-state-pill { background: rgba(220,53,69,0.18); color: #ff6b6b; }
.veh-card.alert-state-off_route .vc-state-pill { background: rgba(251,191,36,0.18);color: #fbbf24; }
.veh-card.alert-state-offline   .vc-state-pill { background: rgba(108,117,125,0.2);color: #9ca3af; }
.veh-card.alert-state-idle_out_zone .vc-state-pill { background: rgba(220,38,38,0.2); color: #f87171; }

/* === Vehicle Tracker no TEMA CLARO =========================================
   O painel usa fundo escuro fixo (--dark-card) com texto branco, pensado para
   o tema escuro. No tema claro isso fica destoante (mancha escura). Aqui o
   painel vira uma superficie clara, com texto/bordas neutros, mantendo as
   cores de estado (verde/amarelo/vermelho) que funcionam nos dois temas.
   Escopo: tudo que NAO for [data-theme="dark"] (claro e o default do :root). */
html:not([data-theme="dark"]) .vehicle-list-card {
    background: var(--neutral-100);
    color: var(--neutral-900);
    border-color: var(--neutral-300);
}
html:not([data-theme="dark"]) .vehicle-list-card .vlc-header {
    border-bottom-color: var(--neutral-300);
    color: var(--neutral-600);
}
html:not([data-theme="dark"]) .vehicle-list-card .vlc-header .vlc-count {
    background: var(--neutral-200);
    color: var(--neutral-800);
}
html:not([data-theme="dark"]) .vehicle-list-card .vlc-body::-webkit-scrollbar-thumb {
    background: var(--neutral-400);
}
html:not([data-theme="dark"]) .veh-card:hover { background: var(--neutral-200); }
html:not([data-theme="dark"]) .veh-card.active {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
}
html:not([data-theme="dark"]) .veh-card .vc-icon { background: var(--neutral-200); }
html:not([data-theme="dark"]) .veh-card .vc-name  { color: var(--neutral-900); }
html:not([data-theme="dark"]) .veh-card .vc-plate { color: var(--neutral-600); }
html:not([data-theme="dark"]) .veh-card .vc-meta  { color: var(--neutral-500); }

/* Marker overlays no mapa (velocidade / timer / desvio) */
.marker-overlay {
    background: #0F1419;
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.35);
    border: 1.5px solid;
    pointer-events: none;
    transform: translate(0, -10px);
}
.marker-overlay.speeding  { border-color: #dc3545; color: #ff6b6b; }
.marker-overlay.off_route { border-color: #fbbf24; color: #fbbf24; }
.marker-overlay.stopped   { border-color: #6c757d; color: #d1d5db; }

/* Pill de qualidade do sinal LoRa (popup do mapa + detalhes da TAG). */
.signal-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.signal-pill.signal-excellent { background: rgba(0,200,83,0.15);   color: #00C853; border-color: rgba(0,200,83,0.4); }
.signal-pill.signal-good      { background: rgba(33,150,243,0.15); color: #2196F3; border-color: rgba(33,150,243,0.4); }
.signal-pill.signal-fair      { background: rgba(251,191,36,0.18); color: #b45309; border-color: rgba(251,191,36,0.5); }
.signal-pill.signal-poor      { background: rgba(220,53,69,0.15);  color: #dc3545; border-color: rgba(220,53,69,0.4); }
.signal-pill.signal-unknown   { background: rgba(108,117,125,0.15); color: #6c757d; border-color: rgba(108,117,125,0.4); }

.veh-marker.speeding  { background: #dc3545; animation: pulseRed 1.6s infinite; }
.veh-marker.off_route { background: #fbbf24; }
@keyframes pulseRed {
    0%   { box-shadow: 0 0 0 0    rgba(220,53,69,0.55), 0 4px 12px rgba(0,0,0,0.25); }
    70%  { box-shadow: 0 0 0 10px rgba(220,53,69,0),    0 4px 12px rgba(0,0,0,0.25); }
    100% { box-shadow: 0 0 0 0    rgba(220,53,69,0),    0 4px 12px rgba(0,0,0,0.25); }
}

/* TAG SEM check-in FORA da zona da portaria: marcador vermelho PISCANDO (anel
   pulsante + leve piscada de opacidade) para chamar atenção no mapa ao vivo. */
.veh-marker.idle_out_zone {
    background: #dc2626;
    border-color: #fff;
    animation: idleOutZonePulse 1.1s infinite, idleOutZoneBlink 1.1s steps(1) infinite;
    z-index: 1000;
}
@keyframes idleOutZonePulse {
    0%   { box-shadow: 0 0 0 0    rgba(220,38,38,0.75), 0 4px 12px rgba(0,0,0,0.3); }
    70%  { box-shadow: 0 0 0 16px rgba(220,38,38,0),    0 4px 12px rgba(0,0,0,0.3); }
    100% { box-shadow: 0 0 0 0    rgba(220,38,38,0),    0 4px 12px rgba(0,0,0,0.3); }
}
@keyframes idleOutZoneBlink {
    0%, 60% { opacity: 1; }
    61%, 100% { opacity: 0.55; }
}
/* Mesma pílula compacta do "SEM CHECK-IN", em vermelho e piscando (o estado real
   é "sem check-in"; o vermelho piscando sinaliza que está FORA da zona). */
.marker-overlay.idle_out_zone {
    background: #dc2626; color: #fff; border: none;
    animation: idleOutZoneBlink 1.1s steps(1) infinite;
}

/* SAIU do condomínio (geocerca): CRÍTICO — marcador vermelho piscando (reusa a
   pulsação do idle_out_zone) + pílula vermelha. É o alerta mais grave. */
.veh-marker.geofence_out {
    background: #dc2626; border-color: #fff;
    animation: idleOutZonePulse 1.1s infinite, idleOutZoneBlink 1.1s steps(1) infinite;
    z-index: 1000;
}
.marker-overlay.geofence_out {
    background: #dc2626; color: #fff; border: none;
    animation: idleOutZoneBlink 1.1s steps(1) infinite;
}
/* Card do tracker: borda/ícone/pill vermelhos + piscada (crítico). */
.veh-card.alert-state-geofence_out { border-left-color: #dc2626; animation: idleCardBlink 1.4s ease-in-out infinite; }
.veh-card.alert-state-geofence_out .vc-icon { background: rgba(220,38,38,0.22); color: #f87171; }
.veh-card.alert-state-geofence_out .vc-state-pill { background: rgba(220,38,38,0.2); color: #f87171; }

@media (max-width: 1180px) {
    /* Telas estreitas: todo bloco ocupa a largura inteira (1 coluna logica de
       12 = span 12) e ganha altura propria; o grid vira pilha. */
    #page-dashboard .dash-grid-12 > .dash-block { grid-column: 1 / -1 !important; }
    .vehicle-list-card { max-height: 320px; }
}

/* ---- settings-whatsapp anti-scroll (compactar secoes) ----- */
#page-settings-whatsapp { gap: 0.5rem; }
#page-settings-whatsapp .page-header { margin-bottom: 0; }
#page-settings-whatsapp .content-card-header { padding: 0.5rem 0.9rem; }
#page-settings-whatsapp .content-card-body { padding: 0.7rem 0.9rem; }
#page-settings-whatsapp .content-card-body[style*="gap"] { gap: 0.5rem !important; }
#page-settings-whatsapp .content-card-body > p { margin: 0; }
/* O empilhamento dos 3 cards (credenciais/instancias/teste) usa gap inline
   de 1rem; reduzimos a coluna externa para caber sem scroll em ~768px. */
#page-settings-whatsapp > div[style*="flex-direction:column"] { gap: 0.55rem !important; }
#page-settings-whatsapp .form-label { margin-bottom: 0.2rem; }
#page-settings-whatsapp .form-control-app { min-height: 34px; padding: 0.45rem 0.75rem; }

/* ---- Dashboard anti-scroll (denso, cabe na viewport) ------- *
 * Reduz paddings dos cards do dashboard e limita blocos que
 * podem crescer (alertas recentes) com scroll interno, para a
 * pagina caber em ~768/900px sem rolar a viewport.            */
#page-dashboard .content-card-header { padding: 0.45rem 0.9rem; }
#page-dashboard .content-card-header h3 { font-size: 0.9rem; }
#page-dashboard #recent-alerts {
    padding: 0.4rem 0.9rem;
    overflow-y: auto;
}
#page-dashboard #recent-alerts .activity-item { padding: 0.35rem 0; }
/* A legenda fica enxuta para alinhar com a altura dos alertas. */
#page-dashboard .dash-col-8-4 .content-card-body[style*="flex"] { padding: 0.5rem 0.9rem; gap: 0.3rem !important; }
/* Densidade extra para caber sem scroll na viewport (~768/900px). */
#page-dashboard { gap: 0.5rem; }
#page-dashboard .page-header { margin-bottom: 0; }
/* 6 KPIs em colunas IGUAIS (repeat(6,1fr)). O auto-fill anterior deixava o
   ultimo card mais largo quando sobrava espaco; com 6 tracks fixos todos ficam
   do mesmo tamanho. Em telas menores cai p/ 3 e depois 2 colunas. */
#page-dashboard .stat-grid {
    gap: 0.5rem;
    grid-template-columns: repeat(6, 1fr);
}
@media (max-width: 1200px) {
    #page-dashboard .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
    #page-dashboard .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Bloco kpis: os 6 cards ESTICAM para a MESMA altura (align-items:stretch),
   mesmo o "Leituras 24h" que nao tem sub-linha. align-content:stretch faz as
   linhas do grid preencherem a altura do bloco, sem sobra que gere scroll. */
#page-dashboard #stat-grid.dash-block {
    align-items: stretch;
    align-content: stretch;
    overflow: hidden;
}
#page-dashboard .stat-card {
    padding: 0.55rem 0.75rem;
    align-self: stretch;
}
/* No Dashboard, os cards de KPI NAO devem "levantar" no hover (sem animacao de
   translate). Mantem so um realce sutil de borda, sem movimento. */
#page-dashboard .stat-card:hover { transform: none; box-shadow: var(--shadow-sm); }
#page-dashboard .stat-value { font-size: 1.15rem; }
#page-dashboard .stat-icon { width: 34px; height: 34px; font-size: 1.05rem; }
#page-dashboard .dash-col-8-4,
#page-dashboard .dash-grid-12 { gap: 0.5rem; }
/* === Altura: --dash-row (altura de 1 unidade do grid) escala com a viewport
   para o layout PADRAO (kpis h:1 + faixa principal h:7 = ~8 unidades + gaps)
   caber SEM scroll de pagina. clamp(): nunca menor que 64px (legibilidade) nem
   maior que 100px (telas altas nao esticam demais). O desconto (~210px) cobre
   topbar + paddings do main + cabecalho da pagina + gaps entre as 2 faixas.
   Se o usuario aumentar blocos alem disso, ai sim a pagina rola. */
#page-dashboard .dash-grid-12 {
    --dash-row: clamp(54px, calc((100vh - 252px) / 8), 92px);
}
/* Tile ESCURO (CARTO dark) suavizado para o aspecto "Google Maps dark" — clareia
   um pouco, reduz contraste e dessatura, replicando os raster-paints da pagina
   do visitante. Aplicado por className na camada de tile do SGRMap. */
.sgr-tile-dark { filter: brightness(1.08) contrast(0.9) saturate(0.8); }

/* Setas de sentido ao longo do percurso (Leaflet divIcon) — chevron branco
   sobre a linha azul, como no acompanhamento do visitante. */
.sgr-route-arrow {
    background: none !important;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.sgr-route-arrow i {
    color: #fff;
    font-size: 11px;
    line-height: 1;
    text-shadow: 0 0 2px rgba(0,0,0,0.55);
    display: block;
}

/* Pinos de partida (portaria) e destino do percurso. */
.sgr-route-pin { background: none !important; border: none !important; }
.sgr-route-pin .srp-dot {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    color: #fff; font-size: 12px;
    border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}
.sgr-route-pin .srp-gate { background: #16a34a; }
.sgr-route-pin .srp-dest {
    background: #2563eb; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg); width: 26px; height: 26px;
}
.sgr-route-pin .srp-dest i { transform: rotate(45deg); }

/* Card do mapa: coluna flex para o corpo (e o #map) preencherem a altura da
   celula do grid, qualquer que seja o span. */
#page-dashboard [data-dash-block="mapa"] {
    display: flex;
    flex-direction: column;
}
#page-dashboard [data-dash-block="mapa"] .content-card-body {
    flex: 1;
    min-height: 0;
}
#page-dashboard #map { height: 100%; min-height: 240px; }
#page-dashboard .vehicle-list-card { max-height: none; display: flex; flex-direction: column; }
#page-dashboard .vehicle-list-card .vlc-body { flex: 1; min-height: 0; }
#page-dashboard .dash-side-alerts { display: flex; flex-direction: column; }
#page-dashboard .dash-side-alerts .content-card-body { flex: 1; min-height: 0; overflow-y: auto; }
#page-dashboard #recent-alerts { max-height: none; }

/* Viewports baixos (ex.: 1366x768): compactar ainda mais para caber sem
   scroll de pagina. So afeta telas curtas; em 1440x900 fica confortavel. */
@media (max-height: 820px) {
    #page-dashboard { gap: 0.4rem; }
    #page-dashboard .dash-grid-12,
    #page-dashboard .dash-col-8-4 { gap: 0.4rem; }
    #page-dashboard .content-card-header { padding: 0.35rem 0.85rem; }
    #page-dashboard .stat-card { padding: 0.4rem 0.65rem; }
    #page-dashboard .stat-value { font-size: 1rem; }
    #page-dashboard .stat-icon { width: 30px; height: 30px; font-size: 0.95rem; }
    #page-settings-whatsapp { gap: 0.4rem; }
    #page-settings-whatsapp > div[style*="flex-direction:column"] { gap: 0.35rem !important; }
    #page-settings-whatsapp .content-card-header { padding: 0.4rem 0.85rem; }
    #page-settings-whatsapp .content-card-body { padding: 0.5rem 0.85rem; }
    #page-settings-whatsapp .content-card-body[style*="gap"] { gap: 0.35rem !important; }
    #page-settings-whatsapp .form-control-app { min-height: 32px; padding: 0.4rem 0.7rem; }
    #page-settings-whatsapp .form-label { margin-bottom: 0.15rem; font-size: 0.8rem; }
}

/* ============================================================
   DASHBOARD EDITAVEL (personalizar - estilo pipedip)
   - Botoes do header (Atualizar / Personalizar / Concluir).
   - Modo edicao: cada bloco ganha contorno + botao de ocultar (olho).
   - Dropdown lista os blocos com checkbox mostrar/ocultar.
   ============================================================ */
.dash-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.dash-block { position: relative; }

/* --- Affordances de edicao (criadas pelo JS so em modo "Personalizar") --- */
/* Botao de ocultar (olho) no canto sup. direito. */
.dash-block-hide {
    position: absolute;
    top: 6px; right: 6px;
    z-index: 30;
    width: 26px; height: 26px;
    display: flex;
    align-items: center; justify-content: center;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    background: #fff;
    color: var(--neutral-700);
    cursor: pointer;
    font-size: 0.78rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.dash-block-hide:hover { background: rgba(220,53,69,0.1); color: #dc3545; border-color: rgba(220,53,69,0.4); }
html[data-theme="dark"] .dash-block-hide { background: var(--dark-card); border-color: rgba(255,255,255,0.14); color: rgba(255,255,255,0.8); }

/* Barra de arraste (mover/reordenar) no canto sup. esquerdo. */
.dash-drag-handle {
    position: absolute;
    top: 6px; left: 6px;
    z-index: 30;
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    background: #fff;
    color: var(--neutral-700);
    cursor: grab;
    font-size: 0.72rem; font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.dash-drag-handle:active { cursor: grabbing; }
html[data-theme="dark"] .dash-drag-handle { background: var(--dark-card); border-color: rgba(255,255,255,0.14); color: rgba(255,255,255,0.8); }

/* Etiqueta de tamanho (ex.: "6×4") aparece durante o redimensionamento. */
.dash-size-tag {
    position: absolute;
    bottom: 8px; left: 8px;
    z-index: 31;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem; font-weight: 700;
    pointer-events: none;
    opacity: 0; transition: opacity 0.12s;
}
.dash-block.is-resizing .dash-size-tag { opacity: 1; }

/* Alcas de redimensionar: direita (largura), baixo (altura), canto (ambos). */
.dash-rz {
    position: absolute;
    z-index: 30;
    background: transparent;
}
.dash-rz-r  { top: 18px; bottom: 18px; right: -3px; width: 10px; cursor: ew-resize; }
.dash-rz-b  { left: 18px; right: 18px; bottom: -3px; height: 10px; cursor: ns-resize; }
.dash-rz-br { right: -4px; bottom: -4px; width: 18px; height: 18px; cursor: nwse-resize; }
/* Indicador visual da alca de canto (triangulo). */
.dash-rz-br::after {
    content: ""; position: absolute; right: 3px; bottom: 3px;
    width: 0; height: 0;
    border-right: 8px solid var(--primary);
    border-top: 8px solid transparent;
    border-radius: 1px; opacity: 0.85;
}

/* Modo edicao: contorno tracejado + cards nao capturam cliques de conteudo. */
#page-dashboard.dash-editing .dash-block {
    /* box-shadow (nao outline+offset) para o contorno de edicao NAO aumentar a
       altura/area rolavel do dashboard — outline-offset empurra a area de
       overflow do ancestral e fazia aparecer scroll no modo Personalizar. */
    box-shadow: 0 0 0 2px var(--primary);
    border-radius: var(--radius-md);
    transition: box-shadow 0.15s;
}
#page-dashboard.dash-editing .dash-block:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 70%, #fff); }
/* Bloco sendo arrastado: meio transparente, acima dos outros. */
#page-dashboard.dash-editing .dash-block.is-dragging { opacity: 0.55; }
#page-dashboard.dash-editing .dash-block.is-resizing { box-shadow: 0 0 0 3px var(--primary); }
/* Em edicao, o mapa e a lista nao reagem a cliques (so as alcas/botoes). */
#page-dashboard.dash-editing #map,
#page-dashboard.dash-editing .vlc-body,
#page-dashboard.dash-editing #recent-alerts { pointer-events: none; }

/* Blocos ocultos: somem do grid (o reflow preenche o espaco). */
#page-dashboard .dash-block.dash-hidden { display: none; }

/* Dropdown de personalizacao (reaproveita .road-actions-dropdown). */
.dash-customize-dropdown { min-width: 280px; gap: 0.05rem; padding: 0.4rem; }
.dash-customize-dropdown .dash-cz-title {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--neutral-500);
    padding: 0.3rem 0.55rem 0.45rem;
}
.dash-cz-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.55rem;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    color: var(--neutral-800);
    cursor: pointer;
    transition: var(--transition);
}
.dash-cz-item:hover { background: var(--neutral-200); }
.dash-cz-item input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
html[data-theme="dark"] .dash-cz-item { color: rgba(255,255,255,0.85); }
html[data-theme="dark"] .dash-cz-item:hover { background: rgba(255,255,255,0.08); }
.dash-cz-hint {
    font-size: 0.72rem; color: var(--neutral-500);
    padding: 0.55rem 0.55rem; line-height: 1.4;
    margin-top: 0.3rem;
    border-top: 1px solid var(--neutral-300);
    text-align: center;
    text-wrap: balance;
}
.dash-cz-reset {
    display: flex; align-items: center; justify-content: center; gap: 0.45rem; width: 100%;
    padding: 0.55rem 0.6rem; margin-top: 0.15rem;
    border: 1px solid var(--neutral-300); background: var(--neutral-200); border-radius: var(--radius-md);
    color: var(--neutral-700); font-size: 0.82rem; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: var(--transition);
}
.dash-cz-reset:hover { background: var(--neutral-300); color: var(--neutral-900); }
.dash-cz-reset i { color: var(--primary); }
html[data-theme="dark"] .dash-cz-reset { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); }
html[data-theme="dark"] .dash-cz-reset:hover { background: rgba(255,255,255,0.1); }
html[data-theme="dark"] .dash-cz-hint { border-top-color: rgba(255,255,255,0.12); }

/* ============================================================
   ROUTE PAGE (Percurso) - layout split dark panel + map
   ============================================================ */
.route-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: #fff;
    height: calc(100vh - 130px);
    min-height: 440px;
    max-height: calc(100vh - 130px);
}

/* Painel lateral (Percurso / Vias internas): respeita o tema (claro/escuro)
   via tokens --neutral-*, em vez do dark fixo de antes. */
.route-panel {
    background: var(--neutral-100);
    color: var(--neutral-800);
    border-right: 1px solid var(--neutral-200);
    padding: 1rem 1.1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 0;
}
.route-panel h3 { color: var(--neutral-900); font-size: 1.1rem; letter-spacing: -0.01em; }
.route-panel .route-muted { color: var(--neutral-500); font-size: 0.8rem; }

.route-panel .form-label   { color: var(--neutral-600); font-size: 0.78rem; }
.route-panel .form-control-app,
.route-panel select.form-control-app {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
.route-panel .form-control-app:focus {
    background: var(--neutral-100);
    border-color: var(--primary);
}
.route-panel .form-control-app::placeholder { color: var(--neutral-500); }
.route-panel select.form-control-app option { background: var(--neutral-100); color: var(--neutral-800); }

/* Sugestoes de visita ao digitar na busca do Percurso. */
.route-search-pop {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    margin-top: 4px;
    background: var(--neutral-100); border: 1px solid var(--neutral-300);
    border-radius: 10px; box-shadow: var(--shadow-md);
    max-height: 260px; overflow-y: auto; padding: 0.25rem;
}
.route-search-pop.hidden { display: none; }
.route-search-pop .rsp-item {
    display: flex; flex-direction: column; gap: 0.1rem; width: 100%;
    text-align: left; background: none; border: none; cursor: pointer;
    padding: 0.5rem 0.6rem; border-radius: 8px; color: var(--neutral-800);
}
.route-search-pop .rsp-item:hover { background: var(--primary-soft); }
.route-search-pop .rsp-name { font-weight: 600; font-size: 0.85rem; }
.route-search-pop .rsp-meta { font-size: 0.72rem; color: var(--neutral-500); }
.route-search-pop .rsp-empty { padding: 0.6rem; font-size: 0.8rem; color: var(--neutral-500); }

.route-period-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.route-period-chips button {
    border: 1px solid var(--neutral-300);
    background: var(--neutral-50);
    color: var(--neutral-700);
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
}
.route-period-chips button:hover { border-color: var(--primary); color: var(--neutral-900); }
.route-period-chips button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* ===================================================================
   Onboarding guiado — cadeado de página + wizard de primeiros passos
   =================================================================== */

/* Bloqueio de etapa: overlay FIXO cobrindo só a ÁREA DE CONTEÚDO (abaixo da
   topbar, à direita da sidebar) — a navegação (sidebar/topbar) continua
   clicável para o usuário trocar de aba/sair. O fundo (conteúdo da página)
   fica borrado e escurecido; só o card de aviso fica nítido. Fixed (em vez de
   absolute) evita que o page-shell corte/empurre o card. */
.setup-lock {
    position: fixed;
    top: 60px; left: 240px; right: 0; bottom: 0;
    /* Acima do conteudo INCLUSIVE dos mapas Leaflet (.leaflet-pane=400,
       .leaflet-control=1000) — senao o mapa do Dashboard furava o blur. Fica
       abaixo dos dropdowns do header (1100+). Nao precisa ficar abaixo da
       sidebar/topbar: o overlay comeca em top:60px / left:240px, entao
       geometricamente nao cobre a navegacao (continua clicavel). */
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: auto;
    background: rgba(8, 12, 18, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeSlideIn 0.18s ease;
}
/* Acompanha a sidebar colapsada (60px) e o mobile (sidebar fora do fluxo). */
body:has(.main-content.sidebar-collapsed) .setup-lock { left: 60px; }
@media (max-width: 768px) {
    .setup-lock { left: 0; }
}
.setup-lock.hidden { display: none; }
.setup-lock-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-lg, 16px);
    padding: 2rem 1.6rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}
.setup-lock-badge {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 200, 83, 0.12);
    color: var(--primary);
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
}
.setup-lock-step {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--neutral-500);
    font-weight: 600;
}
.setup-lock-title { font-size: 1.1rem; font-weight: 700; color: var(--neutral-800); }
.setup-lock-text { font-size: 0.86rem; color: var(--neutral-600); line-height: 1.5; }
.setup-lock-next {
    display: inline-flex; align-items: center; gap: 0.45rem;
    background: rgba(0, 200, 83, 0.1);
    border: 1px solid rgba(0, 200, 83, 0.35);
    color: var(--primary);
    font-weight: 600;
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-size: 0.86rem;
    margin: 0.3rem 0;
}
.setup-lock-btn { width: 100%; justify-content: center; }
.setup-lock-guide {
    background: none; border: none; cursor: pointer;
    color: var(--neutral-500);
    font-size: 0.8rem;
    display: inline-flex; align-items: center; gap: 0.4rem;
    margin-top: 0.2rem;
}
.setup-lock-guide:hover { color: var(--primary); text-decoration: underline; }

/* Barra de progresso do wizard */
.onb-progress { display: flex; align-items: center; gap: 0.6rem; }
.onb-progress-track {
    flex: 1; height: 7px; border-radius: 999px;
    background: var(--neutral-200); overflow: hidden;
}
.onb-progress-bar {
    height: 100%; width: 0; border-radius: 999px;
    background: var(--primary);
    transition: width 0.3s ease;
}
.onb-progress-label { font-size: 0.8rem; font-weight: 700; color: var(--neutral-600); min-width: 32px; text-align: right; }

/* Lista de etapas no wizard */
.onb-step {
    display: flex; align-items: center; gap: 0.8rem;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md, 12px);
    padding: 0.7rem 0.85rem;
    background: var(--neutral-100);
}
.onb-step--done { background: rgba(0, 200, 83, 0.06); border-color: rgba(0, 200, 83, 0.3); }
.onb-step--next { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.18); }
.onb-step-mark {
    width: 30px; height: 30px; flex: 0 0 auto;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.onb-step .onb-step-num { background: var(--neutral-200); color: var(--neutral-600); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.onb-step--next .onb-step-num { background: var(--primary); color: #fff; }
.onb-step-mark .fa-circle-check { color: var(--primary); font-size: 1.4rem; }
.onb-step-info { flex: 1; min-width: 0; }
.onb-step-title { font-weight: 600; font-size: 0.9rem; color: var(--neutral-800); display: flex; align-items: center; gap: 0.45rem; }
.onb-step-title i { color: var(--neutral-500); width: 16px; text-align: center; }
.onb-step--next .onb-step-title i { color: var(--primary); }
.onb-step-desc { font-size: 0.78rem; color: var(--neutral-500); margin-top: 1px; }
.onb-step-desc:empty { display: none; }
.onb-step-action { flex: 0 0 auto; }

/* Override para a sidebar estreita da pagina "Vias internas": quatro chips de
   modo de fundo nao cabem em uma linha sem truncar. Empilha em grade 2x2 para
   cada rotulo aparecer por inteiro. */
#page-roads .route-period-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
}
#page-roads .route-period-chips button {
    padding: 0.4rem 0.5rem;
    font-size: 0.74rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-width: 0;
}
#page-roads .route-period-chips button i { font-size: 0.78rem; flex: 0 0 auto; }
/* Garante que o rótulo nunca vaze do chip arredondado (corta com reticências). */
#page-roads .route-period-chips button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Menu de acoes secundarias do header de "Vias internas".
   Botao "Ações" abre um dropdown ancorado a direita com os itens agrupados. */
.road-actions-menu { position: relative; display: inline-block; }
.road-actions-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1200;
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.road-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    color: var(--neutral-800);
    transition: var(--transition);
}
.road-menu-item i { width: 18px; text-align: center; color: var(--neutral-600); }
.road-menu-item:hover { background: var(--neutral-200); }
.road-menu-item--danger { color: #dc3545; }
.road-menu-item--danger i { color: #dc3545; }
.road-menu-item--danger:hover { background: rgba(220,53,69,0.1); }
.road-menu-sep { height: 1px; background: var(--neutral-300); margin: 0.25rem 0.2rem; }

html[data-theme="dark"] .road-actions-dropdown { background: var(--dark-card); border-color: rgba(255,255,255,0.12); }
html[data-theme="dark"] .road-menu-item { color: rgba(255,255,255,0.85); }
/* Item de menu / botao desabilitado (ex.: detectar/desenhar via sem geocerca). */
.road-menu-item:disabled, .road-menu-item.is-disabled,
.btn-modern.is-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
html[data-theme="dark"] .road-menu-item i { color: rgba(255,255,255,0.6); }
html[data-theme="dark"] .road-menu-item:hover { background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .road-menu-sep { background: rgba(255,255,255,0.12); }

/* Autocomplete generico (usado pelo Nome do visitante no modal de check-in).
   Aparece logo abaixo do input, com scroll quando passa de 4-5 itens. */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 3px;
    background: #ffffff;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 260px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    border-bottom: 1px solid var(--neutral-200);
    font-size: 0.85rem;
    color: var(--neutral-800);
    transition: background 0.12s ease;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active {
    background: rgba(0, 200, 83, 0.08);
}
.autocomplete-item strong { color: var(--primary); font-weight: 600; }
.autocomplete-item-meta {
    font-size: 0.72rem;
    color: var(--neutral-500);
    margin-top: 0.18rem;
    line-height: 1.3;
}

/* ===== Toggle segmentado (Selecionar / Cadastrar / Sem) ===================== */
.seg-toggle {
    display: inline-flex;
    gap: 2px;
    background: var(--neutral-200);
    border-radius: 8px;
    padding: 2px;
}
.seg-toggle .seg-btn {
    border: none;
    background: transparent;
    color: var(--neutral-600);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}
.seg-toggle .seg-btn:hover { color: var(--neutral-900); }
.seg-toggle .seg-btn.active {
    background: var(--neutral-100);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ===== EntityLinkPicker (busca + chips para vinculo N:N) ===================== */
.entity-link-picker { display: flex; flex-direction: column; gap: 0.5rem; }
.entity-link-picker .elp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.entity-link-picker .elp-chips.hidden { display: none; }
.entity-link-picker .elp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0, 200, 83, 0.10);
    border: 1px solid rgba(0, 200, 83, 0.35);
    color: var(--neutral-900);
    border-radius: 999px;
    padding: 0.25rem 0.3rem 0.25rem 0.7rem;
    font-size: 0.8rem;
    line-height: 1.2;
}
.entity-link-picker .elp-chip small { color: var(--neutral-500); font-weight: 400; }
.entity-link-picker .elp-chip-x {
    border: none;
    background: transparent;
    color: var(--neutral-500);
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: 999px;
    display: inline-flex;
    transition: background 0.12s ease, color 0.12s ease;
}
.entity-link-picker .elp-chip-x:hover { background: rgba(220, 53, 69, 0.12); color: #dc3545; }
.entity-link-picker .elp-search { position: relative; }
.entity-link-picker .elp-search > i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-400);
    font-size: 0.85rem;
    pointer-events: none;
}
.entity-link-picker .elp-input {
    width: 100%;
    padding: 0.55rem 0.7rem 0.55rem 2.1rem;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    /* --neutral-100 e remapeado no dark theme (era var(--surface,#fff), que
       caía sempre em #fff branco pois --surface nao existe -> input branco no dark). */
    background: var(--neutral-100);
    color: var(--neutral-900);
    font-size: 0.85rem;
}
.entity-link-picker .elp-input::placeholder { color: var(--neutral-600); }
.entity-link-picker .elp-input:hover { border-color: var(--neutral-400); }
.entity-link-picker .elp-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}
.entity-link-picker .elp-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 120;
    margin-top: 3px;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: 240px;
    overflow-y: auto;
}
.entity-link-picker .elp-dropdown.hidden { display: none; }
.entity-link-picker .elp-item {
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    border-bottom: 1px solid var(--neutral-200);
    font-size: 0.85rem;
    color: var(--neutral-800);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    transition: background 0.12s ease;
}
.entity-link-picker .elp-item:last-child { border-bottom: none; }
.entity-link-picker .elp-item:hover, .entity-link-picker .elp-item.active {
    background: rgba(0, 200, 83, 0.08);
}
.entity-link-picker .elp-item-meta { font-size: 0.72rem; color: var(--neutral-500); }
.entity-link-picker .elp-empty { padding: 0.6rem 0.7rem; font-size: 0.8rem; color: var(--neutral-500); }

/* Sugestoes (chips clicaveis): veiculos ja vinculados ao visitante selecionado.
   Usa tokens --neutral-* (respeita tema claro/escuro). */
.elp-suggest { margin-top: 0.5rem; }
.elp-suggest.hidden { display: none; }
.elp-suggest-label { display: block; font-size: 0.74rem; color: var(--neutral-500); margin-bottom: 0.35rem; }
.elp-suggest-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.elp-suggest-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--neutral-300); border-radius: 999px;
    background: var(--neutral-100); color: var(--neutral-800);
    font-size: 0.8rem; font-weight: 600; cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.elp-suggest-chip i { color: var(--primary); font-size: 0.78rem; }
.elp-suggest-chip small { color: var(--neutral-500); font-weight: 400; }
.elp-suggest-chip:hover { border-color: var(--primary); background: rgba(0, 200, 83, 0.08); }

/* Cartao de via detectada no OSM (modal). As cores vem das variaveis --neutral-*
   que ja sao re-mapeadas pelo dark theme em [data-theme="dark"]. */
.osm-row:hover {
    background: var(--neutral-200) !important;
    border-color: var(--primary) !important;
}
html[data-theme="dark"] .osm-row {
    background: #232323 !important;        /* combina com forms/buttons no dark */
    border-color: var(--neutral-300) !important;
}
html[data-theme="dark"] .osm-row:hover {
    background: #2A2A2A !important;
    border-color: var(--primary) !important;
}

/* Aviso de contagem no topo do modal de vias detectadas. */
/* Resumo das vias detectadas: cartoes de contagem lado a lado. */
.osm-count-banner {
    display: flex; gap: 0.5rem;
    margin-bottom: 0.7rem;
}
.osm-stat {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.1rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    text-align: center;
}
.osm-stat-n { font-size: 1.35rem; font-weight: 700; line-height: 1; color: var(--primary); }
.osm-stat-l { font-size: 0.72rem; color: var(--neutral-500); }
.osm-stat--muted .osm-stat-n { color: var(--neutral-500); }

/* Wizard (passos do check-in). Indicador no topo + steps com visibilidade
   controlada por classe .hidden. */
.wizard-steps {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem 0.4rem;
    gap: 0.4rem;
    background: rgba(0,0,0,0.015);
}
.wizard-step-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 0 0 auto;
    cursor: default;
    user-select: none;
    transition: opacity 0.15s ease;
}
.wizard-step-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    background: var(--neutral-200);
    color: var(--neutral-500);
    border: 2px solid transparent;
    transition: all 0.15s ease;
}
.wizard-step-label {
    font-size: 0.72rem;
    color: var(--neutral-500);
    font-weight: 500;
    white-space: nowrap;
}
.wizard-step-chip.active .wizard-step-num {
    background: var(--primary);
    color: #fff;
    border-color: rgba(0,200,83,0.25);
    box-shadow: 0 0 0 4px rgba(0,200,83,0.15);
}
.wizard-step-chip.active .wizard-step-label { color: var(--primary); font-weight: 600; }
.wizard-step-chip.completed { cursor: pointer; }
.wizard-step-chip.completed .wizard-step-num {
    background: rgba(0,200,83,0.15);
    color: var(--primary);
    border-color: var(--primary);
}
.wizard-step-chip.completed .wizard-step-label { color: var(--neutral-700); }
.wizard-step-line {
    flex: 1 1 auto;
    height: 2px;
    background: var(--neutral-300);
    margin-bottom: 1rem;   /* alinha com o circulo, ignorando o label */
    min-width: 12px;
}
.wizard-step-line.completed { background: var(--primary); }

/* Cartoes de revisao (passo 4) */
.review-section {
    border: 1px solid var(--neutral-300);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.7rem;
    background: rgba(0,0,0,0.015);
}
.review-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.review-section-edit {
    font-size: 0.72rem;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.review-section-edit:hover { text-decoration: underline; }
.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 1rem;
    font-size: 0.85rem;
}
.review-grid .key   { color: var(--neutral-500); font-size: 0.75rem; }
.review-grid .value { color: var(--neutral-800); font-weight: 500; word-break: break-word; }
.review-grid .empty { color: var(--neutral-400); font-style: italic; font-weight: 400; }

/* Glow na polilinha da via atualmente em edicao. Aplicado via className do
   L.Polyline. O drop-shadow funciona em elementos SVG. */
/* (Removido o glow verde difuso da via em edicao — o destaque agora e' um
   casing claro desenhado por baixo da via, num pane acima das demais.) */

/* Marcador de sentido (seta) no ponto medio de cada via.
   Usa cor da via + contorno escuro para legibilidade em fundo claro/escuro. */
.road-direction-marker {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
    text-shadow:
        0 0 2px rgba(0,0,0,0.95),
        0 0 3px rgba(0,0,0,0.7),
        0 1px 0 rgba(0,0,0,0.6);
    cursor: pointer;
    transition: transform 0.15s ease;
}
.road-direction-marker:hover { transform-origin: center; filter: brightness(1.25); }

/* Faixa de informacoes (distancia/ETA) abaixo do mini-mapa do check-in */
.visit-route-info {
    margin-top: 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    background: rgba(0, 200, 83, 0.08);
    border: 1px solid rgba(0, 200, 83, 0.25);
    color: var(--neutral-700);
    font-size: 0.82rem;
    line-height: 1.3;
}

/* Barra de ferramentas do mapa de destino (check-in): chips de fundo + Limpar. */
.visit-map-tools {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap;
}
.visit-map-tools.hidden { display: none; }
.visit-route-info.warning {
    background: rgba(252, 211, 77, 0.12);
    border-color: rgba(252, 191, 73, 0.45);
    color: #92580d;
}

/* Override em contextos com fundo claro (ex: pagina Analytics).
   O .route-period-chips foi originalmente desenhado para o painel dark da pagina Percurso. */
#ana-period-chips button {
    border-color: var(--neutral-300);
    background: #fff;
    color: var(--neutral-700);
}
#ana-period-chips button:hover {
    border-color: var(--primary);
    color: var(--primary);
}
#ana-period-chips button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.route-endpoint-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    font-size: 0.8rem;
}

/* ---- Lista de vias: cabeçalho + checkbox por linha --------------------- */
.road-list-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem 0.45rem;
    border-bottom: 1px solid var(--neutral-300);
    margin-bottom: 0.35rem;
}
.road-list-head-label {
    flex: 1; min-width: 0;
    font-size: 0.74rem; font-weight: 600;
    color: var(--neutral-600);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.road-del-selected { flex-shrink: 0; }
/* Célula da checkbox (no cabeçalho e em cada linha). */
.road-check-cell {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; flex-shrink: 0; cursor: pointer;
}
.road-check-cell input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; margin: 0; }
/* A checkbox da LINHA só aparece no hover ou quando a via está marcada —
   mantém a lista limpa, mas a seleção fica a um clique de distância. */

.road-row .road-check-cell { opacity: 0; transition: opacity 0.12s ease; }
.road-row:hover .road-check-cell,
.road-row.is-selected .road-check-cell { opacity: 1; }

/* Lapis de editar: aparece no hover da linha. Clicar nele abre o modal;
   clicar no resto da linha so foca a via no mapa. */
.road-row-edit {
    flex-shrink: 0;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--neutral-300);
    background: var(--neutral-100);
    color: var(--neutral-600);
    border-radius: 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.road-row:hover .road-row-edit { opacity: 1; }
.road-row-edit:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.road-row-edit i { font-size: 0.78rem; }
html[data-theme="dark"] .road-row-edit { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.14); color: rgba(255,255,255,0.7); }
html[data-theme="dark"] .road-row-edit:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
/* Destaque temporario ao clicar na via no mapa (rola a lista ate ela). */
.road-row-flash { animation: roadRowFlash 1.6s ease; }
@keyframes roadRowFlash {
    0%, 30%  { background: rgba(0,200,83,0.35); box-shadow: inset 0 0 0 2px var(--primary); }
    100%     { background: transparent; box-shadow: none; }
}
.route-endpoint-row .endpoint-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.route-endpoint-row .endpoint-dot.start { background: var(--primary); box-shadow: 0 0 0 3px rgba(0,200,83,0.2); }
.route-endpoint-row .endpoint-dot.end   { background: var(--neutral-500); }
.route-endpoint-row .endpoint-label {
    color: var(--neutral-500);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}
.route-endpoint-row .endpoint-value { color: var(--neutral-800); margin-top: 1px; line-height: 1.25; }

/* Roads (#page-roads): a page tem page-header acima do .route-layout, logo
   o layout precisa descontar tambem a altura do header de pagina (~70px)
   para nao gerar scroll na viewport. O mapa+painel encolhem; a lista de
   vias rola por DENTRO (#road-list abaixo). */
#page-roads .route-layout,
#page-route .route-layout {
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
    min-height: 360px;
}

/* Lista de vias cadastradas: scroll INTERNO, nunca rola a pagina.
   flex:1 + min-height:0 garante que o bloco encolha e role por dentro. */
#road-list {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    overflow-y: auto;
}
#road-list::-webkit-scrollbar { width: 6px; }
#road-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }

.route-map-wrap {
    position: relative;
    min-width: 0;
}
.route-map { width: 100%; height: 100%; }

/* Contador de vias no canto superior direito do mapa (Vias internas). */
.roads-count-badge {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 1000;            /* acima dos tiles/markers, abaixo de modais */
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.55rem 0.4rem 0.4rem;
    background: var(--neutral-100);
    color: var(--neutral-700);
    border: 1px solid var(--neutral-300);
    border-radius: 30px;
    font-size: 0.78rem; font-weight: 600;
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    pointer-events: none;     /* nao captura clique do mapa */
}
/* Icone em "chip" verde para destacar (estilo painel pro). */
.roads-count-badge i {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    font-size: 0.78rem;
}
.roads-count-badge #roads-count-num { font-weight: 800; color: var(--neutral-900); font-size: 0.92rem; }

/* Badge de contagem da geocerca (pontos · area) no modal — estilo unificado com
   o badge de vias: chip de icone + numero forte + rotulo discreto. */
.geofence-badge {
    height: 40px;
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0 0.8rem 0 0.45rem;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: 30px;
    font-size: 0.8rem; color: var(--neutral-600); white-space: nowrap;
}
.geofence-badge > i {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary); font-size: 0.8rem;
}
.geofence-badge strong { color: var(--neutral-900); font-weight: 800; }
.geofence-badge .gfb-sep { color: var(--neutral-400); }
.geofence-badge .gfb-area { color: var(--neutral-700); font-weight: 600; }
/* Acima do teto de area permitido: realce vermelho. */
.geofence-badge.geofence-badge-over {
    border-color: rgba(220,53,69,0.5);
    background: rgba(220,53,69,0.10);
}
.geofence-badge.geofence-badge-over > i { background: rgba(220,53,69,0.15); color: #dc3545; }
.geofence-badge.geofence-badge-over .gfb-area { color: #dc3545; }

/* Overlay de loading da consulta OSM — cobre a tela inteira e bloqueia
   interacao enquanto a busca de vias roda. */
.osm-loading-overlay {
    position: fixed; inset: 0;
    z-index: 12000;                 /* acima de tudo (modais, toasts) */
    display: flex; align-items: center; justify-content: center;
    background: rgba(8, 12, 18, 0.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeSlideIn 0.15s ease;
}
.osm-loading-overlay.hidden { display: none; }
.osm-loading-card {
    text-align: center;
    color: #fff;
    padding: 1.8rem 2rem;
    width: min(380px, 88vw);
    background: rgba(17, 24, 39, 0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
/* Ícone de busca pulsando dentro de um halo verde. */
.osm-loading-icon {
    width: 64px; height: 64px; margin: 0 auto 0.4rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 200, 83, 0.14);
    animation: osmPulse 1.4s ease-in-out infinite;
}
.osm-loading-icon i { font-size: 1.7rem; color: var(--primary); }
@keyframes osmPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,200,83,0.35); }
    50%      { box-shadow: 0 0 0 12px rgba(0,200,83,0); }
}
.osm-loading-title { margin-top: 0.7rem; font-size: 1.05rem; font-weight: 700; }
.osm-loading-sub   { margin-top: 0.35rem; font-size: 0.85rem; color: rgba(255,255,255,0.75); line-height: 1.4; min-height: 2.4em; }
/* Barra de progresso animada (creep) */
.osm-loading-track {
    margin-top: 1rem; height: 8px; border-radius: 999px;
    background: rgba(255,255,255,0.14); overflow: hidden;
}
.osm-loading-bar {
    height: 100%; width: 8%; border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), #6ee7a8);
    transition: width 0.4s ease;
}

/* Legenda Realizado x Previsto (canto inferior esquerdo do mapa de percurso) */
.route-legend {
    position: absolute;
    bottom: 0.9rem; left: 0.9rem;
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    display: flex;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    z-index: 400;
    font-size: 0.78rem;
    color: var(--neutral-700);
}
.route-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.rl-swatch { display: inline-block; width: 22px; height: 0; border-radius: 2px; }
.rl-swatch.rl-real    { border-top: 4px solid #00C853; }
.rl-swatch.rl-planned { border-top: 4px dashed #2563eb; }

.route-overlay-vehicle {
    position: absolute;
    top: 1rem; right: 1rem;   /* lado direito: nao cobre o controle de zoom (top-left) */
    background: var(--dark-card);
    color: #fff;
    border-radius: 14px;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 220px;
    max-width: 280px;
    z-index: 400;
}
.route-overlay-vehicle .veh-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.route-overlay-vehicle .veh-info { line-height: 1.3; }
.route-overlay-vehicle .veh-name { font-weight: 700; font-size: 0.9rem; }
.route-overlay-vehicle .veh-sub  { font-size: 0.76rem; color: rgba(255,255,255,0.6); margin-top: 2px; }

.route-overlay-stats {
    position: absolute;
    bottom: 1rem; left: 1rem; right: 1rem;
    background: #fff;
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: auto repeat(4, 1fr) auto;
    align-items: center;
    gap: 1rem;
    z-index: 400;
}
.route-overlay-stats .stats-close {
    background: none; border: none; cursor: pointer; color: var(--neutral-500);
    font-size: 1rem; padding: 4px 8px; border-radius: 6px;
}
.route-overlay-stats .stats-close:hover { background: var(--neutral-200); color: var(--neutral-800); }
.route-overlay-stats .stats-title {
    font-weight: 700;
    color: var(--neutral-900);
    font-size: 0.95rem;
    padding-right: 1rem;
    border-right: 1px solid var(--neutral-300);
}
.route-overlay-stats .kpi { display: flex; align-items: center; gap: 0.55rem; }
.route-overlay-stats .kpi-icon {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.route-overlay-stats .kpi-label { font-size: 0.7rem; color: var(--neutral-500); text-transform: uppercase; letter-spacing: 0.05em; }
.route-overlay-stats .kpi-value { font-weight: 700; color: var(--neutral-900); font-size: 0.95rem; line-height: 1.1; }

.route-empty-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(245,247,250,0.7);
    backdrop-filter: blur(2px);
    z-index: 500;
    pointer-events: none;
}

/* Bloqueio do painel de Vias internas enquanto não há geocerca definida.
   Cobre o painel (busca/lista/chips), capturando os cliques. SEM botão —
   a ação de definir a geocerca vive no overlay central do mapa. */
.road-panel-lock {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: 1.5rem;
    background: color-mix(in srgb, var(--neutral-100) 86%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: inherit;
    z-index: 20;
    pointer-events: all;
}
.road-panel-lock > i { font-size: 1.8rem; color: var(--primary); margin-bottom: 0.2rem; }
.road-panel-lock-title { font-weight: 700; font-size: 0.95rem; color: var(--neutral-900); }
.road-panel-lock p { font-size: 0.82rem; color: var(--neutral-600); line-height: 1.45; max-width: 280px; margin: 0; }
.route-empty-overlay .empty-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem 1.8rem;
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 320px;
    pointer-events: none;
}
/* Icone ILUSTRATIVO do card = só o filho DIRETO (> i). Sem o ">" a regra
   pegava tambem os icones DENTRO do botao, deixando-os gigantes (2rem) e em
   bloco. O botao usa o tamanho normal do .btn-modern. */
.route-empty-overlay .empty-card > i { font-size: 2rem; color: var(--neutral-400); margin-bottom: 0.6rem; display: block; }
.route-empty-overlay .empty-card p { color: var(--neutral-600); font-size: 0.9rem; }
/* Variante com botao (onboarding da geocerca): o card precisa receber cliques
   (o overlay tem pointer-events:none) e ganha o icone na cor primaria. */
.route-empty-overlay .empty-card--cta { pointer-events: auto; max-width: 360px; }
.route-empty-overlay .empty-card--cta > i { color: var(--primary); }
.route-empty-overlay .empty-card--cta p { margin-bottom: 1rem; line-height: 1.45; }
.route-empty-overlay .empty-card--cta .btn-modern { width: 100%; justify-content: center; }

.route-marker-start, .route-marker-end {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.72rem;
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.route-marker-start { background: var(--primary); }
.route-marker-end   { background: #2D3440; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 240px !important; }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-grid .span-2 { grid-column: span 1; }
    .dash-col-8-4 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    /* No celular o KPI da TAG tambem cai para 2 colunas (sem forcar 215px). */
    #tag-detail-stats { grid-template-columns: repeat(2, 1fr); }
    .route-layout { grid-template-columns: 1fr; height: auto; }
    .route-map { height: 420px; }
    .route-overlay-stats { grid-template-columns: 1fr; text-align: center; gap: 0.6rem; }
    .route-overlay-stats .stats-title { border-right: 0; border-bottom: 1px solid var(--neutral-300); padding-bottom: 0.5rem; }
}
@media (max-width: 480px) {
    h2 { font-size: 1.3rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Anti-overflow horizontal em mobile -------------------- *
 * A varredura detectou estouro de ~14px em Settings (grids 2-col
 * com inputs number/textarea que nao encolhem). Garantimos que
 * campos e itens de grid/flex possam encolher abaixo do seu
 * min-content e que o container principal nunca role lateralmente
 * no celular (validado em 390px).                                 */

/* Guarda global: nada de scroll horizontal na pagina em si.
   Usa `clip` (e nao `hidden`): `overflow-x: hidden` converte o eixo Y para
   `auto`, tornando o <body> um scroll-container e QUEBRANDO `position: sticky`
   (ex.: painel de variaveis em Notificacoes). `clip` contem o estouro
   horizontal sem virar container de scroll. */
html, body { max-width: 100%; overflow-x: clip; }

/* Inputs/selects/textarea sempre cabem no container (number nao estoura). */
.form-control-app,
.input-premium { min-width: 0; max-width: 100%; }

/* Filhos de grid/flex podem encolher (min-width:auto e o padrao que estoura). */
.filters-bar > *,
.cfg-busca-wrap { min-width: 0; }
.cfg-busca-wrap { max-width: 100%; }

@media (max-width: 640px) {
    /* Em telas estreitas (ex.: 390px) o painel principal nao rola lateral. */
    .main-content { overflow-x: hidden; padding: 1rem; }
    .page-shell { max-width: 100%; }

    /* Grids de 2+ colunas dos formularios de Settings empilham em
       coluna unica. Cobre as variantes inline usadas nas sub-telas
       (1fr 1fr, 1fr 1fr auto, 2fr 1fr, 1fr 120px, auto 1fr auto). */
    #page-settings [style*="grid-template-columns"],
    #page-settings-operacional [style*="grid-template-columns"],
    #page-settings-notificacoes [style*="grid-template-columns"],
    #page-settings-whatsapp [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Hub de Settings sempre em coluna unica no celular. */
    .cfg-colunas { column-count: 1 !important; }

    /* Barra de filtros e busca ocupam a largura toda, sem min-width fixo. */
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar > * { width: 100%; max-width: 100% !important; }

    /* Busca de configuracoes alinhada a largura total. */
    .cfg-busca-wrap { margin-left: 0; }

    /* Containers de largura fixa das sub-telas se adaptam a viewport. */
    #page-settings-whatsapp > div[style*="max-width"],
    #page-settings-operacional .content-card,
    #page-settings-notificacoes .content-card { max-width: 100% !important; }

    /* Codigos/placeholders longos quebram em vez de empurrar a largura.
       (As tabelas continuam rolando por dentro de .table-wrap.) */
    .content-card-body code { word-break: break-word; }
}

/* Modais nunca ultrapassam a viewport no celular; conteudo rola por dentro. */
@media (max-width: 480px) {
    .modal-box { max-width: 100%; }
    .modal-overlay { padding: 0.6rem; }
}

/* ---- Signup Page ----------------------------------------- */
.signup-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.6rem;
}
@media (max-width: 760px) {
    .signup-grid { grid-template-columns: 1fr; }
}
.signup-form-col h3, .signup-plans-col h3 {
    margin-bottom: 0.6rem;
    font-weight: 600;
}
.signup-plan-card {
    border: 1px solid var(--neutral-300);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    background: #fff;
    transition: border-color 0.15s, transform 0.15s;
}
.signup-plan-card.featured {
    border-color: var(--primary);
    background: linear-gradient(180deg, rgba(0,200,83,0.06) 0%, #fff 100%);
    box-shadow: 0 4px 12px rgba(0,200,83,0.12);
}
.signup-plan-card:hover { transform: translateY(-1px); }
.signup-plan-card ul li::marker { color: var(--primary); }

/* ---- Plan Banner ------------------------------------------ */
#plan-banner {
    margin: 0 1.5rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#plan-banner a { font-weight: 700; text-decoration: underline; margin-left: 0.3rem; }
.plan-banner-trial {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
}
.plan-banner-trial a { color: #9a3412; }
.plan-banner-danger {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}
.plan-banner-danger a { color: #991b1b; }

/* =========================================================
   DARK THEME — aplicado via [data-theme="dark"] no <html>
   Sobrescreve variaveis sem reescrever componentes.
   Conforme Memorial Descritivo (PDF): "Tema escuro para nao
   cansar a visao dos operadores, com elementos em neon".
   ========================================================= */
html[data-theme="dark"] {
    color-scheme: dark;       /* widgets nativos (checkbox, radio, scroll, date) seguem o tema */
    accent-color: var(--primary);

    --neutral-100: #1A1A1A;   /* card background */
    --neutral-200: #0F0F0F;   /* page background */
    --neutral-300: #2C2C2C;   /* borders */
    --neutral-400: #3A3A3A;
    --neutral-500: #888A8E;
    --neutral-600: #A3A6AC;
    --neutral-700: #C9CCD2;
    --neutral-800: #E4E6EA;
    --neutral-900: #F2F4F7;

    --primary-soft:  rgba(57, 181, 96, 0.18);
    --secondary-soft: rgba(59, 130, 246, 0.18);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
    --shadow-lg: 0 20px 40px -12px rgba(0,0,0,0.6);

    /* Badge/status — tons claros/neon para contraste sobre fundo escuro. */
    --badge-success-fg: #4ADE80;
    --badge-warning-fg: #F0C14B;
    --badge-danger-fg:  #F87171;
    --badge-info-fg:    #60A5FA;
    --badge-neutral-fg: #AEB4BE;

    /* Sidebar / header escuros (look original neon). */
    --sidebar-bg:      #232323;
    --sidebar-text:    rgba(255,255,255,0.72);
    --sidebar-text-strong: #FFFFFF;
    --sidebar-muted:   #8B93A1;
    --sidebar-hover:   rgba(255,255,255,0.06);
    --sidebar-active:  rgba(0,200,83,0.14);
    --sidebar-border:  rgba(255,255,255,0.05);

    --header-bg:       #232323;
    --header-text:     #FFFFFF;
    --header-border:   rgba(255,255,255,0.05);
}

/* Body / scroll dark */
html[data-theme="dark"] body {
    background: var(--neutral-200);
    color: var(--neutral-800);
}
html[data-theme="dark"] html::-webkit-scrollbar-thumb,
html[data-theme="dark"] body::-webkit-scrollbar-thumb,
html[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

/* Cards */
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .activity-item,
html[data-theme="dark"] .veh-card {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .content-card-header,
html[data-theme="dark"] .premium-table-shell .table-wrap thead {
    background: linear-gradient(180deg, #232323 0%, #1A1A1A 100%);
    color: var(--neutral-800);
    border-color: var(--neutral-300);
}
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 { color: var(--neutral-900); }

/* Inputs / forms */
html[data-theme="dark"] .form-control-app,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .form-control-app::placeholder { color: var(--neutral-500); }
html[data-theme="dark"] .form-label { color: var(--neutral-700); }
html[data-theme="dark"] .form-control-app:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: var(--primary);
    background: #2A2A2A;
}
html[data-theme="dark"] select option { background: #232323; color: var(--neutral-800); }
/* Restaura a seta SVG do select custom no dark (o shorthand `background` acima
   limpa o background-image herdado do tema claro). */
html[data-theme="dark"] select.form-control-app {
    background-color: #232323;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23A3A6AC' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}

/* Botoes secundarios (neutros) — preserva variantes coloridas (primary/danger/secondary) */
html[data-theme="dark"] .btn-modern:not(.btn-primary-modern):not(.btn-danger-modern):not(.btn-secondary-modern) {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .btn-modern:not(.btn-primary-modern):not(.btn-danger-modern):not(.btn-secondary-modern):hover {
    background: #2A2A2A;
    border-color: var(--primary);
    color: var(--primary);
}

/* Tabelas */
html[data-theme="dark"] .data-table { color: var(--neutral-800); }
html[data-theme="dark"] .data-table thead { background: #232323; }
html[data-theme="dark"] .data-table thead th,
html[data-theme="dark"] .premium-table-shell .data-table thead th {
    color: var(--neutral-600);
    background: #232323;
    border-color: var(--neutral-300);
}
html[data-theme="dark"] .data-table tbody tr { border-color: var(--neutral-300); }
html[data-theme="dark"] .data-table tbody tr:hover { background: #232323; }

/* Pagination */
html[data-theme="dark"] .page-btn {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-700);
}
html[data-theme="dark"] .page-btn:hover { border-color: var(--primary); color: var(--primary); }
html[data-theme="dark"] .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Modal overlay um pouco mais escuro pra contraste */
html[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.75); }

/* Dividers / dashed borders */
html[data-theme="dark"] hr,
html[data-theme="dark"] [style*="border-top:1px dashed"],
html[data-theme="dark"] [style*="border-top: 1px dashed"] {
    border-color: var(--neutral-300) !important;
}

/* Plan banners (mantem cores quentes mas legiveis no dark) */
html[data-theme="dark"] .plan-banner-trial {
    background: #3a2a1a; border-color: #b65f1a; color: #fdba74;
}
html[data-theme="dark"] .plan-banner-danger {
    background: #3a1818; border-color: #c54b4b; color: #fca5a5;
}

/* Empty states */
html[data-theme="dark"] .empty-state { color: var(--neutral-500); }

/* Filtros / search bar */
html[data-theme="dark"] .filters-bar,
html[data-theme="dark"] .premium-search-shell {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
}

/* Stat icon — fundo circular ja tem cor especifica, manter */
/* Badges semanticas (active, inactive, etc) — manter cores existentes */

/* Ajuste especifico p/ Leaflet attribution sobre fundo escuro */
html[data-theme="dark"] .leaflet-container { background: #181818; }
html[data-theme="dark"] .leaflet-control-attribution {
    background: rgba(20,20,20,0.85);
    color: var(--neutral-600);
}
html[data-theme="dark"] .leaflet-control-attribution a { color: var(--neutral-700); }

/* Popup do Leaflet */
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
    background: #1A1A1A;
    color: var(--neutral-800);
}

/* Faixa de info verde da prevista de rota */
html[data-theme="dark"] .visit-route-info {
    background: rgba(57, 181, 96, 0.12);
    border-color: rgba(57, 181, 96, 0.35);
    color: var(--neutral-700);
}
html[data-theme="dark"] .visit-route-info.warning {
    background: rgba(252, 191, 73, 0.10);
    border-color: rgba(252, 191, 73, 0.35);
    color: #fbbf24;
}

/* Override em chips do Analytics no dark fica mais legivel */
html[data-theme="dark"] #ana-period-chips button {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-700);
}
html[data-theme="dark"] #ana-period-chips button:hover {
    border-color: var(--primary);
    color: var(--primary);
}
html[data-theme="dark"] #ana-period-chips button.active {
    background: var(--primary);
    color: #fff;
}

/* Zebra striping da tabela: cor branca fixa em <td> tem alta especificidade
   e sobrepoe o tbody dark. Override neutraliza pra deixar o tr controlar a cor. */
html[data-theme="dark"] .premium-table-shell .data-table tbody tr:nth-child(odd) td {
    background-color: transparent;
}
html[data-theme="dark"] .premium-table-shell .data-table tbody tr:nth-child(even) td {
    background-color: rgba(255,255,255,0.02);
}
html[data-theme="dark"] .premium-table-shell .data-table tbody tr:hover td {
    background-color: rgba(57, 181, 96, 0.08);
}

/* Dropdowns flutuantes (notificacoes, user menu) */
html[data-theme="dark"] .user-dropdown,
html[data-theme="dark"] .notif-dropdown {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .user-dropdown-item,
html[data-theme="dark"] .notif-list .notif-item {
    color: var(--neutral-800);
}
html[data-theme="dark"] .user-dropdown-item:hover { background: rgba(255,255,255,0.05); }
html[data-theme="dark"] .user-dropdown-item--danger:hover { background: rgba(220,53,69,0.15); }
html[data-theme="dark"] .notif-empty,
html[data-theme="dark"] .notif-foot { color: var(--neutral-600); border-color: var(--neutral-300); }

/* KPIs da Analytics + Login card precisam ficar legiveis */
html[data-theme="dark"] .ana-kpi {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}

/* Tela de login / signup — card e inputs em dark coerente com a tela de fundo */
html[data-theme="dark"] .login-card {
    background: var(--neutral-100);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.04);
    color: var(--neutral-800);
}
html[data-theme="dark"] .login-card .form-label {
    color: var(--neutral-700);
}
html[data-theme="dark"] .login-card .login-logo p,
html[data-theme="dark"] .login-card > div[style*="color:var(--neutral-500)"] {
    color: var(--neutral-600) !important;
}
html[data-theme="dark"] .input-premium {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .input-premium::placeholder {
    color: var(--neutral-500);
}
html[data-theme="dark"] .input-premium:focus {
    background: #2A2A2A;
    border-color: var(--primary);
}

/* Plan cards (pagina Plano e Uso e Signup) */
html[data-theme="dark"] .signup-plan-card {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
}
html[data-theme="dark"] .signup-plan-card.featured {
    background: linear-gradient(180deg, rgba(0,200,83,0.10) 0%, var(--neutral-100) 100%);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,200,83,0.18);
}

/* Modal footer / overlays do mapa de Percurso */
html[data-theme="dark"] .modal-footer {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
}
html[data-theme="dark"] .route-overlay-stats,
html[data-theme="dark"] .route-empty-overlay .empty-card {
    background: var(--neutral-100);
    color: var(--neutral-800);
    border-color: var(--neutral-300);
}

/* Tags inline de codigo (ex: lista de eventos no modal de Webhook,
   placeholders nos templates de WhatsApp). Usa cor do tema. */
code, kbd {
    font-family: 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
    font-size: 0.85em;
    padding: 0.12em 0.4em;
    border-radius: 4px;
    background: var(--neutral-200);
    color: var(--primary);
    border: 1px solid var(--neutral-300);
}
html[data-theme="dark"] code,
html[data-theme="dark"] kbd {
    background: rgba(57, 181, 96, 0.10);
    color: var(--primary-light);
    border-color: rgba(57, 181, 96, 0.25);
}

/* =========================================================
   Custom <select> — substituicao visual via select-enhance.js
   O <select> nativo continua no DOM (escondido) pra JS legado.
   ========================================================= */
/* ===== Troca de empresa (admin global) — chip/badge do topbar ===== */
.imp-switch { position: relative; display: flex; align-items: center; }
.imp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--neutral-300);
    border-radius: 999px;
    background: var(--neutral-100);
    color: var(--neutral-800);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.imp-chip:hover { border-color: var(--primary); color: var(--primary); }
.imp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.45);
    color: var(--warning, #b45309);
    font-size: 0.8rem;
    min-width: 0;                 /* permite o texto interno encolher/truncar */
    max-width: 360px;
    overflow: hidden;
}
.imp-badge > i { flex: none; }
/* O rotulo "Assumindo: <nome>" trunca; o botao Voltar fica SEMPRE inteiro. */
.imp-badge > span {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.imp-badge strong { font-weight: 700; }
.imp-voltar {
    flex: none;                   /* nunca encolhe nem corta o texto */
    border: none;
    background: var(--warning, #d97706);
    color: #fff;
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
.imp-voltar:hover { filter: brightness(0.95); }
.imp-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-width: 86vw;
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md, 10px);
    box-shadow: var(--shadow-md, 0 12px 28px rgba(0,0,0,0.18));
    z-index: 4000;
    overflow: hidden;
}
.imp-dropdown-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--neutral-200);
    color: var(--neutral-500);
}
.imp-dropdown-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--neutral-900);
    font-size: 0.88rem;
}
.imp-dropdown-list { max-height: 320px; overflow-y: auto; padding: 0.3rem; }
.imp-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.6rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: var(--neutral-800);
}
.imp-dropdown-item:hover { background: var(--primary-soft); color: var(--primary); }
.imp-dropdown-item i { color: var(--neutral-500); }
.imp-dropdown-item:hover i { color: var(--primary); }
.imp-item-name { flex: 1; font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-item-slug { font-family: monospace; font-size: 0.72rem; color: var(--neutral-500); }
.imp-dropdown-empty { padding: 0.9rem; text-align: center; color: var(--neutral-500); font-size: 0.85rem; }
html[data-theme="dark"] .imp-dropdown { background: #1F1F1F; }
html[data-theme="dark"] .imp-dropdown-item:hover i,
html[data-theme="dark"] .imp-dropdown-item:hover { color: var(--primary); }

/* ===== Relatórios (admin): KPIs compactos + filtros bem dispostos ===== */
/* Grid responsivo que acomoda 5 KPIs sem quebrar 1 sozinho numa linha. */
#page-preports .ana-kpis {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.7rem;
    margin-bottom: 1rem;
}
#page-preports .ana-kpi {
    padding: 0.7rem 0.8rem;
    gap: 0.6rem;
}
#page-preports .ana-kpi-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    font-size: 0.95rem;
}
#page-preports .ana-kpi-label { font-size: 0.66rem; }
#page-preports .ana-kpi-value { font-size: 1.2rem; }

/* Barra de filtros: os campos distribuem-se pela largura toda (sem bunching
   à esquerda). O Condomínio cresce, datas/status mantêm largura compacta. */
#page-preports .prep-filters {
    display: flex;
    gap: 0.85rem 0.9rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
#page-preports .prep-filter-field { flex: 0 1 auto; }
/* O Condomínio (campo principal e pesquisável) ocupa o espaço livre. */
#page-preports .prep-filter-field.is-tenant { flex: 1 1 320px; min-width: 240px; }
#page-preports .prep-filter-field.is-status { flex: 0 1 auto; }
#page-preports .prep-filter-field input[type="date"] { max-width: 160px; }
/* Rótulos dos filtros: discretos, uniformes, com respiro do campo. */
#page-preports .prep-filter-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--neutral-500);
}

/* ===== Cards de gateway de pagamento (Mercado Pago) ===== */
.gateway-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.gateway-card {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 1.1rem 1.25rem;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
}
.gateway-card-logo {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--neutral-300);
}
.gateway-card-logo img { width: 100%; height: 100%; object-fit: contain; }
.gateway-card-logo-fallback {
    width: 100%; height: 100%;
    align-items: center; justify-content: center;
    font-size: 1.5rem; color: var(--primary);
}
.gateway-card-body { flex: 1 1 auto; min-width: 0; }
.gateway-card-name { font-weight: 700; font-size: 1.05rem; color: var(--neutral-900); }
.gateway-card-meta { margin: 0.3rem 0; }
.gateway-card-desc { font-size: 0.82rem; color: var(--neutral-500); }
.gateway-card-actions { flex: 0 0 auto; }
html[data-theme="dark"] .gateway-card-logo { background: #fff; }

.sgr-select-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.sgr-select-native {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    pointer-events: none;
    opacity: 0;
}
.sgr-select-toggle {
    width: 100%;
    /* Padding uniforme: o caret e um flex-item real (nao background-image), entao
       nao precisa de padding-right extra — senao fica "solto" no meio, longe da
       borda. A seta vai para o canto direito via .sgr-select-label { flex:1 }. */
    padding: 0.6rem 0.85rem;
    min-height: 38px;
    border: 1.5px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.02);
    color: var(--neutral-900);
    font-size: 0.92rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.2;
}
.sgr-select-toggle:hover  { border-color: var(--neutral-400); }
.sgr-select-toggle:focus,
.sgr-select-wrap.open .sgr-select-toggle {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}
.sgr-select-toggle.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--neutral-200);
}
.sgr-select-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sgr-select-label.placeholder {
    color: var(--neutral-500);
    font-weight: 400;
}
.sgr-select-caret {
    color: var(--neutral-500);
    font-size: 0.7rem;
    transition: transform 0.18s ease;
}
.sgr-select-wrap.open .sgr-select-caret {
    transform: rotate(180deg);
    color: var(--primary);
}

.sgr-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 0.3rem;
    background: #fff;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 280px;
    overflow-y: auto;
    animation: sgrSelectIn 0.12s ease-out;
}
@keyframes sgrSelectIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Caixa de busca dentro do menu (opt-in via data-searchable) */
.sgr-select-search {
    position: sticky;
    top: 0;
    padding: 0.15rem 0.15rem 0.35rem;
    background: inherit;
    z-index: 1;
}
.sgr-select-search-input {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--neutral-300);
    border-radius: 8px;
    background: var(--neutral-100);
    color: var(--neutral-900);
    font-size: 0.88rem;
    outline: none;
}
.sgr-select-search-input:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}
.sgr-select-empty {
    padding: 0.6rem 0.75rem;
    color: var(--neutral-500);
    font-size: 0.85rem;
    text-align: center;
    list-style: none;
}
.sgr-select-item {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--neutral-800);
    font-size: 0.9rem;
    transition: background 0.12s, color 0.12s;
    user-select: none;
    line-height: 1.35;
}
.sgr-select-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}
.sgr-select-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.sgr-select-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    font-style: italic;
}

/* Dark mode */
html[data-theme="dark"] .sgr-select-toggle {
    background: #232323;
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
html[data-theme="dark"] .sgr-select-toggle.disabled {
    background: rgba(255,255,255,0.04);
}
html[data-theme="dark"] .sgr-select-menu {
    background: #1F1F1F;
    border-color: var(--neutral-300);
    box-shadow: 0 16px 32px rgba(0,0,0,0.6);
}
html[data-theme="dark"] .sgr-select-item {
    color: var(--neutral-800);
}
html[data-theme="dark"] .sgr-select-item:hover {
    background: rgba(57, 181, 96, 0.16);
    color: var(--primary-light);
}
html[data-theme="dark"] .sgr-select-item.active {
    background: var(--primary);
    color: #fff;
}

/* Scrollbar customizada do menu */
.sgr-select-menu::-webkit-scrollbar { width: 6px; }
.sgr-select-menu::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 3px; }
html[data-theme="dark"] .sgr-select-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* Toggle de tema no header */
.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-right: 0.5rem;
}
.theme-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: var(--primary);
    border-color: var(--primary);
}

/* ===== Campo de busca padrao (lupa interna, estilo pipedip) ===== */
/* Wrapper compacto, alinhado a direita das filters-bar. NAO esticar. */
.search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 300px;
    max-width: 100%;
    flex: 0 0 auto;
}
.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-600);
    font-size: 0.85rem;
    pointer-events: none;
}
.search-box input.search-input {
    width: 100%;
    height: 38px;
    padding: 0 0.85rem 0 2.1rem;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: var(--neutral-100);
    color: var(--neutral-900);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.search-box input.search-input::placeholder {
    color: var(--neutral-600);
    font-weight: 400;
}
.search-box input.search-input:hover { border-color: var(--neutral-400); }
.search-box input.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
@media (max-width: 600px) {
    .search-box { width: 100%; }
}
/* Busca do painel de vias — respeita o tema (claro/escuro). */
.search-box--panel i { color: var(--neutral-500); }
.search-box--panel input.search-input {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
    color: var(--neutral-800);
}
.search-box--panel input.search-input::placeholder { color: var(--neutral-500); }
.search-box--panel input.search-input:hover { border-color: var(--neutral-400); }
.search-box--panel input.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 181, 96, 0.25);
}

/* Selects de filtro: largura ajustada ao conteudo (texto inteiro, sem corte).
   width:auto faz o select medir a maior option; min-width garante respiro e o
   max-width evita estourar a barra. Substitui os max-width inline antigos que
   cortavam "Todas as severidades", etc. */
/* Filtros COMPACTOS lado a lado (estilo pipedip): nao esticam, largura ~ do
   conteudo. flex:0 0 auto impede o select de crescer e ocupar a linha toda.
   O select.filter-select e' enhanced por select-enhance.js, que esconde o
   <select> nativo e mostra um <div class="sgr-select-wrap"> no lugar — por isso
   a regra precisa mirar o WRAP (caso contrario o wrap herda width:100% e cada
   filtro vira uma barra full-width empilhada). O seletor do select nativo fica
   como fallback caso o enhancer nao rode. */
.filters-bar select.form-control-app.filter-select,
.filters-bar .sgr-select-wrap {
    display: inline-block;
    width: auto !important;
    flex: 0 0 auto;
    min-width: 190px;
    max-width: 240px;
}
/* Search-box: largura fixa modesta, vai pra direita, sem esticar. */
.filters-bar .search-box { flex: 0 0 auto; }
/* Variante "lg": larga o bastante p/ mostrar o placeholder inteiro ("Buscar por
   título, descrição ou placa do veículo...") sem cortar. Cresce p/ ocupar o
   espaço livre da barra com um piso confortável (vence a regra .filters-bar
   acima por causa do flex-grow:1). */
/* Busca "grande": largura fixa suficiente para o placeholder, SEM esticar
   (flex:0 0 auto + margin-left:auto inline ja a empurra para a direita). */
.search-box.search-box--lg,
.filters-bar .search-box.search-box--lg { width: 440px; min-width: 0; flex: 0 0 auto; }
@media (max-width: 600px) {
    .filters-bar select.form-control-app.filter-select,
    .filters-bar .sgr-select-wrap { width: 100% !important; max-width: 100%; flex: 1 1 100%; }
    .search-box.search-box--lg,
    .filters-bar .search-box.search-box--lg { width: 100%; min-width: 0; flex: 1 1 100%; }
}

/* WhatsApp (Evolution) — layout 2 colunas (estilo pipedip): credenciais+teste
   a esquerda, instancias (largo) a direita. Aproveita a largura da tela em vez
   de uma coluna estreita com vazio ao lado. */
.wa-grid {
    display: grid;
    grid-template-columns: minmax(320px, 380px) 1fr;
    gap: 1rem;
    align-items: start;
}
.wa-col-left { display: flex; flex-direction: column; gap: 1rem; }
.wa-col-right { min-width: 0; }
@media (max-width: 900px) {
    .wa-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   NOTIFICAÇÕES AO CONDUTOR — layout 2 colunas + editor de variáveis (VarEditor)
   ========================================================================== */
/* O fade padrao de .page-shell anima `transform`, e um ancestral com transform
   vira containing-block e QUEBRA o `position: sticky` do painel de variaveis.
   Nesta tela usamos um fade so de opacidade (sem transform). */
#page-settings-notificacoes { animation: fadeInOpacity 0.15s ease; }
@keyframes fadeInOpacity { from { opacity: 0; } to { opacity: 1; } }

.notif-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.25rem;
    align-items: start;
}
.notif-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
/* Cola logo abaixo do header fixo (60px) ao rolar a pagina. */
.notif-aside { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 84px); overflow-y: auto; }
@media (max-width: 980px) {
    .notif-layout { grid-template-columns: 1fr; }
    .notif-aside { position: static; }
}

/* Cabeçalho de cada card de template */
.notif-tpl-head {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--neutral-200);
}
.notif-tpl-icon {
    flex: 0 0 auto;
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--ic) 14%, transparent);
    color: var(--ic); font-size: 1rem;
}
.notif-tpl-titles { flex: 1 1 auto; min-width: 0; }
.notif-tpl-titles h3 { margin: 0; font-size: 0.98rem; font-weight: 600; color: var(--neutral-900); }
.notif-tpl-titles p { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--neutral-600); }
.notif-tpl-body { padding: 1rem 1.25rem 1.25rem; }
/* Tipo DESLIGADO: esmaece o corpo E bloqueia interação — sem clicar em
   "Inserir variável"/"Pré-visualizar" nem digitar na mensagem desativada. */
.notif-tpl:has(.ve-switch input:not(:checked)) .notif-tpl-body {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.notif-actions { display: flex; justify-content: flex-end; padding-top: 0.25rem; }

/* Toggle (switch) reutilizável */
.ve-switch { flex: 0 0 auto; display: inline-flex; cursor: pointer; }
.ve-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ve-switch-track {
    width: 42px; height: 24px; border-radius: 999px;
    background: var(--neutral-300); position: relative;
    transition: background .18s ease;
}
.ve-switch-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: transform .18s ease;
}
.ve-switch input:checked + .ve-switch-track { background: #25D366; }
.ve-switch input:checked + .ve-switch-track .ve-switch-thumb { transform: translateX(18px); }
.ve-switch input:focus-visible + .ve-switch-track { box-shadow: 0 0 0 3px var(--primary-soft); }

/* Painel lateral de variáveis */
.notif-var-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.notif-var-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    width: 100%; text-align: left; cursor: pointer;
    padding: 0.45rem 0.6rem; border-radius: var(--radius-md);
    border: 1px solid var(--neutral-200); background: var(--neutral-100);
    color: var(--neutral-800); font-size: 0.8rem;
    transition: border-color .15s, background .15s;
}
/* Hover: realce sutil que respeita o tema (NAO usar --neutral-50/#fff, que
   ficava branco no dark e estourava o contraste). */
.notif-var-item:hover { border-color: var(--primary); background: var(--neutral-200); }
.notif-var-item .nv-label { font-weight: 500; }
/* O {token} e' apenas uma LEGENDA, nao um botao: cancela o pill (borda/fundo)
   que o estilo global de <code> aplica — fica so o texto verde monoespacado. */
.notif-var-item .nv-token {
    font-family: monospace; font-size: 0.74rem; color: var(--primary); white-space: nowrap;
    background: none !important; border: none !important; padding: 0 !important;
}
.notif-var-item.is-copied { border-color: #25D366; }
.notif-var-item.is-copied .nv-token::after { content: " ✓"; color: #25D366; }

.notif-fmt {
    margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px dashed var(--neutral-200);
    display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.78rem; color: var(--neutral-600);
}
.notif-fmt strong { color: var(--neutral-800); font-size: 0.74rem; text-transform: uppercase; letter-spacing: .03em; }
.notif-fmt code { font-family: monospace; background: var(--neutral-100); padding: 0.05rem 0.3rem; border-radius: 4px; color: var(--neutral-900); }

/* ---- VarEditor (toolbar + textarea + preview) ---- */
.var-editor { position: relative; }
.ve-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.ve-btn {
    display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
    padding: 0.4rem 0.7rem; font-size: 0.78rem; font-family: inherit; cursor: pointer;
    border: 1px solid var(--neutral-300); border-radius: var(--radius-md);
    background: var(--neutral-100); color: var(--neutral-700);
    transition: border-color .15s, background .15s, color .15s;
}
.ve-btn:hover { background: var(--neutral-200); color: var(--neutral-900); border-color: var(--primary); }
html[data-theme="dark"] .ve-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ve-btn i.fa-tag { color: var(--primary); }
.ve-btn-preview.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.ve-btn-preview.is-on i { color: #fff; }
.ve-caret { font-size: 0.62rem; opacity: 0.7; }
.ve-var-wrap { position: relative; }
.ve-area {
    width: 100%; resize: vertical; min-height: 120px;
    font-family: 'Segoe UI', system-ui, sans-serif; font-size: 0.88rem; line-height: 1.5;
}

/* Menu de variáveis — portalado para o <body> com position:fixed (top/left
   definidos inline pelo JS). z-index altissimo p/ ficar acima de cards,
   modais e tudo mais. */
.ve-menu {
    position: fixed; z-index: 12000;
    min-width: 240px; max-height: 280px; overflow-y: auto;
    background: var(--neutral-100); border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md); box-shadow: 0 10px 30px rgba(0,0,0,.16);
    padding: 0.35rem;
}
.ve-menu-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    width: 100%; text-align: left; cursor: pointer;
    padding: 0.5rem 0.6rem; border: 0; background: transparent; border-radius: var(--radius-sm);
    color: var(--neutral-800); font-size: 0.82rem; font-family: inherit;
}
.ve-menu-item:hover { background: var(--neutral-200); }
.ve-menu-label { font-weight: 500; color: var(--neutral-800); }
.ve-menu-token { font-family: monospace; font-size: 0.74rem; color: var(--primary); white-space: nowrap; }
/* Modo escuro: fundo do popover e texto legíveis (antes era #fff fixo). */
html[data-theme="dark"] .ve-menu { background: var(--dark-card); border-color: rgba(255,255,255,0.14); }
html[data-theme="dark"] .ve-menu-item { color: rgba(255,255,255,0.85); }
html[data-theme="dark"] .ve-menu-label { color: rgba(255,255,255,0.85); }
html[data-theme="dark"] .ve-menu-item:hover { background: rgba(255,255,255,0.08); }

/* Pré-visualização estilo bolha WhatsApp */
.ve-preview {
    margin-top: 0.75rem; padding: 0.85rem;
    background:
        repeating-linear-gradient(45deg, rgba(0,0,0,.02) 0 12px, transparent 12px 24px),
        #e9e2d8;
    border-radius: var(--radius-md); border: 1px solid var(--neutral-200);
}
.ve-preview-head {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
    /* Fundo do preview e' SEMPRE bege claro (estilo WhatsApp), entao o titulo
       usa PRETO fixo (nao o --neutral-600, que clareia no dark e sumia). */
    color: #111b21; margin-bottom: 0.5rem;
}
.ve-preview-head i { color: #1faa54; }
.ve-preview-bubble {
    background: #d9fdd3; color: #111b21;
    padding: 0.6rem 0.8rem; border-radius: 8px 8px 8px 2px;
    font-size: 0.86rem; line-height: 1.5; max-width: 85%;
    box-shadow: 0 1px 1px rgba(0,0,0,.12); word-break: break-word;
}
.ve-preview-vazio { color: #667781; font-style: italic; }

/* Chip do token de evento no modal de Webhooks (ex.: track.received).
   Antes usava background:white inline — medonho no modo escuro. Agora segue o
   tema: fundo suave + texto na cor primaria. */
.wh-event-token {
    background: var(--neutral-100);
    color: var(--primary);
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--neutral-300);
    font-size: 0.78rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
html[data-theme="dark"] .wh-event-token {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--primary);
}

/* ============================================================
   ICON PICKER — seletor visual de icone (catalogo de servicos)
   ============================================================ */
.icon-picker { position: relative; }
.icon-picker-btn {
    display: flex; align-items: center; gap: 0.6rem;
    width: 100%; cursor: pointer; text-align: left;
}
.icon-picker-current {
    flex: 0 0 auto;
    width: 26px; height: 26px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary);
    font-size: 0.95rem;
}
.icon-picker-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--neutral-800); }
.icon-picker-caret { flex: 0 0 auto; font-size: 0.7rem; color: var(--neutral-500); }

.icon-picker-pop {
    /* Posicionado em FIXED via JS (positionIconPop) para escapar do overflow:hidden
       do modal e ficar acima de tudo no eixo Z. z-index alto = sobre o modal. */
    position: fixed; z-index: 3000; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md); box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    padding: 0.5rem;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.35rem;
    max-height: 240px; overflow-y: auto;
}
.icon-picker-opt {
    display: inline-flex; align-items: center; justify-content: center;
    aspect-ratio: 1 / 1; min-height: 38px;
    border: 1px solid var(--neutral-200); border-radius: 8px;
    background: var(--neutral-100); color: var(--neutral-700);
    cursor: pointer; font-size: 1rem;
    transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.icon-picker-opt:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.icon-picker-opt.is-selected { background: var(--primary); border-color: var(--primary); color: #fff; }

html[data-theme="dark"] .icon-picker-pop {
    background: var(--dark-card); border-color: rgba(255,255,255,0.14);
}
html[data-theme="dark"] .icon-picker-opt {
    background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8);
}
html[data-theme="dark"] .icon-picker-opt:hover { color: var(--primary); }
html[data-theme="dark"] .icon-picker-opt.is-selected { color: #fff; }
@media (max-width: 480px) {
    .icon-picker-pop { grid-template-columns: repeat(5, 1fr); }
}

/* ============================================================
   PASSWORD EYE — botao mostrar/ocultar senha (auto em todo input password)
   ============================================================ */
.pwd-eye-wrap { position: relative; display: block; width: 100%; }
/* O input dentro do wrapper ocupa a largura toda e abre espaco a' direita p/
   o olho nao cobrir o texto digitado. */
.pwd-eye-wrap > input.has-pwd-eye { width: 100%; padding-right: 2.4rem; }
.pwd-eye-btn {
    position: absolute;
    top: 50%; right: 0.5rem;
    transform: translateY(-50%);
    width: 1.9rem; height: 1.9rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0; cursor: pointer;
    color: var(--neutral-500);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: color .12s, background .12s;
    padding: 0;
}
.pwd-eye-btn:hover { color: var(--primary); background: rgba(0,0,0,0.04); }
.pwd-eye-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* Tema escuro: olho discreto, realce no hover. */
html[data-theme="dark"] .pwd-eye-btn { color: rgba(255,255,255,0.5); }
html[data-theme="dark"] .pwd-eye-btn:hover { color: var(--primary); background: rgba(255,255,255,0.06); }
/* Na tela de login/cadastro (input-premium escuro) o olho acompanha o tema. */
#login-screen .pwd-eye-btn,
#signup-screen .pwd-eye-btn { color: rgba(255,255,255,0.5); }
#login-screen .pwd-eye-btn:hover,
#signup-screen .pwd-eye-btn:hover { color: var(--primary); background: rgba(255,255,255,0.06); }

/* ============================================================
   BARRA DE SELECAO DE VIAS (excluir varias) — mais clara
   ============================================================ */
.road-sel-bar {
    display: flex; flex-direction: column; gap: 0.45rem;
    background: rgba(220,53,69,0.12);
    border: 1px solid rgba(220,53,69,0.35);
    border-radius: 10px; padding: 0.6rem 0.7rem; margin-top: 0.4rem;
}
.road-sel-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.road-sel-count { font-size: 0.82rem; font-weight: 700; color: #ff7780; }
.road-sel-all {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,119,128,0.4);
    color: #ff9da3; font-size: 0.74rem; font-weight: 600; font-family: inherit;
    padding: 0.25rem 0.55rem; border-radius: 7px; cursor: pointer;
    transition: background .12s, color .12s;
}
.road-sel-all:hover:not(:disabled) { background: rgba(255,119,128,0.18); color: #fff; }
.road-sel-all:disabled { opacity: 0.5; cursor: default; }
.road-sel-hint { font-size: 0.72rem; color: rgba(255,255,255,0.6); line-height: 1.35; }
html[data-theme="light"] .road-sel-hint { color: var(--neutral-600); }
.road-sel-actions { display: flex; gap: 0.35rem; }

/* Marcador de PORTARIA (ponto de entrada) no mapa de Vias internas. */
/* Pinos e setas do PERCURSO (pagina Percurso) — estilo do acompanhamento do
   visitante: portaria (verde), destino (azul) e setas de sentido sobre a rota. */
.route-pin {
    width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.route-pin i { transform: rotate(45deg); color: #fff; font-size: 0.8rem; }
.route-pin-portaria { background: var(--primary); }
.route-pin-dest     { background: #1d4ed8; }
.route-arrow {
    width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
    color: #ffffff; font-size: 12px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.75));
}

/* Setas de DIRECAO ao longo do traçado do percurso — pequenos chevrons brancos
   que indicam o sentido do caminho. .route-dir gira pelo heading do trecho. */
.route-dir {
    width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
    transform: rotate(var(--rot, 0deg)); transform-origin: center;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.55));
}
.route-dir svg { display: block; }

.portaria-marker {
    width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.portaria-marker i { transform: rotate(45deg); color: #fff; font-size: 0.85rem; }
.portaria-marker:hover { filter: brightness(1.1); }

/* ====================== INBOX / CONVERSAS (WhatsApp) ====================== */
.inbox-shell {
    display: grid; grid-template-columns: 320px 1fr;
    height: calc(100dvh - 220px); min-height: 420px; overflow: hidden; padding: 0;
}
.inbox-shell.hidden { display: none; }

/* ===== Chat da EQUIPE (canal unico do condominio) ===== */
.team-chat {
    display: flex; flex-direction: column;
    height: calc(100dvh - 220px); min-height: 420px; overflow: hidden; padding: 0;
}
.team-chat.hidden { display: none; }
.team-chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--neutral-300); flex: none;
}
.team-chat-net { font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.team-chat-net.online { color: var(--primary); background: var(--primary-soft); }
.team-chat-net.poll   { color: var(--neutral-600); background: var(--neutral-200); }
/* Area de mensagens (relativa, para ancorar o botao "descer"). */
.team-msg-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.team-chat .inbox-messages { flex: 1; min-height: 0; }

/* LINHA da mensagem: avatar FORA da bolha. Recebidas a esquerda, enviadas a
   direita (avatar do lado de fora correspondente). */
.team-row { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 82%; }
.team-row.in  { align-self: flex-start; flex-direction: row; }
.team-row.out { align-self: flex-end;   flex-direction: row-reverse; }
.team-row-av { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; }
.team-row-av-i { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-size: 0.72rem; font-weight: 700; }
.team-row-flash .team-bubble { animation: teamFlash 1.4s ease; }
@keyframes teamFlash { 0%,100% { box-shadow: none; } 25% { box-shadow: 0 0 0 3px var(--primary); } }

.team-bubble {
    padding: 0.45rem 0.65rem; border-radius: 12px;
    font-size: 0.86rem; line-height: 1.35; position: relative; word-break: break-word; min-width: 0;
}
/* Cores por autor: ENVIADA (eu) = azul a direita; TERCEIROS = cinza a esquerda. */
.team-bubble.in  { background: var(--neutral-200); color: var(--neutral-900); border-bottom-left-radius: 4px; }
.team-bubble.out { background: #2563eb; color: #fff; border-bottom-right-radius: 4px; }
.team-bubble-name { font-size: 0.7rem; font-weight: 700; color: var(--primary); margin-bottom: 0.1rem; }

/* Coluna que agrupa a bolha + o botao Responder abaixo dela. */
.team-bubble-wrap { display: flex; flex-direction: column; min-width: 0; }
.team-row.out .team-bubble-wrap { align-items: flex-end; }
.team-row.in  .team-bubble-wrap { align-items: flex-start; }

/* Botao "Responder" verde ABAIXO da bolha (estilo WhatsApp). Discreto: aparece
   no hover da linha em telas com mouse; sempre visivel no touch (sem hover). */
.team-reply-action {
    display: inline-flex; align-items: center; gap: 0.3rem;
    margin-top: 0.2rem; padding: 0.18rem 0.6rem;
    border: none; border-radius: 999px;
    background: var(--success, #16a34a); color: #fff;
    font-size: 0.72rem; font-weight: 600; cursor: pointer;
    opacity: 0; transform: translateY(-2px); transition: opacity 0.12s, transform 0.12s;
}
.team-reply-action i { font-size: 0.66rem; }
.team-reply-action:hover { filter: brightness(0.95); }
.team-row:hover .team-reply-action { opacity: 1; transform: translateY(0); }
@media (hover: none) {
    .team-reply-action { opacity: 1; transform: none; }
}

/* Realce de mencao (@todos / @Nome) dentro do corpo da mensagem. */
.team-mention { font-weight: 700; color: var(--primary); }
.team-bubble.out .team-mention { color: #cfe0ff; }

/* Popover de autocomplete de mencao (@) — acima da area de compose. */
.team-mention-pop {
    margin: 0 0.6rem;
    max-height: 220px; overflow-y: auto;
    background: #fff; border: 1px solid var(--neutral-300);
    border-radius: 10px; box-shadow: var(--shadow-md);
    padding: 0.3rem;
}
.team-mention-pop.hidden { display: none; }
.team-mention-item {
    display: flex; align-items: center; gap: 0.55rem;
    width: 100%; padding: 0.45rem 0.55rem;
    border: none; background: transparent; border-radius: 8px;
    cursor: pointer; text-align: left; color: var(--neutral-800);
}
.team-mention-item.active, .team-mention-item:hover { background: var(--primary-soft); color: var(--primary); }
.team-mention-ic {
    width: 26px; height: 26px; flex: none; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--neutral-200); color: var(--neutral-600); font-size: 0.75rem;
}
.team-mention-item.active .team-mention-ic, .team-mention-item:hover .team-mention-ic { background: var(--primary); color: #fff; }
.team-mention-nm { font-weight: 600; font-size: 0.86rem; }
.team-mention-sub { margin-left: auto; color: var(--neutral-500); font-size: 0.72rem; }
html[data-theme="dark"] .team-mention-pop { background: #1F1F1F; }

/* Citacao dentro da bolha (mensagem respondida) — clicavel: rola ate a original */
.team-reply-quote {
    display: block; width: 100%; text-align: left; cursor: pointer;
    border: none; border-left: 3px solid var(--primary);
    background: rgba(0,0,0,0.06); border-radius: 6px; padding: 0.25rem 0.45rem; margin-bottom: 0.3rem;
}
.team-bubble.out .team-reply-quote { background: rgba(255,255,255,0.18); border-left-color: #fff; }
.team-reply-quote-name { display: block; font-size: 0.68rem; font-weight: 700; opacity: 0.9; }
.team-reply-quote-text { display: block; font-size: 0.74rem; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Botao "descer para as mais recentes" (canto inferior direito) */
.team-scroll-down {
    position: absolute; bottom: 12px; right: 14px; z-index: 5;
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--neutral-300);
    background: var(--neutral-100); color: var(--neutral-700); cursor: pointer;
    box-shadow: var(--shadow-md); font-size: 0.95rem;
}
.team-scroll-down.hidden { display: none; }
.team-scroll-down:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Barra "respondendo a..." acima do compose */
.team-reply-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.8rem; border-top: 1px solid var(--neutral-300); background: var(--primary-soft); }
.team-reply-bar.hidden { display: none; }
.team-reply-info { flex: 1; min-width: 0; border-left: 3px solid var(--primary); padding-left: 0.5rem; font-size: 0.8rem; overflow: hidden; }
.team-reply-label { color: var(--neutral-500); margin-right: 0.25rem; }
.team-reply-text { color: var(--neutral-600); margin-left: 0.35rem; white-space: nowrap; }
.team-reply-x { background: none; border: none; cursor: pointer; color: var(--neutral-500); font-size: 1rem; flex: none; }

.team-bubble-body { white-space: pre-wrap; }
.team-bubble-body { white-space: pre-wrap; }
.team-bubble-meta { font-size: 0.62rem; opacity: 0.7; text-align: right; margin-top: 0.15rem; }
.team-bubble-img { max-width: 240px; max-height: 280px; border-radius: 8px; display: block; object-fit: cover; }
/* Player de audio customizado (estilo WhatsApp). */
.team-audio { display: flex; align-items: center; gap: 0.55rem; min-width: 210px; max-width: 260px; padding: 0.15rem 0; }
.team-audio audio { display: none; }
.team-audio-btn {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.9rem; padding: 0;
    background: rgba(0,0,0,0.10); color: inherit; transition: background 0.12s;
}
.team-audio-btn:hover { background: rgba(0,0,0,0.18); }
.team-audio-btn i { transform: translateX(1px); }       /* centra o triangulo do play */
.team-audio.playing .team-audio-btn i, .team-audio-btn .fa-pause { transform: none; }
.team-audio-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.28rem; }
.team-audio-track { position: relative; height: 4px; border-radius: 2px; background: rgba(0,0,0,0.16); cursor: pointer; }
.team-audio-track::after { content: ''; position: absolute; inset: -7px 0; }   /* area de clique maior */
.team-audio-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px; background: currentColor; opacity: 0.85; }
.team-audio-time { font-size: 0.66rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.team-audio-mic { flex: 0 0 auto; font-size: 0.85rem; opacity: 0.55; }

/* Mensagens enviadas (balao azul): contraste em branco. Vale para os dois chats. */
.team-bubble.out .team-audio-btn, .inbox-bubble.out .team-audio-btn { background: rgba(255,255,255,0.22); color: #fff; }
.team-bubble.out .team-audio-btn:hover, .inbox-bubble.out .team-audio-btn:hover { background: rgba(255,255,255,0.34); }
.team-bubble.out .team-audio-track, .inbox-bubble.out .team-audio-track { background: rgba(255,255,255,0.32); }
.team-bubble.out .team-audio-fill, .inbox-bubble.out .team-audio-fill { background: #fff; opacity: 1; }
.team-bubble.out .team-audio-mic, .inbox-bubble.out .team-audio-mic { opacity: 0.8; }

/* Thumbnail clicavel de imagem/video (abre o lightbox). */
.team-media-thumb { position: relative; display: inline-block; padding: 0; border: none; background: none; cursor: pointer; border-radius: 8px; overflow: hidden; line-height: 0; }
.team-media-thumb img, .team-media-thumb video { transition: filter 0.12s; }
.team-media-thumb:hover img, .team-media-thumb:hover video { filter: brightness(0.92); }
.team-media-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.team-media-play i { width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }

/* Lightbox de midia compartilhado (chat da equipe + WhatsApp): imagem/video/PDF. */
.ui-lightbox { position: fixed; inset: 0; z-index: 3500; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.88); padding: 3rem 1rem; }
.ui-lightbox.hidden { display: none; }
.ui-lightbox-body { max-width: 92vw; max-height: 86vh; width: 100%; display: flex; align-items: center; justify-content: center; }
.ui-lightbox-media { max-width: 92vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); display: block; }
.ui-lightbox-frame { width: min(92vw, 980px); height: 86vh; border: none; border-radius: 8px; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.ui-lightbox-close, .ui-lightbox-download { position: fixed; top: 16px; width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.14); color: #fff; font-size: 1.05rem; text-decoration: none; }
.ui-lightbox-close { right: 16px; }
.ui-lightbox-download { right: 68px; }
.ui-lightbox-close:hover, .ui-lightbox-download:hover { background: rgba(255,255,255,0.28); }
/* Cartao de arquivo generico (estilo WhatsApp): icone colorido + nome +
   subtitulo (extensao/baixar) + botao de download. Usado nos 2 chats. */
.team-file-card {
    display: inline-flex; align-items: center; gap: 0.6rem; max-width: 260px; cursor: pointer;
    border: 1px solid rgba(0,0,0,0.12); background: rgba(0,0,0,0.05); border-radius: 10px;
    padding: 0.5rem 0.6rem; color: inherit; text-align: left; transition: background 0.12s, border-color 0.12s;
}
.team-file-card:hover { background: rgba(0,0,0,0.10); }
.team-file-ic {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; font-size: 1.05rem;
}
/* Cores por categoria de arquivo. */
.team-file-ic.doc-word   { background: #2b579a; }
.team-file-ic.doc-excel  { background: #1d6f42; }
.team-file-ic.doc-ppt    { background: #c43e1c; }
.team-file-ic.doc-text   { background: #5b6470; }
.team-file-ic.doc-zip    { background: #b58105; }
.team-file-ic.doc-code   { background: #3b7dd8; }
.team-file-ic.doc-audio  { background: #7c3aed; }
.team-file-ic.doc-video  { background: #be185d; }
.team-file-ic.doc-image  { background: #0891b2; }
.team-file-ic.doc-generic{ background: #64748b; }
.team-file-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.team-file-name { font-size: 0.84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-file-sub  { font-size: 0.72rem; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-file-dl {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; margin-left: 0.15rem;
    background: rgba(0,0,0,0.07); color: inherit; font-size: 0.8rem; opacity: 0.85; transition: background 0.12s, opacity 0.12s;
}
.team-file-card:hover .team-file-dl { opacity: 1; background: rgba(0,0,0,0.12); }
/* Variante em bolha enviada (azul): borda/fundo claros sobre o azul. */
.team-bubble.out .team-file-card, .inbox-bubble.out .team-file-card { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.28); color: #fff; }
.team-bubble.out .team-file-card:hover, .inbox-bubble.out .team-file-card:hover { background: rgba(255,255,255,0.26); }
.team-bubble.out .team-file-dl, .inbox-bubble.out .team-file-dl { background: rgba(255,255,255,0.22); }
.team-bubble.out .team-file-card:hover .team-file-dl, .inbox-bubble.out .team-file-card:hover .team-file-dl { background: rgba(255,255,255,0.34); }
/* Chip de documento (PDF) clicavel -> abre no lightbox. Usado nos 2 chats. */
.team-doc-chip {
    display: inline-flex; align-items: center; gap: 0.5rem; max-width: 240px; cursor: pointer;
    border: 1px solid rgba(0,0,0,0.12); background: rgba(0,0,0,0.05); border-radius: 8px;
    padding: 0.5rem 0.65rem; color: inherit; font-size: 0.82rem; text-align: left; transition: background 0.12s;
}
.team-doc-chip:hover { background: rgba(0,0,0,0.10); }
.team-doc-chip i { font-size: 1.3rem; color: #e2483d; flex: 0 0 auto; }   /* vermelho de PDF */
.team-doc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-bubble.out .team-doc-chip, .inbox-bubble.out .team-doc-chip { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.28); color: #fff; }
.team-bubble.out .team-doc-chip:hover, .inbox-bubble.out .team-doc-chip:hover { background: rgba(255,255,255,0.28); }
.team-bubble.out .team-doc-chip i, .inbox-bubble.out .team-doc-chip i { color: #fff; }
/* "Ver percurso": link verde DENTRO do cartao (estilo WhatsApp), nao um botao. */
.team-visit-link { color: #16a34a; text-decoration: none; font-size: 0.82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.2rem; width: fit-content; }
.team-visit-link:hover { text-decoration: underline; }
.team-bubble.out .team-visit-link { color: #4ade80; }

/* Cartao de visitante compartilhado */
.team-visit-card { display: flex; gap: 0.5rem; align-items: center; background: rgba(0,0,0,0.06); border-radius: 8px; padding: 0.4rem 0.5rem; margin-bottom: 0.25rem; }
.team-bubble.out .team-visit-card { background: rgba(255,255,255,0.18); }
.team-visit-ic { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.team-visit-info { display: flex; flex-direction: column; min-width: 0; }
.team-visit-info small { opacity: 0.8; }

/* Barra de gravacao de audio */
.team-rec-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; border-top: 1px solid var(--neutral-300); background: rgba(220,38,38,0.06); flex: none; }
.team-rec-bar.hidden { display: none; }
.team-rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #dc2626; box-shadow: 0 0 0 0 rgba(220,38,38,0.5); animation: teamRecPulse 1.2s infinite; flex: none; }
@keyframes teamRecPulse {
    0%   { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); opacity: 1; }
    70%  { box-shadow: 0 0 0 8px rgba(220,38,38,0); opacity: 1; }
    100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); opacity: 0.6; }
}
.team-rec-label { color: #dc2626; font-size: 0.84rem; }
.team-rec-clock { color: var(--neutral-700); font-variant-numeric: tabular-nums; font-size: 0.84rem; }
/* Onda animada (barrinhas) — reforça o "está gravando". */
.team-rec-wave { display: inline-flex; align-items: center; gap: 2px; height: 16px; }
.team-rec-wave i { width: 3px; height: 5px; border-radius: 2px; background: #dc2626; display: inline-block; animation: teamRecWave 0.9s ease-in-out infinite; }
.team-rec-wave i:nth-child(2) { animation-delay: 0.12s; }
.team-rec-wave i:nth-child(3) { animation-delay: 0.24s; }
.team-rec-wave i:nth-child(4) { animation-delay: 0.36s; }
.team-rec-wave i:nth-child(5) { animation-delay: 0.48s; }
@keyframes teamRecWave { 0%,100% { height: 5px; } 50% { height: 15px; } }

/* Resultados do "compartilhar visitante" */
.team-share-item { display: flex; flex-direction: column; gap: 0.1rem; width: 100%; text-align: left; background: none; border: 1px solid var(--neutral-200); border-radius: 8px; padding: 0.5rem 0.6rem; cursor: pointer; color: var(--neutral-800); }
.team-share-item:hover { background: var(--primary-soft); border-color: var(--primary); }
.team-share-item small { color: var(--neutral-500); font-size: 0.74rem; }

html[data-theme="dark"] .team-bubble.in { background: rgba(255,255,255,0.08); color: #e7e9ec; }
/* Coluna esquerda: lista de conversas */
.inbox-list { display: flex; flex-direction: column; border-right: 1px solid var(--neutral-300); min-width: 0; }
.inbox-list-head { padding: 0.7rem; border-bottom: 1px solid var(--neutral-300); }
.inbox-threads { flex: 1; overflow-y: auto; }
.inbox-loading, .inbox-empty-mini { padding: 1.5rem; text-align: center; color: var(--neutral-500); font-size: 0.85rem; }
.inbox-empty-mini i { font-size: 1.6rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }
.inbox-thread {
    display: flex; gap: 0.6rem; width: 100%; text-align: left; padding: 0.65rem 0.7rem;
    background: none; border: none; border-bottom: 1px solid var(--neutral-200);
    cursor: pointer; align-items: center; color: inherit;
}
.inbox-thread:hover { background: var(--neutral-100); }
.inbox-thread.active { background: var(--neutral-200); }
.inbox-thread-main { flex: 1; min-width: 0; }
.inbox-thread-top { display: flex; justify-content: space-between; gap: 0.4rem; align-items: baseline; }
.inbox-thread-top strong { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-thread-top small { color: var(--neutral-500); font-size: 0.68rem; flex: 0 0 auto; }
.inbox-thread-sub { display: flex; justify-content: space-between; gap: 0.4rem; align-items: center; margin-top: 0.15rem; }
.inbox-thread-sub span { color: var(--neutral-500); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-thread-assign { margin-top: 0.2rem; }
.inbox-assigned-chip { font-size: 0.66rem; color: var(--primary); background: rgba(0,0,0,0.04); border-radius: 999px; padding: 0.05rem 0.4rem; }
.inbox-badge { background: var(--primary); color: #fff; border-radius: 999px; font-size: 0.65rem; padding: 0.05rem 0.4rem; flex: 0 0 auto; }
.inbox-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
}
/* Coluna direita: conversa */
.inbox-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.inbox-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--neutral-500); gap: 0.5rem; }
.inbox-empty i { font-size: 2.4rem; opacity: 0.5; }
.inbox-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.inbox-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--neutral-300); }
.inbox-chat-who { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.inbox-chat-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.inbox-assign-bar { padding: 0.5rem 0.9rem; font-size: 0.78rem; background: rgba(0,150,80,0.08); border-bottom: 1px solid var(--neutral-200); color: var(--neutral-700); }
.inbox-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; background: var(--neutral-50, rgba(0,0,0,0.02)); }
.inbox-bubble { max-width: 72%; padding: 0.45rem 0.65rem; border-radius: 10px; font-size: 0.86rem; line-height: 1.35; position: relative; }
.inbox-bubble.in  { align-self: flex-start; background: var(--neutral-200); color: var(--neutral-900); border-top-left-radius: 3px; }
.inbox-bubble.out { align-self: flex-end; background: #2563eb; color: #fff; border-top-right-radius: 3px; }
.inbox-bubble-name { font-size: 0.68rem; font-weight: 700; opacity: 0.9; margin-bottom: 0.15rem; display: flex; align-items: center; gap: 0.3rem; }
.inbox-bubble-ava {
    width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.52rem; font-weight: 700; background: rgba(255,255,255,0.25); color: #fff;
}
.inbox-bubble-ava-fallback { background: rgba(255,255,255,0.3); }
.inbox-bubble-meta { font-size: 0.62rem; opacity: 0.7; text-align: right; margin-top: 0.15rem; }
.inbox-bubble-img { max-width: 240px; border-radius: 8px; display: block; }
.inbox-compose { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.6rem 0.8rem; border-top: 1px solid var(--neutral-300); }
.inbox-compose textarea { flex: 1; resize: none; max-height: 120px; min-height: 38px; }
.inbox-compose-disabled { opacity: 0.7; }
@media (max-width: 820px) {
    .inbox-shell { grid-template-columns: 1fr; height: calc(100dvh - 180px); }
    .inbox-list { display: none; }
}

/* ====================== ATUALIZAÇÕES (admin global) ====================== */
/* Abas internas (pílulas grandes) */
.sys-tabs {
    display: inline-flex; gap: 4px; margin-bottom: 1.1rem;
    background: var(--neutral-200); border-radius: 10px; padding: 4px;
}
.sys-tab {
    display: inline-flex; align-items: center; gap: 0.45rem;
    border: none; background: transparent; color: var(--neutral-600);
    font-size: 0.86rem; font-weight: 600; padding: 0.5rem 1rem;
    border-radius: 8px; cursor: pointer; transition: background .12s, color .12s;
    white-space: nowrap;
}
.sys-tab:hover { color: var(--neutral-900); }
.sys-tab.active {
    background: var(--neutral-100); color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.14);
}
/* Grade de cartões de ação (backups/dumps) */
.sys-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 0.9rem;
}
.sys-action-card {
    display: flex; align-items: flex-start; gap: 0.8rem;
    background: var(--neutral-100); border: 1px solid var(--neutral-300);
    border-radius: 12px; padding: 0.95rem 1rem;
}
.sys-action-icon {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.sys-action-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.sys-action-body strong { font-size: 0.9rem; color: var(--neutral-900); }
.sys-action-body small { color: var(--neutral-500); font-size: 0.78rem; line-height: 1.35; }
.sys-action-btn { flex: 0 0 auto; align-self: center; }
.sys-check {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-size: 0.76rem; color: var(--neutral-600); cursor: pointer; margin-top: 0.35rem;
}
@media (max-width: 560px) {
    .sys-action-card { flex-wrap: wrap; }
    .sys-action-btn { width: 100%; }
}
