/* --- CONFIGURACIÓN GLOBAL CRM --- */
.crm-container {
    display: flex !important;
    flex-direction: row !important;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    background: #fff;
    font-family: 'Montserrat', sans-serif;
}

.crm-container button,
.crm-container input,
.crm-container select,
.crm-container h1,
.crm-container h2,
.crm-container h3,
.crm-container h4,
.crm-container p,
.crm-container span {
    font-family: 'Montserrat', sans-serif !important;
}

/* --- SIDEBAR --- */
/* --- SIDEBAR --- */
.crm-sidebar {
    width: 60px;
    /* Mini */
    height: 100%;
    overflow-y: visible;
    /* Changed from auto to allow tooltips if any */
    background: #fff;
    border-right: 1px solid #eee;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
}

.crm-header-mini {
    display: none;
    /* Hide Header */
}

/* [STANDARDIZED] Styles moved to pos_global.css (.cheesy-sidebar-item)
.crm-nav-btn {
    width: 40px;
    height: 40px;
    margin: 0 0 10px 0;
    border-radius: 8px;
    padding: 0;
    font-size: 16px;
    color: #666;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.crm-nav-btn span {
    display: none;
}

.crm-nav-btn:hover {
    background: #eee;
    color: var(--vino);
}

.crm-nav-btn.active {
    background: #fff;
    color: var(--vino);
    font-weight: 800;
    box-shadow: none;
    background: #fff5f5;
}
*/

.crm-stats-widget {
    display: none;
    /* Hide stats */
}

/* --- ÁREA PRINCIPAL --- */
.crm-main-area {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.crm-subview {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
}

/* --- LISTA DE USUARIOS --- */
.crm-list-pane {
    width: 390px;
    height: 100%;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background: #fff;
    flex-shrink: 0;
}

.crm-search-box {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.crm-search-wrapper {
    position: relative;
    width: 100%;
}

.crm-search-wrapper input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 15px 12px 40px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #f9f9f9;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.crm-search-wrapper input:focus {
    background: #fff;
    border-color: var(--vino);
    box-shadow: 0 0 0 3px rgba(94, 28, 38, 0.1);
}

.crm-search-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
}

.crm-scroll-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.crm-user-card {
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.2s;
}

.crm-user-card:hover {
    background: #fafafa;
}

.crm-user-card.active {
    background: #fff5f6;
    border-right: 4px solid var(--vino);
}

/* Avatar CRM */
.u-avatar-mini {
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    background: #eee;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
    flex-shrink: 0;
}

.u-avatar-mini.selected {
    background: var(--vino);
    color: white;
    transform: scale(1.1);
    box-shadow:
        0 0 0 2px white,
        0 0 0 4px var(--vino);
}

.u-avatar-mini.selected::after {
    content: '✓';
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--verde);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.u-info {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.u-info h4 {
    margin: 0 0 3px 0;
    font-size: 15px;
    color: #333;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.u-info p {
    margin: 0;
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* FAB Botón Imprimir Lote */
.fab-batch-print {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--vino);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-weight: 800;
    box-shadow: 0 5px 20px rgba(94, 28, 38, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    animation: popIn 0.3s;
}

.fab-batch-print:hover {
    background: #4a151e;
    transform: translateX(-50%) translateY(-2px);
}

#batchCountBadge {
    background: white;
    color: var(--vino);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
}

/* --- DETALLE DEL CLIENTE --- */
.crm-detail-pane {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: block !important;
    position: relative !important;
    background: #fdfdfd;
}

.crm-empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

.crm-empty-state i {
    font-size: 40px;
    margin-bottom: 15px;
}

.crm-detail-content {
    padding: 30px 40px 20px 40px;
    height: auto !important;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
    padding-bottom: 20px !important;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 25px;
    margin-bottom: 30px;
    background: #fff;
    padding: 25px;
    border-radius: 16px;
    border: 1px solid #eee;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.detail-avatar {
    width: 100px;
    height: 100px;
    font-size: 36px;
    border-radius: 50%;
    background: var(--vino);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(94, 28, 38, 0.3);
}

.detail-info {
    flex: 1;
}

.detail-info h2 {
    margin: 0 0 8px 0;
    font-size: 26px;
    color: #333;
    font-weight: 800;
}

.role-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    background: #e3f2fd;
    color: #2980b9;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.detail-kpis {
    display: flex;
    gap: 20px;
}

.kpi-box {
    text-align: center;
    background: #f9f9f9;
    border: 1px solid #eee;
    padding: 15px 25px;
    border-radius: 12px;
    min-width: 90px;
}

.kpi-box span {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: var(--vino);
}

.kpi-box label {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
}

/* Tabs Detalle */
.detail-tabs {
    display: flex;
    gap: 30px;
    border-bottom: 2px solid #eee;
    margin-bottom: 25px;
}

.d-tab {
    background: none;
    border: none;
    padding: 15px 5px;
    font-weight: 600;
    font-size: 14px;
    color: #aaa;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.d-tab.active {
    color: var(--vino);
    border-bottom-color: var(--vino);
    font-weight: 800;
}

/* Dashboard CRM */
.crm-dashboard-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
    flex-wrap: wrap;
}

.fav-prod-card {
    flex: 1;
    min-width: 200px;
    background: linear-gradient(135deg, #fff 0%, #fff5f6 100%);
    border: 1px solid #ffe0e3;
    border-left: 4px solid var(--vino);
    border-radius: 12px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    animation: fadeIn 0.5s ease;
}

.fav-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: var(--vino);
}

.fav-info h5 {
    margin: 0;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.fav-info div {
    font-weight: 800;
    font-size: 14px;
    color: #333;
    margin-top: 2px;
}

.crm-history-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 0 !important;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #eee;
    flex-shrink: 0;
}

.chart-wrapper {
    height: 350px !important;
    width: 100%;
    border-radius: 16px;
    border: 1px solid #eee;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    background: #fff;
    margin-bottom: 20px;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
}

.chart-wrapper canvas {
    max-height: 100% !important;
    max-width: 100% !important;
}

#crm-orders-list-dynamic {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.order-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.order-history-item:hover {
    background: #fff8e1;
}

.order-history-item:last-child {
    border-bottom: none;
}

/* Botones Contacto */
.btn-contact {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition:
        transform 0.1s,
        opacity 0.2s;
}

.btn-contact:active {
    transform: scale(0.98);
}

.btn-contact:hover {
    opacity: 0.9;
}

.btn-whatsapp {
    background-color: #25d366;
    color: white;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.2);
}

.btn-email {
    background-color: #f0f2f5;
    color: #555;
    border: 1px solid #ddd;
}

.btn-card-print {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    color: var(--vino);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    margin-right: 10px;
}

.btn-card-print:hover {
    background: var(--vino);
    color: white;
    border-color: var(--vino);
}

/* --- PERFIL EXTENDIDO --- */
.crm-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.crm-section-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.crm-section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--vino);
    text-transform: uppercase;
    margin-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-form-group {
    margin-bottom: 12px;
}

.crm-form-group label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
    font-weight: 600;
}

.crm-input,
.crm-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    box-sizing: border-box;
}

.crm-input:focus,
.crm-select:focus {
    border-color: var(--vino);
    outline: none;
    background: #fffafb;
}

.btn-save-profile {
    background: var(--vino);
    color: white;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s;
}

.btn-save-profile:hover {
    background: #4a151e;
    transform: translateY(-2px);
}

/* --- SECCIÓN FIDELIDAD --- */
.crm-loyalty-section {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #eee;
}

.crm-stamps-grid {
    display: flex;
    gap: 5px;
}

.crm-stamp {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #aaa;
    border: 1px solid #ccc;
}

.crm-stamp.filled {
    background: #f1c40f;
    color: #fff;
    border-color: #d4ac0d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.crm-stamp.gift {
    border-color: var(--vino);
    background: #fff;
    color: var(--vino);
}

/* --- IMPRESIÓN --- */
.cheesy-card-face {
    width: 85.6mm;
    height: 54mm;
    border-radius: 4mm;
    overflow: hidden;
    position: relative;
    font-family: 'Montserrat', sans-serif;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 1px dashed #ccc;
    page-break-inside: avoid;
    flex-shrink: 0;
}

.cheesy-card-face.front {
    background: var(--vino);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.card-logo-img {
    width: 25mm;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.cheesy-card-face.back {
    background: white;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
}

.card-header-back {
    background: #f4f4f4;
    color: #555;
    font-size: 6pt;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2mm 4mm;
    letter-spacing: 1px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.card-body-back {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 4mm;
    gap: 4mm;
}

.card-qr-box img {
    width: 25mm;
    height: 25mm;
    mix-blend-mode: multiply;
}

.card-info-box {
    text-align: left;
    flex: 1;
    overflow: hidden;
}

.card-info-box h4 {
    margin: 0;
    color: var(--vino);
    font-size: 10pt;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-id-code {
    font-family: monospace;
    font-size: 7pt;
    color: #888;
    margin-bottom: 2mm;
}

.card-instruction {
    font-size: 5pt;
    color: #555;
    line-height: 1.2;
    margin: 0;
}

.card-footer-back {
    background: var(--vino);
    color: white;
    font-size: 5pt;
    text-align: center;
    padding: 1mm;
    font-weight: bold;
    letter-spacing: 1px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Modal Batch Print */
#batchPreviewContainer {
    flex: 1;
    overflow-y: auto;
    background: #555;
    padding: 30px;
    display: flex;
    justify-content: center;
}

#modalBatchPrint .batch-page {
    background: white;
    width: 100%;
    min-height: 500px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    padding: 20px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-content: start;
}

#modalBatchPrint .batch-page::before {
    content: 'Vista Previa de Hoja';
    grid-column: span 2;
    font-size: 12px;
    font-weight: bold;
    color: #999;
    text-transform: uppercase;
    border-bottom: 1px dashed #ddd;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

#modalBatchPrint .batch-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #f0f0f0;
    padding: 10px;
    border-radius: 8px;
    background: #fafafa;
}

/* --- MODALES CRM (Estilos faltantes) --- */
.modal-header-dark {
    background: #333;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.modal-title-white {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.btn-close-white {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.modal-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 10px 20px;
}

.modal-title-vino {
    margin: 0;
    color: var(--vino);
    font-size: 20px;
    font-weight: 800;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
}

/* Botones Generales */
.btn-main-action {
    background: var(--vino);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-main-action:hover {
    background: #4a151e;
    transform: translateY(-2px);
}

.btn-secondary {
    background: white;
    border: 1px solid #ddd;
    color: #555;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

/* --- ESTILOS MIGRADOS DE JS (CRM UI) --- */

/* Listas y Estados Vacíos */
.list-empty-state {
    padding: 20px;
    text-align: center;
    color: #999;
}

.list-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* Loyalty Section */
.loyalty-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loyalty-icon {
    color: #f1c40f;
    font-size: 24px;
}

.loyalty-title {
    margin: 0;
    color: #333;
}

.loyalty-subtitle {
    margin: 0;
    font-size: 11px;
    color: #888;
}

/* Cumpleaños */
.birthday-age {
    font-size: 18px;
    color: #555;
}

.birthday-label {
    color: var(--vino);
    font-weight: bold;
}

/* Historial de Pedidos */
.history-empty {
    padding: 30px;
    text-align: center;
    color: #ccc;
}

.history-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.history-title {
    color: #555;
    margin: 15px 0 10px 0;
}

.order-item-title {
    font-weight: bold;
    color: #333;
}

.order-item-meta {
    font-size: 12px;
    color: #888;
}

.order-item-amount {
    font-weight: bold;
    color: var(--vino);
    font-size: 15px;
}

.order-item-status {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Notas y Perfil */
.address-box {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 12px;
    margin-bottom: 10px;
}

.address-icon {
    color: var(--vino);
}

.notes-container {
    margin-top: 20px;
}

.notes-actions {
    margin-top: 20px;
}

.profile-check-label {
    font-size: 11px;
    text-transform: none;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.profile-stat-val {
    color: #999;
    font-weight: normal;
}

.profile-map-container {
    height: 150px;
    background: #eee;
    border-radius: 8px;
    margin-top: 10px;
    overflow: hidden;
}

.profile-map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 12px;
}

.profile-map-frame {
    width: 100%;
    height: 100%;
    border: 0;
}

/* Batch Print Info */
.batch-info-count {
    color: var(--vino);
    font-size: 24px;
}

.batch-info-pages {
    font-weight: 800;
}

/* Card Modal */
.card-modal-qr {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

.card-modal-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--vino);
    margin: 15px 0 5px 0;
}

.card-modal-id {
    font-family: monospace;
    color: #666;
    font-size: 16px;
    letter-spacing: 2px;
}

/* --- ESTILOS MIGRADOS DE JS (CRM UI) --- */

/* Listas y Estados Vacíos */
.list-empty-state {
    padding: 20px;
    text-align: center;
    color: #999;
}

.list-loading {
    padding: 20px;
    text-align: center;
    color: #999;
}

/* Loyalty Section */
.loyalty-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loyalty-icon {
    color: #f1c40f;
    font-size: 24px;
}

.loyalty-title {
    margin: 0;
    color: #333;
}

.loyalty-subtitle {
    margin: 0;
    font-size: 11px;
    color: #888;
}

/* Cumpleaños */
.birthday-age {
    font-size: 18px;
    color: #555;
}

.birthday-label {
    color: var(--vino);
    font-weight: bold;
}

/* Historial de Pedidos */
.history-empty {
    padding: 30px;
    text-align: center;
    color: #ccc;
}

.history-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.history-title {
    color: #555;
    margin: 15px 0 10px 0;
}

.order-item-title {
    font-weight: bold;
    color: #333;
}

.order-item-meta {
    font-size: 12px;
    color: #888;
}

.order-item-amount {
    font-weight: bold;
    color: var(--vino);
    font-size: 15px;
}

.order-item-status {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Notas y Perfil */
.address-box {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 12px;
    margin-bottom: 10px;
}

.address-icon {
    color: var(--vino);
}

.notes-container {
    margin-top: 20px;
}

.notes-actions {
    margin-top: 20px;
}

.profile-check-label {
    font-size: 11px;
    text-transform: none;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.profile-stat-val {
    color: #999;
    font-weight: normal;
}

.profile-map-container {
    height: 150px;
    background: #eee;
    border-radius: 8px;
    margin-top: 10px;
    overflow: hidden;
}

.profile-map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 12px;
}

.profile-map-frame {
    width: 100%;
    height: 100%;
    border: 0;
}

/* Batch Print Info */
.batch-info-count {
    color: var(--vino);
    font-size: 24px;
}

.batch-info-pages {
    font-weight: 800;
}

/* Card Modal */
.card-modal-qr {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

.card-modal-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--vino);
    margin: 15px 0 5px 0;
}

.card-modal-id {
    font-family: monospace;
    color: #666;
    font-size: 16px;
    letter-spacing: 2px;
}

/* =============================================================
   REGLAS DE IMPRESIÓN (LÓGICA BLINDADA)
   ============================================================= */
@media print {

    /* RESET GLOBAL */
    @page {
        margin: 0;
        size: letter;
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        height: 100%;
        background: white !important;
        overflow: visible !important;
        display: block !important;
    }

    /* OCULTAR TODO EL SISTEMA */
    body>*:not(#modals-container) {
        display: none !important;
        visibility: hidden !important;
    }

    /* MOSTRAR SOLO MODAL ACTIVO */
    .modal-overlay[style*='display: flex'],
    .modal-overlay[style*='display: block'] {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        background: white !important;
        z-index: 99999 !important;
        overflow: visible !important;
    }

    /* CONTENEDOR DEL MODAL: Quitamos estilos de ventana */
    .modal-content {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        position: static !important;
        overflow: visible !important;
        background: transparent !important;
        display: block !important;
        height: auto !important;
        flex: none !important;
        /* Anular flexbox del modal */
    }

    /* OCULTAR UI DEL MODAL (Botones, Header, etc.) */
    /* IMPORTANTE: Mostramos batchPreviewContainer (Padre) O printableCardArea (Individual) O Ticket */
    .modal-content>*:not(#batchPreviewContainer):not(#printableCardArea):not(#printablePayslipArea) {
        display: none !important;
    }

    /* LIBERAR CONTENEDOR BATCH (Quitar scroll y fondo gris para imprimir) */
    #batchPreviewContainer {
        display: block !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
    }

    #printableBatchArea {
        width: 100% !important;
        max-width: none !important;
    }

    /* --- ESTILOS DE LA HOJA FÍSICA --- */

    /* MODO BATCH (GRID REAL) */
    .batch-page {
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 10mm !important;
        box-sizing: border-box !important;
        page-break-after: always !important;
        break-after: page !important;
        background: white !important;
        box-shadow: none !important;
        min-height: 0 !important;

        /* Grid de Impresión (2 Columnas x 4 Filas) */
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: repeat(4, 1fr) !important;
        gap: 0 !important;
        align-content: center !important;
    }

    .batch-page::before {
        display: none !important;
    }

    /* Ocultar texto preview */

    .batch-cell {
        display: flex !important;
        justify-content: center;
        align-items: center;
        border: 1px dashed #eee !important;
        padding: 0 !important;
        background: transparent !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* MODO INDIVIDUAL (CENTRADO) */
    .print-page {
        width: 100%;
        height: 100vh;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        page-break-after: always !important;
    }

    /* FORZAR GRAFICOS */
    .cheesy-card-face,
    .cheesy-card-face * {
        visibility: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .cheesy-card-face {
        box-shadow: none !important;
        border: 1px dashed #ccc !important;
    }
}

.pdf-btn-circle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-btn-nav {
    background: transparent;
    border: 1px solid #666;
    color: white;
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
}

.pdf-btn-tool {
    background: #444;
    color: #ccc;
    border: none;
    border-radius: 6px;
    height: 36px;
    padding: 0 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}

.pdf-btn-tool.active {
    background: var(--vino);
    color: white;
    box-shadow: 0 0 10px var(--vino);
}

.pdf-btn-save {
    background: var(--verde);
    color: white;
    border: none;
    border-radius: 6px;
    height: 36px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.pdf-btn-save:hover {
    background: #219150;
}

/* --- RESPONSIVE CRM --- */

.contact-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Ensure button content is always centered */
.btn-contact {
    justify-content: center;
}

/* Tablet (Portrait/Small) */
@media (max-width: 1024px) {
    .crm-list-pane {
        width: 320px;
        /* Reducir ancho de lista */
    }

    .crm-user-card {
        padding: 15px 10px;
        gap: 10px;
    }

    .u-avatar-mini {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }

    .contact-actions {
        justify-content: center;
        width: 100%;
    }

    .detail-info {
        width: 100%;
    }

    .detail-kpis {
        width: 100%;
        justify-content: center;
    }

    .crm-profile-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile (Landscape/Portrait) */
@media (max-width: 768px) {
    .crm-sidebar {
        width: 0;
        display: none;
        /* Hide sidebar on mobile */
    }

    .crm-list-pane {
        width: 100%;
        border-right: none;
    }

    .crm-detail-pane {
        display: none !important;
        /* Hide details by default */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 50;
        background: #fdfdfd;
    }

    /* Active Details View (Toggled via JS) */
    .crm-subview.mobile-detail-active .crm-list-pane {
        display: none !important;
    }

    .crm-subview.mobile-detail-active .crm-detail-pane {
        display: block !important;
    }

    /* Back Button */
    .crm-back-btn {
        display: flex !important;
        margin-bottom: 15px;
    }

    .detail-header {
        padding: 15px;
        margin-bottom: 15px;
    }

    .detail-avatar {
        width: 80px;
        height: 80px;
    }

    .detail-kpis {
        gap: 10px;
        flex-wrap: wrap;
    }

    .kpi-box {
        flex: 1;
        min-width: 80px;
        padding: 10px 5px;
    }

    .crm-dashboard-top {
        flex-direction: column;
        align-items: stretch;
    }

    .crm-history-controls {
        flex-direction: column;
    }
}