@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #f5f3ff;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--background);
    margin: 0; padding: 0;
    font-size: 13px;
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 100%; margin: 0; padding: 10px 20px 20px 20px; }

.card {
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

/* Header & Nav */
.header-main {
    position: sticky;
    top: 0;
    z-index: 2500;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 10px 20px;
    margin: -10px -20px 20px -20px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-container { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; padding: 5px 0; }

.main-group-btn {
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    margin-right: 8px;
    font-size: 11px;
    transition: all 0.2s;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.main-group-btn.active.btn-logistica { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.main-group-btn.active.btn-administracion { background: #fdf2f8; color: #db2777; border-color: #fbcfe8; }
.main-group-btn.active.btn-analisis { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }

.sub-nav-container { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 5px; }

.tab-btn { padding: 6px 14px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; margin-right: 6px; background: transparent; color: var(--text-muted); font-size: 11px; transition: 0.2s; }
.tab-active { background: var(--surface) !important; color: var(--primary) !important; box-shadow: var(--shadow-sm); }

/* Sub-tabs Modernization */
.sub-tab-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 10px;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sub-tab-btn:hover {
    color: var(--text-main);
    background: rgba(0,0,0,0.03);
}

.sub-tab-active {
    background: white !important;
    color: var(--primary) !important;
    box-shadow: var(--shadow-sm);
}

/* Dashboard Cards */
.dashboard-resumen { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.dash-card {
    background: var(--surface);
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-align: center;
    border: 1px solid var(--border);
    border-bottom: 3px solid var(--primary);
}
.dash-card h4 { margin: 0; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dash-card .value { font-size: 20px; font-weight: 800; color: var(--text-main); margin-top: 4px; }
.dash-card.alert { border-bottom-color: var(--danger); }

/* Dashboard & Stats (General) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 15px;
}

.card-stats {
    background: var(--surface);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s;
}

.card-stats:hover { transform: translateY(-2px); }

.card-stats h4 {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.stat-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.stat-label { font-size: 12px; color: var(--text-muted); }

canvas { max-width: 100% !important; height: auto !important; }

/* Table & Rows (Global) */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; }

/* Monitor Layout (Specific for Monitoring Tab) */
.monitor-layout { display: flex; gap: 20px; align-items: flex-start; }
.monitor-layout .left-panel { width: 62%; flex: 0 0 62%; }
.monitor-layout .map-container { width: 38%; flex: 0 0 38%; position: sticky; top: 120px; }

/* Ultra Compact Table only for Monitoring Tab */
#v-monitoreo table th,
#v-monitoreo table td {
    padding: 5px 8px;
    font-size: 11px;
}

#v-monitoreo .card h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--primary);
}

#main-map { height: 750px; width: 100%; border-radius: var(--radius-md); }

.viaje-row-container { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 4px; overflow: hidden; background: white; transition: 0.2s; }
.viaje-row-container:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }

.viaje-row-header {
    display: grid;
    grid-template-columns: 60px 110px 1.2fr 1fr 1.5fr 100px 90px 120px;
    gap: 10px;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    font-size: 12px;
}
.header-activos { grid-template-columns: 55px 95px 1.1fr 1.35fr 210px 245px 105px !important; }
.header-resumen-viaje { grid-template-columns: 55px 95px 1.1fr 1.35fr 210px 245px 105px !important; }
.viaje-cliente-ruta { display: grid; gap: 4px; min-width: 0; }
.viaje-cliente-ruta b, .viaje-cliente-ruta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viaje-cliente-ruta small { color: #64748b; font-size: 10px; }
.viaje-facturacion, .viaje-liquidacion { display: grid; gap: 2px; font-size: 9px; line-height: 1.15; }
.viaje-finanzas-compactas { display: flex; align-items: center; flex-wrap: wrap; column-gap: 7px; row-gap: 3px; }
.viaje-finanzas-compactas > span { white-space: nowrap; }
.viaje-finanzas-compactas > span:first-child { color: var(--text-muted); }
.viaje-finanzas-compactas > span:first-child b { color: var(--text-main); font-size: 11px; }
.viaje-facturacion { border-left: 1px solid #dbeafe; padding-left: 8px; }
.viaje-facturacion-principal { display: flex; justify-content: space-between; gap: 8px; color: #1e40af; }
.viaje-facturacion-principal b { color: #1d4ed8; font-size: 11px; }
.viaje-facturacion-detalle { color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viaje-facturacion-utilidad { color: #047857; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viaje-liquidacion-principal { display: flex; justify-content: space-between; gap: 8px; color: var(--text-muted); }
.viaje-liquidacion-principal b { color: var(--text-main); font-size: 11px; }
.viaje-liquidacion-detalle { color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viaje-liquidacion-detalle b, .viaje-facturacion-detalle b, .viaje-facturacion-utilidad b { color: var(--text-main); font-size: 10px; }
.viaje-liquidacion-saldo b { color: #15803d; }
.viaje-liquidacion-comision { color: #7e22ce; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viaje-liquidacion-anticipo { color: #dc2626; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viaje-liquidacion-comision b, .viaje-liquidacion-anticipo b { font-size: 10px; }
.viaje-pago-estado { display: grid; justify-items: center; gap: 5px; }
.viaje-condicion-pago { font-size: 10px; font-weight: bold; text-align: center; }
.viaje-estado { color: white; padding: 4px 8px; border-radius: 12px; font-size: 10px; text-align: center; font-weight: bold; width: fit-content; }
.viaje-detalles { display: none; padding: 20px; border-top: 1px solid var(--border); background: #fcfcfd; }

/* Components */
.btn { padding: 6px 12px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 10px; display: inline-flex; align-items: center; gap: 4px; transition: 0.2s; }
.btn-assign { background: var(--primary); color: white; }
.btn-track { background: var(--info); color: white; }
.btn-edit { background: #f1f5f9; color: var(--secondary); border: 1px solid var(--border); }

.badge { padding: 4px 8px; border-radius: 20px; color: white; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-indicator.active { background: var(--success); }
.status-indicator.inactive { background: var(--danger); }

input, select, textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; }
label { font-weight: 600; display: block; margin-top: 10px; margin-bottom: 4px; color: var(--text-main); font-size: 12px; }

/* Modal & Full Screen (FIXED TAPADO) */
#full-screen-container {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    z-index: 5000;
    padding: 20px;
}
.full-screen-content {
    width: 100%; height: 100%;
    max-width: 1400px; margin: 0 auto;
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
}
#full-screen-body { flex: 1; overflow-y: auto; padding-right: 5px; }

#modal-asignar { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 6000; padding: 20px; overflow-y: auto; }
.overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); z-index: 5500; }

/* Dropdown Gestión Manual */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.dropdown-content.show { display: block; }
.dropdown-manual-activos .dropdown-content { top: auto; bottom: 100%; margin-bottom: 4px; }
.dropdown-content button { padding: 10px 15px; border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-size: 11px; border-bottom: 1px solid #f1f5f9; }
.dropdown-content button:hover { background: #f8fafc; color: var(--primary); }



/* Lightbox */
.modal-img { display: none; position: fixed; z-index: 10000; padding: 40px 20px; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); box-sizing: border-box; text-align: center; }
.modal-img-content { max-width: 95%; max-height: 85vh; border-radius: 8px; object-fit: contain; margin: 0 auto; }
.zoom-wrapper { overflow: auto; max-height: 75vh; margin-top: 10px; cursor: grab; }
.modal-img-close { position: absolute; top: 15px; right: 25px; color: white; font-size: 35px; font-weight: bold; cursor: pointer; }

/* Printing Logic */
#orden-anticipo-print, #liquido-producto-print { display: none; }

@media print {
    /* Ocultar todo por defecto */
    body > * { display: none !important; }

    /* Estilos base de impresión */
    @page {
        size: A4;
        margin: 0;
    }
    body {
        margin: 0; padding: 0;
        background: white;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Orden de Anticipo */
    body.printing-order #orden-anticipo-print {
        display: block !important;
        position: absolute;
        left: 0; top: 0;
        width: 100%;
        background: white;
        padding: 15mm 20mm; /* Márgenes internos para que no toque los bordes del papel */
        min-height: 297mm;
    }

    /* Liquido Producto (Usa posiciones absolutas para coincidir con formulario pre-impreso) */
    body.printing-liquido #liquido-producto-print {
        display: block !important;
        position: absolute;
        left: 0; top: 0;
        width: 100%;
        background: white;
        height: 297mm;
        padding: 0;
    }

    /* Comprobante / Imagen / Remito Foto */
    body.printing-img #modal-img-viewer {
        display: block !important;
        position: absolute;
        left: 0; top: 0;
        width: 100%;
        background: white;
        padding: 10mm;
    }

    body.printing-img #modal-img-viewer .modal-img-content {
        max-width: 100%;
        max-height: none;
        object-fit: contain;
    }

    body.printing-img #modal-img-viewer button,
    body.printing-img #modal-img-viewer .modal-img-close {
        display: none !important;
    }
}

/* Estilos para Impresión de Orden de Anticipo */
.print-membrete { max-height: 80px; display: block; margin: 0 auto 20px auto; }
.print-header { border-bottom: 2px solid #1a73e8; padding-bottom: 15px; margin-bottom: 25px; }
.print-header h2 { margin: 0; color: #1a73e8; font-size: 24px; }
.print-section { margin-bottom: 30px; }
.print-section h4 { margin: 0 0 15px 0; color: #475569; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; font-size: 16px; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.print-field { margin-bottom: 10px; }
.print-label { display: block; font-size: 10px; color: #64748b; text-transform: uppercase; font-weight: bold; }
.print-value { font-size: 14px; font-weight: bold; color: #1e293b; }
.print-amount-box { background: #f1f5f9; padding: 20px; border-radius: 12px; text-align: center; border: 2px solid #cbd5e1; margin: 20px 0; }
.print-amount-box span { display: block; font-size: 12px; color: #64748b; font-weight: bold; margin-bottom: 5px; }
#p-monto { font-size: 32px; font-weight: 900; color: #16a34a; }
.print-footer { display: flex; justify-content: space-between; margin-top: 80px; }
.signature-line { border-top: 1px solid #333; width: 200px; text-align: center; padding-top: 10px; font-size: 12px; font-weight: bold; }

/* Floating Form Modals */
.modal-form-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 7000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-form-content {
    background: white;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp 0.3s ease-out;
}

.fletero-search { position: relative; }
.fletero-search-results {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}
.fletero-search-result {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
}
.fletero-search-result:hover { background: var(--primary-soft); }
.fletero-search-empty { padding: 10px 12px; color: var(--text-muted); }

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.close-modal-btn {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    transition: 0.2s;
}

.close-modal-btn:hover {
    background: var(--danger);
    color: white;
}
.leaflet-container { z-index: 1 !important; }

/* SweetAlert Overwrite to stay on top of all modals */
.swal2-container { z-index: 20000 !important; }

/* Login Screen */
#auth-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--background); display: flex; align-items: center; justify-content: center;
    z-index: 100000; flex-direction: column;
}
.login-card {
    background: white; padding: 40px; border-radius: 24px;
    box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; text-align: center;
    border: 1px solid var(--border);
}
.login-card h2 { margin-bottom: 8px; color: var(--text-main); font-weight: 800; }
.login-card p { margin-bottom: 24px; color: var(--text-muted); }
.login-card input { margin-bottom: 15px; }
.btn-login {
    background: var(--primary); color: white; width: 100%; padding: 12px;
    border: none; border-radius: 12px; font-weight: 700; cursor: pointer;
    transition: 0.2s; font-size: 14px;
}
.btn-login:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* Estilos Buscador Global */
.search-global-container {
    position: relative;
    width: 250px;
}
.search-global-input {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 13px;
    background: #f8fafc;
    transition: all 0.3s;
}
.search-global-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}
.search-global-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}
.search-results-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 400px;
    max-height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 2000;
    margin-top: 10px;
    display: none;
    overflow-y: auto;
    border: 1px solid var(--border);
}
.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.search-result-item:hover, .search-result-item.selected {
    background: #f1f5f9;
    border-left: 3px solid var(--primary);
}
.search-highlight {
    background-color: #fff9c4;
    font-weight: bold;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}
.search-global-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.search-kbd-hint {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #94a3b8;
    background: #fff;
    padding: 2px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    pointer-events: none;
    font-weight: bold;
}
.search-group-header {
    padding: 8px 15px;
    font-size: 10px;
    color: #64748b;
    background: #f8fafc;
    font-weight: 800;
    text-transform: uppercase;
    border-bottom: 1px solid #f1f5f9;
    letter-spacing: 0.5px;
}
@keyframes highlight-flash {
    0% { background-color: #fff9c4; outline: 3px solid #fde047; }
    100% { background-color: transparent; outline: 3px solid transparent; }
}
.row-highlight-flash {
    animation: highlight-flash 2.5s ease-out;
    border-radius: 8px;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-title {
    font-weight: bold;
    color: var(--text-main);
    font-size: 13px;
}
.search-result-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.search-result-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    text-transform: uppercase;
}

/* Forzar alineación horizontal en botones de cabecera */
.main-group-btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    white-space: nowrap !important;
    height: 38px !important; /* Altura fija para que sean angostos */
    padding: 0 15px !important;
}

/* Estilos Cupos Modernos */
.cupo-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}
.cupo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.cupo-visual {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}
.cupo-visual svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}
.circle-bg {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 8;
}
.circle-progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s ease-out;
}
.percentage-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.percentage-inner b {
    font-size: 18px;
    line-height: 1;
    color: var(--text-main);
}
.percentage-inner span {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .container { padding: 8px 10px 16px; }
    .header-main { margin: -8px -10px 16px; padding: 8px 10px; }
    .header-main > div:first-child { align-items: stretch !important; }
    .header-main > div:first-child > div { width: 100% !important; flex: none !important; justify-content: center; }
    .header-main > div:first-child > div:first-child { justify-content: space-between; }
    .search-global-container { width: 100% !important; }
    .search-results-panel { width: 100%; }
    .main-group-btn { margin-right: 0; padding: 0 10px !important; }
    .nav-container, .sub-nav-container { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { flex: 0 0 auto; }
    .monitor-layout { flex-direction: column; }
    .monitor-layout .left-panel,
    .monitor-layout .map-container { width: 100%; flex: 0 0 100%; }
    .monitor-layout .map-container { position: static; }
    #main-map { height: 55vh; min-height: 320px; }
    .lista-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .lista-container table { min-width: 680px; }
    .modal-form-content { padding: 20px; }
}

/* Bandeja de chats de WhatsApp (js/panel/17-bandeja.js) */
.bandeja { display: flex; height: calc(100vh - 220px); min-height: 480px; background: white; border-radius: 12px; border: 1px solid #e2e8f0; overflow: hidden; }
.bandeja-lista-col { width: 340px; flex-shrink: 0; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.bandeja-lista { flex: 1; overflow-y: auto; }
.bandeja-fila { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 13px; }
.bandeja-fila:hover { background: #f8fafc; }
.bandeja-fila.activa { background: #eef2ff; }
.bandeja-avatar { width: 38px; height: 38px; border-radius: 50%; background: #cbd5e1; color: white; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bandeja-etiqueta { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: #f1f5f9; color: #475569; }
.bandeja-noleidos { background: #16a34a; color: white; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.bandeja-chat { flex: 1; display: flex; flex-direction: column; background: #efeae2; min-width: 0; }
.bandeja-encabezado { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-size: 13px; }
.bandeja-volver { display: none; padding: 4px 10px; }
.bandeja-mensajes { flex: 1; overflow-y: auto; padding: 12px 6%; display: flex; flex-direction: column; gap: 4px; }
.bandeja-dia { align-self: center; background: #e2e8f0; color: #475569; font-size: 11px; border-radius: 8px; padding: 2px 10px; margin: 8px 0; }
.bandeja-burbuja { max-width: 70%; padding: 6px 9px 4px; border-radius: 8px; font-size: 13px; box-shadow: 0 1px 1px rgba(0,0,0,0.08); }
.bandeja-burbuja.entrante { align-self: flex-start; background: white; }
.bandeja-burbuja.saliente { align-self: flex-end; background: #d9fdd3; }
.bandeja-burbuja.operador { background: #dbeafe; }
.bandeja-burbuja.sistema { background: #fef9c3; }
.bandeja-autor { font-size: 10px; font-weight: 700; color: #475569; margin-bottom: 2px; }
.bandeja-pie { font-size: 10px; color: #64748b; text-align: right; margin-top: 2px; }
.bandeja-boton-plantilla { margin-top: 6px; padding: 5px; text-align: center; color: #2563eb; border-top: 1px solid rgba(0,0,0,0.08); font-weight: 600; }
.bandeja-composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.bandeja-composer textarea { flex: 1; resize: none; border-radius: 8px; border: 1px solid #cbd5e1; padding: 8px 10px; font-size: 13px; font-family: inherit; max-height: 140px; }
@media (max-width: 768px) {
    .bandeja { height: calc(100vh - 170px); }
    .bandeja-lista-col { width: 100%; border-right: none; }
    .bandeja-chat { display: none; }
    .bandeja.con-chat .bandeja-lista-col { display: none; }
    .bandeja.con-chat .bandeja-chat { display: flex; }
    .bandeja-volver { display: inline-block; }
    .bandeja-burbuja { max-width: 88%; }
}
