:root {
    /* Mapeamento de Cores URJAIS TEC */
    --cor-fundo: #F7FAF9;         
    --cor-primaria: #1A1A1A;      
    --cor-secundaria: #FFFFFF;    
    --cor-texto: #1A1A1A;         
    --cor-texto-secundario: #4A5568; 
    --cor-realce: #B8860B;        
    --cor-borda: #E2E8F0;         
    --cor-sucesso: #38a169;
    --cor-aviso: #dd6b20;
    --cor-perigo: #e53e3e;
    --sombra-caixa: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
* { box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    margin: 0; 
    background-color: var(--cor-fundo); 
    color: var(--cor-texto); 
    display: flex; 
    flex-direction: column;
    height: 100vh; 
    overflow: hidden; 
}
.container-app { display: flex; width: 100%; flex-grow: 1; overflow: hidden; }
.sidebar { 
    width: 200px; 
    background-color: var(--cor-primaria); 
    color: white; 
    padding: 24px; 
    flex-shrink: 0; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px solid var(--cor-borda);
    transition: width 0.3s ease-in-out, padding 0.3s ease-in-out; 
    z-index: 2000; 
}
.sidebar-header { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    margin-bottom: 40px; 
    overflow: hidden;
    justify-content: center; /* Alinhar o Logo no centro */
}
/* CORREÇÃO: Mostrar H1 e deixar o .sidebar-collapsed cuidar de esconder quando encolhido */
.sidebar-header h1 { 
    font-size: 1.2rem;
    margin: 0;
    white-space: nowrap;
    transition: opacity 0.3s, width 0.3s;
} 
.sidebar-header .logo-icon { fill: white; width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-nav { flex-grow: 1; overflow-y: auto; overflow-x: hidden; }
/* Scrollbar customizada para o menu lateral */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; color: #a0aec0; transition: background-color 0.2s, color 0.2s; font-weight: 500; cursor: pointer; padding: 12px; border-radius: 6px; margin-bottom: 8px; font-size: 0.95rem; }
.sidebar-nav a .nav-icon { fill: #a0aec0; transition: fill 0.2s; width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-nav a:hover, .sidebar-nav a.active { background-color: var(--cor-realce); color: white; }
.sidebar-nav a:hover .nav-icon, .sidebar-nav a.active .nav-icon { fill: white; }
.sidebar-nav a span { white-space: normal; line-height: 1.2; word-wrap: break-word; transition: opacity 0.2s, width 0.2s; } 

.sidebar-footer { 
    margin-top: auto; 
    flex-shrink: 0;
    padding-top: 15px; 
    border-top: 1px solid var(--cor-borda);
    text-align: center; /* Centralizar o branding */
}
.sidebar-footer .branding {
    font-size: 0.75rem; 
    color: #a0aec0; 
    opacity: 0.7;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.main-content { flex-grow: 1; padding: 32px; overflow-y: auto; transition: margin-left 0.3s ease-in-out; } 
header { 
    display: flex; 
    align-items: center; 
    margin-bottom: 32px; 
    justify-content: space-between; 
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
header h2 { 
    margin: 0; 
    font-size: 1.875rem; 
    font-weight: 700; 
    color: var(--cor-realce); 
    border: none; 
    padding: 0;
    white-space: normal;
    line-height: 1.2;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.user-profile { font-weight: 600; color: var(--cor-texto-secundario); } 
.tela { display: none; }
.tela.ativa { display: block; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.card { background-color: var(--cor-secundaria); padding: 24px; border-radius: 8px; box-shadow: var(--sombra-caixa); margin-bottom: 24px; border: 1px solid var(--cor-borda); } 
.card h4 { color: var(--cor-realce); margin-top: 20px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--cor-borda); }
.card h4:first-child { margin-top: 0; }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.card-header h3 { margin: 0; font-size: 1.125rem; font-weight: 600; color: var(--cor-texto); border: none; padding: 0; }
.card.full-width { grid-column: 1 / -1; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 24px; }
.kpi-card { 
    background-color: var(--cor-secundaria); 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: var(--sombra-caixa); 
    transition: background-color 0.2s;
    border: 1px solid var(--cor-borda); 
}
.kpi-card[data-action="navegar-kpi"],
.kpi-card[data-action="navegar-kpi-disponiveis"] { /* Adicionado seletor */
    cursor: pointer;
}
.kpi-card[data-action="navegar-kpi"]:hover,
.kpi-card[data-action="navegar-kpi-disponiveis"]:hover {
    background-color: #F0F0F0; 
}
.kpi-card-title { font-size: 0.875rem; font-weight: 600; color: var(--cor-texto-secundario); margin-bottom: 8px; }
.kpi-card-value { font-size: 2rem; font-weight: 700; color: var(--cor-texto); }
.kpi-card-value.success { color: var(--cor-sucesso); }
.kpi-card-value.danger { color: var(--cor-perigo); }

/* LISTAS DE ALERTAS E STATUS CLICÁVEIS */
.alert-list li[data-action], .status-list li[data-action] {
    cursor: pointer;
    transition: background-color 0.2s;
}
.alert-list li[data-action]:hover, .status-list li[data-action]:hover {
    background-color: rgba(0, 0, 0, 0.05); 
}

.alert-list, .status-list { list-style: none; padding: 0; margin: 0; }
.alert-list li, .status-list li { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--cor-borda); font-size: 0.9rem; }
.alert-list li:last-child, .status-list li:last-child { border-bottom: none; }
.alert-icon { width: 20px; height: 20px; margin-right: 12px; flex-shrink: 0; }
.tag { padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 700; color: white; white-space: nowrap; }
.tag-success { background-color: var(--cor-sucesso); } .tag-warning { background-color: var(--cor-aviso); } .tag-info { background-color: var(--cor-realce); } .tag-danger { background-color: var(--cor-perigo); }
.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-size: 0.95em; font-weight: 600; transition: all 0.2s; }
.btn-primary { background-color: var(--cor-realce); color: white; }
.table-container { 
    overflow-x: auto; 
    transform: rotateX(180deg); /* Truque para barra de scroll no topo */
}
table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 20px; 
    transform: rotateX(180deg); /* Desfaz a rotação para o conteúdo ficar legível */
}
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--cor-borda); white-space: nowrap; }
th { background-color: #F0F0F0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cor-texto); }

/* Tabela Compacta para evitar Scroll Horizontal excessivo */
.tabela-compacta th, .tabela-compacta td {
    padding: 8px 10px;
    font-size: 0.85rem;
}
.tabela-compacta td .actions { gap: 3px; }
.tabela-compacta .btn-small {
    padding: 4px 8px;
    font-size: 0.75rem;
}

tbody tr:hover { background-color: #F0F0F0; } 
td .actions { display: flex; justify-content: flex-end; gap: 5px; }
.btn-small { padding: 6px 12px; font-size: 0.8rem; background-color: var(--cor-borda); color: var(--cor-texto); border: none; border-radius: 4px; cursor: pointer; margin-left: 5px; } 
.btn-danger { background-color: var(--cor-perigo); color: white; }

.col-valor {
    width: 15%; 
    min-width: 130px; 
}

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background-color: var(--cor-secundaria); padding: 30px; border-radius: 8px; width: 90%; max-width: 800px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); position: relative; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin:0; border: none; padding: 0; color: var(--cor-realce); font-size: 1.5rem;}
.modal-close-btn { background: none; border: none; font-size: 2rem; cursor: pointer; color: var(--cor-texto-secundario); line-height: 1; }
.modal-footer { margin-top: 30px; display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.form-group input, .form-group select { 
    width: 100%; padding: 10px; border: 1px solid var(--cor-borda); border-radius: 6px; font-size: 1rem; 
    background-color: var(--cor-secundaria); 
    color: var(--cor-texto); 
}
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.9rem; }
.documento-upload { display: flex; align-items: center; gap: 10px; position: relative; }
.documento-upload img { height: 40px; width: 60px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 1px solid var(--cor-borda);}
.btn-remover-foto { position: absolute; left: 55px; top: -5px; background: red; color: white; border: none; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; padding: 0; }
#resumo-acerto { background-color: #F0F0F0; padding: 20px; border-radius: 8px; margin-top: 20px; border: 1px solid var(--cor-borda); } 
#resumo-acerto h4 { margin-top: 0; color: var(--cor-realce); }
#resumo-acerto p { display: flex; justify-content: space-between; margin: 8px 0; font-size: 1.1rem; }
#resumo-acerto p span:last-child { font-weight: 700; }
#resumo-acerto .total { border-top: 2px solid var(--cor-borda); padding-top: 10px; font-size: 1.3rem; color: var(--cor-realce); }
.success-text { color: var(--cor-sucesso); font-weight: bold; }
.danger-text { color: var(--cor-perigo); font-weight: bold; }
.chart-container { position: relative; height: 300px; }
input[type="date"] {
    color-scheme: dark;
}

/* === ESTILOS PARA MOBILE === */
.mobile-menu-btn {
    display: none; 
    background: none;
    border: none;
    padding: 0;
    margin-right: 15px;
    cursor: pointer;
}
.mobile-menu-btn svg {
    width: 30px;
    height: 30px;
    fill: var(--cor-realce);
}
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1900; 
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
.sidebar-overlay.ativo {
    opacity: 1;
    visibility: visible;
}
.btn-container-mobile {
    display: none; /* Escondido em Desktop */
}

/* === NOVOS ESTILOS PARA MENU RETRÁTIL (DESKTOP) === */
.desktop-menu-btn {
    background: none;
    border: none; /* Tirado a borda */
    color: var(--cor-texto); /* Usa a cor principal do texto */
    cursor: pointer;
    padding: 0; /* Tirado padding */
    margin-right: 15px; /* Espaço entre o botão e o título */
    flex-shrink: 0; 
}
.desktop-menu-btn:hover {
    color: var(--cor-realce); /* Hover dourado */
}
.desktop-menu-btn .nav-icon {
    width: 28px; /* Aumentado um pouco */
    height: 28px;
    fill: currentColor;
    font-weight: bold; 
}
.desktop-menu-btn .icon-expand { display: none; }


/* Estado Encolhido (Aplicado ao BODY) */
body.sidebar-collapsed .sidebar {
    width: 70px;
    padding: 24px 12px;
}
body.sidebar-collapsed .sidebar .sidebar-header {
    justify-content: center;
}
body.sidebar-collapsed .sidebar .sidebar-header h1 {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
body.sidebar-collapsed .sidebar .sidebar-nav a {
    justify-content: center;
}
body.sidebar-collapsed .sidebar .sidebar-nav a span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}
body.sidebar-collapsed .sidebar .sidebar-footer .branding {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
body.sidebar-collapsed .desktop-menu-btn .icon-collapse { display: none; }
body.sidebar-collapsed .desktop-menu-btn .icon-expand { display: block; }


/* === REGRAS PARA ECRÃS PEQUENOS (MOBILE) === */
@media (max-width: 768px) {
    .desktop-menu-btn {
        display: none !important;
    }
    
    header h2 {
        font-size: 1.3rem;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 2000;
        transform: translateX(-100%);
        width: 250px; 
        padding: 24px; 
    }
    .sidebar.ativo {
        transform: translateX(0);
    }
    .main-content {
        padding: 20px; 
    }
    .mobile-menu-btn {
        display: block; 
    }
    .user-profile {
        display: none; 
    }
    header .btn {
        display: none;
    }
    .btn-container-mobile {
        display: block;
        position: fixed; 
        bottom: 20px;
        right: 20px;
        z-index: 500; 
    }
    .btn-container-mobile .btn {
        font-size: 1.5rem; 
        width: 56px; 
        height: 56px;
        border-radius: 50%;
        padding: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    .card:last-child {
        margin-bottom: 100px;
    }
}
@media (min-width: 769px) {
    header .btn {
        display: block;
    }
}

/* Spinner de Loading nos Botões */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Histórico de Quilometragem */
.table-km-history { width: 100%; border-collapse: collapse; margin-top: 10px; background: rgba(0,0,0,0.05); border-radius: 8px; overflow: hidden; border: 1px solid var(--cor-borda); }
.table-km-history th { text-align: left; padding: 10px; font-size: 0.85rem; color: var(--cor-texto-secundario); border-bottom: 1px solid var(--cor-borda); background-color: rgba(0,0,0,0.02); }
.table-km-history td { padding: 8px 10px; border-bottom: 1px solid var(--cor-borda); }
.table-km-history input { width: 100%; padding: 8px 10px; background: var(--cor-secundaria); border: 1px solid var(--cor-borda); border-radius: 4px; color: var(--cor-texto); font-size: 0.9rem; transition: border-color 0.2s; }
.table-km-history input:focus { border-color: var(--cor-realce); outline: none; }
.table-km-history .btn-remover-km { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; border-radius: 4px; padding: 6px 12px; cursor: pointer; transition: 0.2s; font-weight: 600; font-size: 0.85rem; }
.table-km-history .btn-remover-km:hover { background: #ef4444; color: #fff; border-color: #ef4444; }