        /* ================================================================
           DESIGN SYSTEM — CSS Custom Properties
           ================================================================ */
        :root {
            --primary: #1E40AF;
            --primary-hover: #1E3A8A;
            --primary-light: #EFF6FF;
            --primary-border: #BFDBFE;
            --primary-50: #DBEAFE;
            --success: #059669;
            --success-light: #ECFDF5;
            --success-border: #A7F3D0;
            --warning: #B45309;
            --warning-light: #FFFBEB;
            --warning-border: #FDE68A;
            --danger: #DC2626;
            --danger-light: #FEF2F2;
            --danger-border: #FECACA;
            --bg: #F8FAFC;
            --surface: #FFFFFF;
            --border: #E2E8F0;
            --border-hover: #CBD5E1;
            --text-primary: #0F172A;
            --text-secondary: #475569;
            --text-muted: #94A3B8;
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;
            --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
            --shadow-md: 0 2px 4px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06);
            --shadow-lg: 0 4px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.10);
            --font-stack: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            --font-mono: 'IBM Plex Mono', 'SF Mono', SFMono-Regular, Consolas, monospace;
            --transition-fast: 150ms ease;
            --transition-normal: 250ms ease;
            --easing-emphasized: cubic-bezier(0.4, 0, 0.2, 1);
            /* Toggle-scoped tokens — keep visual tuning one-line. */
            --toggle-track: #CBD5E1;
            --toggle-track-hover: #94A3B8;
            --toggle-knob: #FFFFFF;
            --toggle-knob-shadow: 0 1px 2px rgba(15, 23, 42, 0.12),
                                  0 1px 1px rgba(15, 23, 42, 0.06);
            --toggle-knob-shadow-hover: 0 1px 3px rgba(15, 23, 42, 0.20);
            --toggle-track-inset: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
            --toggle-focus-ring: 0 0 0 3px rgba(30, 64, 175, 0.22);
        }

        /* ================================================================
           RESET & BASE
           ================================================================ */
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: var(--font-stack);
            background: var(--bg);
            color: var(--text-primary);
            min-height: 100vh;
            line-height: 1.5;
            font-size: 14px;
            -webkit-font-smoothing: antialiased;
            font-feature-settings: 'cv11' 1, 'ss01' 1;
            letter-spacing: -0.006em;
        }

        /* ================================================================
           LAYOUT
           ================================================================ */
        .container { max-width: 1080px; margin: 0 auto; padding: 20px; }
        .hidden { display: none !important; }

        /* ================================================================
           HEADER
           ================================================================ */
        .app-header {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 16px 0;
            margin-bottom: 8px;
            border-bottom: 1px solid var(--border);
        }
        .app-header__title {
            font-size: 22px;
            font-weight: 700;
            color: var(--text-primary);
            flex-grow: 1;
            letter-spacing: -0.02em;
        }
        .app-header__title svg { vertical-align: -3px; margin-right: 8px; }

        /* Health indicator */
        .health-indicator {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid var(--border);
            background: var(--surface);
            transition: all var(--transition-fast);
            position: relative;
        }
        .health-indicator:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
        .health-dot {
            width: 8px; height: 8px; border-radius: 50%;
            display: inline-block;
        }
        .health-dot.healthy { background: var(--success); }
        .health-dot.degraded { background: var(--warning); }
        .health-dot.unhealthy { background: var(--danger); }
        .health-dot.loading { background: var(--text-muted); animation: health-pulse 1.5s ease-in-out infinite; }
        @keyframes health-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }
        .health-dot.healthy { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }

        /* Health dropdown panel */
        .health-panel {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg);
            padding: 16px;
            min-width: 260px;
            z-index: 100;
            display: none;
        }
        .health-panel.show { display: block; }
        .health-panel__title { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
        .health-service {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 6px 0;
            font-size: 13px;
        }
        .health-service + .health-service { border-top: 1px solid var(--border); }
        .health-service__name { color: var(--text-primary); }
        .health-service__status { font-weight: 600; }
        .health-service__status.ok { color: var(--success); }
        .health-service__status.no { color: var(--danger); }

        /* Header buttons */
        .btn-header {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all var(--transition-fast);
            text-decoration: none;
        }
        .btn-header:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg); }

        /* ================================================================
           BUTTONS
           ================================================================ */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 10px 20px;
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-weight: 600;
            border: none;
            cursor: pointer;
            transition: all var(--transition-fast);
            line-height: 1.4;
        }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn:active:not(:disabled) { transform: scale(0.98); }
        .btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
        .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
        .btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
        .btn-secondary:hover:not(:disabled) { background: var(--surface); border-color: var(--border-hover); color: var(--text-primary); }
        .btn-success { background: var(--success); color: #fff; }
        .btn-success:hover:not(:disabled) { background: #047857; }
        .btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger-border); }
        .btn-danger-outline:hover:not(:disabled) { background: var(--danger-light); }
        .btn-sm { padding: 6px 12px; font-size: 12px; }
        .btn-full { width: 100%; }

        /* ================================================================
           CARDS
           ================================================================ */
        .card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 24px;
            box-shadow: var(--shadow-sm);
        }
        .card + .card { margin-top: 16px; }

        /* ================================================================
           TABS
           ================================================================ */
        .tabs {
            display: flex;
            gap: 4px;
            border-bottom: 2px solid var(--border);
            margin-bottom: 20px;
        }
        .tab-btn {
            padding: 10px 20px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
            background: none;
            border: none;
            border-bottom: 2px solid transparent;
            margin-bottom: -2px;
            cursor: pointer;
            transition: all var(--transition-fast);
            border-radius: var(--radius-sm) var(--radius-sm) 0 0;
        }
        .tab-btn:hover { color: var(--text-primary); background: var(--bg); }
        .tab-btn.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
            font-weight: 600;
            background: var(--primary-light);
        }
        .tab-content { display: none; }
        .tab-content.active { display: block; }

        /* ================================================================
           INFO PANELS (collapsible documentation banners)
           ================================================================ */
        .info-panel {
            background: var(--primary-light);
            border: 1px solid var(--primary-border);
            border-radius: var(--radius-md);
            margin-bottom: 20px;
            overflow: hidden;
        }
        .info-panel__header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 16px;
            cursor: pointer;
            user-select: none;
            transition: background var(--transition-fast);
        }
        .info-panel__header:hover { background: rgba(37,99,235,0.06); }
        .info-panel__icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px; height: 22px;
            background: var(--primary);
            color: #fff;
            border-radius: 50%;
            font-size: 12px;
            font-weight: 700;
            flex-shrink: 0;
        }
        .info-panel__summary { flex-grow: 1; font-size: 13px; color: var(--primary); font-weight: 500; }
        .info-panel__toggle {
            font-size: 12px;
            color: var(--primary);
            font-weight: 500;
            white-space: nowrap;
        }
        .info-panel__toggle::after { content: ' \25BE'; }
        .info-panel.open .info-panel__toggle::after { content: ' \25B4'; }
        .info-panel__body {
            max-height: 0;
            overflow: hidden;
            transition: max-height 300ms ease, padding 300ms ease;
            padding: 0 16px;
        }
        .info-panel.open .info-panel__body {
            max-height: 2000px;
            padding: 0 16px 16px;
        }
        .info-panel__body p { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.6; }
        .info-panel__body strong { color: var(--text-primary); }
        /* Pipeline "Opciones" dropdown — the 4 upload toggles live here now
           (rarely touched). The pipeline info panel needs overflow visible so
           the absolutely-positioned dropdown isn't clipped; the header keeps
           its own radius so the hover background still looks rounded. */
        #info-pipeline { position: relative; overflow: visible; }
        #info-pipeline .info-panel__header { border-radius: calc(var(--radius-md) - 1px); }
        .pipeline-options-btn {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            background: var(--surface);
            color: var(--primary);
            border: 1px solid var(--primary-border);
            border-radius: var(--radius-sm);
            padding: 4px 10px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
        }
        .pipeline-options-btn:hover { background: var(--primary-light); }
        .pipeline-options-dropdown {
            display: none;
            position: absolute;
            right: 0;
            top: calc(100% + 6px);
            z-index: 1200;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
            padding: 14px 16px;
            flex-direction: column;
            gap: 12px;
            min-width: 320px;
        }
        .pipeline-options-dropdown.open { display: flex; }

        /* Pipeline stepper inside info panel */
        .stepper {
            display: flex;
            align-items: flex-start;
            gap: 0;
            margin: 16px 0 8px;
        }
        .stepper__step {
            flex: 1;
            text-align: center;
            position: relative;
        }
        .stepper__circle {
            width: 32px; height: 32px;
            background: var(--primary);
            color: #fff;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 700;
            margin-bottom: 8px;
            position: relative;
            z-index: 1;
        }
        .stepper__label { font-size: 12px; font-weight: 600; color: var(--text-primary); display: block; }
        .stepper__desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; display: block; padding: 0 4px; }
        .stepper__step + .stepper__step::before {
            content: '';
            position: absolute;
            top: 16px;
            left: -50%;
            right: 50%;
            height: 2px;
            background: var(--primary-border);
            z-index: 0;
        }

        /* ================================================================
           FORMS
           ================================================================ */
        .form-group { margin-bottom: 16px; }
        .form-label {
            display: block;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 6px;
        }
        .form-input {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-family: var(--font-stack);
            color: var(--text-primary);
            background: var(--surface);
            transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
        }
        .form-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
        }
        .form-input::placeholder { color: var(--text-muted); }
        .form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
        .form-hint.valid { color: var(--success); }
        .form-hint.invalid { color: var(--danger); }

        /* Input with icon */
        .input-icon-wrap {
            position: relative;
        }
        .input-icon-wrap .form-input { padding-left: 38px; }
        .input-icon-wrap svg {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
        }

        /* Phone input with prefix */
        .phone-input-wrap {
            display: flex;
            align-items: center;
        }
        .phone-prefix {
            padding: 10px 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-right: none;
            border-radius: var(--radius-sm) 0 0 var(--radius-sm);
            font-size: 14px;
            font-weight: 600;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        .phone-input-wrap .form-input {
            border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
        }

        /* ================================================================
           Toggle switch — used for ``Extraer campos``,
           ``Corregir orientación``, ``Registrar en Odoo``,
           ``Numerar documentos``, ``Incluir datos OCR``, etc.
           Designed as a single component:
             .toggle-row > .toggle (label.input + .toggle__slider)
                         + .toggle-label (text + optional .toggle-hint)
           ================================================================ */
        .toggle-row {
            display: flex;
            align-items: flex-start;     /* hint can wrap below the label */
            gap: 12px;
            padding: 10px 0;
        }
        .toggle {
            position: relative;
            width: 40px;
            height: 22px;
            flex-shrink: 0;
            margin-top: 1px;             /* baseline-align with label */
        }
        .toggle input {
            opacity: 0;
            width: 0;
            height: 0;
            position: absolute;
        }
        .toggle__slider {
            position: absolute;
            cursor: pointer;
            inset: 0;
            background: var(--toggle-track);
            border-radius: 22px;
            box-shadow: var(--toggle-track-inset);
            transition: background 180ms var(--easing-emphasized),
                        box-shadow 150ms ease;
        }
        .toggle__slider::before {
            content: '';
            position: absolute;
            height: 16px;
            width: 16px;
            left: 3px;
            bottom: 3px;
            background: var(--toggle-knob);
            border-radius: 50%;
            box-shadow: var(--toggle-knob-shadow);
            transition: transform 180ms var(--easing-emphasized),
                        box-shadow 150ms ease;
        }
        /* Hover: deeper off colour + a whisper-louder knob shadow.
           On the on state, switch to the primary-hover blue. */
        .toggle:hover .toggle__slider {
            background: var(--toggle-track-hover);
        }
        .toggle:hover .toggle__slider::before {
            box-shadow: var(--toggle-knob-shadow-hover);
        }
        .toggle input:checked + .toggle__slider {
            background: var(--primary);
            box-shadow: none;
        }
        .toggle input:checked:hover + .toggle__slider {
            background: var(--primary-hover);
        }
        /* Visible focus ring on the slider when the hidden input is
           keyboard-focused. ``:focus-visible`` keeps the ring out of
           plain mouse interactions. The compound shadow preserves
           the inset depth ring while focused. */
        .toggle input:focus-visible + .toggle__slider {
            box-shadow: var(--toggle-focus-ring), var(--toggle-track-inset);
            outline: none;
        }
        .toggle input:checked:focus-visible + .toggle__slider {
            box-shadow: var(--toggle-focus-ring);
        }
        .toggle input:checked + .toggle__slider::before {
            transform: translateX(18px);
        }
        /* Active: a tiny knob press for tactile feedback. */
        .toggle:active .toggle__slider::before {
            transform: scale(0.94);
        }
        .toggle input:checked:active + .toggle__slider::before {
            transform: translateX(18px) scale(0.94);
        }
        /* Disabled — present for future use; no consumer today. */
        .toggle input:disabled + .toggle__slider {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .toggle input:disabled + .toggle__slider::before {
            background: #F1F5F9;
        }

        /* Label + optional hint. The label is its own column inside
           .toggle-row so the hint wraps under the label without the
           old hardcoded ``margin-left: 50px`` (which broke whenever
           the toggle column changed width). */
        .toggle-label {
            display: flex;
            flex-direction: column;
            gap: 2px;
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
            cursor: pointer;
            line-height: 1.35;
            letter-spacing: -0.005em;
            user-select: none;
        }
        .toggle-hint {
            font-size: 11px;
            font-weight: 400;
            color: var(--text-secondary);
            line-height: 1.4;
            margin: 0;
        }

        /* ================================================================
           DROP ZONE
           ================================================================ */
        .drop-zone {
            border: 2px dashed var(--border);
            border-radius: var(--radius-md);
            padding: 40px 20px;
            text-align: center;
            cursor: pointer;
            transition: all var(--transition-normal);
            background: var(--bg);
        }
        .drop-zone:hover, .drop-zone.dragover {
            border-color: var(--primary);
            background: var(--primary-light);
        }
        .drop-zone:hover svg, .drop-zone.dragover svg { color: var(--primary); }
        .drop-zone svg { color: var(--text-muted); transition: color var(--transition-fast); margin-bottom: 8px; }
        .drop-zone__title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
        .drop-zone__hint { font-size: 12px; color: var(--text-muted); }
        .drop-zone input[type="file"] { display: none; }
        /* Compact pipeline layout (Diego 2026-07-13): phone + action buttons on
           one row; minimized dropzone. Scoped so the Clasificación dropzone
           keeps its full size. */
        .pipeline-form__row {
            display: flex;
            gap: 8px;
            align-items: flex-start;
            flex-wrap: wrap;
        }
        .pipeline-form__phone { flex: 0 1 300px; min-width: 220px; }
        .pipeline-form__lead { flex: 0 1 150px; min-width: 120px; }
        .drop-zone--compact { padding: 12px 16px; }
        .drop-zone--compact svg { margin: 0 6px 0 0; vertical-align: middle; }
        .drop-zone--compact .drop-zone__title { font-size: 13px; display: inline; margin: 0 6px 0 0; }
        .drop-zone--compact .drop-zone__hint { font-size: 11px; display: inline; }

        /* File list */
        .file-list { margin-top: 10px; }
        .file-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 13px;
            color: var(--text-primary);
        }
        .file-item + .file-item { margin-top: 4px; }
        .file-item svg { color: var(--text-muted); flex-shrink: 0; }
        .file-item__name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .file-item__size { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
        .file-item__remove {
            background: none; border: none; cursor: pointer; color: var(--text-muted);
            padding: 2px; border-radius: 4px; display: flex;
        }
        .file-item__remove:hover { color: var(--danger); background: var(--danger-light); }

        /* ================================================================
           ALERTS
           ================================================================ */
        .alert {
            padding: 12px 16px;
            border-radius: var(--radius-sm);
            font-size: 13px;
            margin-bottom: 16px;
            display: flex;
            align-items: flex-start;
            gap: 10px;
        }
        .alert svg { flex-shrink: 0; margin-top: 1px; }
        .alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }
        .alert-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
        .alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }

        /* ================================================================
           LOADING SPINNER
           ================================================================ */
        .loading-overlay {
            text-align: center;
            padding: 32px 20px;
        }
        .spinner {
            width: 36px; height: 36px;
            border: 3px solid var(--border);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
            margin: 0 auto 12px;
        }
        @keyframes spin { to { transform: rotate(360deg); } }
        .loading-text { font-size: 14px; color: var(--text-secondary); }
        /* Blocking overlay shown while uploading to SharePoint (#2). Below
           modals (2000) so a duplicate-warning dialog can still appear on top. */
        .sp-upload-overlay {
            position: fixed; inset: 0; z-index: 1500;
            background: rgba(15, 23, 42, 0.55);
            display: flex; align-items: center; justify-content: center;
            animation: fadeIn 0.15s ease;
        }
        .sp-upload-overlay__box {
            background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius-md); padding: 28px 32px; max-width: 380px;
            text-align: center; box-shadow: 0 12px 48px rgba(0,0,0,0.35);
        }
        .sp-upload-overlay__text { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
        .sp-upload-overlay__hint { font-size: 13px; color: var(--text-secondary); }

        /* ================================================================
           CONFIDENCE RING (SVG)
           ================================================================ */
        .confidence-ring-wrap {
            display: flex;
            align-items: center;
            gap: 24px;
            padding: 20px 0;
        }
        .confidence-ring { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
        .confidence-ring svg { transform: rotate(-90deg); }
        .confidence-ring__bg { fill: none; stroke: var(--border); stroke-width: 8; }
        .confidence-ring__fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
        .confidence-ring__text {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: 700;
            transform: none;
        }
        .confidence-ring__text.high { color: var(--success); }
        .confidence-ring__text.medium { color: var(--warning); }
        .confidence-ring__text.low { color: var(--danger); }
        .confidence-details__class { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
        .confidence-details__desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; font-style: italic; }
        .confidence-details__meta { font-size: 12px; color: var(--text-muted); }
        .confidence-details__meta span + span::before { content: ' \00B7 '; margin: 0 4px; }

        /* ================================================================
           BADGES
           ================================================================ */
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: 600;
            white-space: nowrap;
        }
        .badge-high { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
        .badge-medium { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }
        .badge-low { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }
        .badge-review {
            background: var(--danger);
            color: #fff;
            padding: 2px 10px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: 700;
            animation: pulse-review 2s infinite;
        }
        @keyframes pulse-review {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }
        .badge-source {
            background: var(--bg);
            color: var(--text-secondary);
            border: 1px solid var(--border);
            font-size: 10px;
            padding: 1px 6px;
        }

        /* ================================================================
           RESULT CARDS (batch)
           ================================================================ */
        .result-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 12px;
            margin: 16px 0;
        }
        .doc-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 16px;
            transition: box-shadow var(--transition-fast);
        }
        .doc-card:hover { box-shadow: var(--shadow-md); }
        .doc-card__header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
        }
        .doc-card__icon { color: var(--text-muted); flex-shrink: 0; }
        .doc-card__filename {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-primary);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex-grow: 1;
        }
        .doc-card__type {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            font-weight: 600;
        }
        .doc-card__class { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
        .doc-card__desc { font-size: 12px; color: var(--text-secondary); font-style: italic; margin-bottom: 6px; }
        .doc-card__error { font-size: 12px; color: var(--danger); }
        .doc-card__attachments { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
        .doc-card__att-title { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
        .doc-card__att-item {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            padding: 3px 0;
        }

        /* ================================================================
           ENTITY CARDS (Pipeline results)
           ================================================================ */
        /* Compact cards (Diego 2026-07-13: "las 3 cajitas... más pequeña"). */
        .entity-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 10px;
            margin-bottom: 12px;
        }
        .entity-card {
            padding: 10px 12px;
            border-radius: var(--radius-md);
            border: 1px solid;
        }
        .entity-card__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 3px; }
        .entity-card__value { font-size: 13.5px; font-weight: 600; margin-bottom: 1px; }
        .entity-card__meta { font-size: 11px; }

        .entity-card.contact { background: var(--primary-light); border-color: var(--primary-border); }
        .entity-card.contact .entity-card__label { color: var(--primary); }
        .entity-card.contact .entity-card__value { color: #1E40AF; }
        .entity-card.contact .entity-card__meta { color: #3B82F6; }

        .entity-card.lead { background: var(--warning-light); border-color: var(--warning-border); }
        .entity-card.lead .entity-card__label { color: var(--warning); }
        .entity-card.lead .entity-card__value { color: #92400E; }
        .entity-card.lead .entity-card__meta { color: #B45309; }
        .entity-card__crm-btn {
            display: inline-flex; align-items: center; gap: 4px;
            margin-top: 6px; padding: 3px 10px;
            font-size: 11px; font-weight: 600; color: #92400E;
            background: #FFFFFF; border: 1px solid var(--warning-border);
            border-radius: var(--radius-sm); text-decoration: none;
            cursor: pointer; transition: all var(--transition-fast);
        }
        .entity-card__crm-btn:hover { background: var(--warning); border-color: var(--warning); color: #FFFFFF; }

        .entity-card.sharepoint { background: var(--success-light); border-color: var(--success-border); }
        .entity-card.sharepoint .entity-card__label { color: var(--success); }
        .entity-card.sharepoint .entity-card__value { color: #065F46; }
        .entity-card.sharepoint .entity-card__meta { color: #059669; }

        /* Lead selector */
        .lead-selector { margin: 16px 0; }
        .lead-selector__title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 10px; }
        .lead-cards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
        .lead-card {
            padding: 12px 16px;
            border: 2px solid var(--border);
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
            min-width: 180px;
            flex: 1;
        }
        .lead-card:hover { border-color: var(--primary-border); background: var(--primary-light); }
        .lead-card.selected { border-color: var(--primary); background: var(--primary-light); }
        .lead-card__name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
        .lead-card__meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

        /* ================================================================
           PIPELINE TABLE
           ================================================================ */
        .pipeline-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
            margin-top: 16px;
        }
        .pipeline-table th {
            background: var(--bg);
            padding: 10px 12px;
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 2px solid var(--border);
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.03em;
        }
        .pipeline-table td {
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
            vertical-align: middle;
        }
        .pipeline-table tr:hover td { background: var(--bg); }
        .pipeline-table a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
        }
        .pipeline-table a:hover { text-decoration: underline; }

        /* ================================================================
           PIPELINE GROUPS (per-class upload)
           ================================================================ */
        .pipeline-group {
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            margin-bottom: 12px;
            overflow: hidden;
        }
        .pipeline-group--uploaded { border-left: 4px solid var(--success); }
        .pipeline-group--error { border-left: 4px solid var(--danger); }
        .pipeline-group__header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            background: var(--bg);
            border-bottom: 1px solid var(--border);
            gap: 12px;
        }
        /* Collapsible group cards: collapsed shows only the header. The caret
           rotates; the group-level drop target lives on the card, so dragging
           a doc onto a collapsed group still works. */
        .pipeline-group__collapse-btn {
            display: inline-flex;
            align-items: center;
            background: none;
            border: none;
            padding: 2px;
            cursor: pointer;
            color: var(--text-secondary);
            flex-shrink: 0;
        }
        .pipeline-group__collapse-btn:hover { color: var(--primary); }
        .pipeline-group__collapse-btn svg { transition: transform var(--transition-fast); }
        .pipeline-group--collapsed .pipeline-group__collapse-btn svg { transform: rotate(-90deg); }
        .pipeline-group--collapsed > *:not(.pipeline-group__header) { display: none; }
        .pipeline-group--collapsed .pipeline-group__header { border-bottom: none; }
        .pipeline-group__title {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
            flex-grow: 1;
        }
        .pipeline-group__count {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 500;
            white-space: nowrap;
        }
        .pipeline-group__doc {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 16px;
            border-bottom: 1px solid var(--border);
            font-size: 13px;
        }
        .pipeline-group__doc:last-child { border-bottom: none; }
        .pipeline-group__doc--excluded {
            opacity: 0.4;
            text-decoration: line-through;
        }

        /* Document selection checkboxes */
        .doc-checkbox {
            position: relative; width: 16px; height: 16px; flex-shrink: 0; cursor: pointer;
            -webkit-appearance: none; appearance: none; margin: 0;
            background: var(--surface); border: 1.5px solid var(--border-hover, #CBD5E1);
            border-radius: 4px; transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1); outline: none;
        }
        .doc-checkbox:hover { border-color: var(--primary); background: var(--primary-light); }
        .doc-checkbox:checked { background: var(--primary); border-color: var(--primary); }
        .doc-checkbox:checked::after {
            content: ''; position: absolute; top: 2px; left: 4.5px;
            width: 4.5px; height: 8px; border: solid #fff; border-width: 0 1.5px 1.5px 0;
            transform: rotate(45deg); animation: checkPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }
        .doc-checkbox:focus-visible { box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15); }
        .doc-checkbox:indeterminate { background: var(--primary); border-color: var(--primary); }
        .doc-checkbox:indeterminate::after {
            content: ''; position: absolute; top: 6px; left: 3px;
            width: 8px; height: 0; border-bottom: 1.5px solid #fff;
            animation: checkPopFlat 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }
        @keyframes checkPop { 0% { opacity: 0; transform: rotate(45deg) scale(0.5); } 100% { opacity: 1; transform: rotate(45deg) scale(1); } }
        @keyframes checkPopFlat { 0% { opacity: 0; transform: scaleX(0.5); } 100% { opacity: 1; transform: scaleX(1); } }
        .group-select-all {
            display: flex; align-items: center; gap: 6px; cursor: pointer;
            font-size: 11px; color: var(--text-muted); font-weight: 500;
            user-select: none; white-space: nowrap; transition: color var(--transition-fast);
        }
        .group-select-all:hover { color: var(--text-secondary); }

        /* Floating download bar */
        .batch-download-bar {
            position: sticky; bottom: 0; left: 0; right: 0; z-index: 100;
            background: var(--surface); border-top: 1px solid var(--border);
            box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06), 0 -1px 4px rgba(15, 23, 42, 0.04);
            padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
            transform: translateY(100%); opacity: 0;
            transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
            pointer-events: none; border-radius: 0 0 var(--radius-md) var(--radius-md);
        }
        .batch-download-bar.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
        .batch-download-bar__info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); min-width: 180px; }
        .batch-download-bar__count {
            display: inline-flex; align-items: center; justify-content: center;
            min-width: 22px; height: 22px; padding: 0 6px;
            background: var(--primary); color: #fff; border-radius: 11px;
            font-size: 11px; font-weight: 700; flex-shrink: 0;
        }
        .batch-download-bar__actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
        .batch-download-bar__download {
            display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px;
            background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm);
            font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
            transition: background var(--transition-fast), transform 0.1s ease; white-space: nowrap;
        }
        .batch-download-bar__download:hover { background: var(--primary-hover); }
        .batch-download-bar__download:active { transform: scale(0.97); }
        .batch-download-bar__clear {
            padding: 7px 12px; background: transparent; color: var(--text-muted);
            border: 1px solid var(--border); border-radius: var(--radius-sm);
            font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
            transition: all var(--transition-fast); white-space: nowrap;
        }
        .batch-download-bar__clear:hover { color: var(--text-secondary); border-color: var(--border-hover, #CBD5E1); background: var(--bg); }
        .batch-download-bar__clear--strong { color: var(--text-secondary); background: var(--surface); }
        .pipeline-selection-bar { margin-top: 12px; }
        .bulk-group-summary {
            padding: 8px 20px 0;
            color: var(--text-muted);
            font-size: 12px;
            font-weight: 500;
        }

        .pipeline-group__doc-name {
            flex-grow: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .pipeline-group__doc-badge {
            font-size: 10px;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: 600;
            background: var(--primary-light);
            color: var(--primary);
            white-space: nowrap;
        }
        .pipeline-group__compress-warn {
            padding: 8px 16px; border-top: 1px solid var(--border);
            background: #fff7ed; color: #9a3412; font-size: 12px;
            display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
        }
        .pipeline-group__footer {
            padding: 10px 16px;
            background: var(--bg);
            border-top: 1px solid var(--border);
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }
        .pipeline-group__sp-links {
            font-size: 12px;
            color: var(--text-secondary);
        }
        .pipeline-group__sp-links a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
        }
        .pipeline-group__sp-links a:hover { text-decoration: underline; }
        .pipeline-group__analysis {
            padding: 10px 16px 12px;
            background: var(--bg);
            border-top: 1px solid var(--border);
            font-size: 12px;
        }
        .pipeline-group__analysis .analysis-title {
            font-weight: 600; color: var(--text-secondary);
            text-transform: uppercase; letter-spacing: 0.03em; font-size: 11px; margin-bottom: 4px;
        }
        .pipeline-group__analysis .analysis-summary { color: var(--text-primary); margin-bottom: 8px; line-height: 1.45; }
        .pipeline-group__analysis .analysis-noflags { color: var(--text-muted); font-style: italic; }
        .analysis-lineas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
        .linea-roja {
            padding: 5px 8px; border-radius: 6px; line-height: 1.4;
            border-left: 3px solid var(--border); background: var(--background);
        }
        .linea-roja__sev {
            display: inline-block; text-transform: uppercase; font-size: 10px; font-weight: 700;
            letter-spacing: 0.04em; margin-right: 6px; padding: 1px 5px; border-radius: 4px;
            color: #fff; background: var(--text-muted);
        }
        .linea-roja--alta { border-left-color: var(--danger, #dc2626); background: rgba(220,38,38,0.06); }
        .linea-roja--alta .linea-roja__sev { background: var(--danger, #dc2626); }
        .linea-roja--media { border-left-color: #d97706; background: rgba(217,119,6,0.06); }
        .linea-roja--media .linea-roja__sev { background: #d97706; }
        .linea-roja--baja { border-left-color: #2563eb; background: rgba(37,99,235,0.05); }
        .linea-roja--baja .linea-roja__sev { background: #2563eb; }
        .btn-upload-group {
            font-size: 12px;
            padding: 6px 14px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--primary);
            background: var(--primary);
            color: white;
            cursor: pointer;
            font-weight: 600;
            transition: all var(--transition-fast);
            white-space: nowrap;
        }
        .btn-upload-group:hover { background: var(--primary-hover); }
        .btn-upload-group:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-upload-group--success {
            background: var(--success);
            border-color: var(--success);
        }
        .btn-upload-group--error {
            background: var(--danger);
            border-color: var(--danger);
        }
        .btn-merge-toggle {
            padding: 3px 10px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--primary);
            background: var(--primary-light);
            color: var(--primary);
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;
        }
        .btn-merge-toggle:hover { background: var(--primary); color: white; }
        .btn-merge-toggle--off {
            border-color: var(--warning-color, #f59e0b);
            background: #fef3c7;
            color: #92400e;
        }
        .btn-merge-toggle--off:hover { background: #f59e0b; color: white; }
        .btn-sm-link {
            font-size: 12px;
            background: none;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 2px 6px;
            text-decoration: underline;
        }
        .btn-sm-link:hover { color: var(--text-primary); }
        .btn-sm-danger {
            font-size: 12px;
            background: none;
            border: none;
            color: var(--danger);
            cursor: pointer;
            padding: 2px 6px;
        }
        .btn-sm-danger:hover { text-decoration: underline; }

        /* Thumbnail previews */
        .pipeline-group__doc-thumb {
            width: 72px; height: 96px;
            object-fit: cover;
            border-radius: 4px;
            border: 1px solid var(--border);
            flex-shrink: 0;
            background: linear-gradient(90deg, var(--bg) 25%, #e2e8f0 50%, var(--bg) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s ease-in-out infinite;
        }
        .pipeline-group__doc-thumb[src] { animation: none; background: var(--bg); }

        /* Two-column shell: the app and the preview are real side-by-side
           columns, so the resize divider is the gap between them and never
           overlays the content. */
        #app-shell { display: flex; align-items: flex-start; justify-content: center; }
        #app-section { flex: 1 1 auto; min-width: 0; }
        /* Preview panel — a sticky right column (stays in view while the page
           scrolls). Hidden → the app takes the full width. */
        .preview-panel {
            flex: 0 0 420px; align-self: flex-start;
            position: sticky; top: 0; height: 100vh; max-height: 100vh;
            background: var(--surface); border-left: 1px solid var(--border);
            box-shadow: -4px 0 24px rgba(0,0,0,0.10);
            display: flex; flex-direction: column;
            min-width: 280px; max-width: 80vw;
        }
        .preview-panel.hidden { display: none; }
        .preview-panel__resize {
            position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
            cursor: col-resize; z-index: 2;
        }
        .preview-panel__resize:hover, .preview-panel__resize.active {
            background: var(--primary); opacity: 0.3;
        }
        .preview-panel__header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
        .preview-panel__filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 13px; font-weight: 600; }
        .preview-panel__close { background: none; border: none; font-size: 22px; cursor: pointer; padding: 0 4px; color: var(--text-secondary); }
        .preview-panel__close:hover { color: var(--text-primary); }
        /* Continuous vertical scroll of all pages (Diego #2). Pages stack in a
           column with a gap; the body scrolls. */
        /* Stays ``center`` — the default, unzoomed look is unchanged. When a page
           is zoomed WIDER than this container, ``applyPreviewZoom`` overrides
           align-items to flex-start inline, because centring puts half the
           overflow *before* the scroll origin where scrollLeft cannot reach it,
           making the left edge of the page permanently unreadable. Neither
           ``align-items: safe center`` (parses, doesn't help) nor auto margins
           (flexbox still centres negative free space) solve it declaratively. */
        .preview-panel__body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; scrollbar-gutter: stable; overflow-anchor: none; --preview-page-w: auto; }
        .preview-panel__body--pdf { padding: 0; }
        .preview-panel__body--pdf iframe { width: 100%; height: 100%; border: none; }
        /* Needs align-items explicitly now that the base rule no longer centers. */
        .preview-panel__body--unsupported { align-items: center; justify-content: center; gap: 12px; color: var(--text-secondary); font-size: 13px; text-align: center; padding-top: 40px; }
        .preview-panel__img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; display: block; }
        .preview-panel__img--error { min-height: 120px; width: 100%; background: var(--bg); }
        /* Zoom. Driven by ONE custom property on the body, so a zoom step is a
           single style write no matter how many pages are stacked. max-width has
           to be lifted on BOTH the img and its wrap: the text overlay is
           ``inset: 0`` inside the wrap, so a wrap still clamped to 100% around a
           widened image would misplace every span. */
        .preview-panel__body--zoomed .preview-panel__img { width: var(--preview-page-w); max-width: none; }
        .preview-panel__body--zoomed .preview-page { max-width: none; }
        .preview-panel__toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 16px; border-bottom: 1px solid var(--border); }
        .preview-panel__zoom-btn { padding: 4px 8px; line-height: 1; display: inline-flex; }
        .preview-panel__zoom-level { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; }
        .preview-panel__toolbar-hint { margin-left: auto; font-size: 11px; color: var(--text-secondary); }
        /* One page in the scroll stack: shrink-wraps its img so the transparent
           selectable-text layer aligns exactly over it. */
        .preview-page { position: relative; display: inline-block; max-width: 100%; }
        .preview-textlayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; }
        .preview-textlayer span {
            position: absolute; color: transparent; white-space: pre; cursor: text;
            transform-origin: 0 0; user-select: text; -webkit-user-select: text;
        }
        .preview-textlayer span::selection { background: rgba(37, 99, 235, 0.35); }
        .preview-textlayer span::-moz-selection { background: rgba(37, 99, 235, 0.35); }
        .preview-panel__source-badge {
            font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
            background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-border);
            margin-left: 8px; flex-shrink: 0;
        }
        .preview-panel__nav { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-top: 1px solid var(--border); }
        .preview-panel__counter { font-size: 12px; color: var(--text-secondary); }
        .preview-panel__nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
        /* Loading overlay: kept ON TOP of the previous image so the
           user always sees something while the next page downloads.
           Wiping the body innerHTML on every Pág → click was the
           single biggest cause of the "broken button" perception. */
        .preview-panel__body { position: relative; }
        .preview-panel__body--loading .preview-panel__img { opacity: 0.55; transition: opacity 0.15s ease; }
        .preview-panel__spinner {
            position: absolute; top: 50%; left: 50%;
            width: 36px; height: 36px;
            margin: -18px 0 0 -18px;
            border: 3px solid var(--border);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: preview-spin 0.8s linear infinite;
            pointer-events: none;
            z-index: 2;
        }
        @keyframes preview-spin { to { transform: rotate(360deg); } }
        /* Inline error banner — page-nav stays visible underneath so
           the user can retry via the buttons themselves OR the inline
           "Reintentar" button. Never hide the nav on failure. */
        .preview-panel__error {
            position: absolute; left: 16px; right: 16px; top: 16px;
            display: flex; align-items: center; gap: 12px;
            padding: 10px 14px;
            background: var(--danger-light, #fef2f2);
            color: var(--danger, #b91c1c);
            border: 1px solid var(--danger-border, #fecaca);
            border-radius: 6px;
            font-size: 13px;
            z-index: 3;
        }
        .preview-panel__error-text { flex: 1; }
        .preview-panel__retry { flex-shrink: 0; }
        /* Narrow screens: stack the preview under the content instead of a
           side column, and drop the drag handle. */
        @media (max-width: 900px) {
            #app-shell { flex-direction: column; }
            .preview-panel {
                position: static; height: auto; max-height: 70vh;
                flex-basis: auto; width: 100%; min-width: 0; max-width: 100%;
                border-left: none; border-top: 1px solid var(--border);
            }
            .preview-panel__resize { display: none; }
        }

        /* Add/delete group buttons */
        .btn-add-group {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 10px 20px; margin-top: 12px;
            background: var(--primary-light); border: 2px dashed var(--primary-border);
            border-radius: var(--radius-md); cursor: pointer;
            font-size: 14px; font-weight: 600; color: var(--primary);
            transition: all var(--transition-fast);
        }
        .btn-add-group:hover { background: var(--primary); color: white; border-color: var(--primary); border-style: solid; }
        .btn-delete-group {
            background: none; border: none; font-size: 16px; cursor: pointer;
            color: var(--text-muted); padding: 2px 6px; line-height: 1;
        }
        .btn-delete-group:hover { color: var(--danger); }
        .unassigned-section {
            margin-top: 8px; padding: 12px; background: var(--warning-light);
            border: 1px solid var(--warning-border); border-radius: var(--radius-sm);
        }
        .unassigned-section__title { font-size: 13px; font-weight: 600; color: var(--warning); margin-bottom: 8px; }
        .unassigned-doc { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
        .unassigned-doc select { font-size: 12px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 3px; }

        /* Editable group title */
        .pipeline-group__title--editable { cursor: pointer; }
        .pipeline-group__title--editable:hover { text-decoration: underline dashed var(--text-muted); text-underline-offset: 3px; }
        .pipeline-group__title-input {
            font-size: 14px; font-weight: 600; padding: 2px 8px;
            border: 1px solid var(--primary); border-radius: 3px;
            outline: none; flex: 1; min-width: 200px;
        }

        /* Inline rename */
        .pipeline-group__doc-name--editable { cursor: pointer; }
        .pipeline-group__doc-name--editable:hover { text-decoration: underline dashed var(--text-muted); text-underline-offset: 3px; }
        .rename-input {
            font-size: 13px;
            padding: 2px 6px;
            border: 1px solid var(--primary);
            border-radius: 3px;
            outline: none;
            flex-grow: 1;
            min-width: 120px;
            font-family: var(--font-stack);
        }

        .sp-folder-link {
            color: var(--primary);
            text-decoration: none;
            font-weight: 600;
        }
        .sp-folder-link:hover { text-decoration: underline; }

        /* Drag handle */
        .drag-handle {
            cursor: grab;
            color: var(--text-muted);
            flex-shrink: 0;
            padding: 0 2px;
            user-select: none;
        }
        .drag-handle:active { cursor: grabbing; }
        .pipeline-group__doc.dragging {
            opacity: 0.4;
            background: var(--primary-light);
        }
        .pipeline-group__doc.drag-over {
            border-top: 2px solid var(--primary);
        }
        .pipeline-group--drag-target {
            border-color: var(--primary);
            background: var(--primary-light);
        }

        /* SharePoint browser panel */
        .sp-browser { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
        .sp-browser__toggle {
            width: 100%; padding: 10px 16px; border: none; background: none; cursor: pointer;
            display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
            color: var(--text-secondary); transition: background var(--transition-fast);
        }
        .sp-browser__toggle:hover { background: var(--background); }
        .sp-browser__toggle svg { transition: transform var(--transition-fast); }
        .sp-browser__toggle.open svg { transform: rotate(90deg); }
        .sp-browser__body { display: none; border-top: 1px solid var(--border); }
        .sp-browser__body.open { display: block; }
        .sp-browser__toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
        .sp-browser__tabs { display: flex; gap: 0; }
        .sp-browser__tab {
            padding: 6px 14px; font-size: 12px; font-weight: 600; border: 1px solid var(--border);
            background: var(--background); color: var(--text-secondary); cursor: pointer;
            transition: all var(--transition-fast);
        }
        .sp-browser__tab:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
        .sp-browser__tab:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
        .sp-browser__tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
        .sp-browser__refresh {
            margin-left: auto; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
            background: var(--surface); cursor: pointer; color: var(--text-secondary); font-size: 12px;
            display: flex; align-items: center; gap: 4px; transition: background var(--transition-fast);
        }
        .sp-browser__refresh:hover { background: var(--background); }
        .sp-browser__table { width: 100%; border-collapse: collapse; font-size: 12px; }
        .sp-browser__table th { text-align: left; padding: 6px 16px; font-weight: 600; color: var(--text-secondary); background: var(--background); border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
        .sp-browser__table th.sp-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
        .sp-browser__table th.sp-sortable:hover { color: var(--primary); }
        .sp-browser__table td { padding: 6px 16px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
        .sp-browser__table tr:last-child td { border-bottom: none; }
        .sp-browser__table a { color: var(--primary); text-decoration: none; }
        .sp-browser__table a:hover { text-decoration: underline; }
        /* Compact per-row action icons (replaced the wrapping text buttons). */
        .sp-icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 26px;
            height: 26px;
            padding: 0;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            cursor: pointer;
            vertical-align: middle;
            transition: all var(--transition-fast);
        }
        .sp-icon-btn:hover { color: var(--primary); border-color: var(--primary-border); background: var(--primary-light); }
        .sp-icon-btn:disabled { opacity: 0.5; cursor: default; }
        .sp-icon-btn--danger:hover { color: var(--danger); border-color: var(--danger-border, #fecaca); background: var(--danger-light, #fef2f2); }
        /* Long-filename guard: the name truncates with an ellipsis (full name
           in the title tooltip) instead of wrapping and inflating the row. */
        .sp-browser__file-name {
            display: inline-block;
            max-width: 340px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: middle;
        }
        .sp-browser__table tr { cursor: pointer; transition: background var(--transition-fast); }
        .sp-browser__table tr:hover { background: var(--background); }
        .sp-browser__table tr.active { background: var(--primary-light); }
        .sp-browser__bulkbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--background); flex-wrap: wrap; }
        .sp-browser__bulkhint { font-size: 11px; color: var(--text-muted); }
        .sp-browser__filter { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
        .sp-browser__filter-input { flex: 1; max-width: 320px; padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); }
        .sp-browser__label-filter { padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); }
        .sp-browser__filter-count { font-size: 11px; color: var(--text-muted); }
        /* Trámite labels: chips on the right of each file row + assign popover */
        .sp-label-cell { white-space: nowrap; }
        .sp-label-chip { display: inline-flex; align-items: center; padding: 1px 8px; margin-right: 4px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; font-weight: 600; line-height: 1.5; }
        .sp-label-btn { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 4px; opacity: 0.55; vertical-align: middle; }
        .sp-label-btn:hover { opacity: 1; }
        .sp-label-popover { position: absolute; z-index: 2100; display: flex; flex-direction: column; gap: 6px; max-width: 240px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.18)); }
        .sp-label-popover__title { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
        .sp-label-popover__empty { font-size: 12px; color: var(--text-muted); }
        .sp-label-popover__chips { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
        .sp-label-popover__create { display: flex; gap: 6px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
        .sp-label-popover__input { flex: 1; padding: 4px 8px; font-size: 12px; }
        .sp-label-chip--toggle { cursor: pointer; background: transparent; text-align: left; }
        .sp-label-chip--toggle.is-on { font-weight: 700; }
        .sp-label-popover__row { display: flex; align-items: center; gap: 4px; }
        .sp-label-popover__row .sp-label-chip--toggle { flex: 1 1 auto; margin-right: 0; }
        .sp-label-popover__del { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; padding: 2px 4px; background: none; border: none; border-radius: 4px; cursor: pointer; color: var(--text-muted); opacity: 0.5; }
        .sp-label-popover__del:hover { opacity: 1; color: var(--danger, #dc2626); background: var(--danger-bg, rgba(220,38,38,0.08)); }
        /* Results (Pipeline / Clasificación) document filter box */
        .docs-filter { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
        .docs-filter__input { max-width: 360px; }
        .docs-filter__count { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
        .idealista-import__row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
        .idealista-import__row .form-input { flex: 1; }
        .idealista-import__phone { font-size: 13px; color: var(--text-primary); font-weight: 600; margin-top: 6px; }
        .idealista-import__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
        .idealista-inbox { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
        .idealista-inbox__empty { font-size: 13px; color: var(--text-secondary); padding: 8px 0; }
        .idealista-inbox__item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
            padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-subtle, #fafafa); }
        .idealista-inbox__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
        .idealista-inbox__ref { font-weight: 600; font-size: 14px; color: var(--text-primary); }
        .idealista-inbox__meta { font-size: 12px; color: var(--text-secondary); }
        .idealista-inbox__actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
        .idealista-inbox__discard { color: var(--text-secondary); background: transparent; border: 1px solid var(--border); }
        .idealista-inbox__discard:hover:not(:disabled) { color: #c0392b; border-color: #c0392b; }
        .sp-select { display: inline-flex; align-items: center; vertical-align: middle; margin-right: 6px; cursor: pointer; }
        .sp-select input { cursor: pointer; }
        .sp-browser__empty { padding: 20px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
        .sp-browser__loading { padding: 20px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
        .sp-browser__file-icon { display: inline-flex; margin-right: 6px; color: var(--text-muted); }
        .sp-add-to-pipeline-btn { padding: 3px 8px !important; font-size: 11px !important; gap: 4px !important; white-space: nowrap; }
        .sp-browser__preview { border-top: 1px solid var(--border); background: var(--background); }
        .sp-browser__preview-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 8px 16px; border-bottom: 1px solid var(--border);
        }
        .sp-browser__preview-header span { font-size: 12px; font-weight: 600; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .sp-browser__preview-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-secondary); padding: 0 4px; }
        .sp-browser__preview-close:hover { color: var(--text-primary); }
        .sp-browser__preview-body { display: flex; align-items: center; justify-content: center; min-height: 200px; max-height: 50vh; overflow: auto; padding: 8px; }
        .sp-browser__preview-body iframe { width: 100%; height: 50vh; border: none; border-radius: 4px; }
        .sp-browser__preview-body img { max-width: 100%; max-height: 50vh; border: 1px solid var(--border); border-radius: 4px; }
        .sp-browser__preview-loading { color: var(--text-muted); font-size: 13px; }

        /* SharePoint folder selector */
        .sp-folder-count-badge {
            font-size: 11px; font-weight: 500; color: var(--primary);
            background: var(--primary-light); padding: 2px 8px; border-radius: 10px;
            margin-left: 6px;
        }
        .sp-folder-reused-badge {
            font-size: 11px; font-weight: 600; color: var(--success);
            background: var(--success-light); border: 1px solid var(--success-border);
            padding: 2px 8px; border-radius: 10px; margin-left: 8px; white-space: nowrap;
        }
        .sp-folder-change-btn {
            background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
            padding: 2px 10px; font-size: 11px; color: var(--primary); cursor: pointer;
            margin-left: 8px; transition: all var(--transition-fast);
        }
        .sp-folder-change-btn:hover { background: var(--primary-light); border-color: var(--primary); }
        .sp-folder-open-btn {
            display: inline-block; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
            padding: 2px 10px; font-size: 11px; color: var(--primary); cursor: pointer; text-decoration: none;
            margin-left: 8px; transition: all var(--transition-fast);
        }
        .sp-folder-open-btn:hover { background: var(--primary-light); border-color: var(--primary); text-decoration: none; }
        .sp-folder-selector {
            margin: 8px 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
            background: var(--surface); overflow: hidden;
        }
        .sp-folder-selector__header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
        .sp-folder-selector__search {
            width: 100%; padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
            font-size: 13px; background: var(--background); color: var(--text-primary);
            outline: none; transition: border-color var(--transition-fast);
        }
        .sp-folder-selector__search:focus { border-color: var(--primary); }
        .sp-folder-selector__results { max-height: 320px; overflow-y: auto; }
        .sp-folder-item {
            border-bottom: 1px solid var(--border); transition: background var(--transition-fast);
        }
        .sp-folder-item:last-child { border-bottom: none; }
        .sp-folder-item--active { background: var(--primary-light); }
        .sp-folder-item__header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 8px 14px; gap: 8px;
        }
        .sp-folder-item__info {
            display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer;
            min-width: 0;
        }
        .sp-folder-item__info:hover { color: var(--primary); }
        .sp-folder-item__name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .sp-folder-item__meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
        .sp-folder-item__select-btn {
            padding: 4px 12px; border: 1px solid var(--primary); border-radius: var(--radius-sm);
            background: none; color: var(--primary); font-size: 11px; font-weight: 600;
            cursor: pointer; white-space: nowrap; transition: all var(--transition-fast);
        }
        .sp-folder-item__select-btn:hover:not(:disabled) { background: var(--primary); color: #fff; }
        .sp-folder-item__select-btn--active {
            background: var(--success); color: #fff; border-color: var(--success); cursor: default;
        }
        .sp-folder-item__preview { padding: 0 14px 10px; }
        .sp-folder-item__preview-tabs { display: flex; gap: 0; margin-bottom: 8px; }
        .sp-folder-item__preview-content { max-height: 200px; overflow-y: auto; }

        /* Duplicate warning modal */
        .dup-modal {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.4); display: flex; align-items: center;
            /* Above the upload overlay (1500): an interactive confirmation must
               always stay clickable, never be covered by the passive overlay. */
            justify-content: center; z-index: 1600;
        }
        .dup-modal__content {
            background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
            width: 100%; max-width: 520px; overflow: hidden;
        }
        .dup-modal__header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
        .dup-modal__header h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 0; }
        .dup-modal__body { padding: 16px 20px; }
        .dup-modal__warning { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
        .dup-modal__table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 16px; }
        .dup-modal__table th { text-align: left; padding: 6px 8px; font-weight: 600; color: var(--text-secondary); background: var(--background); border-bottom: 1px solid var(--border); }
        .dup-modal__table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
        .dup-modal__actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); }
        .btn-danger { background: var(--danger); color: #fff; border: none; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; }
        .btn-danger:hover { opacity: 0.9; }

        /* ================================================================
           RE-AUTH MODAL
           ================================================================ */
        .reauth-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(15,23,42,0.55); backdrop-filter: blur(4px);
            display: flex; align-items: center; justify-content: center;
            z-index: 2000; animation: fadeIn 0.2s ease;
        }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        .reauth-card {
            background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
            width: 100%; max-width: 400px; overflow: hidden; animation: slideUp 0.3s ease;
        }
        @keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
        .reauth-header {
            padding: 20px 24px 16px; display: flex; align-items: center; gap: 12px;
            border-bottom: 1px solid var(--border);
        }
        .reauth-header__icon {
            width: 40px; height: 40px; border-radius: 10px; display: flex;
            align-items: center; justify-content: center;
            background: var(--warning-light); border: 1px solid var(--warning-border);
        }
        .reauth-header__text h3 { font-size: 16px; font-weight: 600; margin: 0; }
        .reauth-header__text p { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
        .reauth-body { padding: 20px 24px; }
        .reauth-body .form-group { margin-bottom: 14px; }
        .reauth-body .form-group:last-of-type { margin-bottom: 0; }
        .reauth-body label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-secondary); }
        .reauth-body input {
            width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--border);
            border-radius: var(--radius-sm); font-family: var(--font-stack);
            transition: border-color var(--transition-fast);
        }
        .reauth-body input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }
        .reauth-error { font-size: 13px; color: var(--danger); margin-bottom: 12px; display: none; }
        .reauth-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
        .reauth-footer__logout { font-size: 13px; color: var(--text-muted); cursor: pointer; background: none; border: none; text-decoration: underline; }
        .reauth-footer__logout:hover { color: var(--danger); }

        /* ================================================================
           PROGRESS TRACKER
           ================================================================ */
        .progress-tracker {
            background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
            overflow: hidden; margin: 16px 0; animation: slideUp 0.3s ease-out;
        }
        .progress-tracker__header {
            padding: 20px 24px 16px; border-bottom: 1px solid var(--border); background: var(--bg);
        }
        .progress-tracker__title-row {
            display: flex; align-items: center; justify-content: space-between;
            margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
        }
        .progress-tracker__title {
            font-size: 15px; font-weight: 600; color: var(--text-primary);
            display: flex; align-items: center; gap: 8px;
        }
        .progress-tracker__title .spinner-sm {
            width: 18px; height: 18px; border: 2.5px solid var(--border);
            border-top-color: var(--primary); border-radius: 50%;
            animation: spin 0.8s linear infinite; flex-shrink: 0;
        }
        .progress-tracker__stage-badge {
            font-size: 10px; font-weight: 600; padding: 2px 10px; border-radius: 10px;
            background: var(--primary-light); color: var(--primary);
            border: 1px solid var(--primary-border);
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .progress-tracker__stage-badge--done {
            background: var(--success-light); color: var(--success); border-color: var(--success-border);
        }
        .progress-tracker__meta {
            display: flex; align-items: center; gap: 16px;
            font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono);
        }
        .progress-tracker__meta-item { display: inline-flex; align-items: center; gap: 4px; }
        .progress-tracker__meta-value { font-weight: 500; color: var(--text-primary); }

        /* Progress bar */
        .progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 10px; }
        .progress-bar__fill {
            height: 100%; background: var(--primary); border-radius: 3px;
            transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .progress-bar__fill--complete { background: var(--success); }
        .progress-bar__fill--error { background: var(--danger); }
        .progress-bar__fill--indeterminate {
            width: 30% !important;
            animation: indeterminate 1.6s ease-in-out infinite;
        }
        @keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(430%); } }
        .progress-bar__text {
            display: flex; justify-content: space-between;
            font-size: 12px; color: var(--text-muted); margin-top: 6px;
        }

        /* Stats row */
        .progress-tracker__stats {
            display: grid; grid-template-columns: repeat(4, 1fr);
            gap: 1px; background: var(--border); border-bottom: 1px solid var(--border);
        }
        .progress-stat { padding: 12px 16px; background: var(--surface); text-align: center; }
        .progress-stat__value {
            font-size: 17px; font-weight: 700; font-family: var(--font-mono);
            color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.2;
        }
        .progress-stat__label {
            font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
            color: var(--text-muted); font-weight: 600; margin-top: 2px;
        }
        .progress-timing {
            display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 1px; background: var(--border); border-bottom: 1px solid var(--border);
        }
        .progress-timing__item {
            display: flex; align-items: center; justify-content: space-between;
            gap: 8px; padding: 8px 14px; background: var(--surface);
            min-width: 0; border-left: 3px solid transparent;
        }
        .progress-timing__item--active {
            background: var(--primary-light); border-left-color: var(--primary);
        }
        .progress-timing__item--done {
            background: var(--bg);
        }
        .progress-timing__label {
            font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
            color: var(--text-muted); font-weight: 700; white-space: nowrap;
        }
        .progress-timing__value {
            font-size: 12px; font-family: var(--font-mono); font-weight: 700;
            color: var(--text-primary); white-space: nowrap;
        }

        /* Summary bar */
        .progress-tracker__summary {
            padding: 12px 24px; display: flex; align-items: center; gap: 12px;
            cursor: pointer; transition: background var(--transition-fast);
            border-bottom: 1px solid var(--border);
        }
        .progress-tracker__summary:hover { background: var(--bg); }
        .progress-tracker__summary-current {
            flex: 1; font-size: 13px; color: var(--text-secondary);
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .progress-tracker__summary-current strong { color: var(--text-primary); font-weight: 600; }
        .progress-tracker__expand-btn {
            font-size: 12px; color: var(--primary); font-weight: 500;
            background: none; border: none; cursor: pointer; padding: 4px 8px;
            border-radius: var(--radius-sm); transition: background var(--transition-fast);
            white-space: nowrap;
        }
        .progress-tracker__expand-btn:hover { background: var(--primary-light); }

        /* Document queue */
        .progress-tracker__queue {
            max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
        }
        .progress-tracker.expanded .progress-tracker__queue {
            max-height: 600px; overflow-y: auto;
        }
        .progress-queue__item {
            display: flex; align-items: center; gap: 10px;
            padding: 7px 24px; border-bottom: 1px solid var(--border);
            font-size: 13px; transition: background 0.2s ease;
        }
        .progress-queue__item:last-child { border-bottom: none; }
        .progress-queue__item--pending { color: var(--text-muted); }
        .progress-queue__item--active {
            background: var(--primary-light); border-left: 3px solid var(--primary); padding-left: 21px;
        }
        .progress-queue__item--complete { color: var(--text-secondary); }
        .progress-queue__item--error {
            background: var(--danger-light); border-left: 3px solid var(--danger); padding-left: 21px;
        }
        @keyframes completeFlash { 0% { background: var(--success-light); } 100% { background: transparent; } }
        .progress-queue__item--just-done { animation: completeFlash 0.8s ease-out; }
        .progress-queue__icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
        .progress-queue__icon .spinner-xs {
            width: 14px; height: 14px; border: 2px solid var(--primary-border);
            border-top-color: var(--primary); border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }
        @keyframes checkDraw { 0% { stroke-dashoffset: 24; } 100% { stroke-dashoffset: 0; } }
        .progress-queue__check {
            stroke: var(--success); stroke-width: 2.5; fill: none;
            stroke-dasharray: 24; stroke-dashoffset: 24;
            animation: checkDraw 0.35s ease-out 0.1s forwards;
        }
        .progress-queue__filename {
            flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
            font-weight: 500; color: inherit;
        }
        .progress-queue__page-info {
            font-family: var(--font-mono); font-size: 11px; color: var(--primary);
            font-weight: 500; white-space: nowrap;
        }
        .progress-queue__result {
            font-size: 11px; color: var(--success); font-weight: 600;
            white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
        }
        .progress-queue__minibar {
            width: 50px; height: 3px; background: var(--border);
            border-radius: 2px; overflow: hidden; flex-shrink: 0;
        }
        .progress-queue__minibar-fill {
            height: 100%; background: var(--primary); border-radius: 2px;
            transition: width 0.3s ease;
        }

        /* Completion state */
        @keyframes trackerDone {
            0% { border-color: var(--border); }
            50% { border-color: var(--success); box-shadow: 0 0 0 3px rgba(5,150,105,0.12); }
            100% { border-color: var(--success-border); box-shadow: none; }
        }
        .progress-tracker--complete { animation: trackerDone 0.6s ease-out; border-color: var(--success-border); }
        .progress-tracker--complete .progress-tracker__header { background: var(--success-light); }

        @media (max-width: 640px) {
            .progress-tracker__header { padding: 16px; }
            .progress-tracker__meta { flex-wrap: wrap; gap: 8px; }
            .progress-tracker__stats { grid-template-columns: repeat(2, 1fr); }
            .progress-timing { grid-template-columns: repeat(2, 1fr); }
            .progress-timing__item { padding: 8px 12px; }
            .progress-tracker__summary { padding: 10px 16px; }
            .progress-queue__item { padding: 7px 16px; }
            .progress-queue__result { display: none; }
            .progress-queue__minibar { display: none; }
        }

        /* Relabel modal */
        .relabel-modal {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }
        .relabel-modal__content {
            background: var(--surface);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            width: 100%;
            max-width: 480px;
            max-height: 70vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .relabel-modal__header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .relabel-modal__header h3 { font-size: 16px; font-weight: 600; }
        .relabel-modal__search {
            padding: 12px 20px;
            border-bottom: 1px solid var(--border);
        }
        .relabel-modal__search input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 13px;
            outline: none;
        }
        .relabel-modal__search input:focus { border-color: var(--primary); }
        .relabel-modal__list {
            overflow-y: auto;
            flex: 1;
            padding: 8px 0;
        }
        .relabel-modal__item {
            padding: 10px 20px;
            cursor: pointer;
            font-size: 13px;
            transition: background var(--transition-fast);
            display: flex;
            align-items: flex-start;
            gap: 8px;
        }
        .relabel-modal__item:hover { background: var(--primary-light); }
        .relabel-modal__item-id {
            font-weight: 600;
            color: var(--text-secondary);
            min-width: 36px;
        }
        .client-row__main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
        .client-row__top {
            display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
            min-width: 0;
        }
        .client-source-badge {
            display: inline-flex; align-items: center;
            padding: 2px 7px; border-radius: 999px;
            font-size: 10.5px; font-weight: 700; line-height: 1.25;
            border: 1px solid var(--border);
            color: var(--text-secondary); background: var(--surface);
            white-space: nowrap;
        }
        .client-source-badge--odoo {
            color: #075985; background: #e0f2fe; border-color: #7dd3fc;
        }
        .client-source-badge--detected {
            color: #166534; background: #dcfce7; border-color: #86efac;
        }
        .client-source-badge--both {
            color: #4338ca; background: #e0e7ff; border-color: #a5b4fc;
        }

        /* DNI/NIE/Passport identifier stack — primary on top, alts indented
           beneath. Type label is muted; the number itself is monospace
           so digits line up; the validity badge sits inline. */
        .client-id-line {
            display: inline-flex; align-items: center; gap: 5px;
            font-size: 12px; line-height: 1.4;
        }
        .client-id-line--primary { color: var(--text-secondary); }
        .client-id-line--alt {
            color: var(--text-muted);
            font-size: 11px;
            padding-left: 4px;
        }
        .client-id-type {
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.02em;
            font-size: 10.5px;
            color: var(--text-muted);
        }
        .client-id-value {
            font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
            letter-spacing: 0.02em;
        }
        .id-badge { flex: 0 0 auto; vertical-align: -1px; }
        .id-badge--ok { color: #16a34a; }
        .id-badge--bad { color: #dc2626; }
        .fields-id-extra {
            display: inline-flex; align-items: center; gap: 5px;
            margin-left: 8px; vertical-align: middle;
        }

        /* Group choice modal — overlays relabel modal during reclassification */
        .group-choice-modal {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1001;
            animation: modalFadeIn 0.18s ease-out;
            padding: 16px;
        }
        .group-choice-modal__content {
            background: var(--surface);
            border-radius: var(--radius-lg);
            box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.06), 0 16px 40px rgba(0,0,0,0.1);
            width: 100%;
            max-width: 420px;
            overflow: hidden;
            animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }
        .group-choice-modal__header {
            padding: 18px 20px 14px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .group-choice-modal__header h3 {
            font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -0.01em;
        }
        .group-choice-modal__body { padding: 0 20px 4px; }
        .group-choice-modal__hint {
            font-size: 13px; color: var(--text-secondary); margin: 0 0 14px; line-height: 1.55;
        }
        .group-choice-modal__hint strong { color: var(--text-primary); font-weight: 600; }
        .group-choice-modal__options { display: flex; flex-direction: column; gap: 6px; }
        .group-choice-modal__option {
            position: relative; display: flex; align-items: center; justify-content: space-between;
            gap: 12px; padding: 11px 14px; background: var(--bg); border: 1.5px solid var(--border);
            border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition-fast);
            text-align: left; font-family: inherit; font-size: 13px; line-height: 1.4; outline: none;
        }
        .group-choice-modal__option:hover {
            border-color: var(--primary-border); background: var(--primary-light);
            box-shadow: 0 1px 4px rgba(30, 64, 175, 0.08);
        }
        .group-choice-modal__option:focus-visible {
            border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
        }
        .group-choice-modal__option:active { transform: scale(0.985); }
        .group-choice-modal__option-icon {
            display: flex; align-items: center; justify-content: center;
            width: 28px; height: 28px; border-radius: 6px;
            background: var(--primary-light); border: 1px solid var(--primary-border);
            flex-shrink: 0; color: var(--primary);
        }
        .group-choice-modal__option:hover .group-choice-modal__option-icon { background: var(--primary-50); }
        .group-choice-modal__option-body { flex: 1; min-width: 0; }
        .group-choice-modal__option-name {
            font-weight: 600; color: var(--text-primary); display: block;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .group-choice-modal__option-count {
            font-size: 11.5px; color: var(--text-muted); font-weight: 400; white-space: nowrap; flex-shrink: 0;
        }
        .group-choice-modal__option--create {
            background: transparent; border-style: dashed; border-color: var(--primary-border); margin-top: 2px;
        }
        .group-choice-modal__option--create:hover {
            background: var(--primary-light); border-style: dashed; border-color: var(--primary);
        }
        .group-choice-modal__option--create .group-choice-modal__option-icon {
            background: transparent; border: 1.5px dashed var(--primary-border);
        }
        .group-choice-modal__option--create:hover .group-choice-modal__option-icon {
            border-color: var(--primary); background: var(--primary-light);
        }
        .group-choice-modal__option--create .group-choice-modal__option-name { color: var(--primary); }
        .group-choice-modal__actions {
            display: flex; justify-content: flex-end; padding: 14px 20px; margin-top: 8px;
            border-top: 1px solid var(--border);
        }

        /* ================================================================
           LOGIN
           ================================================================ */
        .login-wrap {
            min-height: 80vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 50%, #ECFDF5 100%);
        }
        .login-card {
            width: 100%;
            max-width: 420px;
            padding: 40px 36px;
            border-top: 3px solid var(--primary);
            box-shadow: var(--shadow-lg);
        }
        .login-tabs {
            display: flex;
            gap: 0;
            margin-bottom: 20px;
            border-bottom: 2px solid var(--border);
        }
        .login-tab-btn {
            flex: 1;
            padding: 10px;
            font-size: 13px;
            font-weight: 500;
            color: var(--text-secondary);
            background: none;
            border: none;
            border-bottom: 2px solid transparent;
            margin-bottom: -2px;
            cursor: pointer;
            transition: all var(--transition-fast);
        }
        .login-tab-btn:hover { color: var(--text-primary); }
        .login-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
        .login-tab-content { display: none; }
        .login-tab-content.active { display: block; }
        .login-card__title {
            font-size: 26px;
            font-weight: 700;
            text-align: center;
            margin-bottom: 4px;
            letter-spacing: -0.03em;
        }
        .login-card__subtitle {
            font-size: 14px;
            color: var(--text-secondary);
            text-align: center;
            margin-bottom: 28px;
        }

        /* ================================================================
           ACCORDION (Ayuda tab)
           ================================================================ */
        .accordion { margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
        .accordion + .accordion { margin-top: 0; }
        .accordion__header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 14px 16px;
            cursor: pointer;
            user-select: none;
            background: var(--surface);
            transition: background var(--transition-fast);
            font-weight: 600;
            font-size: 14px;
            color: var(--text-primary);
        }
        .accordion__header:hover { background: var(--bg); }
        .accordion__arrow {
            margin-left: auto;
            transition: transform var(--transition-fast);
            color: var(--text-muted);
        }
        .accordion.open .accordion__arrow { transform: rotate(180deg); }
        .accordion__body {
            max-height: 0;
            overflow: hidden;
            transition: max-height 300ms ease;
        }
        .accordion.open .accordion__body { max-height: 5000px; }
        .accordion__content {
            padding: 0 16px 16px;
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.7;
        }
        .accordion__content h4 { color: var(--text-primary); margin: 12px 0 6px; font-size: 13px; }
        .accordion__content p { margin-bottom: 8px; }
        .accordion__content ul { margin: 6px 0 12px 20px; }
        .accordion__content li { margin-bottom: 4px; }
        .accordion__content code {
            background: var(--bg);
            padding: 1px 5px;
            border-radius: 3px;
            font-size: 12px;
            border: 1px solid var(--border);
            font-family: var(--font-mono);
        }
        .accordion__content .code-block {
            background: #1E293B;
            color: #E2E8F0;
            padding: 14px 16px;
            border-radius: var(--radius-sm);
            overflow-x: auto;
            font-size: 12px;
            font-family: var(--font-mono);
            line-height: 1.6;
            margin: 8px 0 12px;
        }

        /* Classes search in help tab */
        .classes-search {
            margin-bottom: 12px;
        }
        .classes-search input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            font-size: 13px;
            font-family: var(--font-stack);
        }
        .classes-search input:focus {
            outline: none;
            border-color: var(--primary);
        }
        .classes-list {
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
        }
        .classes-item {
            display: flex;
            gap: 12px;
            padding: 8px 12px;
            font-size: 13px;
            border-bottom: 1px solid var(--border);
        }
        .classes-item:last-child { border-bottom: none; }
        .classes-item__id { font-weight: 600; color: var(--primary); min-width: 50px; font-family: monospace; }
        .classes-item__desc { color: var(--text-secondary); }

        /* ================================================================
           JSON COLLAPSIBLE
           ================================================================ */
        .json-collapsible summary {
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            color: var(--text-secondary);
            padding: 8px 0;
            user-select: none;
        }
        .json-collapsible summary:hover { color: var(--text-primary); }
        .json-collapsible pre {
            background: #1E293B;
            color: #E2E8F0;
            padding: 16px;
            border-radius: var(--radius-sm);
            overflow-x: auto;
            font-size: 12px;
            line-height: 1.5;
            max-height: 400px;
            font-family: var(--font-mono);
        }

        /* ================================================================
           UTILITY
           ================================================================ */
        .mt-4 { margin-top: 16px; }
        .mt-3 { margin-top: 12px; }
        .mb-4 { margin-bottom: 16px; }
        .mb-3 { margin-bottom: 12px; }
        .text-center { text-align: center; }
        .flex-between { display: flex; justify-content: space-between; align-items: center; }
        .section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
        .divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

        /* ================================================================
           SKELETON LOADING
           ================================================================ */
        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }
        .skeleton {
            background: linear-gradient(90deg, var(--bg) 25%, #e2e8f0 50%, var(--bg) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s ease-in-out infinite;
            border-radius: var(--radius-sm);
        }

        /* ================================================================
           ANIMATIONS
           ================================================================ */
        @keyframes slideUp {
            from { opacity: 0; transform: translateY(12px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .card--animate { animation: slideUp 0.3s ease-out; }
        .pipeline-group { transition: border-color 0.3s ease, box-shadow 0.3s ease; }

        /* Upload progress bar on group bottom */
        @keyframes uploadPulse {
            0% { background-position: 0% 50%; }
            100% { background-position: 100% 50%; }
        }
        .pipeline-group--uploading { border-left: 4px solid var(--primary); position: relative; }
        .pipeline-group--uploading::after {
            content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
            background: linear-gradient(90deg, var(--primary-light), var(--primary), var(--primary-light));
            background-size: 200% 100%; animation: uploadPulse 1.5s ease-in-out infinite;
        }

        /* Pending groups get a subtle left border */
        .pipeline-group:not(.pipeline-group--uploaded):not(.pipeline-group--error):not(.pipeline-group--uploading) {
            border-left: 4px solid var(--border-hover);
        }

        /* Button loading state */
        .btn--loading { pointer-events: none; position: relative; color: transparent !important; }
        .btn--loading::after {
            content: ''; position: absolute; width: 16px; height: 16px;
            border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
            border-radius: 50%; animation: spin 0.6s linear infinite;
            top: 50%; left: 50%; margin: -8px 0 0 -8px;
        }

        /* ================================================================
           TOOLTIPS
           ================================================================ */
        [data-tooltip] { position: relative; }
        [data-tooltip]::after {
            content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px);
            left: 50%; transform: translateX(-50%); background: var(--text-primary); color: #fff;
            padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500;
            white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.15s ease; z-index: 100;
        }
        [data-tooltip]:hover::after { opacity: 1; }

        /* ================================================================
           TOAST NOTIFICATIONS
           ================================================================ */
        .toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
        @keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        @keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }
        .toast {
            background: var(--text-primary); color: #fff; padding: 10px 20px; border-radius: var(--radius-md);
            font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px;
            animation: toastIn 0.3s ease-out;
        }
        .toast--exit { animation: toastOut 0.3s ease-in forwards; }
        .toast__undo {
            background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff; padding: 3px 10px;
            border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
        }
        .toast__undo:hover { background: rgba(255,255,255,0.1); }

        /* ================================================================
           ALERT RETRY
           ================================================================ */
        .alert-retry-btn {
            background: transparent; border: 1px solid currentColor; color: inherit;
            padding: 4px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
            cursor: pointer; white-space: nowrap; margin-left: auto; flex-shrink: 0;
        }
        .alert-retry-btn:hover { opacity: 0.8; }

        /* ================================================================
           PAGE REORDER MODAL
           ================================================================ */
        .page-reorder-modal {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
            display: flex; align-items: center; justify-content: center; z-index: 1000;
            animation: modalFadeIn 0.2s ease-out;
        }
        @keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes modalScaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
        .page-reorder-modal__content {
            background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
            width: 100%; max-width: 780px; max-height: 85vh; display: flex; flex-direction: column;
            overflow: hidden; animation: modalScaleIn 0.2s ease-out;
        }
        .page-reorder-modal__header {
            padding: 16px 20px; border-bottom: 1px solid var(--border);
            display: flex; align-items: center; justify-content: space-between;
        }
        .page-reorder-modal__header h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
        .page-reorder-modal__close {
            background: none; border: none; font-size: 22px; cursor: pointer;
            color: var(--text-secondary); padding: 0 4px; border-radius: 50%; width: 32px; height: 32px;
            display: flex; align-items: center; justify-content: center; transition: background var(--transition-fast);
        }
        .page-reorder-modal__close:hover { background: var(--bg); color: var(--text-primary); }
        .page-reorder-modal__info {
            padding: 8px 20px; font-size: 12px; color: var(--text-secondary); background: var(--bg);
            border-bottom: 1px solid var(--border);
        }
        .page-reorder-modal__grid {
            display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 12px; padding: 20px; overflow-y: auto; flex: 1;
        }
        .page-reorder-modal__page {
            border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: grab;
            position: relative; text-align: center; transition: all var(--transition-fast);
            background: var(--surface);
        }
        .page-reorder-modal__page:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); }
        .page-reorder-modal__page.dragging { opacity: 0.4; border-style: dashed; }
        .page-reorder-modal__page.drag-over { border-color: var(--primary); background: var(--primary-light); }
        .page-reorder-modal__page img {
            width: 100%; display: block; border-radius: 4px 4px 0 0;
            background: var(--bg); min-height: 120px;
        }
        .page-reorder-modal__page-num {
            font-size: 12px; padding: 6px 4px; background: var(--bg); color: var(--text-secondary);
            font-weight: 600; border-top: 1px solid var(--border);
        }
        .page-reorder-modal__page-original {
            font-size: 10px; color: var(--text-muted); margin-top: -2px; padding-bottom: 4px;
        }
        .page-reorder-modal__actions {
            padding: 12px 20px; border-top: 1px solid var(--border);
            display: flex; gap: 8px; justify-content: flex-end; background: var(--bg);
        }
        .page-reorder-modal__page-actions {
            display: flex; gap: 2px; justify-content: center; padding: 4px;
            border-top: 1px solid var(--border); background: var(--bg);
        }
        .page-reorder-modal__page-btn {
            background: none; border: 1px solid transparent; border-radius: 4px;
            cursor: pointer; padding: 3px 5px; color: var(--text-muted);
            display: inline-flex; align-items: center; transition: all var(--transition-fast);
        }
        .page-reorder-modal__page-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
        .page-reorder-modal__page-btn--delete:hover { color: var(--danger); border-color: var(--danger-border); background: var(--danger-light); }
        .page-reorder-modal__page-btn[title]::after { content: none; }

        /* Page-split selection mode */
        .page-reorder-modal__toolbar {
            display: flex; align-items: center; gap: 10px;
            padding: 8px 20px; background: var(--bg);
            border-bottom: 1px solid var(--border); font-size: 13px;
            flex-wrap: wrap;
        }
        .prm-toggle {
            display: inline-flex; align-items: center; gap: 6px;
            cursor: pointer; user-select: none;
            font-weight: 600; color: var(--text-primary);
        }
        .prm-toggle input { cursor: pointer; }
        .prm-toggle--mode {
            padding-left: 4px;
            font-weight: 500;
            color: var(--text-secondary);
            font-size: 12px;
        }
        .prm-toggle--mode input { accent-color: var(--primary); }
        .prm-toolbar-hint {
            color: var(--text-muted); font-size: 12px; font-style: italic;
        }
        .prm-select-count {
            color: var(--primary); font-weight: 600; font-size: 12px;
            background: var(--primary-light); padding: 2px 8px;
            border-radius: 10px;
        }
        .page-reorder-modal__page-select {
            position: absolute; top: 6px; left: 6px; z-index: 2;
            width: 22px; height: 22px; display: flex; align-items: center;
            justify-content: center; background: rgba(255,255,255,0.92);
            border: 1px solid var(--border); border-radius: 4px;
            cursor: pointer;
        }
        .page-reorder-modal__page-select input { cursor: pointer; margin: 0; }
        .page-reorder-modal__page--selected {
            border-color: var(--primary) !important;
            box-shadow: 0 0 0 3px var(--primary-light);
        }
        .page-reorder-modal__page--selected img {
            outline: 2px solid var(--primary);
        }

        /* Crop modal overlay */
        .crop-modal {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(15,23,42,0.65); display: flex; align-items: center;
            justify-content: center; z-index: 1100;
            animation: fadeIn 0.2s ease;
        }
        .crop-modal__content {
            background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
            width: 90vw; max-width: 800px; max-height: 90vh; display: flex; flex-direction: column;
            overflow: hidden;
        }
        .crop-modal__header {
            padding: 14px 20px; border-bottom: 1px solid var(--border);
            display: flex; align-items: center; justify-content: space-between;
        }
        .crop-modal__header h3 { font-size: 15px; font-weight: 600; margin: 0; }
        .crop-modal__body {
            flex: 1; overflow: auto; display: flex; align-items: center;
            justify-content: center; background: #1e1e2e; position: relative;
            min-height: 300px; cursor: crosshair;
        }
        .crop-modal__body img { max-width: 100%; max-height: 70vh; display: block; user-select: none; pointer-events: none; }
        .crop-modal__selection {
            position: absolute; border: 2px dashed #fff; background: rgba(30,64,175,0.15);
            box-shadow: 0 0 0 9999px rgba(0,0,0,0.45); pointer-events: none;
            transition: none;
        }
        .crop-modal__hint {
            padding: 8px 20px; font-size: 12px; color: var(--text-muted); text-align: center;
            border-bottom: 1px solid var(--border); background: var(--bg);
        }
        .crop-modal__actions {
            padding: 12px 20px; border-top: 1px solid var(--border);
            display: flex; gap: 8px; justify-content: flex-end; background: var(--bg);
        }

        /* Page reordered badge */
        .pipeline-group__doc-badge--pages {
            background: var(--warning-light); color: var(--warning);
        }

        /* ================================================================
           ACCESSIBILITY & FOCUS
           ================================================================ */
        :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
        }

        /* ================================================================
           RESPONSIVE
           ================================================================ */
        @media (max-width: 640px) {
            .container { padding: 12px; }
            .app-header { flex-wrap: wrap; }
            .tabs { overflow-x: auto; }
            .tab-btn { white-space: nowrap; padding: 8px 14px; font-size: 13px; }
            .stepper { flex-direction: column; gap: 12px; }
            .stepper__step + .stepper__step::before { display: none; }
            .confidence-ring-wrap { flex-direction: column; text-align: center; }
            .entity-cards { grid-template-columns: 1fr; }
            .result-grid { grid-template-columns: 1fr; }
            .pipeline-table { font-size: 12px; }
            .pipeline-table th, .pipeline-table td { padding: 6px 8px; }
            .batch-download-bar { align-items: stretch; padding: 10px 12px; }
            .batch-download-bar__info { min-width: 0; width: 100%; }
            .batch-download-bar__actions { width: 100%; justify-content: flex-start; }
            .batch-download-bar__clear,
            .batch-download-bar__download { flex: 1 1 auto; justify-content: center; }
        }

        /* ================================================================
           FIELD EXTRACTION — drawer panel, doc-card chip, alert
           ================================================================ */
        /* Bolita de líneas rojas en la fila del documento (Diego, 24-08).
           Reutiliza los estilos .linea-roja ya existentes para el detalle; aquí
           sólo el chip y su modal. Mismo tamaño y forma que .fields-chip para
           que la fila no se descuadre al aparecer. */
        .lr-chip {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 3px 10px; border-radius: 999px;
            font-size: 12px; font-weight: 500;
            border: 1px solid transparent; cursor: pointer;
            font-family: inherit; line-height: 1.5;
        }
        .lr-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

        /* Las dos bolitas (Diego, 26-08: una para alta y otra para media, sin
           texto). El contenedor lleva ancho mínimo para que las filas no salten
           al aparecer una segunda bolita o al desaparecer. */
        .lr-dots {
            display: inline-flex; align-items: center; gap: 4px;
            min-width: 44px; vertical-align: middle;
        }
        .lr-dot {
            display: inline-flex; align-items: center; justify-content: center;
            width: 20px; height: 20px; padding: 0;
            border-radius: 50%; border: 1px solid transparent;
            font-size: 11px; font-weight: 700; font-family: inherit;
            line-height: 1; cursor: pointer;
        }
        /* La de `alta` domina: es la que sale en pocas filas y la que obliga a
           mirar. La de `media` está encendida en casi todas (medido: 311 medias
           frente a 121 altas en 200 documentos), así que informa sin gritar. */
        .lr-dot--alta {
            width: 22px; height: 22px; font-size: 12px;
            background: var(--danger, #dc2626); color: #fff;
            border-color: var(--danger, #dc2626);
        }
        .lr-dot--media {
            background: rgba(217, 119, 6, 0.12); color: #b45309;
            border-color: rgba(217, 119, 6, 0.35);
        }
        .lr-dot--limpio {
            background: var(--bg); color: var(--text-secondary);
            border-color: var(--border); font-weight: 500;
        }
        .lr-dot:hover { filter: brightness(0.95); }
        .lr-dot:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

        /* Columna de riesgo del navegador de SharePoint. Estrecha y de ancho
           fijo: es una columna de iconos, no de contenido, y así el nombre del
           fichero conserva todo el espacio que tenía. */
        .sp-browser__table th.sp-risk-th {
            width: 52px; text-align: center; cursor: default;
        }
        .sp-browser__table td.sp-risk-cell {
            width: 52px; text-align: center; white-space: nowrap;
        }
        .sp-risk-cell .lr-dots { min-width: 0; }
        /* Aviso cuando no se han podido leer los avisos de Odoo: sin esto,
           cuarenta celdas en blanco parecerían «ningún documento tiene
           problemas», que es la confusión peligrosa. */
        .sp-browser__aviso {
            margin: 0 0 8px; padding: 6px 10px; border-radius: 6px;
            background: rgba(217, 119, 6, 0.08); color: #b45309;
            border: 1px solid rgba(217, 119, 6, 0.25); font-size: 12px;
        }

        /* Fila para "Ver todas" (izquierda) y "Sugerir línea roja" (derecha).
           `margin-left: auto` en el segundo lo empuja a la derecha aunque el
           primero no esté — que es el caso normal, sin filtro de gravedad. */
        .lr-modal__superior {
            display: flex; align-items: center; margin-bottom: 6px; min-height: 26px;
        }
        .lr-modal__todas {
            margin: 0;
            background: none; border: none; padding: 0;
            color: var(--primary); font-size: 12px; font-family: inherit;
            cursor: pointer; text-decoration: underline;
        }

        .lr-chip--alta {
            background: rgba(220, 38, 38, 0.10); color: var(--danger, #dc2626);
            border-color: rgba(220, 38, 38, 0.25);
        }
        .lr-chip--media {
            background: rgba(217, 119, 6, 0.10); color: #b45309;
            border-color: rgba(217, 119, 6, 0.25);
        }
        .lr-chip--limpio {
            background: var(--bg); color: var(--text-secondary);
            border-color: var(--border);
        }
        .lr-chip:hover { filter: brightness(0.97); }
        .lr-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

        /* z-index 2000: por encima del overlay de subida (1500) y del modal de
           duplicados (1600), como el resto de modales de la app. */
        .lr-modal-overlay {
            position: fixed; inset: 0; z-index: 2000;
            background: rgba(15, 23, 42, 0.45);
            display: flex; align-items: center; justify-content: center; padding: 24px;
        }
        .lr-modal {
            background: var(--surface, #fff); border-radius: 10px;
            max-width: 880px; width: 100%; max-height: 82vh; overflow: auto;
            padding: 18px 20px; box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
        }
        .lr-modal__head {
            display: flex; align-items: center; justify-content: space-between;
            gap: 12px; margin-bottom: 10px; font-size: 14px;
        }
        .lr-modal__close {
            background: none; border: none; font-size: 22px; cursor: pointer;
            color: var(--text-secondary); padding: 0 4px; line-height: 1;
        }
        .lr-modal__close:hover { color: var(--text-primary); }
        .lr-modal__summary {
            font-size: 13px; color: var(--text-secondary);
            margin-bottom: 12px; line-height: 1.5;
        }
        .lr-modal__vacio { font-size: 13px; color: var(--text-secondary); font-style: italic; }
        .lr-modal__lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

        /* ── Sugerir cambios al catálogo desde el documento ─────────────────
           Los botones van SÓLO dentro del modal (`.lr-modal__lista`): la misma
           clase `.linea-roja` se usa en la tarjeta del grupo, donde no hay
           botones y donde reservar sitio para ellos descuadraría la lista. */
        .lr-modal__lista .linea-roja { position: relative; padding-right: 60px; }
        .lr-acciones {
            position: absolute; top: 4px; right: 5px;
            display: inline-flex; gap: 2px;
        }
        /* Visibles siempre y no sólo al pasar por encima: en táctil no hay
           "encima", y con teclado un botón que aparece al enfocarlo se salta. */
        .lr-accion {
            display: inline-flex; align-items: center; justify-content: center;
            width: 24px; height: 24px; padding: 0;
            background: none; border: 1px solid transparent; border-radius: 5px;
            color: var(--text-muted); cursor: pointer;
        }
        .lr-accion:hover {
            color: var(--text-primary);
            background: var(--surface, #fff); border-color: var(--border);
        }
        .lr-accion:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

        .lr-modal__proponer {
            margin-left: auto;
            display: inline-flex; align-items: center; gap: 5px;
            padding: 5px 11px; border-radius: 6px;
            background: var(--surface, #fff); border: 1px dashed var(--border);
            color: var(--text-secondary); font-size: 12px; font-family: inherit;
            cursor: pointer;
        }
        .lr-modal__proponer:hover { color: var(--primary); border-color: var(--primary); }
        .lr-modal__proponer:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

        /* El formulario. Va en su propio overlay POR ENCIMA del detalle (2100 >
           2000) en vez de sustituirlo: quien escribe la objeción necesita seguir
           viendo el aviso del que habla. */
        .lr-sug-overlay { z-index: 2100; }
        .lr-sug { max-width: 560px; }
        .lr-sug__doc {
            font-size: 12px; color: var(--text-secondary);
            word-break: break-word; margin-bottom: 10px;
        }
        .lr-sug__contexto {
            font-size: 13px; line-height: 1.45; margin-bottom: 14px;
            padding: 8px 10px; border-radius: 6px;
            border-left: 3px solid var(--border); background: var(--background);
        }
        .lr-sug__codigo {
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
            font-size: 11px; color: var(--text-muted); margin-right: 6px;
        }
        .lr-sug__cuerpo { display: flex; flex-direction: column; gap: 12px; }
        .lr-sug__campo { display: flex; flex-direction: column; gap: 4px; }
        .lr-sug__campo > span { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
        .lr-sug__campo input, .lr-sug__campo select, .lr-sug__campo textarea {
            width: 100%; padding: 7px 9px; font: inherit; font-size: 13px;
            color: var(--text-primary); background: var(--surface, #fff);
            border: 1px solid var(--border); border-radius: 6px;
        }
        .lr-sug__campo textarea { resize: vertical; }
        /* El tipo de documento fijo: mismo hueco que un input, sin aspecto de
           control — nada aquí se puede tocar, es un dato del documento. */
        .lr-sug__clase-fija {
            padding: 7px 9px; font-size: 13px; color: var(--text-primary);
            background: var(--background); border: 1px solid var(--border);
            border-radius: 6px;
        }
        .lr-sug__ayuda { font-size: 11px; color: var(--text-muted); }
        .lr-sug__fila { display: flex; gap: 10px; }
        .lr-sug__fila > * { flex: 1; min-width: 0; }
        .lr-sug__nota { font-size: 12px; color: var(--text-muted); margin: 0; }
        .lr-sug__error { font-size: 12px; color: var(--danger, #dc2626); margin: 0; }
        .lr-sug__hecho { font-size: 13px; color: var(--text-primary); margin: 0 0 14px; }
        .lr-sug__pie { display: flex; justify-content: flex-end; gap: 8px; }

        .fields-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 3px 10px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 500;
            border: 1px solid transparent;
            background: var(--primary-light);
            color: var(--primary);
            border-color: var(--primary-border);
            cursor: pointer;
            transition: background var(--transition-fast), transform var(--transition-fast);
            white-space: nowrap;
        }
        .fields-chip:hover { background: var(--primary-50); }
        .fields-chip:active { transform: translateY(1px); }
        .fields-chip--extracting {
            background: var(--warning-light); color: var(--warning); border-color: var(--warning-border);
            cursor: default;
        }
        .fields-chip--ready {
            background: var(--success-light); color: var(--success); border-color: var(--success-border);
        }
        .fields-chip--pending {
            background: var(--surface); color: var(--text-secondary); border-color: var(--border);
        }
        .fields-chip--error {
            background: var(--danger-light); color: var(--danger); border-color: var(--danger-border);
        }
        .fields-chip--warning {
            background: var(--warning-light); color: var(--warning); border-color: var(--warning-border);
            font-weight: 600;
        }

        /* ================================================================
           CLIENT RESOLUTION (multi-client conflict UI)
           ================================================================ */
        .client-resolution-banner {
            display: flex; align-items: flex-start; gap: 12px;
            padding: 14px 16px; margin-bottom: 14px;
            background: linear-gradient(0deg, var(--warning-light), var(--warning-light));
            border: 1px solid var(--warning-border);
            border-left: 4px solid var(--warning);
            border-radius: var(--radius-sm);
            color: var(--warning);
        }
        .client-resolution-banner__content {
            flex: 1; line-height: 1.4;
        }
        .client-resolution-banner__content strong {
            display: block; font-size: 14px; margin-bottom: 2px;
            color: var(--text-primary);
        }
        .client-resolution-banner__content p {
            font-size: 13px; color: var(--text-secondary); margin: 0;
        }
        .client-resolution-banner__cta {
            background: var(--warning); color: white; border: none;
            padding: 8px 14px; border-radius: var(--radius-sm);
            font-weight: 600; font-size: 13px; cursor: pointer;
            transition: background var(--transition-fast);
            white-space: nowrap;
        }
        .client-resolution-banner__cta:hover { filter: brightness(0.95); }

        .pipeline-group--needs-client {
            border-left: 4px solid var(--warning) !important;
        }

        .btn-resolve-clients {
            background: var(--warning); color: white; border: none;
            padding: 4px 10px; border-radius: 12px;
            font-size: 12px; font-weight: 600;
            cursor: pointer; margin-left: 6px;
            display: inline-flex; align-items: center; gap: 4px;
            transition: filter var(--transition-fast);
        }
        .btn-resolve-clients:hover { filter: brightness(0.95); }

        /* Feature 4: per-group "Asignar a cliente" button. Quieter
           than the warning-style resolve-clients badge — it's always
           available, not an alert. */
        .btn-assign-client {
            background: var(--surface); color: var(--text-secondary);
            border: 1px solid var(--border);
            padding: 3px 9px; border-radius: 12px;
            font-size: 11.5px; font-weight: 500;
            cursor: pointer; margin-left: 6px;
            display: inline-flex; align-items: center; gap: 4px;
            transition: background var(--transition-fast),
                        border-color var(--transition-fast),
                        color var(--transition-fast);
        }
        .btn-assign-client:hover {
            background: var(--primary-light); color: var(--primary);
            border-color: var(--primary-border);
        }
        .btn-assign-client svg { flex: 0 0 auto; opacity: 0.85; }

        .client-resolution-modal {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(15, 23, 42, 0.55); display: flex;
            align-items: center; justify-content: center; z-index: 1100;
            animation: fadeIn 0.2s ease;
        }
        .client-resolution-modal__content {
            background: var(--surface); border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            width: 92vw; max-width: 720px; max-height: 90vh;
            display: flex; flex-direction: column; overflow: hidden;
        }
        .client-resolution-modal__header {
            display: flex; align-items: flex-start; justify-content: space-between;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border);
        }
        .client-resolution-modal__header h3 {
            font-size: 16px; font-weight: 600; margin-bottom: 4px;
        }
        .client-resolution-modal__subtitle {
            font-size: 13px; color: var(--text-secondary); margin: 0;
        }
        .client-resolution-modal__body {
            padding: 16px 20px; overflow-y: auto; flex: 1;
        }
        .client-resolution-modal__detected {
            margin-bottom: 18px;
        }
        .client-resolution-modal__section-label {
            font-size: 11px; font-weight: 600; text-transform: uppercase;
            letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 8px;
        }
        .client-resolution-modal__chips {
            display: flex; flex-wrap: wrap; gap: 8px;
        }
        .client-chip {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 5px 12px; border-radius: 14px;
            border: 1px solid var(--border); font-size: 13px; font-weight: 500;
        }
        .client-chip--readonly { cursor: default; }
        .client-chip__dot {
            width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
        }
        .client-resolution-modal__options {
            display: grid; grid-template-columns: 1fr; gap: 12px;
        }
        @media (min-width: 640px) {
            .client-resolution-modal__options { grid-template-columns: 1fr 1fr; }
        }
        .client-resolution-option {
            display: flex; gap: 12px; align-items: flex-start;
            text-align: left; padding: 16px;
            border: 1px solid var(--border); border-radius: var(--radius-sm);
            background: var(--bg); cursor: pointer;
            transition: all var(--transition-fast);
        }
        .client-resolution-option:hover:not(.client-resolution-option--disabled) {
            border-color: var(--primary); background: var(--primary-light);
        }
        .client-resolution-option--disabled {
            opacity: 0.5; cursor: not-allowed;
        }
        .client-resolution-option__icon {
            font-size: 24px; flex: 0 0 32px;
            display: inline-flex; align-items: center; justify-content: center;
        }
        .client-resolution-option__title {
            font-size: 14px; font-weight: 600; color: var(--text-primary);
            margin-bottom: 4px;
        }
        .client-resolution-option__desc {
            font-size: 12px; color: var(--text-secondary); line-height: 1.4;
        }

        /* Page-assignment view (Option B) */
        .page-assign-modal__content {
            max-width: 1100px; width: 95vw;
        }
        .page-assign-modal__clients {
            display: flex; gap: 8px; flex-wrap: wrap;
            padding: 12px 20px; border-bottom: 1px solid var(--border);
            background: var(--bg);
        }
        .page-assign-client-chip {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 6px 12px; border-radius: 16px;
            border: 1px solid var(--border); font-size: 13px; font-weight: 500;
            cursor: pointer; transition: all var(--transition-fast);
        }
        .page-assign-client-chip--active {
            box-shadow: 0 0 0 2px currentColor;
            transform: translateY(-1px);
        }
        .page-assign-client-chip__count {
            background: rgba(255,255,255,0.6); padding: 1px 7px;
            border-radius: 10px; font-size: 11px; font-weight: 600;
        }
        .page-assign-bulk-btn {
            margin-left: auto; padding: 5px 12px;
            background: var(--surface); border: 1px solid var(--border);
            border-radius: 14px; font-size: 12px; cursor: pointer;
            color: var(--text-secondary);
        }
        .page-assign-bulk-btn--clear { margin-left: 4px; }
        .page-assign-bulk-btn:hover { background: var(--bg); }

        .page-assign-modal__grid {
            user-select: none;
        }
        .page-assign-page {
            cursor: pointer !important;
            transition: transform 0.08s ease, box-shadow var(--transition-fast);
        }
        .page-assign-page:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }
        .page-assign-page--assigned {
            border-width: 3px;
        }
        .page-assign-modal__progress {
            font-size: 13px; color: var(--text-secondary);
        }
        .fields-chip--unsupported {
            background: var(--bg); color: var(--text-muted); border-color: var(--border);
            cursor: not-allowed;
        }
        .fields-chip__dot {
            width: 6px; height: 6px; border-radius: 50%;
            background: currentColor; opacity: 0.7;
        }
        .fields-chip__spinner {
            width: 10px; height: 10px; border-radius: 50%;
            border: 1.5px solid currentColor; border-top-color: transparent;
            animation: fields-chip-spin 0.8s linear infinite;
        }
        @keyframes fields-chip-spin { to { transform: rotate(360deg); } }

        /* Slide-in drawer */
        .fields-panel {
            position: fixed; top: 0; right: 0; bottom: 0;
            width: 440px; max-width: 100vw;
            background: var(--surface);
            border-left: 1px solid var(--border);
            box-shadow: var(--shadow-lg);
            display: flex; flex-direction: column;
            transform: translateX(100%);
            transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
            z-index: 1000;
        }
        .fields-panel--open { transform: translateX(0); }
        .fields-panel__head {
            padding: 20px 24px 16px;
            border-bottom: 1px solid var(--border);
            display: flex; align-items: flex-start; justify-content: space-between;
            gap: 12px;
        }
        .fields-panel__title {
            font-size: 15px; font-weight: 600; color: var(--text-primary);
            display: flex; flex-direction: column; gap: 2px; min-width: 0;
        }
        .fields-panel__title small {
            font-size: 12px; font-weight: 400; color: var(--text-secondary);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .fields-panel__close {
            background: transparent; border: none; cursor: pointer;
            padding: 4px; border-radius: 6px; color: var(--text-muted);
            transition: background var(--transition-fast), color var(--transition-fast);
        }
        .fields-panel__close:hover { background: var(--bg); color: var(--text-primary); }
        .fields-panel__body {
            flex: 1; overflow-y: auto; padding: 20px 24px;
        }
        .fields-panel__foot {
            padding: 14px 24px; border-top: 1px solid var(--border);
            display: flex; align-items: center; gap: 8px;
        }
        .fields-panel__meta {
            margin-left: auto; font-size: 11px; color: var(--text-muted);
            font-family: var(--font-mono);
        }

        .fields-group {
            margin-bottom: 20px;
        }
        .fields-group__label {
            font-size: 11px; font-weight: 600; text-transform: uppercase;
            letter-spacing: 0.08em; color: var(--text-muted);
            margin-bottom: 8px; padding-bottom: 6px;
            border-bottom: 1px solid var(--border);
        }
        .fields-group__row {
            display: grid; grid-template-columns: 140px 1fr;
            gap: 8px 12px; padding: 6px 0;
            font-size: 13px; align-items: baseline;
        }
        .fields-group__key {
            color: var(--text-secondary); font-weight: 500;
        }
        .fields-group__value {
            color: var(--text-primary); word-break: break-word;
        }
        .fields-group__value--null {
            color: var(--text-muted); font-style: italic;
        }

        .fields-panel__json {
            margin-top: 12px;
            background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
            padding: 12px; font-family: var(--font-mono); font-size: 12px;
            max-height: 300px; overflow: auto; white-space: pre;
        }

        .fields-panel__warning {
            display: flex; gap: 10px; align-items: flex-start;
            margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius-sm);
            font-size: 13px;
        }

        .fields-client-card {
            border: 1px solid var(--border); border-radius: var(--radius-sm);
            padding: 12px 14px; margin-bottom: 14px; background: var(--surface);
        }
        .fields-client-card__title {
            font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
            color: var(--primary); margin-bottom: 10px; padding-bottom: 6px;
            border-bottom: 1px dashed var(--border);
        }
        .fields-client-card .fields-group:last-child { margin-bottom: 0; }

        .fields-panel__skeleton {
            display: flex; flex-direction: column; gap: 12px;
        }
        .fields-panel__skeleton-bar {
            height: 12px; border-radius: 6px;
            background: linear-gradient(90deg, var(--bg) 0%, var(--border) 50%, var(--bg) 100%);
            background-size: 200% 100%;
            animation: fields-skeleton 1.2s infinite;
        }
        @keyframes fields-skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

        /* Backdrop */
        .fields-backdrop {
            position: fixed; inset: 0; background: rgba(15,23,42,0.24);
            z-index: 999; opacity: 0; pointer-events: none;
            transition: opacity 220ms ease;
        }
        .fields-backdrop--open { opacity: 1; pointer-events: auto; }

        /* Inline alert with action buttons (used for extraction errors) */
        .alert--actionable {
            display: flex; align-items: flex-start; gap: 12px;
            padding: 12px 14px;
        }
        .alert--actionable .alert__content { flex: 1; display: flex; flex-direction: column; gap: 2px; }
        .alert--actionable .alert__content strong { font-weight: 600; }
        .alert--actionable .alert__actions { display: flex; gap: 6px; flex-shrink: 0; }
        .alert--actionable .alert__actions .btn { padding: 4px 10px; font-size: 12px; }

        /* Extract-fields disabled banner */
        .extract-disabled-banner {
            margin-bottom: 12px;
            background: var(--warning-light); color: var(--warning);
            border: 1px solid var(--warning-border); border-radius: var(--radius-sm);
            padding: 8px 12px; font-size: 13px;
            display: flex; align-items: center; gap: 10px;
        }
        .extract-disabled-banner__spacer { flex: 1; }
        .extract-disabled-banner .btn-link {
            color: var(--warning); font-weight: 600;
            background: transparent; border: none; cursor: pointer;
            text-decoration: underline; font-size: 13px;
        }

        @media (max-width: 520px) {
            .fields-panel { width: 100vw; }
            .fields-group__row { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
        }
