/* ========================================================================
   ARCHIVO DE ESTILOS PRINCIPAL: style.css
   ORGANIZACIÓN:
   1. Variables Globales (--root)
   2. Reseteo y Estilos Base (body, html)
   3. Estilos de Componentes (botones, inputs, modales, etc.)
   4. Estilos de Layout Principal (header, main, tabs)
   5. Estilos Específicos por Módulo (ordenes, etc.)
   6. Estilos Responsivos (@media max-width)
   7. Estilos de Impresión (@media print)
   ======================================================================== */

/* ========================================================================
   1. VARIABLES GLOBALES
   ======================================================================== */
:root {
    /* Colores base */
    --background-default: #ffffff;
    --background-lighter: #f0f2f5;
    --background-panel: #e4e6eb;
    
    /* Colores de texto */
    --text-primary: #050505;
    --text-secondary: #65676b;
    
    /* Colores de borde */
    --border: #e4e6eb;
    --border-color: #e4e6eb;
    
    /* Colores de acento */
    --accent: #0084ff;
    
    /* Colores de mensaje */
    --message-incoming: #e4e6eb;
    --message-outgoing: #0084ff;
    --message-status: #65676b;
    
    /* Colores de iconos */
    --icon-color: #65676b;
    
    /* Otros colores */
    --primary-strong: #050505;
    --primary-weak: #65676b;
}

/* ========================================================================
   2. RESETEO Y ESTILOS BASE
   ======================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #e9eef2;
    position: relative; /* Para el contexto de apilamiento */
}

/* Comportamiento base para la vista en pantalla */
@media screen {
    html, body {
        max-width: 100vw;
        overflow-x: hidden;
    }
    body {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

hr, .hr-strong {
    border: none;
    border-top: 3px solid #0b1836;
    margin: 1.5em 0;
}

/* Prevenir zoom en inputs en iOS */
@supports (-webkit-touch-callout: none) {
    input,
    textarea,
    select {
        font-size: 16px;
    }
}

/* ========================================================================
   3. ESTILOS DE COMPONENTES
   ======================================================================== */

/* --- Botones --- */
.eleventa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    background-color: white;
    color: #374151; /* gray-700 */
    border-color: #d1d5db; /* gray-300 */
}

.dark .eleventa-btn {
    background-color: #1f2937; /* gray-800 */
    color: #e5e7eb; /* gray-200 */
    border-color: #4b5563; /* gray-600 */
}

.eleventa-btn:hover {
    background-color: #f9fafb; /* gray-50 */
    border-color: #9ca3af; /* gray-400 */
}

.dark .eleventa-btn:hover {
    background-color: #374151; /* gray-700 */
    border-color: #9ca3af; /* gray-400 */
}

.eleventa-btn-primary {
    background-color: #2563eb; /* primary-600 */
    color: white;
    border-color: transparent;
}

.dark .eleventa-btn-primary {
    background-color: #3b82f6; /* primary-500 */
    color: white;
}

.eleventa-btn-primary:hover {
    background-color: #1d4ed8; /* primary-700 */
    color: white;
}

.dark .eleventa-btn-primary:hover {
    background-color: #2563eb; /* primary-600 */
}

.eleventa-btn:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.dark .eleventa-btn:disabled {
    background-color: #374151;
    color: #6b7280;
    border-color: #4b5563;
}

.eleventa-btn-secondary {
    background-color: #6b7280;
    color: white;
    border: none;
}
.dark .eleventa-btn-secondary {
    background-color: #4b5563;
    color: #e5e7eb;
}
.eleventa-btn-secondary:hover {
    background-color: #4b5563;
    transform: scale(1.05);
}
.dark .eleventa-btn-secondary:hover {
    background-color: #374151;
}

/* --- Inputs y Formularios --- */
.form-input { 
    border: 1px solid #d1d5db; /* gray-300 */
    padding: 0.625rem 0.875rem; 
    border-radius: 0.5rem; 
    width: 100%; 
    transition: all 0.2s ease-in-out; 
    font-size: 0.875rem;
    color: #111827; /* gray-900 */
    background-color: #fff;
}
.dark .form-input {
    background-color: #1f2937; /* gray-800 */
    border-color: #4b5563; /* gray-600 */
    color: #f3f4f6; /* gray-100 */
}
.form-input:focus { 
    outline: none;
    border-color: #2563eb; /* primary-600 */
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.dark .form-input:focus {
    border-color: #3b82f6; /* primary-500 */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.eleventa-input {
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
}
.dark .eleventa-input {
    background-color: #1f2937; /* gray-800 */
    border-color: #4b5563; /* gray-600 */
    color: #f3f4f6; /* gray-100 */
}
.eleventa-input:focus {
    background-color: white;
    border-color: #2563eb;
}
.dark .eleventa-input:focus {
    background-color: #111827; /* gray-900 */
    border-color: #3b82f6; /* primary-500 */
}

/* Force light mode for auth container inputs */
#auth-container .form-input,
#auth-container .eleventa-input {
    background-color: #fff;
    border-color: #d1d5db;
    color: #111827;
}
#auth-container .form-input:focus,
#auth-container .eleventa-input:focus {
    border-color: #2563eb;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Pestañas --- */
.tab-button {
    /* Estilos base manejados por Tailwind en HTML */
    transition: all 0.2s ease;
}

/* Estilos por defecto (Ingreso y fallback) */
.tab-button-active {
    background-color: #eff6ff; /* primary-50 */
    color: #1d4ed8 !important; /* primary-700 */
}
.dark .tab-button-active {
    background-color: #1e3a8a; /* blue-900 */
    color: #bfdbfe !important; /* blue-200 */
}
.tab-button-active i { color: #1d4ed8 !important; }
.dark .tab-button-active i { color: #bfdbfe !important; }

/* --- Colores Específicos por Pestaña --- */

/* Mis Ordenes - Indigo */
.tab-button-active[data-tab="mis-ordenes"] {
    background-color: #e0e7ff;
    color: #4338ca !important;
}
.dark .tab-button-active[data-tab="mis-ordenes"] {
    background-color: #312e81;
    color: #c7d2fe !important;
}
.tab-button-active[data-tab="mis-ordenes"] i { color: #4338ca !important; }
.dark .tab-button-active[data-tab="mis-ordenes"] i { color: #c7d2fe !important; }

/* Precios - Emerald */
.tab-button-active[data-tab="precios"] {
    background-color: #ecfdf5;
    color: #047857 !important;
}
.dark .tab-button-active[data-tab="precios"] {
    background-color: #064e3b;
    color: #6ee7b7 !important;
}
.tab-button-active[data-tab="precios"] i { color: #047857 !important; }
.dark .tab-button-active[data-tab="precios"] i { color: #6ee7b7 !important; }

/* Inventario - Amber */
.tab-button-active[data-tab="inventario"] {
    background-color: #fffbeb;
    color: #b45309 !important;
}
.dark .tab-button-active[data-tab="inventario"] {
    background-color: #78350f;
    color: #fcd34d !important;
}
.tab-button-active[data-tab="inventario"] i { color: #b45309 !important; }
.dark .tab-button-active[data-tab="inventario"] i { color: #fcd34d !important; }

/* Clientes - Teal */
.tab-button-active[data-tab="clientes"] {
    background-color: #f0fdfa;
    color: #0f766e !important;
}
.dark .tab-button-active[data-tab="clientes"] {
    background-color: #134e4a;
    color: #5eead4 !important;
}
.tab-button-active[data-tab="clientes"] i { color: #0f766e !important; }
.dark .tab-button-active[data-tab="clientes"] i { color: #5eead4 !important; }

/* Proveedores - Orange */
.tab-button-active[data-tab="proveedores"] {
    background-color: #fff7ed;
    color: #c2410c !important;
}
.dark .tab-button-active[data-tab="proveedores"] {
    background-color: #7c2d12;
    color: #fdba74 !important;
}
.tab-button-active[data-tab="proveedores"] i { color: #c2410c !important; }
.dark .tab-button-active[data-tab="proveedores"] i { color: #fdba74 !important; }

/* Tecnicos - Cyan */
.tab-button-active[data-tab="tecnicos"] {
    background-color: #ecfeff;
    color: #0e7490 !important;
}
.dark .tab-button-active[data-tab="tecnicos"] {
    background-color: #164e63;
    color: #67e8f9 !important;
}
.tab-button-active[data-tab="tecnicos"] i { color: #0e7490 !important; }
.dark .tab-button-active[data-tab="tecnicos"] i { color: #67e8f9 !important; }

/* Facturas - Rose */
.tab-button-active[data-tab="facturas"] {
    background-color: #fff1f2;
    color: #be123c !important;
}
.dark .tab-button-active[data-tab="facturas"] {
    background-color: #881337;
    color: #fda4af !important;
}
.tab-button-active[data-tab="facturas"] i { color: #be123c !important; }
.dark .tab-button-active[data-tab="facturas"] i { color: #fda4af !important; }

/* Corte - Red */
.tab-button-active[data-tab="corte"] {
    background-color: #fef2f2;
    color: #b91c1c !important;
}
.dark .tab-button-active[data-tab="corte"] {
    background-color: #7f1d1d;
    color: #fca5a5 !important;
}
.tab-button-active[data-tab="corte"] i { color: #b91c1c !important; }
.dark .tab-button-active[data-tab="corte"] i { color: #fca5a5 !important; }

/* Usuarios - Violet */
.tab-button-active[data-tab="gestion-usuarios"] {
    background-color: #f5f3ff;
    color: #6d28d9 !important;
}
.dark .tab-button-active[data-tab="gestion-usuarios"] {
    background-color: #4c1d95;
    color: #c4b5fd !important;
}
.tab-button-active[data-tab="gestion-usuarios"] i { color: #6d28d9 !important; }
.dark .tab-button-active[data-tab="gestion-usuarios"] i { color: #c4b5fd !important; }

/* Reporte - Purple */
.tab-button-active[data-tab="reporte-diario"] {
    background-color: #faf5ff;
    color: #7e22ce !important;
}
.dark .tab-button-active[data-tab="reporte-diario"] {
    background-color: #581c87;
    color: #d8b4fe !important;
}
.tab-button-active[data-tab="reporte-diario"] i { color: #7e22ce !important; }
.dark .tab-button-active[data-tab="reporte-diario"] i { color: #d8b4fe !important; }

/* Configuracion - Slate */
.tab-button-active[data-tab="configuracion"] {
    background-color: #f1f5f9;
    color: #334155 !important;
}
.dark .tab-button-active[data-tab="configuracion"] {
    background-color: #1e293b;
    color: #cbd5e1 !important;
}
.tab-button-active[data-tab="configuracion"] i { color: #334155 !important; }
.dark .tab-button-active[data-tab="configuracion"] i { color: #cbd5e1 !important; }

/* --- Subpestañas --- */
.sub-tab-button {
    border-bottom: 2px solid transparent;
    padding: 0.75rem 0.25rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease-in-out;
}
.sub-tab-button:hover {
    color: #1d4ed8;
    border-bottom-color: #93c5fd;
}
.sub-tab-button.sub-tab-active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}
.dark .sub-tab-button.sub-tab-active {
    color: #60a5fa; /* blue-400 */
    border-bottom-color: #60a5fa;
}

/* --- Modales --- */
.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    display: flex; 
    justify-content: center; 
    align-items: flex-start;
    z-index: 1000; 
    overflow-y: auto; 
    padding: 5vh 1rem;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-container {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}
.dark .modal-container {
    background-color: #1f2937; /* gray-800 */
    color: #f3f4f6; /* gray-100 */
}
.modal-overlay.active .modal-container {
    transform: translateY(0);
}

/* --- Patrón de desbloqueo --- */
.pattern-container { 
    position: relative; 
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
#pattern-lines-canvas { 
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
    z-index: 1;
}
#pattern-lock {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    height: 100%;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
.pattern-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #d1d5db;
    transition: background-color 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    user-select: none;
    justify-self: center;
    align-self: center;
}
.pattern-dot.active { 
    background-color: #2741d3;
    color: white;
    font-weight: bold;
}

/* --- Canvas de Firma --- */
.signature-canvas { 
    border: 2px solid #a0a0a0; 
    border-radius: 0.5rem; 
    cursor: crosshair; 
}

/* Estilo para el contenedor del logo en la orden de servicio */
.logo-container {
    border: 1px solid #000;
    padding: 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
}

/* Previene que los overlays ocultos bloqueen los clics */
#loading-overlay.hidden,
#modal-container.hidden,
#fullscreen-signature-modal.hidden {
    pointer-events: none;
}

/* Estilo para el contenedor del logo en la orden de servicio */
.logo-container {
    border: 1px solid #000;
    padding: 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
}

/* Previene que los overlays ocultos bloqueen los clics */
#loading-overlay.hidden,
#modal-container.hidden,
#fullscreen-signature-modal.hidden {
    pointer-events: none;
}

/* ========================================================================
   4. ESTILOS DE LAYOUT PRINCIPAL
   ======================================================================== */
#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
}
#app.hidden {
    display: none !important;
}
#app > main {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
header {
    width: 100%;
    flex-shrink: 0;
}
main > div.border-b { /* Contenedor de pestañas */
    border-bottom: 1px solid #d1d5db;
}

/* --- Contenido de Pestañas --- */
.tab-content { 
    display: none; 
    position: relative;
    z-index: 1;
}
.tab-active { 
    display: block; 
    z-index: 10;
}
.sub-tab-content { display: block; }
.sub-tab-content.hidden { display: none; }

/* ========================================================================
   5. ESTILOS ESPECÍFICOS POR MÓDULO
   ======================================================================== */

/* --- Tabla de Equipos (Pestaña Ingreso) --- */
.equipment-table-container {
    border: 2px solid #a0a0a0;
    border-radius: 0.375rem;
    overflow: hidden;
}
.equipment-grid {
    display: grid;
    grid-template-columns: 30px 1fr 1fr 1fr 90px 90px 2fr 1fr 2fr 120px;
    gap: 0;
    align-items: stretch;
}
.equipment-table-header {
    font-weight: bold;
    font-size: 0.7rem;
    background-color: #1A202C;
    color: #ffffff;
    border-bottom: 1px solid #b6c6e6;
}
.equipment-table-header .equipment-table-cell {
    justify-content: center;
    text-align: center;
}
.equipment-table-row-data {
    border-top: 1px solid #b6c6e6;
}
.equipment-table-cell {
    padding: 0.5rem;
    border-right: 1px solid #b6c6e6;
    display: flex;
    align-items: center;
    font-size: 0.8rem;
}
.equipment-table-cell:last-child {
    border-right: none;
}
.equipment-grid input, 
.equipment-grid select, 
.equipment-grid textarea {
    border: 1px solid #d1d5db;
    padding: 0.5rem;
    width: 100%;
    height: 2.2em;
    background-color: #f9fafb;
    font-size: 1rem;
    border-radius: 0.25rem;
}
.dark .equipment-grid input, 
.dark .equipment-grid select, 
.dark .equipment-grid textarea {
    background-color: #374151; /* gray-700 */
    border-color: #4b5563; /* gray-600 */
    color: #f3f4f6; /* gray-100 */
}
.equipment-grid select {
    padding: 0.3em 1.5em 0.3em 0.5em;
}
.equipment-grid input:focus, 
.equipment-grid select:focus, 
.equipment-grid textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background-color: white;
}
.dark .equipment-grid input:focus, 
.dark .equipment-grid select:focus, 
.dark .equipment-grid textarea:focus {
    background-color: #1f2937; /* gray-800 */
    border-color: #60a5fa; /* blue-400 */
}

/* --- Tablas Generales --- */
thead.bg-gray-200 {
    background-color: #000000 !important; /* Fondo negro siempre */
}
/* En modo oscuro, mantener el fondo negro */
.dark thead.bg-gray-200 {
    background-color: #000000 !important;
}
/* En modo claro, TAMBIÉN fondo negro */
html:not(.dark) thead.bg-gray-200 {
    background-color: #000000 !important;
}

thead th {
    color: #ffffff !important; /* Texto blanco siempre */
    text-align: center;
    border-right: 1px solid #b6c6e6;
}

/* Asegurar texto blanco en modo claro también */
html:not(.dark) thead th {
    color: #ffffff !important;
}

/* Excepción: Si el header tiene fondo negro explícito en modo claro (como en reportes específicos), mantener texto blanco */
html:not(.dark) thead.bg-black th,
html:not(.dark) thead.bg-gray-900 th {
    color: #ffffff !important;
}

thead th:last-child, tbody td:last-child {
    border-right: none;
}
table th, table td {
    border-bottom: 1px solid #b6c6e6 !important;
}
table th:not(:last-child), table td:not(:last-child) {
    border-right: 1px solid #b6c6e6;
}
tbody td {
    text-align: center;
    border-right: 1px solid #b6c6e6;
}



/* --- "Mis Ordenes" Card --- */
.mis-ordenes-card {
    background-color: #ffffff;
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease-in-out;
}
.dark .mis-ordenes-card {
    background-color: #1f2937; /* gray-800 */
    border-color: #4b5563; /* gray-600 */
    color: #f3f4f6; /* gray-100 */
}
.mis-ordenes-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* --- Botones de Carga de Imagen --- */
.file-upload-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background-color: #f8fafc;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s;
    width: 2rem;
    height: 2rem;
}
.file-upload-label:hover {
    background-color: #f1f5f9;
    transform: scale(1.1);
}
.file-upload-label input[type="file"] {
    display: none;
}
.image-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: #f9fafb;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.image-icon-btn:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    transform: scale(1.1);
}
.image-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #6b7280;
}

/* --- Modal de Firma Fullscreen --- */
#fullscreen-signature-modal {
    animation: fadeIn 0.3s ease-in-out;
    display: none !important; /* Start hidden */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1003;
    background-color: rgba(0, 0, 0, 0.7);
}
#fullscreen-signature-modal:not(.hidden) {
    display: flex !important; /* Show when class .hidden is removed */
    flex-direction: column;
}
#fullscreen-signature-canvas {
    touch-action: none;
    cursor: crosshair;
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================================================
   6. ESTILOS RESPONSIVOS
   ======================================================================== */
@media (max-width: 768px) {
    /* --- AJUSTES GENERALES --- */
    .tab-content {
        padding: 0.75rem;
    }
    #user-email-display {
        display: none;
    }
    .pattern-container {
        position: relative;
        width: 100%;
        max-width: 180px;
        aspect-ratio: 1 / 1;
        margin: 1rem auto 0;
        padding: 0 !important;
        z-index: 50;
    }
    #pattern-lock {
        position: relative;
        z-index: 51;
    }

    /* --- Pestaña Ingreso de Equipos --- */
    #order-form .grid.grid-cols-3 {
        grid-template-columns: 1fr;
        text-align: center;
    }
    #order-form .logo-container,
    #order-form .flex.items-center.justify-end {
        margin: 0 auto;
        justify-content: center;
    }
    #order-form .grid.md\:grid-cols-12 {
        grid-template-columns: 1fr;
    }
    .equipment-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .equipment-grid {
        grid-template-columns: 40px 120px 120px 150px 60px 60px 200px 100px 200px 120px;
        min-width: 1170px;
    }
    .equipment-table-cell::before {
        display: none;
    }
    .equipment-grid input, .equipment-grid select, .equipment-grid textarea {
        padding: 0;
        border: none;
        background-color: transparent;
    }

    /* --- OTRAS PESTAÑAS --- */
    #tab-proveedores .flex.justify-between,
    #tab-facturas .flex.justify-between,
    #tab-gestion-usuarios .flex.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
     #tab-proveedores .flex.justify-between > *,
    #tab-facturas .flex.justify-between > *,
    #tab-gestion-usuarios .flex.justify-between > * {
        width: 100%;
    }
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .min-w-full {
        min-width: 650px;
    }
}

/* --- SOPORTE PARA ORIENTACIÓN LANDSCAPE EN MÓVIL --- */
@media (max-width: 1024px) and (orientation: landscape) {
    html, body, #root, .app-wrapper, main {
        max-height: 100vh;
    }
    #tab-ingreso {
        overflow-y: auto;
    }
    .grid.grid-cols-1.md\:grid-cols-12 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    .form-input {
        padding: 0.35rem 0.5rem;
        font-size: 0.85rem;
    }
    .pattern-container {
        width: 100px;
        height: 100px;
    }
    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* ========================================================================
   7. ESTILOS DE IMPRESIÓN (CORREGIDO)
   ======================================================================== */
@media print {
    /* --- 1. CONFIGURACIÓN DE PÁGINA Y RESETEO FUNDAMENTAL --- */
    @page {
        size: A4; /* Orientación por defecto, el JS puede sobreescribirla */
        margin: 15mm;
    }

    html, body {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    #app, #app > main {
        display: block !important;
        position: static !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* --- 2. OCULTAR ELEMENTOS GENÉRICOS DE UI --- */
    /* Se ocultan todos los elementos que no tienen sentido en un documento impreso.
       El JS se encarga de aislar el área específica. */
    header, nav, footer, .no-print, .tab-button, #app > header, button, input[type="button"], input[type="submit"] {
        display: none !important;
    }

    /* --- 3. ESTILOS GENERALES PARA EL CONTENIDO IMPRIMIBLE --- */
    /* Estas reglas se aplicarán a cualquier área que el JS haga visible para imprimir. */
    .overflow-x-auto {
        overflow-x: visible !important;
    }
    table, .min-w-full {
        width: 100% !important;
        min-width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }
    thead { 
        display: table-header-group !important; 
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    tbody { 
        display: table-row-group !important; 
    }
    tr {
        display: table-row !important; 
        page-break-inside: avoid;
        page-break-after: auto;
    }
    th, td {
        display: table-cell !important;
        padding: 5px 6px !important;
        border: 1px solid #333 !important;
        text-align: center !important;
        vertical-align: middle !important;
        font-size: 10pt !important;
        color: #000 !important;
        background: #fff !important;
    }
    /* Estilo general para cabeceras, texto negro y fondo gris claro por defecto */
    thead th {
        font-weight: bold !important;
        background-color: #e6e6e6 !important;
        color: #000 !important;
    }

    /* CORRECCIÓN: Forzar cabecera negra para la lista de precios */
    .prices-table-header th {
        background-color: #000 !important;
        color: #fff !important;
        border: 1px solid #000 !important;
    }
    /* Anulación específica para Lista de Precios y Proveedores */
    #printable-list thead th,
    #printable-suppliers-list thead th {
        background-color: #000000 !important;
        color: #ffffff !important;
    }
    .equipment-table-cell::before {
        display: none !important;
    }
    #print-header, .print-only {
        display: block !important;
    }

    /* --- Correcciones específicas para Impresión de Orden de Servicio --- */
    #print-area .logo-container {
        border: 1px solid #000 !important;
        padding: 0.5rem !important;
        border-radius: 0.375rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 80px !important;
    }
    
    #print-area .grid.grid-cols-3 {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        align-items: center !important; /* Asegura alineación vertical */
    }

    /* --- Corrección para Orden de Servicio en impresión móvil --- */
    /* Anula los estilos responsivos de la tabla de equipos que causan
       que el contenido se encoja en la página de impresión. */
    #print-area .equipment-grid {
        min-width: 0 !important;
        width: 100% !important;
        grid-template-columns: 30px 1fr 1fr 1fr 90px 90px 2fr 1fr 2fr 120px !important;
    }
}
