/* 
   ELAV Logistics - Modern UI Variables and Reset
*/
:root {
    /* Color Palette baseada na identidade visual ELAV (Verde e Azul escuro) */
    --bg-color: #272B4B;
    /* Azul Escuro do fundo Site Elav */
    --bg-secondary: #ffffff;
    /* Fundo caixas */
    --primary: #9BC141;
    /* Verde característico Elav */
    --primary-hover: #8AB031;
    --primary-dark: #1e213a;
    /* Azul ainda mais escuro para a sidebar */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --text-main: #2C3E50;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --glass-bg: #ffffff;
    --glass-border: #ffffff;

    /* Transitions & Shadows */
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
    --radius: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

input,
select,
textarea {
    color: #1e293b !important;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8 !important;
}

/* Evita Zoom automático no iOS Safari ao clicar em inputs */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    font-size: 16px !important;
}

label {
    color: var(--text-main) !important;
    font-weight: 600;
}

body.light-theme {
    background: linear-gradient(to right, var(--bg-color) 0%, #0a0d1a 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Glassmorphism panel base */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Base Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Driver mode body override */
body.driver-mode .sidebar {
    display: none !important;
}

body.driver-mode .main-content {
    padding: 10px;
}

body.driver-mode .top-header {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

body.driver-mode .cards-layout {
    grid-template-columns: 1fr;
}

body.driver-mode .rota-card {
    cursor: default;
}

body.driver-mode .admin-only:not(#btn-toggle-driver-mode),
body.driver-mode .btn-novo-ciclo {
    display: none !important;
}

.driver-only-action,
.driver-only-panel {
    display: none !important;
}

body.driver-mode .driver-only-action {
    display: flex !important;
}

body.driver-mode .driver-only-panel {
    display: flex !important;
}

body.driver-mode .admin-only-action {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 250px;
    height: 100vh;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .logo img {
    display: none;
}

.sidebar.collapsed .logo::after {
    content: "ELAV";
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
}

.sidebar.collapsed .subtitle,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-profile .user-info {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-item i {
    font-size: 1.2rem;
    margin: 0;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding: 10px;
    flex-shrink: 0;
}

.nav-menu {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.4rem;
}

.subtitle {
    font-size: 0.75rem;
    color: #cbd5e1;
}

.nav-item {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 2px;
    border-left: 3px solid transparent;
}

.nav-item i {
    font-size: 1.1rem;
    width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.0) 100%);
    color: white;
    border-left: 3px solid rgba(255, 255, 255, 0.6);
}

.nav-item:hover i {
    transform: scale(1.25) translateY(-2px) rotate(5deg);
    filter: drop-shadow(0 2px 6px currentColor);
}

.nav-item a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
}

.sidebar.collapsed .nav-item a {
    justify-content: center;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    border-left: 3px solid white;
}

.nav-item.active i {
    color: white !important;
    transform: scale(1.1);
}

.sidebar-footer-container {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-wrapper {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.user-avatar-new {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(to bottom right, #f97316, #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.user-details-new {
    margin-left: 0.75rem;
    overflow: hidden;
}

.user-name-new {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin: 0;
}

.user-status-new {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
}

.status-dot-new {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #22c55e;
    display: inline-block;
}

.btn-logout-new {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout-new:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.group-hover-translate {
    transition: transform 0.2s ease;
}

.btn-logout-new:hover .group-hover-translate {
    transform: translateX(-0.25rem);
}

.sidebar.collapsed .user-wrapper {
    padding: 0.5rem;
    justify-content: center;
}

.sidebar.collapsed .user-details-new {
    display: none;
}

.sidebar.collapsed .btn-logout-new .menu-text {
    display: none;
}

.sidebar.collapsed .btn-logout-new .group-hover-translate {
    margin-right: 0;
}

.sidebar.collapsed .btn-logout-new:hover .group-hover-translate {
    transform: none;
    /* remove slide animation when collapsed */
}

/* O botão de recolher que vai ficar por cima da borda (!important) */
#btn-desktop-menu {
    position: absolute;
    top: 5rem;
    right: -14px;
    /* Move exactly over the right edge */
    width: 28px;
    height: 28px;
    background-color: #f97316;
    /* pwa-accent (Laranja Escuro) */
    color: white;
    border: 4px solid var(--bg-color);
    /* Set exactly the bg color of body */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

#btn-desktop-menu:hover {
    transform: scale(1.1);
}

/* Mantem o botao sobre a borda, mesmo recolhido */
.sidebar.collapsed #btn-desktop-menu {
    right: -14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: #cbd5e1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem 1rem;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 100px;
}

.top-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#viagem-controls {
    display: flex;
    gap: 0.8rem;
}

/* Buttons */
.btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.w-100 {
    width: 100%;
}

.mt-3 {
    margin-top: 0.8rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-4 {
    padding: 1rem;
}

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.text-center {
    text-align: center;
}

/* Views System */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Layout */
.cards-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
}

.interactive-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    transition: var(--transition);
    background: var(--bg-secondary);
    cursor: pointer;
}

.interactive-zone:active {
    cursor: move;
}

.interactive-zone:hover,
.interactive-zone.dragover {
    border-color: var(--primary);
    background: #f1f5f9;
}

.icon-large {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.interactive-zone h3 {
    font-size: 1rem;
}

.interactive-zone p {
    font-size: 0.8rem;
}

.ciclo-stats {
    padding: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-entrega {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-coleta {
    background: #f3e8ff;
    color: #7e22ce;
    border: 1px solid #d8b4fe;
}

.badge-concluido {
    background: #dcfce7 !important;
    color: #166534 !important;
    border: 1px solid #bbf7d0 !important;
}

.badge-insucesso {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tables */
.table-container {
    padding: 1px;
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th,
.modern-table td {
    padding: 0.5rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.modern-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.modern-table tbody tr {
    transition: var(--transition);
}

.modern-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Inputs */
.search-box {
    position: relative;
    flex: 1;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.filters {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
}

/* Rota Cards */
.rota-container {
    padding: 1px;
}

.rota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.rota-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    counter-reset: rota-counter;
}

.rota-card {
    counter-increment: rota-counter;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rota-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.rota-card:hover .fa-bars {
    color: #000000 !important;
}

.rota-card:active {
    cursor: ns-resize;
}

.card-info {
    display: flex;
    flex-direction: column;
}

.rota-num-indicador::before {
    content: counter(rota-counter);
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================
   TELA DE LOGIN
========================================== */
.login-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--primary-dark) 100%);
}

.login-view.active {
    display: flex;
}

.login-box {
    width: 90%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(20px);
}

@media (max-width: 576px) {
    .login-box {
        padding: 2.5rem 1.5rem;
        width: 95%;
    }
}

.login-box h3 {
    color: white;
    font-weight: 300;
    letter-spacing: 1px;
    margin-bottom: 2rem !important;
}

.form-group {
    width: 100%;
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Especial para a tela de login - inputs claros com fundo branco */
.login-input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: #ffffff;
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(155, 193, 65, 0.4);
}

.justify-center {
    justify-content: center;
    display: flex;
    align-items: center;
}

.w-100 {
    width: 100%;
}

.m-0 {
    margin: 0;
}

.mb-3 {
    margin-bottom: 0.8rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-0 {
    padding: 0 !important;
}

/* Correção Driver Mode hiding */
.driver-mode .sidebar {
    display: none !important;
}

body.driver-mode .main-content {
    margin-left: 0 !important;
    padding-bottom: 15px;
}

.driver-only-logout {
    display: none !important;
}

body.driver-mode .driver-only-logout-footer {
    display: inline-flex !important;
}

body.driver-mode #btn-mobile-menu {
    display: none !important;
}

/* ==========================================
   MODAL COMPONENT
========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background: var(--bg-secondary);
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
    animation: slideUp 0.3s ease-out forwards;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-main);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================
   CUSTOM STATS AND UPLOAD UI
========================================== */

/* Top Stats Header */
.stats-header-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

.stats-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: 1px solid var(--border);
    padding-right: 15px;
    min-width: 200px;
}

.stats-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(155, 193, 65, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(155, 193, 65, 0.3);
}

.stats-icon-wrapper i {
    color: var(--primary);
    font-size: 1rem;
}

.stats-info-text {
    display: flex;
    flex-direction: column;
}

.stats-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.stats-title-row h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    margin: 0;
}

.stats-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: monospace;
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.badge-pulse {
    animation: pulse 2s infinite;
    font-size: 0.65rem !important;
    padding: 2px 8px !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.stats-details-row {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.stats-details-row span {
    font-weight: 700;
    color: var(--text-main);
}

/* Stats Metrics Block */
.stats-metrics-container {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.metric-group-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 12px;
    gap: 5px;
}

.stat-metric-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 10px;
    min-width: 80px;
}

.stat-metric-col.border-left {
    border-left: 1px solid var(--border);
}

.stat-metric-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-metric-title.muted {
    color: var(--text-muted);
    opacity: 0.7;
}

.stat-metric-title.success {
    color: var(--success);
}

.stat-metric-title.danger {
    color: var(--danger);
}

.stat-metric-value {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
}

.stat-metric-value.main {
    color: var(--text-main);
}

.stat-metric-value.success {
    color: var(--success);
}

.stat-metric-value.danger {
    color: var(--danger);
}

/* Progress Bar section */
.stats-progress-container {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: rgba(155, 193, 65, 0.05);
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px dotted rgba(155, 193, 65, 0.4);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 4px;
}

.progress-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main);
}

.progress-pct {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text-main);
}

.progress-track {
    width: 100%;
    background: #f1f5f9;
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #fbbf24);
    width: 0%;
    transition: width 1s ease-in-out;
    border-radius: 10px;
}

/* Upload UI */
.upload-card-container {
    background: var(--glass-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}


/* Animations */
.fa-spin {
    animation: fa-spin 2s infinite linear;
}

/* ========== RESPONSIVIDADE MOBILE ========== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    #btn-desktop-menu {
        display: none !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        overflow-y: auto;
        transform: translateX(-100%);
        width: 260px;
        z-index: 99999;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    #btn-mobile-menu {
        display: block !important;
    }

    .btn-close-sidebar {
        display: block !important;
    }

    body.driver-mode {
        min-height: 100vh;
        min-height: 100dvh;
    }

    body.driver-mode .app-container {
        min-height: 100%;
    }

    body.driver-mode .main-content {
        min-height: 100%;
        display: flex;
        flex-direction: column;
        padding: 5px;
    }

    body.driver-mode .content-wrapper,
    body.driver-mode .view-section,
    body.driver-mode .cards-layout,
    body.driver-mode .rota-container {
        display: flex;
        flex-direction: column;
        margin-bottom: 0px !important;
    }

    body.driver-mode .rota-list {
        padding-bottom: 40px;
    }

    .stats-cards-wrapper {
        flex-direction: column;
    }

    .stats-panel {
        width: 100%;
        min-width: unset !important;
    }

    /* Modal adjusts for mobile */
    .modal-content {
        width: 95%;
        margin: 10px;
    }

    /* Ocultar avatar gigante no mobile se preciso (nao ess) */
}

@media (max-width: 992px) {
    .stats-header-container {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-header-info {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-right: 0;
        padding-bottom: 15px;
    }

    .stats-progress-container {
        border-left: none;
        padding-left: 0;
        width: 100%;
        margin-top: 10px;
    }
}

/* Numeracao Estatica para Rota Ativa */
#rota-list {
    counter-reset: rota-counter;
    padding-left: 25px;
    /* Abre margem na esquerda da lista inteira para caber os numeros soltos */
}

#rota-list .rota-card {
    position: relative;
    counter-increment: rota-counter;
}

#rota-list .rota-card::before {
    content: counter(rota-counter);
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ==========================================
   ITEM 3: DRAG & DROP EXPRESSIVO
========================================== */
.sortable-ghost {
    opacity: 0.35;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.18), rgba(155, 193, 65, 0.18)) !important;
    border: 2.5px dashed #f97316 !important;
    border-radius: 8px !important;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.35), 0 8px 24px rgba(249, 115, 22, 0.2) !important;
    transform: scale(0.985);
}

.sortable-chosen {
    box-shadow: 0 8px 28px rgba(249, 115, 22, 0.35) !important;
    border-color: #f97316 !important;
    background: #fff8f0 !important;
    z-index: 100;
    opacity: 0.95;
}

.sortable-drag {
    opacity: 1 !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22), 0 0 0 3px #f97316 !important;
    transform: rotate(-1.5deg) scale(1.03) !important;
    border-color: #f97316 !important;
    background: #fff !important;
    z-index: 9999 !important;
}

/* Linha de destino durante drag */
.sortable-fallback {
    opacity: 0.9;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18) !important;
}

/* ==========================================
   ITEM 4: ANIMAÇÃO "ENVIANDO PARA IA" DARK
========================================== */
@keyframes ia-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

@keyframes ia-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }

    50% {
        box-shadow: 0 0 18px 5px rgba(74, 222, 128, 0.35);
    }
}

@keyframes ia-pulse-border {

    0%,
    100% {
        border-color: rgba(74, 222, 128, 0.5);
    }

    50% {
        border-color: rgba(74, 222, 128, 1);
    }
}

.card-ia-loading {
    background: linear-gradient(135deg, rgba(10, 15, 25, 0.94), rgba(20, 30, 20, 0.97)) !important;
    border: 2px solid rgba(74, 222, 128, 0.6) !important;
    border-radius: 10px !important;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.4) !important;
    animation: ia-glow 1.8s ease-in-out infinite, ia-pulse-border 1.8s ease-in-out infinite !important;
}

.card-ia-loading .ia-status-txt {
    animation: ia-blink 1.1s ease-in-out infinite;
    color: #4ade80;
    font-size: 1rem !important;
    font-weight: 900 !important;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.7);
}

.card-ia-loading .ia-filename {
    color: rgba(180, 230, 180, 0.75);
    font-size: 0.8rem;
    font-family: monospace;
}

@keyframes retorno-blink {

    0%,
    49% {
        color: #4ade80;
        text-shadow: 0 0 10px rgba(74, 222, 128, 0.9), 0 0 20px rgba(74, 222, 128, 0.5);
    }

    50%,
    100% {
        color: #000000;
        text-shadow: 0 0 6px rgba(74, 222, 128, 0.3);
    }
}

.card-ia-retorno {
    font-size: 1.05rem !important;
    font-weight: 900 !important;
    letter-spacing: 0.3px;
    animation: retorno-blink 0.9s step-end infinite;
    margin-top: 2px;
}

/* ==========================================
   ITEM 5: CARDS MOTORISTA MOBILE LEGÍVEIS
========================================== */
@media (max-width: 768px) {
    .rota-card {
        padding: 12px 10px;
        border-radius: 10px;
    }

    /* O grid vira coluna, mas mantemos o alinhamento flex-start */
    .rota-card .card-info > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        align-items: flex-start !important;
        width: 100% !important;
    }
    
    /* Regra geral de alinhamento para os filhos do grid */
    .rota-card .card-info > div[style*="grid-template-columns"] > div {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
    }

    /* Esconde placeholders vazios */
    .rota-card .card-info > div[style*="grid-template-columns"] > div:empty {
        display: none !important;
    }

    /* Esconde o bloco de total/valor no mobile de forma robusta (ganha na especificidade da regra geral de alinhamento) */
    .rota-card .card-info > div[style*="grid-template-columns"] .card-total-box {
        display: none !important;
    }

    /* Ajuste fino nas ações e horários */
    .rota-card .card-actions-wrapper {
        align-items: flex-start !important;
        width: 100% !important;
        margin-top: 5px !important;
    }

    .rota-card .card-actions-wrapper > div {
        justify-content: flex-start !important;
    }

    .rota-card .card-actions-wrapper div[style*="text-align: right"] {
        text-align: left !important;
    }

    /* Cursor default no modo motorista */
    body.driver-mode .rota-card {
        cursor: default !important;
    }

    body.driver-mode .rota-card .driver-only-action {
        width: 100%;
        display: flex !important;
        gap: 8px;
        flex-wrap: wrap;
    }

    body.driver-mode .rota-card .driver-only-action .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
    }

    body.driver-mode #rota-list {
        padding-left: 30px;
    }
}

/* ==========================================
   ITEM 9: ANIMAÇÃO DE BRILHO (DINHEIRO)
========================================== */
@keyframes money-shine {
    0% {
        left: -150%;
    }

    100% {
        left: 150%;
    }
}

.money-animated {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    z-index: 1;
}

.money-animated * {
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.money-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 60%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0) 100%);
    animation: money-shine 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    transform: skewX(-25deg);
    z-index: -1;
}