/* ─── Tipografía global (Outfit – igual que panel de control) ── */
        *, *::before, *::after { box-sizing: border-box; }
        body {
            font-family: 'Outfit', 'Inter', sans-serif !important;
        }
        h1, h2, h3, h4, h5, h6,
        .section-title, .fac-card, .fi, select, input, button, label {
            font-family: 'Outfit', 'Inter', sans-serif !important;
        }

        /* ─── Layout ─────────────────────────────────── */
        .fac-main {
            display: flex;
            justify-content: center;
            padding: 28px 4% 60px;
            margin-left: 100px;
            min-height: 100vh;
            width: calc(100% - 100px);
        }
        .fac-card {
            width: 100%;
            max-width: 1160px;
            background: rgba(255,255,255,0.88);
            backdrop-filter: blur(28px);
            border: 1px solid rgba(255,255,255,0.65);
            padding: 38px 42px;
            border-radius: 28px;
            box-shadow: 0 18px 55px rgba(0,0,0,0.10);
        }
        .fac-form {
            display: flex;
            flex-direction: column;
            gap: 22px;
        }

        /* ─── Section boxes ───────────────────────────── */
        .section-box {
            background: #ffffff;
            border-radius: 18px;
            padding: 22px 26px;
            box-shadow: 0 3px 12px rgba(0,0,0,0.04);
            border: 1px solid rgba(0,0,0,0.06);
            position: relative;
        }
        .section-blocked {
            opacity: 0.45;
            pointer-events: none;
            filter: grayscale(0.8);
            transition: all 0.4s ease;
        }
        .section-blocked::after {
            content: "";
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            cursor: not-allowed;
            z-index: 10;
        }
        .section-title {
            font-size: 0.95rem;
            color: #0f172a;
            margin: 0 0 18px 0;
            display: flex;
            align-items: center;
            gap: 11px;
            font-family: var(--font-display);
            font-weight: 800;
            letter-spacing: -0.3px;
        }
        .section-title i { color: var(--primary); }

        /* ─── Emisor card ─────────────────────────────── */
        .emisor-card {
            background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 55%, #3b82f6 100%);
            border-radius: 20px;
            padding: 22px 28px;
            box-shadow: 0 10px 30px rgba(30,64,175,0.25);
            color: white;
            border: 1px solid rgba(255,255,255,0.12);
        }
        .emisor-header {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 18px;
        }
        .emisor-icon {
            background: rgba(255,255,255,0.18);
            width: 56px;
            height: 56px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            flex-shrink: 0;
            backdrop-filter: blur(6px);
        }
        .emisor-badge {
            background: rgba(255,255,255,0.18);
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.72rem;
            font-weight: 800;
            letter-spacing: 1px;
            backdrop-filter: blur(5px);
            white-space: nowrap;
        }
        /* ─── Emisor chip pills ────────────────────────── */
        .emisor-chip {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.20);
            backdrop-filter: blur(6px);
            border-radius: 50px;
            padding: 7px 15px;
            font-size: 0.82rem;
            font-weight: 600;
            color: #ffffff;
            white-space: nowrap;
            transition: background 0.2s;
        }
        .emisor-chip i {
            opacity: 0.80;
            font-size: 0.78rem;
        }
        .emisor-chip:hover { background: rgba(255,255,255,0.22); }

        /* ─── Inputs ──────────────────────────────────── */
        .fi {
            background: #f8fafc;
            color: #0f172a;
            border: 1px solid #e2e8f0;
            width: 100%;
            padding: 11px 13px;
            border-radius: 11px;
            font-weight: 600;
            font-size: 0.88rem;
            box-sizing: border-box;
            transition: border 0.2s;
        }
        .fi:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
        }
        .label-sm {
            font-size: 0.72rem;
            font-weight: 800;
            color: #475569;
            margin-bottom: 7px;
            display: block;
            letter-spacing: 0.8px;
            text-transform: uppercase;
        }

        /* ─── Cliente search ──────────────────────────── */
        .cliente-search-bar {
            display: flex;
            gap: 10px;
            margin-bottom: 14px;
        }
        .cliente-search-bar input {
            flex: 1;
        }
        .btn-buscar {
            background: var(--grad-premium, linear-gradient(135deg,#1e40af,#3b82f6));
            color: white;
            border: none;
            border-radius: 11px;
            padding: 11px 20px;
            font-weight: 700;
            font-size: 0.88rem;
            cursor: pointer;
            white-space: nowrap;
            transition: opacity 0.2s, transform 0.15s;
        }
        .btn-buscar:hover { opacity: 0.92; transform: translateY(-1px); }
        .cliente-info-premium {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-top: 18px;
            display: none;
        }
        .cliente-info-premium.visible { display: grid; }
        .cliente-card-segment {
            background: #ffffff;
            border-radius: 16px;
            padding: 18px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
            transition: all 0.2s ease;
        }
        .cliente-card-segment:hover { 
            transform: translateY(-3px); 
            border-color: var(--primary); 
            box-shadow: 0 10px 15px -3px rgba(30, 64, 175, 0.1); 
        }
        .segment-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 12px;
            border-bottom: 1px dashed #e2e8f0;
            padding-bottom: 8px;
        }
        .segment-header i { color: var(--primary); font-size: 1rem; }
        .segment-header h4 { margin: 0; font-size: 0.72rem; font-weight: 800; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; }
        
        .info-grid-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
        .info-item { display: flex; flex-direction: column; gap: 2px; }
        .info-label { font-size: 0.6rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.8px; }
        .info-val { font-size: 0.85rem; font-weight: 700; color: #1e293b; overflow: hidden; text-overflow: ellipsis; }
        .info-val.highlight { color: var(--primary); font-size: 1.05rem; font-weight: 900; letter-spacing: -0.3px; }

        /* ─── Detail table ────────────────────────────── */
        .detail-table { width: 100%; border-collapse: collapse; }
        .detail-table thead tr { background: #e8edf4; }
        .detail-table th {
            color: #475569;
            padding: 10px 12px;
            text-align: left;
            font-size: 0.75rem;
            font-weight: 800;
            letter-spacing: 0.5px;
        }
        .detail-table tbody td {
            padding: 9px 12px;
            color: #0f172a;
            font-size: 0.85rem;
            border-bottom: 1px solid #f1f5f9;
        }
        .detail-table input[type="text"],
        .detail-table input[type="number"],
        .fi-grid {
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            padding: 7px 9px;
            width: 100%;
            font-weight: 600;
            font-size: 0.78rem;
            box-sizing: border-box;
            transition: all 0.2s;
        }
        .fi-grid:focus {
            border-color: var(--primary);
            background: #ffffff;
            outline: none;
        }
        select.fi-grid {
            padding: 6px 4px;
        }
        .btn-del {
            background: none;
            border: none;
            color: #ef4444;
            cursor: pointer;
            font-size: 1rem;
            padding: 6px;
            border-radius: 7px;
            transition: background 0.15s;
        }
        .btn-del:hover { background: #fee2e2; }
        .btn-add-line {
            width: 100%;
            padding: 14px;
            margin-top: 12px;
            border: 2px dashed #cbd5e1;
            background: #f8fafc;
            border-radius: 11px;
            color: #64748b;
            cursor: pointer;
            font-weight: 700;
            font-size: 0.88rem;
            transition: all 0.2s;
        }
        .btn-add-line:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

        /* ─── Condiciones & Impuesto ──────────────────── */
        .cond-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 20px;
            margin-bottom: 22px;
        }
        .tax-section { margin-top: 4px; }
        .tax-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; margin-top: 8px; }
        .tax-table th {
            background: #f1f5f9;
            color: #475569;
            padding: 8px 12px;
            text-align: left;
            font-size: 0.72rem;
            font-weight: 800;
            letter-spacing: 0.5px;
        }
        .tax-table td {
            padding: 7px 12px;
            border-bottom: 1px solid #f1f5f9;
            color: #0f172a;
            font-weight: 500;
        }
        .tax-table tr:last-child td { border-bottom: none; }
        .tax-badge {
            display: inline-block;
            background: #dbeafe;
            color: #1e40af;
            border-radius: 6px;
            padding: 2px 8px;
            font-size: 0.72rem;
            font-weight: 700;
        }

        /* ─── Totals panel ────────────────────────────── */
        .totals-panel {
            background: #f8fafc;
            padding: 22px;
            border-radius: 14px;
            text-align: right;
            border: 1px solid #e2e8f0;
        }
        .totals-panel p { margin: 0 0 4px; font-size: 0.82rem; color: #64748b; font-weight: 700; }
        .totals-panel h2 { margin: 0; font-size: 2.3rem; color: var(--primary); font-weight: 900; }

        /* ─── Submit ──────────────────────────────────── */
        .btn-emitir {
            width: 100%;
            padding: 22px;
            background: var(--grad-premium, linear-gradient(135deg,#1e40af,#3b82f6));
            border: none;
            border-radius: 14px;
            color: white;
            font-size: 1.35rem;
            font-weight: 800;
            cursor: pointer;
            box-shadow: 0 10px 28px hsla(221,83%,53%,0.3);
            transition: transform 0.2s, opacity 0.2s;
        }
        .btn-emitir:hover { opacity: 0.93; transform: translateY(-2px); }

        /* --- Estilos Responsivos Facturación --- */
        @media (max-width: 1024px) {
            .fac-main {
                margin-left: 62px;
                width: calc(100% - 62px);
                padding: 20px 2%;
            }
            .cond-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 768px) {
            .fac-main {
                margin-left: 0;
                padding: 15px 15px 100px;
            }
            .fac-card {
                padding: 25px 20px;
                border-radius: 18px;
            }
            .emisor-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
            .cliente-search-bar {
                flex-direction: column;
            }
            .cliente-info-premium.visible {
                grid-template-columns: 1fr;
            }
            .info-grid-inner {
                grid-template-columns: 1fr;
            }
            .cond-grid {
                grid-template-columns: 1fr;
            }
            .detail-table-wrapper {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                margin: 0 -10px;
                padding: 0 10px;
            }
            .detail-table {
                min-width: 600px; /* Asegura scroll horizontal en tablas */
            }
            .totals-panel h2 {
                font-size: 1.8rem;
            }
        }

        /* ─── Custom Activity Select Component ──────────────── */
        .custom-activity-select {
            width: 100%;
            z-index: 100;
        }
        .activity-trigger {
            background: #ffffff;
            border: 2.5px solid var(--primary-light, #e0e7ff);
            border-radius: 12px;
            padding: 8px 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            min-height: 44px;
        }
        .activity-trigger:hover {
            border-color: var(--primary);
            background: #f8fbff;
            transform: translateY(-1px);
        }
        .activity-trigger .activity-text {
            font-size: 0.82rem;
            font-weight: 800;
            color: var(--primary-dark);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 90%;
        }
        .activity-trigger i {
            font-size: 0.7rem;
            color: var(--primary);
            transition: transform 0.3s;
        }
        
        .activity-list-dropdown {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            right: 0;
            background: white;
            border-radius: 16px;
            box-shadow: 0 15px 40px rgba(0,0,0,0.15);
            border: 1px solid #e2e8f0;
            max-height: 280px;
            overflow-y: auto;
            z-index: 1000;
            padding: 8px;
            animation: slideUpFade 0.3s ease-out;
        }

        @keyframes slideUpFade {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .activity-opt {
            padding: 10px 14px;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.2s;
            margin-bottom: 2px;
            border: 1px solid transparent;
        }
        .activity-opt:hover {
            background: #eff6ff;
            border-color: #dbeafe;
        }
        .activity-opt.selected {
            background: var(--grad-premium);
            color: white;
            border: none;
        }
        .activity-opt .act-code {
            font-family: monospace;
            font-weight: 900;
            font-size: 0.75rem;
            opacity: 0.8;
            margin-right: 6px;
        }
        .activity-opt .act-desc {
            font-size: 0.78rem;
            font-weight: 600;
        }
        .activity-opt.selected .act-code, 
        .activity-opt.selected .act-desc {
            color: white;
            opacity: 1;
        }

        /* --- UI Utilities --- */
        .no-spin::-webkit-inner-spin-button,
        .no-spin::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        .no-spin {
            -moz-appearance: textfield;
        }

        /* ─── Premium Modals (Swal2) ───────────────────── */
        .premium-swal-popup {
            border-radius: 24px !important;
            padding: 2.5rem 2rem !important;
            border: 1px solid rgba(255,255,255,0.8);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
        }

        .btn-confirm-premium {
            background: #1e40af !important;
            border-radius: 12px !important;
            padding: 14px 40px !important;
            font-weight: 900 !important;
            font-size: 1.1rem !important;
            text-transform: none !important;
            margin-left: 10px !important;
        }

        .btn-cancel-premium {
            background: #64748b !important;
            border-radius: 12px !important;
            padding: 14px 40px !important;
            font-weight: 900 !important;
            font-size: 1.1rem !important;
            text-transform: none !important;
        }

        .btn-confirm-full {
            width: 100% !important;
            background: #1e40af !important;
            border-radius: 100px !important;
            padding: 20px !important;
            font-weight: 900 !important;
            font-size: 1.1rem !important;
            margin-bottom: 12px !important;
        }

        .btn-deny-flat {
            width: 100% !important;
            background: #f1f5f9 !important;
            color: #475569 !important;
            border-radius: 100px !important;
            padding: 16px !important;
            font-weight: 900 !important;
            font-size: 0.95rem !important;
            margin-bottom: 12px !important;
        }

        .btn-cancel-flat {
            width: 100% !important;
            background: #ffffff !important;
            color: #64748b !important;
            border: 1.5px solid #e2e8f0 !important;
            border-radius: 100px !important;
            padding: 14px !important;
            font-weight: 900 !important;
            font-size: 0.95rem !important;
        }

        .btn-download-xml, .btn-download-pdf {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 24px;
            border-radius: 12px;
            font-weight: 800;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
        }

        .btn-download-xml { background: #f1f5f9; color: #1e293b; }
        .btn-download-pdf { background: #fef2f2; color: #ef4444; }
        
        .btn-download-xml:hover { background: #e2e8f0; }
        .btn-download-pdf:hover { background: #fee2e2; }

        .swal2-title {
            font-family: 'Outfit', sans-serif !important;
            font-weight: 950 !important;
            color: #1e293b !important;
            font-size: 2.2rem !important;
            letter-spacing: -1px !important;
        }

        .swal2-html-container {
            font-family: 'Outfit', sans-serif !important;
        }