  :root {
    /* ── Palette ── */
    --bg:          #f0f2f5;
    --bg-card:     #ffffff;
    --bg-soft:     #e8ebf0;
    --ink:         #0f1117;
    --ink-soft:    #374151;
    --muted:       #6b7280;
    --line:        #e1e5eb;
    --line-soft:   #edf0f4;
    --accent:      #1d6fa4;
    --accent-soft: #dbeafe;
    --danger:      #dc2626;
    --danger-soft: #fee2e2;
    --warning:     #d97706;
    --warning-soft:#fef3c7;
    --info:        #0891b2;
    --info-soft:   #cffafe;
    --gold:        #b45309;
    --success:     #059669;
    --success-soft:#d1fae5;
    /* ── Shadows ── */
    --shadow-sm: 0 1px 3px rgba(15,17,23,0.06), 0 1px 2px rgba(15,17,23,0.04);
    --shadow:    0 4px 12px rgba(15,17,23,0.08), 0 2px 4px rgba(15,17,23,0.04);
    --shadow-lg: 0 16px 40px rgba(15,17,23,0.12), 0 4px 8px rgba(15,17,23,0.06);
    /* ── Radius ── */
    --r-sm: 6px;
    --r:    10px;
    --r-lg: 16px;
    --r-xl: 20px;
  }
  /* ===== MODO OSCURO ===== */
  body.dark-mode {
    --bg:          #0d1117;
    --bg-card:     #161b22;
    --bg-soft:     #21262d;
    --ink:         #e6edf3;
    --ink-soft:    #c9d1d9;
    --muted:       #6e7681;
    --line:        #30363d;
    --line-soft:   #21262d;
    --accent:      #388bce;
    --accent-soft: #0d2135;
    --danger:      #f85149;
    --danger-soft: #2d1317;
    --warning:     #e3b341;
    --warning-soft:#2d1f00;
    --info:        #22d3ee;
    --info-soft:   #0a2330;
    --gold:        #d29922;
    --success:     #3fb950;
    --success-soft:#0d2d17;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow:    0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.6);
  }
  body.dark-mode .sidebar { background: #0d0d0b !important; }
  body.dark-mode .topbar { background: var(--bg); border-color: var(--line); }
  body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
    background: var(--bg-soft) !important; color: var(--ink) !important; border-color: var(--line) !important;
  }
  body.dark-mode .modal { background: var(--bg-card) !important; }
  body.dark-mode .modal-overlay { background: rgba(0,0,0,0.75) !important; }
  body.dark-mode .btn { background: var(--bg-soft) !important; color: var(--ink) !important; border-color: var(--line) !important; }
  body.dark-mode .btn:hover { background: var(--line) !important; }
  body.dark-mode .btn-primary { background: #e8e3d8 !important; color: #111210 !important; }
  body.dark-mode .btn-accent { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
  body.dark-mode .btn-danger { background: var(--danger) !important; color: #fff !important; }
  body.dark-mode .btn-excel { background: #1d6f42 !important; color: #fff !important; }
  body.dark-mode .kpi { background: var(--bg-card); border-color: var(--line); }
  body.dark-mode .card { background: var(--bg-card); border-color: var(--line); }
  body.dark-mode table thead tr { background: var(--bg-soft); }
  body.dark-mode table tbody tr:hover { background: var(--bg-soft); }
  body.dark-mode .badge { background: var(--bg-soft); color: var(--ink); }
  body, .sidebar, .topbar, .card, .modal, input, select, textarea, .btn, .kpi {
    transition: background 0.2s ease, color 0.15s ease, border-color 0.2s ease;
  }

  /* Toggle oscuro en sidebar */
  .dark-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; cursor: pointer; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: #c4bfb5;
    transition: all 0.15s; user-select: none; width: calc(100% - 24px); margin: 0 12px;
  }
  .dark-toggle:hover { background: rgba(255,255,255,0.05); color: #f5f3ee; }
  .dark-toggle-track {
    width: 32px; height: 18px; border-radius: 9px;
    background: #3a3a38; position: relative; transition: background 0.2s; flex-shrink: 0;
  }
  .dark-toggle-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: #c4bfb5; position: absolute; top: 3px; left: 3px;
    transition: transform 0.2s, background 0.2s;
  }
  body.dark-mode .dark-toggle-track { background: var(--accent); }
  body.dark-mode .dark-toggle-thumb { transform: translateX(14px); background: #fff; }




  /* ===== HISTORIAL POR REGISTRO ===== */
  .history-panel {
    position: fixed; right: 0; top: 0; bottom: 0; width: 380px;
    background: var(--bg-card); border-left: 1px solid var(--line);
    z-index: 7000; transform: translateX(100%); transition: transform 0.25s ease;
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  }
  .history-panel.open { transform: translateX(0); }
  .history-panel-header {
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0; background: var(--bg-card);
  }
  .history-panel-body { flex: 1; overflow-y: auto; padding: 8px 0; }
  .history-entry {
    display: flex; gap: 12px; padding: 12px 20px;
    border-bottom: 1px solid var(--line-soft); font-size: 12px;
  }
  .history-entry:last-child { border-bottom: none; }
  .history-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    margin-top: 4px;
  }
  .history-dot.create { background: var(--accent); }
  .history-dot.update { background: var(--warning); }
  .history-dot.delete { background: var(--danger); }
  .history-dot.payment { background: var(--info); }
  .history-body { flex: 1; }
  .history-action { font-weight: 600; color: var(--ink); }
  .history-detail { color: var(--muted); margin-top: 2px; }
  .history-ts { font-size: 10px; color: var(--muted); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }
  .history-btn { cursor: pointer; font-size: 11px; color: var(--accent); border: none; background: none; padding: 2px 6px; border-radius: 4px; }
  .history-btn:hover { background: var(--accent-soft); }

  /* ===== REPORTE RETENCIONES ===== */
  .ret-summary-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
  }

  /* ===== PDF PRINT RETENTION ===== */
  @media print {
    .sidebar, .topbar, .nav-item, .modal-overlay, .alert-panel,
    .search-overlay, .shortcuts-overlay, .history-panel,
    .btn, button, select, input[type=text], input[type=date] { display: none !important; }
    .view { display: block !important; padding: 0 !important; }
    body { background: white !important; }
    .print-only { display: block !important; }
    #retention-print-area { display: block !important; }
  }
  .print-only { display: none; }
  #retention-print-area { display: none; }

  /* ===== ATAJOS DE TECLADO ===== */
  .shortcut-hint {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; color: var(--muted); margin-left: 8px;
  }
  .shortcut-hint kbd {
    background: var(--bg-soft); border: 1px solid var(--line);
    border-radius: 3px; padding: 1px 5px; font-size: 9px;
    font-family: inherit; line-height: 1.4;
  }
  .shortcuts-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 9100;
    align-items: center; justify-content: center;
  }
  .shortcuts-overlay.active { display: flex; }
  .shortcuts-box {
    background: var(--bg-card); border-radius: 12px;
    width: 100%; max-width: 560px; padding: 0;
    box-shadow: var(--shadow-lg); border: 1px solid var(--line);
    overflow: hidden;
  }
  .shortcuts-header {
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; font-size: 15px;
  }
  .shortcuts-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0;
    padding: 8px 0; max-height: 420px; overflow-y: auto;
  }
  .shortcut-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px; font-size: 13px; border-bottom: 1px solid var(--line-soft);
  }
  .shortcut-row:last-child { border-bottom: none; }
  .shortcut-row kbd {
    background: var(--bg-soft); border: 1px solid var(--line);
    border-radius: 4px; padding: 2px 8px; font-size: 11px;
    font-family: 'JetBrains Mono', monospace; white-space: nowrap;
  }

  /* ===== FILTROS GUARDADOS ===== */
  .saved-filters-bar {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 10px; flex-wrap: wrap;
  }
  .saved-filter-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px; font-size: 11px;
    background: var(--bg-soft); border: 1px solid var(--line);
    cursor: pointer; transition: all 0.1s; white-space: nowrap;
  }
  .saved-filter-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
  .saved-filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
  .saved-filter-chip-del { opacity: 0.5; font-size: 10px; }
  .saved-filter-chip-del:hover { opacity: 1; }

  /* ===== VALIDACIÓN SRI ===== */
  .sri-valid   { border-color: var(--accent)   !important; background: var(--accent-soft)   !important; }
  .sri-invalid { border-color: var(--danger)   !important; background: var(--danger-soft)   !important; }
  .sri-hint { font-size: 10px; margin-top: 3px; display: block; }
  .sri-hint.ok  { color: var(--accent); }
  .sri-hint.err { color: var(--danger); }


  /* ─── ENTITY CARDS (clientes/proveedores) ─── */
  .entity-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 4px;
  }
  .entity-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
  }
  .entity-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--accent);
  }
  .entity-card-avatar {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; flex-shrink: 0;
    margin-bottom: 12px; letter-spacing: -0.02em;
  }
  .entity-card-name {
    font-size: 14px; font-weight: 700; color: var(--ink);
    margin-bottom: 4px; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .entity-card-doc {
    font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace;
    margin-bottom: 10px;
  }
  .entity-card-stats {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }
  .entity-card-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
  .entity-card-stat-val { font-size: 14px; font-weight: 700; color: var(--ink); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
  .entity-card-contacts {
    display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px;
  }
  .entity-card-contact {
    font-size: 11px; color: var(--muted);
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .entity-card-actions {
    position: absolute; top: 12px; right: 12px;
    display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s;
  }
  .entity-card:hover .entity-card-actions { opacity: 1; }

  /* View toggle button */
  .view-toggle {
    display: flex; align-items: center; gap: 0;
    border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  }
  .view-toggle-btn {
    padding: 5px 10px; cursor: pointer; background: var(--bg-card);
    color: var(--muted); border: none; font-size: 13px; transition: all 0.1s;
  }
  .view-toggle-btn.active { background: var(--accent); color: white; }
  .view-toggle-btn:hover:not(.active) { background: var(--bg-soft); }

  /* ─── INVOICE PRINT ─── */
  .invoice-paper {
    background: white; padding: 40px 48px;
    border: 1px solid var(--line); border-radius: var(--r);
    max-width: 820px; margin: 0 auto;
    box-shadow: var(--shadow);
  }
  .invoice-header {
    display: grid; grid-template-columns: 1fr auto;
    gap: 24px; margin-bottom: 32px; padding-bottom: 24px;
    border-bottom: 3px solid var(--ink);
  }
  .invoice-title { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }
  .invoice-company-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
  .invoice-meta { text-align: right; }
  .invoice-meta-row { display: flex; gap: 16px; justify-content: flex-end; margin-bottom: 4px; }
  .invoice-meta strong { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: block; margin-bottom: 1px; }
  .invoice-meta span { font-size: 14px; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
  .invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
  .invoice-party-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
  .invoice-party-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
  .invoice-party-detail { font-size: 12px; color: var(--muted); }
  .invoice-items-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
  .invoice-items-table th {
    text-align: left; padding: 10px 14px; font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
    border-bottom: 2px solid var(--ink); background: transparent; font-weight: 700;
  }
  .invoice-items-table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
  .invoice-items-table tr:last-child td { border-bottom: none; }
  .invoice-totals {
    margin-left: auto; width: 280px;
    border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  }
  .invoice-totals-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 14px; font-size: 13px; border-bottom: 1px solid var(--line-soft);
  }
  .invoice-totals-row:last-child { border-bottom: none; }
  .invoice-totals-row.total-final {
    background: var(--ink); color: white;
    font-size: 16px; font-weight: 700; padding: 12px 14px;
  }
  .invoice-footer { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

  @media print {
    .invoice-paper { border: none; padding: 0; box-shadow: none; }
  }



  /* ===== MODO SOLO LECTURA ===== */
  body.readonly-mode .btn-accent,
  body.readonly-mode .btn-primary:not(#authLoginBtn):not([onclick*="logout"]):not([onclick*="Password"]),
  body.readonly-mode .btn-danger,
  body.readonly-mode .btn-icon[onclick*="delete"],
  body.readonly-mode .btn-icon[onclick*="Modal"][title="Editar"],
  body.readonly-mode button[onclick*="openInvoiceModal"],
  body.readonly-mode button[onclick*="openBillModal"],
  body.readonly-mode button[onclick*="openQuoteModal"],
  body.readonly-mode button[onclick*="openCustomerModal"],
  body.readonly-mode button[onclick*="openSupplierModal"],
  body.readonly-mode button[onclick*="openTransactionModal"] {
    display: none !important;
  }
  body.readonly-mode .readonly-badge { display: inline-flex !important; }

  /* ===== LOGIN / AUTENTICACIÓN ===== */
  .auth-screen {
    position: fixed; inset: 0; z-index: 99999;
    background: linear-gradient(135deg, #0f1117 0%, #1a2332 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
  }
  .auth-card {
    background: var(--bg-card); border-radius: var(--r-xl);
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
    width: 100%; max-width: 420px; overflow: hidden;
    animation: modalIn 0.3s ease;
  }
  .auth-header {
    padding: 32px 36px 24px; text-align: center;
    border-bottom: 1px solid var(--line);
  }
  .auth-logo {
    font-size: 28px; font-weight: 800; letter-spacing: -0.03em;
    color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  .auth-logo .dot { color: var(--accent); }
  .auth-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
  .auth-body { padding: 28px 36px 32px; }
  .auth-company-badge {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--bg-soft);
    border-radius: var(--r); margin-bottom: 20px;
  }
  .auth-company-avatar {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; flex-shrink: 0;
  }
  .auth-field { margin-bottom: 16px; }
  .auth-field label {
    display: block; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--muted); margin-bottom: 6px;
  }
  .auth-field input {
    width: 100%; padding: 11px 14px; font-size: 14px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--bg-card); color: var(--ink);
  }
  .auth-field input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29,111,164,0.12);
  }
  .auth-btn {
    width: 100%; padding: 12px; font-size: 14px; font-weight: 600;
    background: var(--accent); color: white; border: none;
    border-radius: var(--r-sm); cursor: pointer; transition: filter 0.15s;
    margin-top: 4px;
  }
  .auth-btn:hover { filter: brightness(1.1); }
  .auth-error {
    background: var(--danger-soft); color: var(--danger);
    padding: 10px 14px; border-radius: var(--r-sm);
    font-size: 12px; margin-bottom: 16px; display: none;
  }
  .auth-error.show { display: block; }
  .auth-switch {
    text-align: center; margin-top: 18px; font-size: 12px; color: var(--muted);
  }
  .auth-switch a { color: var(--accent); cursor: pointer; font-weight: 600; }
  .auth-company-select {
    width: 100%; padding: 11px 14px; font-size: 14px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--bg-card); margin-bottom: 16px;
  }
  .auth-user-pills {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
  }
  .auth-user-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border: 1px solid var(--line);
    border-radius: 24px; cursor: pointer; font-size: 13px;
    transition: all 0.12s; background: var(--bg-card);
  }
  .auth-user-pill:hover { border-color: var(--accent); background: var(--bg-soft); }
  .auth-user-pill.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .auth-user-pill-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent); color: white; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }

  /* ===== GESTIÓN DE USUARIOS ===== */
  .user-role-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  }
  .user-role-badge.admin    { background: var(--danger-soft);  color: var(--danger); }
  .user-role-badge.contador { background: var(--accent-soft);  color: var(--accent); }
  .user-role-badge.vendedor { background: var(--warning-soft); color: var(--warning); }
  .user-role-badge.lectura  { background: var(--bg-soft);      color: var(--muted); }
  .current-user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px; border-radius: var(--r-sm);
    background: var(--bg-soft); cursor: pointer; font-size: 12px;
    border: 1px solid var(--line); transition: all 0.12s;
  }
  .current-user-chip:hover { border-color: var(--accent); }
  .current-user-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: white; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .perm-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px; margin-top: 8px;
  }
  .perm-check {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--line);
    border-radius: var(--r-sm); font-size: 12px; cursor: pointer;
  }
  .perm-check input { width: auto; margin: 0; }
  /* Ocultar elementos sin permiso */
  .perm-hidden { display: none !important; }



  /* ===== MEJORAS DE AUTENTICACIÓN ===== */
  /* Fortaleza de contraseña */
  .pw-strength { margin-top: 8px; }
  .pw-strength-bar {
    height: 5px; border-radius: 3px; background: var(--line);
    overflow: hidden; display: flex; gap: 2px;
  }
  .pw-strength-seg { flex: 1; background: var(--line); border-radius: 2px; transition: background 0.2s; }
  .pw-strength-seg.active-weak   { background: var(--danger); }
  .pw-strength-seg.active-medium { background: var(--warning); }
  .pw-strength-seg.active-strong { background: var(--success); }
  .pw-strength-label { font-size: 10px; margin-top: 4px; font-weight: 600; }
  .pw-strength-label.weak   { color: var(--danger); }
  .pw-strength-label.medium { color: var(--warning); }
  .pw-strength-label.strong { color: var(--success); }
  /* Bloqueo */
  .auth-locked {
    background: var(--danger-soft); color: var(--danger);
    padding: 12px 16px; border-radius: var(--r-sm);
    font-size: 12px; text-align: center; margin-bottom: 14px;
  }
  /* Aviso inactividad */
  .idle-warning {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    background: var(--warning); color: white; z-index: 9998;
    padding: 14px 24px; border-radius: var(--r); box-shadow: var(--shadow-lg);
    font-size: 13px; display: none; align-items: center; gap: 14px;
  }
  .idle-warning.show { display: flex; }
  .idle-warning button {
    background: white; color: var(--warning); border: none;
    padding: 6px 14px; border-radius: var(--r-sm); font-weight: 600; cursor: pointer;
  }
  /* Tabla de accesos */
  .login-history-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
  .login-history-dot.ok   { background: var(--success); }
  .login-history-dot.fail { background: var(--danger); }

  /* ===== NAV COLAPSABLE (ACORDEÓN) ===== */
  .nav-section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px 7px; cursor: pointer; user-select: none;
    transition: color 0.12s; border-radius: var(--r-sm);
  }
  .nav-section-header:hover { background: rgba(255,255,255,0.04); }
  .nav-section-header .nav-label {
    padding: 0; margin: 0; transition: color 0.12s;
  }
  .nav-section-header:hover .nav-label { color: #9ca3af; }
  .nav-section-chevron {
    width: 14px; height: 14px; color: #4b5563;
    transition: transform 0.2s ease; flex-shrink: 0;
  }
  .nav-section.collapsed .nav-section-chevron { transform: rotate(-90deg); }
  .nav-section-items {
    overflow: hidden; transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 1000px; opacity: 1;
  }
  .nav-section.collapsed .nav-section-items {
    max-height: 0; opacity: 0;
  }
  /* Item destacado fuera de secciones (Captura/Lector) */
  .nav-item-feature {
    margin: 4px 8px 10px; padding: 10px 12px;
    background: linear-gradient(135deg, rgba(29,111,164,0.15), rgba(29,111,164,0.05));
    border: 1px solid rgba(29,111,164,0.3); border-radius: var(--r);
    color: #93c5fd; font-weight: 600;
  }
  .nav-item-feature:hover { background: linear-gradient(135deg, rgba(29,111,164,0.25), rgba(29,111,164,0.1)); }
  .nav-item-feature svg { opacity: 1; color: #60a5fa; }

  /* ===== ADJUNTAR ARCHIVOS ===== */
  .attach-zone {
    border: 2px dashed var(--line); border-radius: 8px;
    padding: 14px 16px; cursor: pointer; transition: all 0.15s;
    background: var(--bg-soft); margin-top: 8px;
  }
  .attach-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
  .attach-zone-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
  .attach-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
  .attach-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px; font-size: 12px;
  }
  .attach-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .attach-item-size { color: var(--muted); flex-shrink: 0; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
  .attach-item-del { cursor: pointer; color: var(--danger); opacity: 0.6; flex-shrink: 0; }
  .attach-item-del:hover { opacity: 1; }
  .attach-view-btn { font-size: 11px; color: var(--accent); cursor: pointer; text-decoration: underline; flex-shrink: 0; }

  /* ===== ALERTAS ===== */
  .alert-bell {
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--bg-card); font-size: 13px; transition: all 0.15s; position: relative;
  }
  .alert-bell:hover { background: var(--bg-soft); }
  .alert-bell-badge {
    position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
    border-radius: 8px; background: var(--danger); color: white; font-size: 9px;
    font-weight: 700; display: none; align-items: center; justify-content: center; padding: 0 3px;
  }
  .alert-bell-badge.visible { display: flex; }
  .alert-panel {
    position: fixed; top: 60px; right: 20px; width: 380px;
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 8000;
    display: none; max-height: 520px; overflow-y: auto;
  }
  .alert-panel.active { display: block; }
  .alert-panel-header {
    padding: 14px 16px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: var(--bg-card); z-index: 1;
  }
  .alert-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--line-soft); transition: background 0.1s;
  }
  .alert-item:hover { background: var(--bg-soft); }
  .alert-item:last-child { border-bottom: none; }
  .alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
  .alert-body { flex: 1; min-width: 0; }
  .alert-title { font-weight: 500; font-size: 13px; }
  .alert-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .alert-action { font-size: 11px; color: var(--accent); cursor: pointer; margin-top: 4px; text-decoration: underline; }

  /* ===== FLUJO DE CAJA ===== */
  .cashflow-bar-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
  .cashflow-bar { height: 8px; border-radius: 4px; min-width: 2px; transition: width 0.3s; }
  .cashflow-in  { background: var(--accent); }
  .cashflow-out { background: var(--danger); }
  .cashflow-net-positive { color: var(--accent); }
  .cashflow-net-negative { color: var(--danger); }

  /* ===== BÚSQUEDA GLOBAL ===== */
  .global-search-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; cursor: pointer; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: #c4bfb5;
    transition: all 0.15s; width: calc(100% - 24px);
    margin: 0 12px 12px; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
  }
  .global-search-btn:hover { background: rgba(255,255,255,0.1); color: #f5f3ee; }
  .global-search-btn kbd {
    margin-left: auto; font-size: 10px; opacity: 0.5;
    background: rgba(255,255,255,0.1); border-radius: 4px;
    padding: 2px 6px; font-family: inherit;
  }
  .search-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 9000;
    align-items: flex-start; justify-content: center; padding-top: 80px;
  }
  .search-overlay.active { display: flex; }
  .search-box {
    background: var(--bg-card); border-radius: 12px;
    width: 100%; max-width: 620px; box-shadow: var(--shadow-lg);
    overflow: hidden; border: 1px solid var(--line);
  }
  .search-input-wrap {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
  }
  .search-input-wrap svg { opacity: 0.4; flex-shrink: 0; }
  .search-input-wrap input {
    border: none !important; outline: none; background: transparent !important;
    font-size: 16px; color: var(--ink) !important; width: 100%; font-family: inherit;
  }
  .search-input-wrap input::placeholder { color: var(--muted); }
  .search-results { max-height: 420px; overflow-y: auto; }
  .search-result-group-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em;
    color: var(--muted); padding: 10px 20px 4px; font-weight: 600;
  }
  .search-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; cursor: pointer; transition: background 0.1s;
  }
  .search-result-item:hover, .search-result-item.sr-selected { background: var(--bg-soft); }
  .search-result-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--bg-soft); display: flex; align-items: center;
    justify-content: center; font-size: 15px; flex-shrink: 0;
  }
  .search-result-main { flex: 1; min-width: 0; }
  .search-result-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search-result-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
  .search-result-badge { font-size: 12px; color: var(--muted); font-family: 'JetBrains Mono', monospace; flex-shrink: 0; }
  .search-empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px; }
  .search-footer {
    padding: 10px 20px; border-top: 1px solid var(--line);
    display: flex; gap: 16px; background: var(--bg-soft);
  }
  .search-footer span { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
  .search-footer kbd {
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: 4px; padding: 1px 5px; font-size: 10px; font-family: inherit;
  }


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

  body {
    font-family: 'Inter Tight', sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  .display { font-family: 'Fraunces', serif; font-weight: 500; letter-spacing: -0.02em; }
  .mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

  /* LAYOUT */
  .app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

  /* SIDEBAR */
  .sidebar {
    background: #111827;
    color: #d1d5db;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #374151 transparent;
    display: flex;
    flex-direction: column;
  }
  .brand {
    padding: 20px 16px 16px;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 8px;
    flex-shrink: 0;
  }
  .brand-logo {
    font-family: 'Inter Tight', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #f9fafb;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .brand-logo .dot { color: var(--accent); font-size: 22px; line-height: 0; }
  .brand-tag {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #4b5563;
    margin-top: 3px;
    text-transform: uppercase;
  }

  .nav-section {
    padding: 0 8px;
    margin-bottom: 4px;
  }
  .nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #4b5563;
    padding: 10px 10px 4px;
    font-weight: 600;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    color: #9ca3af;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.12s;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-item:hover { background: #1f2937; color: #f9fafb; }
  .nav-item.active {
    background: rgba(29,111,164,0.18);
    color: #93c5fd;
  }
  .nav-item svg { width: 15px; height: 15px; opacity: 0.75; flex-shrink: 0; }
  .nav-item.active svg { opacity: 1; color: #60a5fa; }

  /* MAIN */
  .main { padding: 0; max-width: 100%; overflow-x: hidden; }
  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
  }
  .page-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
  .page-sub { color: var(--muted); font-size: 11px; margin-top: 1px; }
  .topbar-actions { display: flex; gap: 6px; align-items: center; }

  .content { padding: 24px 28px; }

  .view { display: none; animation: fadeIn 0.2s ease; }
  .view.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

  /* ─── BUTTONS ─── */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--r-sm);
    font-family: inherit; font-size: 12.5px; font-weight: 600;
    border: 1px solid var(--line); background: var(--bg-card);
    color: var(--ink); cursor: pointer; transition: all 0.12s;
    white-space: nowrap; letter-spacing: -0.01em;
  }
  .btn:hover { background: var(--bg-soft); box-shadow: var(--shadow-sm); }
  .btn-primary {
    background: var(--ink); color: #f9fafb; border-color: var(--ink);
  }
  .btn-primary:hover { background: #1f2937; }
  .btn-accent {
    background: var(--accent); color: white; border-color: var(--accent);
  }
  .btn-accent:hover { filter: brightness(1.1); }
  .btn-danger {
    background: var(--danger); color: white; border-color: var(--danger);
  }
  .btn-danger:hover { filter: brightness(1.1); }
  .btn-excel {
    background: #16a34a; color: white; border-color: #16a34a;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .btn-excel:hover { background: #15803d; }
  .btn-excel::before { content: "📊"; font-size: 11px; }
  /* ============================
     DASHBOARD PREMIUM - estilo app
     ============================ */
  .dash-pro {
    color: var(--ink);
  }
  .dash-pro h2 {
    font-family: 'Inter Tight', sans-serif;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    margin: 0 0 14px;
  }
  .dash-pro .pro-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    position: relative;
  }
  .dash-pro .pro-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
  }
  .dash-pro .col-3 { grid-column: span 3; }
  .dash-pro .col-4 { grid-column: span 4; }
  .dash-pro .col-5 { grid-column: span 5; }
  .dash-pro .col-6 { grid-column: span 6; }
  .dash-pro .col-7 { grid-column: span 7; }
  .dash-pro .col-8 { grid-column: span 8; }
  .dash-pro .col-12 { grid-column: span 12; }
  @media (max-width: 1100px) {
    .dash-pro .col-3, .dash-pro .col-4, .dash-pro .col-5,
    .dash-pro .col-6, .dash-pro .col-7, .dash-pro .col-8 { grid-column: span 6; }
  }
  @media (max-width: 700px) {
    .dash-pro .col-3, .dash-pro .col-4, .dash-pro .col-5,
    .dash-pro .col-6, .dash-pro .col-7, .dash-pro .col-8 { grid-column: span 12; }
  }

  /* DONAS sobrias */
  .neon-donut {
    text-align: center;
    position: relative;
  }
  .neon-donut svg { display: block; margin: 0 auto; }
  .neon-donut-label {
    margin-top: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
  }
  .neon-donut-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 10px;
  }

  /* ==============================================
     MODELO Z — Dashboard layout
     ============================================== */
  .z-row {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 20px;
    margin-bottom: 22px;
  }
  @media (max-width: 900px) { .z-row { grid-template-columns: 1fr; } }

  .z-context {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
  }
  .z-context-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 8px;
  }
  .z-context-title {
    font-family: 'Fraunces', serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.1;
    margin: 0 0 18px;
    letter-spacing: -0.02em;
  }
  .z-context-filters {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
  }
  .z-filter-group { display: flex; flex-direction: column; min-width: 140px; }
  .z-filter-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 5px;
    font-weight: 600;
  }
  .z-filter-select {
    padding: 8px 28px 8px 12px;
    font-size: 13px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23857a6e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
  }

  .z-hero {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2520 100%);
    color: #f5f3ee;
    border-radius: 14px;
    padding: 28px 32px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
  }
  .z-hero::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(160,125,42,0.22) 0%, transparent 70%);
    pointer-events: none;
  }
  .z-hero-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 12px;
    position: relative;
  }
  .z-hero-value {
    font-family: 'Fraunces', serif;
    font-size: 56px;
    font-weight: 600;
    color: #f5f3ee;
    line-height: 1;
    letter-spacing: -0.02em;
    position: relative;
    margin-bottom: 14px;
  }
  .z-hero-delta {
    font-size: 14px;
    font-weight: 600;
    color: #6dbf8c;
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .z-hero-delta.negative { color: #e07a7a; }
  .z-hero-arrow { font-size: 16px; }

  /* KPI cards sobrias con franja de color */
  .pro-kpi {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px 18px 18px 22px;
    position: relative;
    overflow: hidden;
  }
  .pro-kpi::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
  }
  .pro-kpi.cyan::before { background: var(--info); }
  .pro-kpi.pink::before { background: var(--danger); }
  .pro-kpi.gold::before { background: var(--gold); }
  .pro-kpi.green::before { background: var(--accent); }
  .pro-kpi-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
    margin-bottom: 8px;
  }
  .pro-kpi-value {
    font-family: 'Fraunces', serif;
    font-size: 30px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1;
    margin-bottom: 4px;
  }
  .pro-kpi-delta {
    font-size: 11px;
    color: var(--muted);
  }
  .pro-kpi-delta.up { color: var(--accent); }
  .pro-kpi-delta.down { color: var(--danger); }

  /* BARRAS horizontales sobrias */
  .equalizer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .equalizer-label {
    width: 140px;
    font-size: 12px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .equalizer-bar-wrap {
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
    background: var(--bg-soft);
    border-radius: 3px;
    overflow: hidden;
  }
  .equalizer-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.5s ease-out;
  }
  .equalizer-value {
    width: 90px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--ink);
  }

  /* HEATMAP sobrio */
  .heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }
  .heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--bg-soft);
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
    border: 1px solid var(--line-soft);
  }
  .heatmap-cell:hover { transform: scale(1.1); z-index: 2; }
  .heatmap-cell[data-level="0"] { background: var(--bg-soft); }
  .heatmap-cell[data-level="1"] { background: rgba(45, 95, 63, 0.18); }
  .heatmap-cell[data-level="2"] { background: rgba(45, 95, 63, 0.4); }
  .heatmap-cell[data-level="3"] { background: rgba(45, 95, 63, 0.65); }
  .heatmap-cell[data-level="4"] { background: var(--accent); }
  .heatmap-cell[data-level="3"] .heatmap-day,
  .heatmap-cell[data-level="4"] .heatmap-day { color: rgba(255,255,255,0.85); }
  .heatmap-day {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
  }

  /* TIMELINE sobrio */
  .timeline-track {
    position: relative;
    height: 80px;
    margin: 16px 0;
  }
  .timeline-line {
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    height: 2px;
    background: var(--line);
  }
  .timeline-node {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    cursor: pointer;
  }
  .timeline-node-label {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .timeline-node-value {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--ink);
    white-space: nowrap;
    font-weight: 500;
  }

  /* AREA CHART sobrio */
  .area-chart svg { width: 100%; height: 100%; display: block; }
  .area-chart-grid-line { stroke: var(--line-soft); stroke-width: 1; }
  .area-chart-label { fill: var(--muted); font-size: 10px; font-family: 'JetBrains Mono', monospace; }

  /* ============================
     SRI DECLARACIONES TOOL
     ============================ */
  .sri-tool {
    --sri-mono: 'JetBrains Mono', monospace;
    color: var(--ink);
  }
  .sri-tool .sri-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
  }
  .sri-tool .sri-tab {
    font-family: var(--sri-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    white-space: nowrap;
    text-transform: uppercase;
    transition: all 0.15s;
  }
  .sri-tool .sri-tab:hover { color: var(--ink); }
  .sri-tool .sri-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
  .sri-tool .sri-panel { display: none; }
  .sri-tool .sri-panel.active { display: block; }
  .sri-tool .sri-section {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
  }
  .sri-tool .sri-section h3 {
    font-family: var(--sri-mono);
    font-size: 11px;
    color: var(--accent);
    margin-bottom: 14px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 600;
  }
  .sri-tool .sri-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
  }
  .sri-tool .sri-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sri-tool .sri-field label {
    font-family: var(--sri-mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }
  .sri-tool .sri-field input,
  .sri-tool .sri-field select {
    font-family: var(--sri-mono);
    font-size: 12px;
    padding: 7px 10px;
    width: 100%;
  }
  .sri-tool .sri-field input.invalid { border-color: var(--danger); }
  .sri-tool .sri-field input.valid { border-color: var(--accent); }
  .sri-tool .sri-upload {
    border: 1.5px dashed var(--line);
    border-radius: 8px;
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
  }
  .sri-tool .sri-upload:hover,
  .sri-tool .sri-upload.drag {
    border-color: var(--accent);
    background: var(--bg-soft);
  }
  .sri-tool .sri-upload input[type=file] { display: none; }
  .sri-tool .sri-upload-text { font-size: 13px; color: var(--ink); margin-bottom: 4px; }
  .sri-tool .sri-upload-hint { font-size: 11px; color: var(--muted); font-family: var(--sri-mono); }
  .sri-tool .sri-file-list { margin-top: 14px; }
  .sri-tool .sri-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-soft);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
    font-family: var(--sri-mono);
  }
  .sri-tool .sri-file-item .name { flex: 1; }
  .sri-tool .sri-file-item button {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 14px;
  }
  .sri-tool .sri-log {
    background: var(--ink);
    color: #f5f3ee;
    padding: 12px;
    border-radius: 4px;
    font-family: var(--sri-mono);
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 12px;
  }
  .sri-tool .sri-log .log-line { padding: 1px 0; }
  .sri-tool .sri-log .log-info { color: #f5f3ee; }
  .sri-tool .sri-log .log-success { color: #6ee7b7; }
  .sri-tool .sri-log .log-warn { color: #fbbf24; }
  .sri-tool .sri-log .log-error { color: #f87171; }
  .sri-tool .sri-form-box {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
    background: var(--bg);
    margin-bottom: 14px;
  }
  .sri-tool .sri-form-title {
    font-family: var(--sri-mono);
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 8px;
  }
  .sri-tool .sri-casilla {
    display: grid;
    grid-template-columns: 60px 1fr 140px;
    gap: 10px;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px dotted var(--line-soft);
    font-size: 12px;
  }
  .sri-tool .sri-casilla.total {
    font-weight: 600;
    background: var(--bg-soft);
    padding: 8px;
    border-radius: 4px;
    margin: 6px 0;
  }
  .sri-tool .sri-casilla .num {
    font-family: var(--sri-mono);
    color: var(--muted);
    font-size: 10px;
  }
  .sri-tool .sri-casilla .val {
    font-family: var(--sri-mono);
    text-align: right;
  }
  .sri-tool .sri-status {
    display: inline-block;
    font-family: var(--sri-mono);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .sri-tool .sri-status.ok { background: rgba(45,95,63,0.12); color: var(--accent); }
  .sri-tool .sri-status.warn { background: rgba(160,125,42,0.12); color: var(--gold); }
  .sri-tool .sri-status.err { background: rgba(184,65,46,0.12); color: var(--danger); }

  /* PORTAL SRI */
  .portal-step {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 14px 16px; border: 1px solid var(--line);
    border-radius: 8px; margin-bottom: 10px;
    background: var(--bg-card); transition: border-color 0.2s;
  }
  .portal-step:hover { border-color: var(--accent); }
  .portal-step-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    font-weight: 700; flex-shrink: 0;
  }
  .portal-step-body { flex: 1; }
  .portal-step-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
  .portal-step-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
  .portal-step-action { margin-top: 8px; }
  .portal-step-action .btn { font-size: 11px; padding: 5px 10px; }
  .checklist-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
  }
  .checklist-item:last-child { border-bottom: none; }
  .checklist-icon { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
  .checklist-ok { color: var(--accent); }
  .checklist-warn { color: var(--warning); }
  .checklist-err { color: var(--danger); }
  .calendario-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 6px; font-size: 11px; font-family: 'JetBrains Mono', monospace;
  }
  .cal-header {
    font-weight: 700; padding: 6px 8px;
    background: var(--bg-soft); border-radius: 4px; text-align: center;
  }
  .cal-cell {
    padding: 5px 8px; border: 1px solid var(--line-soft);
    border-radius: 4px; text-align: center;
  }
  .cal-cell.highlight {
    background: var(--accent-soft); border-color: var(--accent);
    font-weight: 700; color: var(--accent);
  }
  .sri-tool .sri-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }
  .sri-tool .sri-stat {
    background: var(--bg-soft);
    padding: 10px 12px;
    border-radius: 4px;
    border-left: 3px solid var(--accent);
  }
  .sri-tool .sri-stat-label {
    font-family: var(--sri-mono);
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
  }
  .sri-tool .sri-stat-value {
    font-family: var(--sri-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
  }
  .sri-tool .sri-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--sri-mono);
  }
  .sri-tool .sri-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--bg-soft);
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
  }
  .sri-tool .sri-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line-soft);
  }
  .sri-tool .sri-table .right { text-align: right; }
  .sri-tool .sri-empty {
    padding: 32px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
  }
  .sri-tool .sri-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
  }
  .btn-sm { padding: 4px 10px; font-size: 11.5px; font-weight: 600; border-radius: var(--r-sm); }
  .row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .text-muted { color: var(--muted); }
  .text-accent { color: var(--accent); }
  .text-danger { color: var(--danger); }
  .text-warning { color: var(--warning); }
  .btn-icon {
    padding: 5px 7px; background: transparent; border: 1px solid transparent;
    color: var(--muted); cursor: pointer; border-radius: var(--r-sm);
    font-size: 13px; transition: all 0.1s;
  }
  .btn-icon:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }

  /* ─── GRID SYSTEM ─── */
  .grid { display: grid; gap: 16px; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  @media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 700px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

  /* ─── CARD ─── */
  .card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
    box-shadow: var(--shadow-sm);
  }
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }
  .card-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
  .card-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

  /* ─── KPI CARDS ─── */
  .kpi {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 18px 18px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, transform 0.15s;
  }
  .kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
  .kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 600;
  }
  .kpi-value {
    font-family: 'Inter Tight', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: -0.03em;
    color: var(--ink);
  }
  .kpi-delta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .kpi-delta.positive { color: var(--success); }
  .kpi-delta.negative { color: var(--danger); }
  .kpi-stripe {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
    border-radius: var(--r) 0 0 var(--r);
  }
  .kpi.income .kpi-stripe  { background: var(--success); }
  .kpi.expense .kpi-stripe { background: var(--danger); }
  .kpi.profit .kpi-stripe  { background: var(--accent); }
  .kpi.cash .kpi-stripe    { background: var(--gold); }

  /* ─── TABLES ─── */
  .table-wrap { overflow-x: auto; border-radius: 0 0 var(--r) var(--r); }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th {
    text-align: left;
    padding: 9px 14px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    white-space: nowrap;
  }
  td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tbody tr { transition: background 0.08s; }
  tbody tr:hover td { background: var(--bg-soft); }
  .text-right  { text-align: right; }
  .text-center { text-align: center; }
  td.empty { text-align: center; color: var(--muted); padding: 40px; font-size: 13px; }

  /* ─── BADGES ─── */
  .badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-soft);
    color: var(--muted);
    white-space: nowrap;
  }
  .badge.accent  { background: var(--accent-soft);  color: var(--accent); }
  .badge.danger  { background: var(--danger-soft);  color: var(--danger); }
  .badge.warning { background: var(--warning-soft); color: var(--warning); }
  .badge.info    { background: var(--info-soft);    color: var(--info); }
  .badge.success { background: var(--success-soft); color: var(--success); }

  /* ─── FORMS ─── */
  .form-group { margin-bottom: 14px; }
  .form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
  label {
    display: block; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--muted); margin-bottom: 5px;
  }
  input, select, textarea {
    width: 100%; padding: 8px 11px;
    font-family: inherit; font-size: 13px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--bg-card); color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29,111,164,0.12);
  }
  textarea { resize: vertical; min-height: 70px; }

  /* ─── MODAL ─── */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: none; align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(6px);
  }
  .modal-overlay.active { display: flex; }
  .modal {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    width: 90%; max-width: 600px; max-height: 90vh;
    overflow-y: auto; box-shadow: var(--shadow-lg);
    animation: modalIn 0.18s ease;
    border: 1px solid var(--line);
  }
  @keyframes modalIn { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: none; } }
  .modal-header {
    padding: 18px 24px; border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-soft); border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .modal-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
  .modal-body { padding: 20px 24px; }
  .modal-footer {
    padding: 14px 24px; border-top: 1px solid var(--line);
    display: flex; justify-content: flex-end; gap: 8px;
    background: var(--bg-soft); border-radius: 0 0 var(--r-lg) var(--r-lg);
  }

  /* CHARTS */
  .chart-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
  }
  .bar-stack { width: 100%; max-width: 32px; display: flex; flex-direction: column; justify-content: flex-end; height: 180px; }
  .bar-income { background: var(--accent); border-radius: 3px 3px 0 0; transition: height 0.5s ease; }
  .bar-expense { background: var(--danger); border-radius: 0 0 3px 3px; transition: height 0.5s ease; }
  .bar-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

  .chart-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 0 8px;
    border-bottom: 1px solid var(--line-soft);
  }

  /* DONUT */
  .donut-wrap { display: flex; align-items: center; gap: 24px; }
  .donut { position: relative; width: 160px; height: 160px; }
  .donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .donut-value { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; }
  .donut-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
  .legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
  .legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .legend-dot { width: 10px; height: 10px; border-radius: 2px; }

  /* INVOICE */
  .invoice-paper {
    background: white;
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-width: 800px;
    margin: 0 auto;
  }
  .invoice-header { display: flex; justify-content: space-between; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 2px solid var(--ink); }
  .invoice-title { font-family: 'Fraunces', serif; font-size: 36px; font-weight: 600; }
  .invoice-meta { text-align: right; font-size: 13px; }
  .invoice-meta strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
  .invoice-section { margin-bottom: 24px; }
  .invoice-totals { margin-top: 16px; max-width: 320px; margin-left: auto; }
  .invoice-totals-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
  .invoice-totals-row.total { font-size: 18px; font-weight: 600; border-top: 2px solid var(--ink); padding-top: 12px; margin-top: 8px; }

  /* FILTER BAR */
  .filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .filter-bar input, .filter-bar select { width: auto; min-width: 160px; }

  /* ─── TABS ─── */
  .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
  .tab {
    padding: 8px 16px; font-size: 12.5px; font-weight: 600;
    color: var(--muted); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color 0.12s; letter-spacing: -0.01em;
  }
  .tab:hover { color: var(--ink); }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* TOAST */
  /* ─── TOAST ─── */
  .toast {
    position: fixed; bottom: 28px; right: 28px; z-index: 9999;
    background: var(--ink); color: #f9fafb;
    padding: 12px 20px; border-radius: var(--r);
    font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
    pointer-events: none; border: 1px solid rgba(255,255,255,0.1);
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    visibility: hidden;
  }
  .toast.show { opacity: 1; transform: translateY(0); visibility: visible; }

  /* EMPTY STATE */
  .empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
  }
  .empty-icon { font-size: 32px; margin-bottom: 8px; }

  /* PRINT */
  @media print {
    .sidebar, .topbar, .topbar-actions, .filter-bar, .btn { display: none !important; }
    .main, .content { padding: 0 !important; }
    .invoice-paper { border: none; padding: 0; }
  }

  /* MISC */
  .row-flex { display: flex; gap: 8px; align-items: center; }
  .text-muted { color: var(--muted); }
  .text-accent { color: var(--accent); }
  .text-danger { color: var(--danger); }
  .text-warning { color: var(--warning); }
  .text-info { color: var(--info); }
  hr { border: none; border-top: 1px solid var(--line-soft); margin: 16px 0; }

  .ledger-debit { color: var(--accent); font-weight: 500; }
  .ledger-credit { color: var(--danger); font-weight: 500; }

  .progress-row { margin-bottom: 12px; }
  .progress-row-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
  .progress-bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
  .progress-fill { height: 100%; background: var(--accent); transition: width 0.5s ease; }

  /* ==============================================
     BUZÓN INTELIGENTE — DOCUMENT INTAKE
     ============================================== */
  .nav-magic {
    background: linear-gradient(90deg, rgba(160,125,42,0.12), rgba(160,125,42,0));
    border-left: 2px solid var(--gold);
    margin-bottom: 6px;
    position: relative;
  }
  .nav-magic::before {
    content: '✦';
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gold);
    font-size: 11px;
    opacity: 0.7;
  }
  .nav-pill {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
  }

  .inbox-hero {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #f5f3ee;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
  }
  .inbox-hero::before {
    content: '';
    position: absolute;
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(160,125,42,0.25) 0%, transparent 70%);
    pointer-events: none;
  }
  .inbox-hero-title {
    font-family: 'Fraunces', serif;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
  }
  .inbox-hero-sub {
    color: #a8a39a;
    font-size: 14px;
    max-width: 560px;
  }
  .inbox-hero-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 24px;
    position: relative;
  }
  .inbox-hero-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #8a8680;
    margin-bottom: 6px;
  }
  .inbox-hero-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 600;
    color: #f5f3ee;
  }

  .dropzone {
    border: 2px dashed var(--line);
    background: var(--bg-card);
    border-radius: 12px;
    padding: 48px 32px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 20px;
  }
  .dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
  }
  .dropzone-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--muted);
  }
  .dropzone.drag-over .dropzone-icon { color: var(--accent); }
  .dropzone-title {
    font-family: 'Fraunces', serif;
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 4px;
  }
  .dropzone-sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
  }
  .dropzone-formats {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .dropzone-formats .badge {
    background: var(--bg-soft);
    color: var(--ink-soft);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
    letter-spacing: 0.04em;
  }

  .doc-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 16px;
    align-items: start;
    transition: all 0.15s;
  }
  .doc-card:hover { border-color: var(--ink-soft); }
  .doc-card.processing {
    border-color: var(--info);
    background: linear-gradient(90deg, var(--info-soft) 0%, var(--bg-card) 100%);
  }
  .doc-card.auto-approved {
    border-color: var(--accent);
    border-left: 3px solid var(--accent);
  }
  .doc-card.needs-review {
    border-color: var(--warning);
    border-left: 3px solid var(--warning);
  }
  .doc-card.error {
    border-color: var(--danger);
    border-left: 3px solid var(--danger);
  }

  .doc-thumb {
    width: 80px;
    height: 100px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .doc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .doc-meta { min-width: 0; }
  .doc-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
  }
  .doc-type-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
  }
  .doc-type-bill { background: var(--danger-soft); color: var(--danger); }
  .doc-type-invoice { background: var(--accent-soft); color: var(--accent); }
  .doc-type-withholding { background: var(--info-soft); color: var(--info); }
  .doc-type-receipt, .doc-type-payment { background: var(--warning-soft); color: var(--warning); }
  .doc-type-bank { background: #d8d4ec; color: #4a3d8c; }
  .doc-type-payroll { background: #f0d9e3; color: #803960; }
  .doc-type-unknown { background: var(--bg-soft); color: var(--muted); }

  .confidence-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
  }
  .confidence-track {
    width: 60px;
    height: 4px;
    background: var(--bg-soft);
    border-radius: 2px;
    overflow: hidden;
  }
  .confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
  }
  .confidence-high .confidence-fill { background: var(--accent); }
  .confidence-mid .confidence-fill { background: var(--warning); }
  .confidence-low .confidence-fill { background: var(--danger); }

  .doc-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 16px;
    margin-top: 8px;
  }
  .doc-field { font-size: 12px; }
  .doc-field-label {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
  }
  .doc-field-value {
    font-weight: 500;
    color: var(--ink);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
  }
  .doc-field-value.text { font-family: 'Inter Tight', sans-serif; }
  .doc-field-warn {
    color: var(--warning);
    background: var(--warning-soft);
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
  }

  .doc-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    min-width: 130px;
  }
  .doc-actions .btn { width: 100%; justify-content: center; font-size: 12px; padding: 6px 10px; }

  .doc-progress-shimmer {
    position: relative;
    overflow: hidden;
    background: var(--info-soft);
    height: 3px;
    border-radius: 2px;
    margin-top: 10px;
  }
  .doc-progress-shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(44,82,130,0.6), transparent);
    animation: shimmer 1.4s linear infinite;
  }
  @keyframes shimmer { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }

  .doc-status-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
    color: var(--ink-soft);
  }
  .doc-status-line .dot-success { color: var(--accent); }
  .doc-status-line .dot-warning { color: var(--warning); }

  .inbox-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .inbox-tabs {
    display: inline-flex;
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
  }
  .inbox-tab {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-soft);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .inbox-tab.active {
    background: var(--bg-card);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  .inbox-tab .count {
    background: var(--bg-soft);
    color: var(--ink-soft);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
  }
  .inbox-tab.active .count { background: var(--ink); color: var(--bg-card); }

  .inbox-settings-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
  }
  .threshold-control {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
  }
  .threshold-control input[type="range"] {
    width: 180px;
    accent-color: var(--accent);
  }
  .threshold-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent);
    min-width: 40px;
  }

  .inbox-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
  }
  .inbox-empty-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.4; }

  .preview-modal-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    max-height: 70vh;
  }
  .preview-pane {
    background: var(--bg-soft);
    border-radius: 8px;
    overflow: auto;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .preview-pane img {
    max-width: 100%;
    height: auto;
    display: block;
  }
  .preview-pane pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink-soft);
    width: 100%;
  }
  .edit-pane { overflow-y: auto; max-height: 70vh; padding-right: 8px; }
  .edit-pane .form-row { margin-bottom: 12px; }
  .edit-pane label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .edit-pane input, .edit-pane select, .edit-pane textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    background: var(--bg-card);
  }
  .edit-pane input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .edit-pane .field-warn input { border-color: var(--warning); background: var(--warning-soft); }

  .api-config-banner {
    background: linear-gradient(90deg, var(--info-soft) 0%, var(--bg-card) 100%);
    border: 1px solid var(--info);
    border-left: 3px solid var(--info);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
  }
  .api-config-banner.success {
    background: linear-gradient(90deg, var(--accent-soft) 0%, var(--bg-card) 100%);
    border-color: var(--accent);
  }
  .api-config-banner.warn {
    background: linear-gradient(90deg, var(--warning-soft) 0%, var(--bg-card) 100%);
    border-color: var(--warning);
  }

  /* ==============================================
     MULTI-EMPRESA — Topbar Company Switcher
     ============================================== */
  .topbar-company {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 14px 8px 8px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 240px;
  }
  .topbar-company:hover {
    border-color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
  }
  .topbar-company-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--ink), #2d2620);
    color: var(--gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
  }
  .topbar-company-info {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
  }
  .topbar-company-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    margin-bottom: 2px;
    font-weight: 600;
  }
  .topbar-company-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-company-ruc {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    margin-top: 1px;
  }
  .topbar-company-arrow {
    color: var(--muted);
    flex-shrink: 0;
  }

  .company-menu {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: transparent;
    z-index: 1000;
    display: none;
  }
  .company-menu.active { display: block; }
  .company-menu-panel {
    position: absolute;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px;
    width: 380px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
    /* La posición real se setea por JS según el selector del topbar */
    top: 80px;
    right: 32px;
    animation: companyMenuIn 0.18s ease-out;
  }
  @keyframes companyMenuIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .company-menu-title {
    font-family: 'Fraunces', serif;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--ink);
  }
  .company-menu-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .company-menu-item:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .company-menu-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .company-menu-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--ink);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Fraunces', serif;
    flex-shrink: 0;
  }
  .company-menu-item-info { flex: 1; min-width: 0; }
  .company-menu-item-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .company-menu-item-ruc {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
  }
  .company-menu-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }
  .icon-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: all 0.15s;
  }
  .icon-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
  .icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
  .company-menu-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 0;
  }
  .company-menu-empty {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 20px 0;
  }

  .company-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .company-form-grid .form-row { margin-bottom: 0; }
  .company-form-grid .full { grid-column: span 2; }

  /* === COMPANY FORM (rediseñado) === */
  .cf-section {
    padding: 18px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .cf-section:first-child { padding-top: 4px; }
  .cf-section:last-child { border-bottom: 0; padding-bottom: 4px; }

  .cf-section-title {
    font-family: 'Fraunces', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
  }
  .cf-section-sub {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 14px;
  }

  .cf-row {
    margin-bottom: 14px;
  }
  .cf-row:last-child { margin-bottom: 0; }
  .cf-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  @media (max-width: 720px) {
    .cf-row-2 { grid-template-columns: 1fr; gap: 14px; }
  }

  .cf-field { display: flex; flex-direction: column; min-width: 0; }

  .cf-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }
  .cf-req { color: var(--danger); font-weight: 700; }

  .cf-input {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
  }
  .cf-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .cf-input::placeholder { color: var(--muted); }
  .cf-mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; }

  select.cf-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23857a6e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
  }

  .cf-hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 5px;
  }

  .cf-logo-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: var(--bg-soft);
    border-radius: 10px;
    margin-bottom: 16px;
  }
  .cf-logo-preview {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--ink), #2d2620);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-family: 'Fraunces', serif;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
  }
  .cf-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .cf-logo-info { flex: 1; min-width: 0; }

  /* ==============================================
     DASHBOARD PERIOD SELECTOR
     ============================================== */
  .dash-period-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 18px;
    gap: 16px;
    flex-wrap: wrap;
  }
  .dash-period-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 2px;
  }
  .dash-period-value {
    font-family: 'Fraunces', serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.1;
  }
  .dash-period-tabs {
    display: inline-flex;
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    flex-wrap: wrap;
  }
  .dash-period-tab {
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-soft);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: transparent;
    font-family: inherit;
    white-space: nowrap;
  }
  .dash-period-tab:hover { color: var(--ink); }
  .dash-period-tab.active {
    background: var(--bg-card);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
  }

  /* ==============================================
     CONFIGURACIÓN DE MOTORES IA
     ============================================== */
  .ai-mode-card {
    display: flex;
    gap: 24px;
    align-items: center;
    background: var(--bg-soft);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
  }
  .ai-mode-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
  .ai-mode-sub { font-size: 12px; color: var(--muted); }
  .ai-mode-options { display: flex; gap: 8px; }
  .ai-mode-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg-card);
    transition: all 0.15s;
    min-width: 200px;
  }
  .ai-mode-opt:hover { border-color: var(--ink-soft); }
  .ai-mode-opt:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .ai-mode-opt input { accent-color: var(--accent); }
  .ai-mode-opt-title { font-size: 13px; font-weight: 600; color: var(--ink); }
  .ai-mode-opt-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

  .ai-engines-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }
  .ai-engine-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
  }
  .ai-engine-card.enabled {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
  }
  .ai-engine-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
  }
  .ai-engine-card.enabled .ai-engine-header {
    background: linear-gradient(90deg, var(--accent-soft) 0%, var(--bg-card) 100%);
  }
  .ai-engine-logo {
    width: 38px; height: 38px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }
  .ai-engine-logo.ollama { background: #f4f0e6; color: #6d4a2b; }
  .ai-engine-logo.gemini { background: linear-gradient(135deg, #4796e3, #7b6fdc); color: white; font-weight: bold; }
  .ai-engine-logo.claude { background: linear-gradient(135deg, #c08456, #8a5a3a); color: white; font-weight: bold; }

  .ai-engine-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .ai-engine-tag {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
  }

  .ai-badge-free, .ai-badge-paid {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: none;
    letter-spacing: 0;
  }
  .ai-badge-free { background: var(--accent-soft); color: var(--accent); }
  .ai-badge-paid { background: var(--warning-soft); color: var(--warning); }

  .ai-toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
  }
  .ai-toggle input { opacity: 0; width: 0; height: 0; }
  .ai-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--line);
    border-radius: 12px;
    transition: 0.2s;
  }
  .ai-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  }
  .ai-toggle input:checked + .ai-toggle-slider { background: var(--accent); }
  .ai-toggle input:checked + .ai-toggle-slider::before { transform: translateX(18px); }

  .ai-engine-body { padding: 14px 18px; }
  .ai-engine-desc {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin: 0 0 12px;
    line-height: 1.55;
  }
  .ai-field-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
  }
  .ai-field { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .ai-field-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 5px;
    font-weight: 600;
  }
  .ai-input {
    padding: 8px 12px;
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-family: inherit;
    color: var(--ink);
  }
  .ai-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
  }
  select.ai-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23857a6e' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
  }
  .ai-test-row {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .ai-status {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
  }
  .ai-status.ok { color: var(--accent); }
  .ai-status.error { color: var(--danger); }
  .ai-status.testing { color: var(--info); }

  .ai-threshold-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-soft);
    border-radius: 10px;
    padding: 14px 18px;
  }
  .ai-threshold-card input[type="range"] {
    width: 180px;
    accent-color: var(--accent);
  }

  /* === Guía de instalación Ollama === */
  .setup-step {
    display: flex;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .setup-step:last-of-type { border-bottom: 0; }
  .setup-step-num {
    width: 32px; height: 32px;
    background: var(--ink);
    color: var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
  }
  .setup-step-body { flex: 1; min-width: 0; }
  .setup-step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
  }
  .setup-step-body p {
    font-size: 13px;
    color: var(--ink-soft);
    margin: 0 0 10px;
    line-height: 1.55;
  }
  .setup-code {
    display: flex;
    align-items: center;
    background: var(--ink);
    color: #e8e3d8;
    padding: 10px 14px;
    border-radius: 7px;
    margin: 8px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    justify-content: space-between;
    gap: 12px;
  }
  .setup-code code {
    color: var(--gold);
    font-family: inherit;
    background: transparent;
    padding: 0;
  }
  .setup-copy {
    background: rgba(255,255,255,0.1);
    color: #e8e3d8;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .setup-copy:hover { background: rgba(255,255,255,0.18); }
  .setup-note {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
  }
  .setup-details {
    background: var(--bg-soft);
    border-radius: 7px;
    padding: 10px 14px;
    margin: 8px 0;
  }
  .setup-details summary {
    cursor: pointer;
    font-size: 13px;
    user-select: none;
  }
  .setup-details ol, .setup-details ul {
    margin: 10px 0 6px 18px;
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.7;
  }
  .setup-details code {
    background: var(--ink);
    color: var(--gold);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
  }
  .setup-success {
    margin-top: 20px;
    padding: 14px 18px;
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 7px;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.55;
  }

  .badge-rimpe {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  /* ==============================================
     GENERADOR ATS
     ============================================== */
  .ats-period-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
  }
  .ats-period-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr) auto;
    gap: 12px;
    align-items: end;
  }
  .ats-validation {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
  }
  .ats-check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
  }
  .ats-check-row:last-child { border-bottom: 0; }
  .ats-check-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 13px;
  }
  .ats-check-icon.ok { background: var(--accent-soft); color: var(--accent); }
  .ats-check-icon.warn { background: var(--warning-soft); color: var(--warning); }
  .ats-check-icon.fail { background: var(--danger-soft); color: var(--danger); }
  .ats-check-text { flex: 1; }
  .ats-check-detail { font-size: 11px; color: var(--muted); margin-top: 2px; }

  .ats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
  }
  .ats-stat {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
  }
  .ats-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .ats-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
  }
  .ats-stat-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
  }

  .ats-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
  }

  /* ZIP progress overlay */
  .zip-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
  }
  .zip-progress-overlay.active { display: flex; }
  .zip-progress-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    text-align: center;
  }
  .zip-progress-title {
    font-family: 'Fraunces', serif;
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 8px;
  }
  .zip-progress-status {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 20px;
  }
  .zip-progress-bar {
    height: 8px;
    background: var(--bg-soft);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
  }
  .zip-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #4a8060);
    transition: width 0.2s ease;
    border-radius: 4px;
  }
  .zip-progress-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--ink-soft);
  }
  /* ==============================================
     PAGINACIÓN DE LISTAS GRANDES
     ============================================== */
  .pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-soft);
    border-top: 1px solid var(--line);
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
  }
  .pagination-info {
    color: var(--muted);
    font-size: 12px;
  }
  .pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .pagination-page {
    color: var(--ink);
    font-weight: 600;
    padding: 0 8px;
    min-width: 60px;
    text-align: center;
  }
  .pagination-bar button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }
