/**
 * Estilos principales - Tracemark Dashboard Corporativo
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #D4AF37;
    --color-dark: #0F0F0F;
    --color-bg: #F4F5F7;
    --color-card: #FFFFFF;
    --color-text: #1F1F1F;
    --color-text-secondary: #4B5563;
    --color-border: #E5E7EB;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
    --gold: #D4AF37;
    --dark: #1a1a1a;
    --light-bg: #f8f9fa;
    --border: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Inter', 'Helvetica Neue', Arial, sans-serif;
    background-color: #F4F5F7;
    color: #1F1F1F;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER - Barra Negra Corporativa
   ============================================ */
.app-header {
    background: #0F0F0F;
    color: #FFFFFF;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
}

.logo svg {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-link {
    color: #FFFFFF;
    text-decoration: none;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    opacity: 0.85;
}

.nav-link:hover,
.nav-link.active {
    opacity: 1;
    color: #D4AF37;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.env-selector {
    padding: 6px 12px;
    background: #0F0F0F;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    color: #FFFFFF;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.env-selector:hover {
    background: #1a1a1a;
}

/* Opciones del desplegable: fondo claro, texto oscuro */
.env-selector option {
    background: #f8f9fa;
    color: #1a1a1a;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.btn-logout {
    background: transparent;
    color: #FFFFFF;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.app-main {
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    background: #F4F5F7;
}

.step {
    display: none;
}

.step.active {
    display: block;
}

.step-header {
    margin-bottom: 3rem;
    text-align: center;
}

.step-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1F1F1F;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.step-header p {
    color: #4B5563;
    font-size: 1rem;
    margin: 0;
}

/* ============================================
   GRID DE TARJETAS - Dashboard Style
   ============================================ */
.import-types-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.import-type-btn {
    background: #FFFFFF;
    border: none;
    border-radius: 16px;
    padding: 3.5rem 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.import-type-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #D4AF37;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.import-type-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.import-type-btn:hover::before {
    transform: scaleX(1);
}

.import-type-btn.active {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 2px solid #D4AF37;
}

.import-type-btn.active::before {
    transform: scaleX(1);
}

.icon-wrapper {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 160px;
}

.import-type-btn .icon {
    width: 120px;
    height: 120px;
    stroke: #1F1F1F;
    stroke-width: 2.5;
    fill: none;
    transition: all 0.3s;
}

.import-type-btn:hover .icon,
.import-type-btn.active .icon {
    stroke: #D4AF37;
    stroke-width: 3;
    transform: scale(1.05);
}

.import-type-btn h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1F1F1F;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.import-type-btn p {
    color: #4B5563;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    max-width: 280px;
}

/* ============================================
   UPLOAD SECTION
   ============================================ */
.upload-section {
    margin-top: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.upload-actions {
    margin-bottom: 2rem;
    text-align: center;
}

.file-upload-area,
.file-upload-multiple {
    border: 2px dashed #E5E7EB;
    border-radius: 12px;
    padding: 3.5rem 2.5rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.file-upload-area:hover,
.file-upload-multiple:hover {
    border-color: #D4AF37;
    background: rgba(212, 175, 55, 0.02);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.upload-label {
    cursor: pointer;
    display: block;
}

.upload-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    color: #4B5563;
}

.upload-icon svg {
    width: 64px;
    height: 64px;
}

.file-upload-area p,
.file-upload-multiple p {
    font-size: 1.1rem;
    color: #1F1F1F;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.upload-hint {
    display: block;
    color: #4B5563;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: #D4AF37;
    color: #0F0F0F;
    border: none;
    border-radius: 8px;
    padding: 1rem 2.5rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover:not(:disabled) {
    background: #C19D2E;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #FFFFFF;
    color: #1F1F1F;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0.875rem 1.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover:not(:disabled) {
    border-color: #D4AF37;
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   NAVIGATION
   ============================================ */
.step-navigation {
    background: #FFFFFF;
    padding: 1.75rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    border-top: 1px solid #E5E7EB;
}

.step-indicator {
    font-weight: 700;
    color: #1F1F1F;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

/* ============================================
   CSV PREVIEW
   ============================================ */
.csv-preview {
    margin-top: 2rem;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.csv-preview-table {
    width: 100%;
    border-collapse: collapse;
}

.csv-preview-table thead {
    background: #0F0F0F;
    color: #FFFFFF;
}

.csv-preview-table th,
.csv-preview-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

.csv-preview-table th {
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.csv-preview-table tbody tr:hover {
    background: rgba(15, 15, 15, 0.02);
}

/* ============================================
   LOADING
   ============================================ */
.loading {
    text-align: center;
    padding: 4rem;
}

.spinner {
    border: 4px solid #E5E7EB;
    border-top: 4px solid #D4AF37;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #4B5563;
    font-size: 1.1rem;
    font-weight: 500;
}

/* ============================================
   MESSAGES
   ============================================ */
.success-message {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid #10b981;
    padding: 1.25rem;
    border-radius: 8px;
    margin-top: 2rem;
    color: #1F1F1F;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
    padding: 1.25rem;
    border-radius: 8px;
    margin-top: 2rem;
    color: #1F1F1F;
}

.info-message {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
    padding: 1.25rem;
    border-radius: 8px;
    color: #4B5563;
    font-size: 1rem;
}

/* ============================================
   VALIDATION & IMPORT SECTIONS
   ============================================ */
.validation-section,
.import-section {
    margin-top: 2rem;
    text-align: center;
}

#import-results,
#validation-results {
    margin-top: 2rem;
}

.import-summary {
    background: #FFFFFF;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid #E5E7EB;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.import-summary p {
    font-size: 1.1rem;
    color: #1F1F1F;
    font-weight: 600;
}

/* ============================================
   DOCUMENTS SECTION
   ============================================ */
.documents-list {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.document-item {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.document-item img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 4px;
}

.document-item .doc-name {
    font-size: 0.875rem;
    color: #1F1F1F;
    font-weight: 500;
    text-align: center;
    word-break: break-word;
}

.document-item .doc-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.document-item .doc-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.document-item .doc-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.document-item .doc-status.uploading {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* ============================================
   RESULTS SECTION
   ============================================ */
.results-section {
    margin-top: 2rem;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
body.login-page {
    background: #F4F5F7;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-container {
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
    padding: 3.5rem;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-logo {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1F1F1F;
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.login-header p {
    color: #4B5563;
    font-size: 1rem;
    margin: 0;
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.625rem;
    color: #1F1F1F;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
    background: #FFFFFF;
    color: #1F1F1F;
}

.form-group input:focus {
    outline: none;
    border-color: #D4AF37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: #D4AF37;
    color: #0F0F0F;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-login:hover {
    background: #C19D2E;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* ============================================
   UPLOAD SECTION
   ============================================ */
.upload-section-main {
    background: #FFFFFF;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 0.5rem;
}

/* Contenedor principal de controles */
.main-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    align-items: stretch;
}

.upload-grid {
    display: flex;
    gap: 10px;
    flex: 3;
}

/* Cajas de subida pequeñas */
.compact-upload-box {
    flex: 1;
    border: 2px dashed #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
}

.compact-upload-box i {
    font-size: 1.5rem;
    color: #d4af37;
}

.compact-upload-box strong {
    display: block;
    font-size: 0.85rem;
}

.compact-upload-box p {
    margin: 0;
    font-size: 0.7rem;
    color: #6b7280;
}

.compact-upload-box:hover {
    border-color: #d4af37;
    background: #fdfaf0;
}

.compact-upload-box.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f3f4f6;
}

.compact-upload-box.disabled:hover {
    border-color: #e5e7eb;
    background: #f3f4f6;
}

/* Botones de flujo laterales */
.flow-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.flow-actions button {
    padding: 8px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Zona de carga universal */
.main-controls-unified {
    flex-wrap: wrap;
}
.master-load-zone {
    flex: 1;
    min-width: 280px;
    border: 2px dashed #d4af37;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #fffdf5;
    transition: all 0.2s;
}
.master-load-zone:hover {
    border-color: #b8962d;
    background: #fef9e6;
}
.master-load-zone.dragover {
    border-color: #10b981;
    background: #ecfdf5;
}
.master-load-content {
    pointer-events: none;
}
.master-load-content i {
    font-size: 2rem;
    color: #d4af37;
    display: block;
    margin-bottom: 8px;
}
.master-load-content strong {
    display: block;
    font-size: 0.95rem;
    color: #374151;
}
.master-load-content p {
    margin: 4px 0 0 0;
    font-size: 0.75rem;
    color: #6b7280;
}
.load-status-line {
    margin-top: 10px;
    font-size: 0.75rem;
    color: #059669;
    min-height: 1.2em;
}
.flow-actions-sync {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}
.btn-sync-all {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: bold;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}
.btn-sync-all:hover:not(:disabled) {
    background: #059669;
}
.btn-sync-all:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.sync-progress {
    margin-top: 8px;
    border-radius: 6px;
    font-size: 0.7rem;
}
.sync-progress-placeholder {
    padding: 60px 14px;
    background: #f8fafc;
    color: #64748b;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
}
.sync-progress-steps {
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
}
.sync-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}
.sync-step .sync-icon {
    width: 16px;
    text-align: center;
}
.sync-step.pending .sync-icon::before { content: "○"; color: #94a3b8; }
.sync-step.running .sync-icon::before { content: "◐"; color: #d4af37; animation: spin 0.8s linear infinite; }
.sync-step.done .sync-icon::before { content: "✓"; color: #10b981; }
.sync-step.error .sync-icon::before { content: "✗"; color: #ef4444; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barra de soporte ultra-compacta */
.support-bar {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.support-title {
    font-size: 0.7rem;
    font-weight: bold;
    color: #d4af37;
    white-space: nowrap;
}

.support-items {
    display: flex;
    gap: 15px;
    width: 100%;
}

.s-item {
    flex: 1;
}

.s-item label {
    display: block;
    font-size: 0.65rem;
    color: #6b7280;
    margin-bottom: 2px;
}

.s-item select {
    width: 100%;
    padding: 4px;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
}

.upload-header-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1200px) {
    .upload-header-row {
        grid-template-columns: 1fr;
    }
}

.section-header {
    margin-bottom: 0.5rem;
}

.section-header h2 {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1F1F1F;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.section-header p {
    color: #4B5563;
    font-size: 0.75rem;
    margin: 0;
}

.file-upload-area {
    border: 2px dashed #E5E7EB;
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
    background: #FFFFFF;
    transition: all 0.3s;
    cursor: pointer;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-upload-area:hover {
    border-color: #D4AF37;
    background: rgba(212, 175, 55, 0.02);
}

.file-upload-area-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: #F5F5F5;
    border-color: #D0D0D0;
}

.file-upload-area-disabled .upload-label {
    cursor: not-allowed;
    color: #999;
}

.file-upload-area-disabled svg {
    color: #999 !important;
}

.file-upload-area-disabled p,
.file-upload-area-disabled small {
    color: #999 !important;
}

.upload-label {
    display: block;
    cursor: pointer;
}

.upload-icon {
    margin-bottom: 0.5rem;
    color: #4B5563;
}

.upload-icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
}

.upload-label p {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1F1F1F;
    margin-bottom: 0.125rem;
}

.upload-hint {
    font-size: 0.6875rem;
    color: #4B5563;
}

.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 3px solid #E5E7EB;
    border-top: 3px solid #D4AF37;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   TABLES PREVIEW - NUEVA ESTRUCTURA COMPACTA
   ============================================ */
.preview-container {
    padding: 10px;
    max-width: 100%;
    background: #eee;
}

/* Barra de contadores rápida */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    background: var(--dark);
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
}

.stats-bar i {
    margin-right: 5px;
    color: var(--gold);
}

.stats-bar strong {
    color: var(--gold);
    font-weight: 700;
}

/* Grid de dos columnas */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.table-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.table-card h3 {
    font-size: 0.75rem;
    margin-top: 0;
    margin-bottom: 8px;
    color: #666;
    border-bottom: 2px solid var(--gold);
    display: inline-block;
    padding-bottom: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.filtered-card {
    border: 2px solid var(--gold);
    margin-top: 10px;
}

/* Tablas ultra-compactas */
.table-responsive {
    max-height: 350px;
    overflow: auto;
    font-size: 11px;
    position: relative; /* Para que el dropdown se posicione correctamente */
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.preview-table th {
    position: sticky;
    top: 0;
    background: #f1f1f1;
    padding: 6px 4px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    z-index: 10;
}

.preview-table td {
    padding: 4px;
    border-bottom: 1px solid #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
}

.preview-table td:last-child {
    position: relative;
}

.preview-table tr:hover {
    background-color: #fff9e6;
}

.preview-table .clickable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.preview-table .clickable-row:hover {
    background-color: #fff9e6;
}

.preview-table .clickable-row.selected {
    background-color: #ffeaa7;
    font-weight: 600;
}

.preview-table tr.matched {
    background: #f0fdf4; /* Fondo verde claro para filas con match */
}

.preview-table tr.unmatched {
    background: #fef2f2; /* Fondo rojo claro para filas sin match */
}

.preview-table .confidence-high {
    color: #10b981;
    font-weight: 600;
}

.preview-table .confidence-medium {
    color: #f59e0b;
    font-weight: 600;
}

.preview-table .confidence-none {
    color: #6b7280;
}

/* ============================================
   ACTION FOOTER
   ============================================ */
.action-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--gold);
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-box label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1F1F1F;
}

.filter-box select {
    padding: 5px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    min-width: 200px;
}

.btn-secondary {
    background: #f0f0f0;
    color: #1F1F1F;
    border: 1px solid var(--border);
    padding: 5px 15px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: 0.3s;
}

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

.btn-primary {
    background: var(--gold);
    color: black;
    border: none;
    padding: 10px 25px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 3px;
    transition: 0.3s;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.btn-primary:hover:not(:disabled) {
    background: #b8962d;
}

.btn-primary:disabled,
.btn-step.btn-disabled {
    background: #d0d0d0;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
}

@media (max-width: 1200px) {
    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }
    
    .action-buttons .btn-step {
        flex: 1;
        min-width: 150px;
    }
}

#import-results {
    margin-top: 0.75rem;
}

.success-message {
    background: #D1FAE5;
    color: #065F46;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border-left: 4px solid #10B981;
    font-size: 0.8125rem;
}

.error-message {
    background: #FEE2E2;
    color: #991B1B;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border-left: 4px solid #EF4444;
    font-size: 0.8125rem;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 400px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    background: #D1FAE5;
    color: #065F46;
    border-left: 4px solid #10B981;
}

.toast-error {
    background: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid #EF4444;
}

/* ============================================
   DOCUMENTS REVIEW SECTION
   ============================================ */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.review-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: #1F1F1F;
}

.review-stats {
    font-size: 0.85rem;
    color: #666;
}

.review-stats span {
    font-weight: 600;
    color: var(--gold);
}

/* Toolbar de la tabla */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 10px 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px 8px 0 0;
    margin-top: 15px;
}

/* Filtros compactos */
.filter-group {
    display: flex;
    gap: 5px;
}

.review-filters {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-filter {
    padding: 5px 12px;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-filter.active {
    background: #d4af37;
    color: white;
    border-color: #b8962d;
}

/* Botones de acción globales (Derecha) */
.action-group {
    display: flex;
    gap: 8px;
}

.btn-toolbar {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.btn-toolbar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
}

.btn-danger-outline:hover { background: #fee2e2; }

.btn-success-solid {
    background: #10b981;
    color: white;
}

.btn-success-solid:hover { background: #059669; }

/* Iconos en las filas de la tabla (solo iconos, sin relleno) */
.row-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: calc(1.1rem + 2px);
    padding: 0;
    min-width: auto;
    border-radius: 2px;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 0.85;
}

.icon-btn.edit,
.icon-btn.assign {
    color: #6b7280;
}

.icon-btn.delete {
    color: #ef4444;
}

/* En la tabla de revisión, botones solo icono: sin background */
#documents-review-preview .btn-edit-match,
#documents-review-preview .btn-delete-doc {
    background: none !important;
    min-width: auto;
    padding: 0;
}
#documents-review-preview .btn-edit-match:hover,
#documents-review-preview .btn-delete-doc:hover {
    background: none !important;
}

/* Contenedor tabla revisión: altura máxima y scroll */
#documents-review-preview {
    max-height: 400px;
    overflow-y: auto;
}

/* Columna Relacionado con: tamaño de letra +2px respecto al resto */
#documents-review-preview .relacionado-con {
    font-size: 13px;
}

/* Ajuste tabla para que pegue con el toolbar */
#documents-review-preview table {
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.documents-review-table-container {
    max-height: 400px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
}

.review-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 11px;
}

.review-table th {
    position: sticky;
    top: 0;
    background: #f1f1f1;
    padding: 6px 4px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    z-index: 10;
}

.review-table td {
    padding: 4px;
    border-bottom: 1px solid #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    text-align: center;
}

.review-table tr.matched {
    background: #f0fdf4;
}

.review-table tr.unmatched {
    background: #fef2f2;
}

.review-table tr:hover {
    background: #fff9e6;
}

.confidence-high {
    color: #10b981;
    font-weight: 600;
}

.confidence-medium {
    color: #f59e0b;
    font-weight: 600;
}

.btn-edit-match {
    padding: 4px 12px;
    min-width: 70px; /* Mismo ancho para todos los botones */
    background: var(--gold);
    color: black;
    border: none;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
}

.btn-edit-match:hover {
    background: #b8962d;
}

.btn-delete-doc {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    min-width: 60px;
    transition: background 0.2s;
}

.btn-delete-doc:hover {
    background: #c82333;
}

/* Fondo oscuro detrás del modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Ventana modal */
.match-modal {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    width: 95%;
    max-width: 800px; /* Ventana más ancha */
    max-height: 90vh; /* Ventana más alta */
    display: flex;
    flex-direction: column;
    border: 1px solid #d4af37;
}

.search-container {
    margin-bottom: 10px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #d4af37;
}

.modal-header {
    font-size: 1.2rem;
    font-weight: bold;
    color: #d4af37;
    margin-bottom: 20px;
    border-bottom: 2px solid #f1f1f1;
    padding-bottom: 10px;
    text-align: center;
}

/* Dropdown para asignar/editar (legacy, si se usa en tabla) */
.match-dropdown {
    padding: 15px;
    background: #fff;
    border: 1px solid #d4af37;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border-radius: 8px;
    width: 350px !important;
}

.grid-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    flex-grow: 1; /* Permite que los grids ocupen el espacio disponible */
    max-height: 300px; /* Más espacio antes de hacer scroll */
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 15px;
    background: #fdfdfd;
    border-radius: 8px;
}

.grid-item {
    padding: 10px 8px;
    font-size: 0.8rem;
    text-align: center;
    background: white;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.grid-item:hover {
    border-color: #d4af37;
    background: #fff9e6;
    transform: translateY(-2px);
}

.grid-item.selected {
    background: #d4af37;
    color: white;
    border-color: #b8962d;
    box-shadow: 0 4px 8px rgba(212, 175, 55, 0.3);
}

.section-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin: 10px 0;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Asegurar que las celdas de acción permitan que el dropdown se vea */
.preview-table td:last-child {
    position: relative;
    overflow: visible !important;
}

/* Permitir que el dropdown se vea fuera del contenedor de la tabla */
.documents-review-table-container {
    position: relative;
    overflow: visible;
}

.documents-review-table-container .table-responsive {
    overflow: auto; /* Mantener scroll para tablas largas */
}

.match-selector {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.8rem;
    margin-bottom: 0;
    background: white;
}

.dropdown-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.btn-dropdown-cancel,
.btn-dropdown-save {
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-dropdown-cancel {
    background: #e5e7eb;
    color: #374151;
}

.btn-dropdown-cancel:hover {
    background: #d1d5db;
}

.btn-dropdown-save {
    background: var(--gold);
    color: black;
}

.btn-dropdown-save:hover {
    background: #b8962d;
}

.review-actions {
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Modal de edición de matching */
.match-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.match-editor-modal .modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
}

.match-editor-modal h3 {
    margin-top: 0;
    font-size: 1rem;
    color: #1F1F1F;
}

.match-editor-modal select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.error-message ul {
    margin-top: 0.25rem;
    padding-left: 1.25rem;
    font-size: 0.75rem;
}

.info-message {
    background: #DBEAFE;
    color: #1E40AF;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border-left: 4px solid #3B82F6;
    font-size: 0.8125rem;
}

/* ============================================
   DOCUMENTS SECTION
   ============================================ */
.documents-section-main {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1rem;
}

.file-upload-multiple {
    border: 2px dashed #E5E7EB;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: #FFFFFF;
    transition: all 0.3s;
    cursor: pointer;
}

.file-upload-multiple:hover {
    border-color: #D4AF37;
    background: rgba(212, 175, 55, 0.02);
}

.documents-list {
    margin-top: 2rem;
}

.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #F4F5F7;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.doc-name {
    flex: 1;
    font-weight: 500;
    color: #1F1F1F;
}

.doc-status {
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-right: 1rem;
}

.doc-status.pending {
    background: #FEF3C7;
    color: #92400E;
}

.doc-status.uploading {
    background: #DBEAFE;
    color: #1E40AF;
}

.doc-status.success {
    background: #D1FAE5;
    color: #065F46;
}

.doc-status.error {
    background: #FEE2E2;
    color: #991B1B;
}

.btn-upload-doc {
    background: #D4AF37;
    color: #0F0F0F;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upload-doc:hover {
    background: #C19D2E;
    transform: translateY(-1px);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .import-types-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.75rem;
    }
}

@media (max-width: 768px) {
    .app-main {
        padding: 2rem 1.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 1.5rem;
    }
    
    .header-left {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .header-right {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .import-types-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .import-type-btn {
        padding: 2.5rem 2rem;
        min-height: 280px;
    }
    
    .icon-wrapper {
        height: 140px;
    }
    
    .import-type-btn .icon {
        width: 100px;
        height: 100px;
    }
    
    .upload-section-main,
    .tables-preview-section,
    .documents-section-main {
        padding: 2rem 1.5rem;
    }
    
    .file-upload-area,
    .file-upload-multiple {
        padding: 2.5rem 1.5rem;
    }
    
    .tables-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    .table-container {
        min-height: 500px;
    }
    
    .table-preview-scroll {
        display: flex;
        flex-direction: column;
    }
    
    .table-scroll-container {
        max-height: 400px;
        height: 400px;
        overflow-y: auto;
        overflow-x: auto;
    }
    
    .preview-table {
        font-size: 0.75rem;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 0.5rem 0.75rem;
    }
    
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filtered-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .document-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .doc-status {
        margin-right: 0;
    }
}

/* Configuración de datos de soporte: todo el ancho, poca altura */
/* El módulo de configuración está dentro de .upload-header-row (grid): que ocupe el 100% del ancho del contenedor */
.support-config-section,
#support-data-config {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.support-config-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px 20px;
    align-items: end;
}
.support-config-grid .config-item {
    min-width: 0;
}
.support-config-grid .config-item label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 1200px) {
    .support-config-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .support-config-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
