/* ============================================================
   VARIABLES Y RESET
   ============================================================ */
:root {
    --primary: #0f172a;
    --secondary: #1e293b;
    --bg-color: #f0f4f8;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(226, 232, 240, 0.5);
    --user-accent: #10b981;
    --user-accent-glow: rgba(16, 185, 129, 0.15);
    --green-clean: #10b981;
    --red-clean: #ef4444;
    --blue-clean: #3b82f6;
    --purple-clean: #8b5cf6;
    --orange-clean: #f59e0b;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --primary: #f1f5f9;
    --secondary: #cbd5e1;
    --bg-color: #0a0f1a;
    --surface: rgba(30, 41, 59, 0.85);
    --surface-solid: #1e293b;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.6);
    --green-clean: #34d399;
    --red-clean: #f87171;
    --blue-clean: #60a5fa;
    --purple-clean: #c084fc;
    --orange-clean: #fbbf24;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 9999px;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.top-bar {
    background: var(--surface);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* El contenedor principal de tu logo */
.brand {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
    position: relative;
    overflow: hidden; /* Esto es la magia que esconde los textos cuando suben/bajan */
    height: 40px; /* Le damos altura fija para que no brinque a lo güey */
    padding: 0 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

/* Pa' que agarre brillito al pasar el mouse */
.brand:hover {
    background: var(--user-accent-glow);
}

.brand img {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 0 5px var(--user-accent-glow));
}

/* Los contenedores internos (Normal y Hover) */
.brand-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    width: 100%;
}

/* Posición inicial del texto normal */
.brand .normal-state {
    transform: translateY(0);
    opacity: 1;
}

/* El texto de "Volver" arranca escondido abajo */
.brand .hover-state {
    position: absolute;
    left: 8px;
    transform: translateY(100%);
    opacity: 0;
}

/* ================================
   LA MAGIA CUANDO PASAS EL RATÓN
   ================================ */
/* El texto normal se va pa'rriba y desaparece */
.brand:hover .normal-state {
    transform: translateY(-100%);
    opacity: 0;
}

/* El texto de "Volver" sube y se muestra */
.brand:hover .hover-state {
    transform: translateY(0);
    opacity: 1;
}

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-action-round {
    background: var(--bg-color);
    border: 1px solid var(--border);
    font-size: 16px;
    cursor: pointer;
    color: var(--text-main);
    transition: all var(--transition);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.btn-action-round:hover {
    border-color: var(--user-accent);
    color: var(--user-accent);
    transform: scale(1.1);
    box-shadow: 0 4px 10px var(--user-accent-glow);
}

.btn-premium {
    padding: 8px 16px;
    background: var(--user-accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--user-accent-glow);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
}
.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--user-accent-glow);
    filter: brightness(1.05);
}

/* ============================================================
   RFC SELECTOR BAR
   ============================================================ */
.rfc-selector-bar {
    background: var(--surface);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.rfc-selector-bar label {
    font-size: 10px;
    font-weight: 800;
    color: var(--user-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rfc-selector-bar select {
    background: var(--bg-color);
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    outline: none;
    transition: all var(--transition);
    font-family: var(--font);
    min-width: 220px;
    cursor: pointer;
}
.rfc-selector-bar select:focus {
    border-color: var(--user-accent);
    box-shadow: 0 0 0 3px var(--user-accent-glow);
}

.rfc-badge {
    background: var(--user-accent-glow);
    color: var(--user-accent);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--user-accent);
    white-space: nowrap;
}

.filter-tags {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}
.filter-tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
    font-family: var(--font);
}
.filter-tag.active {
    border-color: var(--user-accent);
    color: var(--user-accent);
    background: var(--user-accent-glow);
}
.filter-tag:hover {
    border-color: var(--user-accent);
    color: var(--user-accent);
}

/* ============================================================
   MAIN CONTAINER
   ============================================================ */
.main-container {
    flex: 1;
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
}

/* ============================================================
   PANEL IZQUIERDO: ÁRBOL FINANCIERO
   ============================================================ */
.panel-tree {
    flex: 0 0 460px;
    background: var(--surface);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 180px);
}

.panel-tree .panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.02);
}

.panel-tree .panel-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.panel-tree .tree-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* ============================================================
   ÁRBOL FINANCIERO - DISEÑO MODERNO Y LIMPIO
   ============================================================ */
.arbol-wrapper {
    padding: 4px 0;
    font-family: var(--font);
}

.arbol-nodo {
    position: relative;
    margin-left: 18px;
}

.arbol-nodo::before {
    content: '';
    position: absolute;
    top: -8px;
    bottom: 0;
    left: -10px;
    border-left: 2px solid var(--border);
    opacity: 0.6;
}

.arbol-nodo:last-child::before {
    bottom: auto;
    height: 28px;
}

.arbol-item-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.arbol-item-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -10px;
    width: 10px;
    border-top: 2px solid var(--border);
    opacity: 0.6;
}

.arbol-nodo.nivel-0 { margin-left: 0; }
.arbol-nodo.nivel-0 > .arbol-item-container::before,
.arbol-nodo.nivel-0::before { display: none; }

.carpeta-contenido {
    display: flex;
    flex: 1;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.carpeta-contenido:hover {
    border-color: var(--user-accent);
    box-shadow: 0 4px 12px var(--user-accent-glow);
    background: var(--surface-solid);
}

.carpeta-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    padding-right: 8px;
}

.carpeta-nombre {
    font-weight: 700;
    font-size: 11px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-toggle-tree {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    transition: all 0.2s ease;
    z-index: 2;
}
.btn-toggle-tree:hover {
    border-color: var(--user-accent);
    color: var(--user-accent);
    background: var(--user-accent-glow);
}
.btn-toggle-tree.rotado {
    transform: rotate(-90deg);
}

.btn-accion-arbol {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 11px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}
.carpeta-contenido:hover .btn-accion-arbol {
    opacity: 0.7;
    transform: scale(1);
}
.btn-accion-arbol:hover { opacity: 1 !important; }

.arbol-hijos {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 1;
}
.arbol-hijos.oculto {
    grid-template-rows: 0fr;
    opacity: 0;
    pointer-events: none;
}
.arbol-hijos-inner {
    overflow: hidden;
}

.sat-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px dashed var(--text-muted);
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}
.sat-badge.amarrado {
    border-color: var(--user-accent);
    color: var(--user-accent);
    background: var(--user-accent-glow);
    border-style: solid;
}
.sat-badge.acumulativa {
    color: #4CAF50;
    border: 1px solid #4CAF50;
}
.sat-badge.alerta {
    border-color: var(--red-clean);
    color: var(--red-clean);
    border-style: dashed;
}

/* ============================================================
   CABECERA DEL PANEL IZQUIERDO
   ============================================================ */
.panel-tree .panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.02);
}

.panel-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.panel-tree .panel-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
}

.panel-tree .panel-header .header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

/* ============================================================
   PANEL DERECHO: CLIENTES Y PROVEEDORES
   ============================================================ */
.panel-list {
    flex: 1;
    background: var(--surface);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 180px);
}

.panel-list .panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-list .panel-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-list .panel-header input {
    background: var(--bg-color);
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    outline: none;
    transition: all var(--transition);
    font-family: var(--font);
    min-width: 180px;
}
.panel-list .panel-header input:focus {
    border-color: var(--user-accent);
    box-shadow: 0 0 0 3px var(--user-accent-glow);
}

.panel-list .list-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

/* ============================================================
   TARJETA DE TERCERO
   ============================================================ */
.tercero-card {
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: all var(--transition);
    cursor: pointer;
}
.tercero-card:hover {
    border-color: var(--user-accent);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.tercero-card .tercero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tercero-card .tercero-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.tercero-card .tercero-rfc {
    font-family: var(--mono);
    font-weight: 900;
    font-size: 13px;
    color: var(--primary);
}
.tercero-card .tercero-nombre {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}
.tercero-card .tercero-badge {
    font-size: 9px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 700;
}
.badge-cliente {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green-clean);
    border: 1px solid var(--green-clean);
}
.badge-proveedor {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red-clean);
    border: 1px solid var(--red-clean);
}
.badge-ambos {
    background: rgba(139, 92, 246, 0.12);
    color: var(--purple-clean);
    border: 1px solid var(--purple-clean);
}

.tercero-card .tercero-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tercero-card .tercero-actions button {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.btn-asignar-regla {
    background: var(--user-accent);
    color: white;
    box-shadow: 0 2px 8px var(--user-accent-glow);
}
.btn-asignar-regla:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--user-accent-glow);
}
.btn-ver-facturas {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border) !important;
}
.btn-ver-facturas:hover {
    border-color: var(--user-accent) !important;
    color: var(--user-accent);
    background: var(--user-accent-glow);
}
.btn-regla-existente {
    background: rgba(16, 185, 129, 0.08);
    color: var(--user-accent);
    border: 1px solid var(--user-accent) !important;
    font-size: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    cursor: default;
}

.tercero-card .tercero-stats {
    display: flex;
    gap: 16px;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    flex-wrap: wrap;
    border-top: 1px dashed var(--border);
    padding-top: 6px;
}
.tercero-card .tercero-stats span {
    font-weight: 600;
}
.tercero-card .tercero-stats .stat-val {
    color: var(--primary);
    font-weight: 700;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.empty-state .es-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}
.empty-state h2 {
    margin: 0 0 6px 0;
    color: var(--primary);
    font-size: 18px;
}
.empty-state p {
    margin: 0;
    font-size: 12px;
}

/* ============================================================
   MODALES
   ============================================================ */
.db-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.db-modal-content {
    background: var(--surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    width: 95%;
    max-width: 900px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.35s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.db-modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.db-modal-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--primary);
    font-weight: 800;
}
.db-modal-header p {
    margin: 2px 0 0 0;
    font-size: 11px;
    color: var(--text-muted);
}
.db-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    line-height: 1;
    padding: 0 4px;
}
.db-modal-close:hover {
    color: var(--red-clean);
    transform: rotate(90deg);
}

.db-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.db-modal-body .form-group {
    margin-bottom: 14px;
}
.db-modal-body .form-group label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    color: var(--user-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.db-modal-body .form-group select,
.db-modal-body .form-group input,
.db-modal-body .form-group textarea {
    width: 100%;
    background: var(--bg-color);
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    outline: none;
    transition: all var(--transition);
    font-family: var(--font);
}
.db-modal-body .form-group select:focus,
.db-modal-body .form-group input:focus,
.db-modal-body .form-group textarea:focus {
    border-color: var(--user-accent);
    box-shadow: 0 0 0 3px var(--user-accent-glow);
}

.db-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.db-modal-footer button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.btn-modal-cancel {
    background: var(--bg-color);
    color: var(--text-muted);
}
.btn-modal-cancel:hover {
    background: var(--border);
}
.btn-modal-save {
    background: var(--user-accent);
    color: white;
    box-shadow: 0 4px 12px var(--user-accent-glow);
}
.btn-modal-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--user-accent-glow);
}
.btn-modal-delete {
    background: var(--red-clean);
    color: white;
}
.btn-modal-delete:hover {
    background: #dc2626;
}

/* ============================================================
   TABLAS MINI
   ============================================================ */
.db-table-mini {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.db-table-mini th {
    background: var(--bg-color);
    padding: 8px 10px;
    text-align: left;
    position: sticky;
    top: 0;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    z-index: 2;
    font-size: 9px;
    text-transform: uppercase;
}
.db-table-mini td {
    padding: 8px 10px;
    border-bottom: 1px dashed var(--border);
    color: var(--text-main);
    font-size: 10px;
}
.db-table-mini tr:hover {
    background: var(--user-accent-glow);
}

.db-badge-micro {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 9px;
    font-weight: 700;
    background: var(--bg-color);
    color: var(--text-muted);
    border: 1px solid var(--border);
    display: inline-block;
}

.badge-excepcion {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red-clean);
    border-color: var(--red-clean);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
    width: 100%;
    pointer-events: none;
}

.toast-msg {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-left: 4px solid var(--user-accent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    font-family: var(--font);
}
.toast-msg.show {
    transform: translateX(0);
}

/* ============================================================
   VISTA PREVIA EXCEL
   ============================================================ */
.excel-preview-container {
    overflow-x: auto;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
    max-height: 60vh;
}

.excel-preview-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: var(--font);
}

.excel-preview-container th {
    background: #1a472a;
    color: white;
    padding: 8px 12px;
    text-align: left;
    font-weight: 800;
    font-size: 11px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.excel-preview-container th:first-child,
.excel-preview-container td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--surface-solid);
    border-right: 2px solid var(--border);
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.excel-preview-container th:first-child {
    z-index: 11;
    background: #10321c;
}

.excel-preview-container td {
    padding: 6px 12px;
    border-bottom: 1px dashed var(--border);
    font-size: 11px;
    color: var(--text-main);
    text-align: right;
}
.excel-preview-container td:first-child {
    text-align: left;
}

.excel-preview-container tr:nth-child(even) td {
    background: var(--surface);
}
.excel-preview-container tr:nth-child(even) td:first-child {
    background: var(--surface);
}

.excel-preview-container tr:hover td {
    background: var(--user-accent-glow) !important;
    color: var(--user-accent);
}

/* ============================================================
   MODAL VISOR PDF MAESTRO
   ============================================================ */
.pdf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.pdf-modal-content {
    position: relative;
    width: 98%;
    max-width: none;
    height: 96vh;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalSlideUp 0.35s ease;
}

.pdf-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: var(--bg-color);
}

.pdf-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: var(--red-clean);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.pdf-close:hover {
    transform: scale(1.1);
    background: #dc2626;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

/* ============================================================
   BUSCADOR CUSTOM SUGERENCIAS
   ============================================================ */
.sugerencia-item {
    padding: 8px 10px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
}
.sugerencia-item:hover {
    background: var(--user-accent-glow);
    color: var(--user-accent);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
        padding: 12px;
    }
    .panel-tree {
        flex: none;
        max-height: 300px;
    }
    .panel-list {
        max-height: 600px;
    }
    .rfc-selector-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-tags {
        margin-left: 0;
        justify-content: flex-start;
    }
    .tercero-card .tercero-header {
        flex-direction: column;
        align-items: stretch;
    }
    .tercero-card .tercero-actions {
        justify-content: flex-start;
    }
    .db-modal-content {
        max-width: 95%;
    }
}

@media (max-width: 500px) {
    .top-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .top-actions {
        flex-wrap: wrap;
    }
    .panel-list .panel-header {
        flex-direction: column;
        align-items: stretch;
    }
    .panel-list .panel-header input {
        min-width: 100%;
    }
    .rfc-selector-bar select {
        min-width: 100%;
    }
    .tercero-card .tercero-info {
        flex-direction: column;
        align-items: flex-start;
    }
    .db-modal-content {
        width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-md);
    }
    .excel-preview-container table {
        font-size: 9px;
    }
    .excel-preview-container th,
    .excel-preview-container td {
        padding: 3px 6px;
    }
}