/* ============================================================
   SPYRO INTELLIGENCE — Design System v6 (Inbox/Bandeja)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f8f9fc; --bg-white: #fff; --bg-subtle: #f1f2f6;
  --border: #e0e2ea; --border-light: #ecedf2;
  --text: #1a1b2e; --text-secondary: #555770; --text-muted: #8b8da0;
  --accent: #6c5ce7; --accent-light: #f0edff; --accent-hover: #5a49d6;
  --green: #059669; --green-bg: #ecfdf5; --green-border: #a7f3d0;
  --red: #dc2626; --red-bg: #fef2f2; --red-border: #fecaca;
  --orange: #d97706; --orange-bg: #fffbeb;
  --purple: #6c5ce7; --purple-bg: #f0edff;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
  --transition: .2s ease;
  --sidebar-width: 200px;
  --sidebar-bg: #1a1b2e;
  --sidebar-text: rgba(255,255,255,.6);
  --sidebar-text-active: #fff;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(108,92,231,.25);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Inter',system-ui,sans-serif; background:var(--bg); color:var(--text); font-size:14px; line-height:1.5; -webkit-font-smoothing:antialiased; }

/* ─── Layout ─── */
.app-layout { display:flex; min-height:100vh; }
.main-content { flex:1; margin-left:var(--sidebar-width); padding:24px 32px; max-width:1440px; }  /* cap base para modo clásico/theme=off; el tema Linear lo refina con --content-max (Codex #138 P3) */

/* ─── Sidebar ─── */
.sidebar { position:fixed; left:0; top:0; bottom:0; width:var(--sidebar-width); background:var(--sidebar-bg); display:flex; flex-direction:column; z-index:200; }
.sidebar-header { padding:16px 16px 12px; display:flex; align-items:center; gap:10px; border-bottom:1px solid rgba(255,255,255,.06); }
.sidebar-logo { width:32px; height:32px; border-radius:8px; background:linear-gradient(135deg,#6c5ce7,#a78bfa); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.sidebar-logo svg { width:18px; height:18px; }
.sidebar-brand-name { font-size:14px; font-weight:800; color:#fff; }
.sidebar-brand-sub { font-size:9px; font-weight:500; color:rgba(255,255,255,.3); text-transform:uppercase; letter-spacing:.5px; }
.sidebar-brand { display:flex; flex-direction:column; }
.sidebar-nav { flex:1; padding:8px 8px; display:flex; flex-direction:column; gap:2px; }
.sidebar-section-label { font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.8px; color:rgba(255,255,255,.2); padding:12px 10px 4px; }
.sidebar-link { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:6px; color:var(--sidebar-text); text-decoration:none; font-size:13px; font-weight:500; transition:all .15s; cursor:pointer; }
.sidebar-link:hover { background:var(--sidebar-hover); color:var(--sidebar-text-active); }
.sidebar-link.active { background:var(--sidebar-active-bg); color:var(--sidebar-text-active); }
.sidebar-link.disabled { opacity:.3; cursor:default; }
.sidebar-link svg { width:18px; height:18px; flex-shrink:0; opacity:.7; }
.sidebar-link.active svg { opacity:1; }
.nav-badge { margin-left:auto; background:var(--accent); color:#fff; font-size:10px; font-weight:700; padding:2px 6px; border-radius:10px; }
.nav-badge:empty { display:none; }  /* Ocultar en paginas que no actualizan el contador */
.sidebar-footer { padding:12px; border-top:1px solid rgba(255,255,255,.06); }
.sidebar-user { display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:6px; }
.sidebar-avatar { width:28px; height:28px; border-radius:6px; background:linear-gradient(135deg,#6c5ce7,#a78bfa); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; font-size:12px; flex-shrink:0; }
.sidebar-user-info { flex:1; min-width:0; }
.sidebar-user-name { font-size:12px; font-weight:600; color:#fff; }
.sidebar-user-role { font-size:10px; color:rgba(255,255,255,.3); }
.sidebar-logout { color:rgba(255,255,255,.3); display:flex; transition:var(--transition); }
.sidebar-logout:hover { color:var(--red); }
.sidebar-logout svg { width:16px; height:16px; }

/* ─── Stats Bar ─── */
/* Tarjetas KPI ocultas: las pestañas + .bandeja-summary ya cubren esta información */
.stats-bar { display:none !important; }
.m-stats { display:none !important; }
/* Selector original conservado para facil reactivacion futura:
.stats-bar { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
*/

.stat-card {
  background:var(--bg-white);
  border:1px solid var(--border);
  border-radius:var(--r);
  padding:18px 20px;
  box-shadow:var(--shadow);
  display:flex; align-items:center; gap:14px;
  transition:all .2s ease;
  position:relative;
  overflow:hidden;
}

.stat-card::before {
  content:'';
  position:absolute; left:0; top:0; bottom:0; width:3px;
  border-radius:0 2px 2px 0;
}

.stat-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-md); }

.stat-card.orange::before { background:var(--orange); }
.stat-card.accent::before { background:var(--accent); }
.stat-card.neutral::before { background:var(--text-muted); }
.stat-card.green::before { background:var(--green); }

.stat-icon {
  width:42px; height:42px;
  border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}

.stat-card.orange .stat-icon { background:var(--orange-bg); color:var(--orange); }
.stat-card.accent .stat-icon { background:var(--accent-light); color:var(--accent); }
.stat-card.neutral .stat-icon { background:var(--bg-subtle); color:var(--text-muted); }
.stat-card.green .stat-icon { background:var(--green-bg); color:var(--green); }

.stat-body { flex:1; min-width:0; }
.stat-value { font-size:24px; font-weight:800; color:var(--text); line-height:1.1; }
.stat-card.orange .stat-value { color:var(--orange); }
.stat-card.green .stat-value { color:var(--green); }
.stat-label { font-size:11px; font-weight:500; color:var(--text-muted); text-transform:uppercase; letter-spacing:.3px; margin-top:3px; }

/* ─── Upload Zone (Premium) ─── */
.upload-section { margin-bottom:20px; }

.dropzone {
  display:flex; align-items:center; gap:12px;
  padding:14px 20px;
  border:2px dashed var(--border);
  border-radius:var(--r);
  cursor:pointer;
  transition:all .25s ease;
  background:var(--bg-white);
}

.dropzone:hover {
  border-color:var(--accent);
  background:var(--accent-light);
  transform:translateY(-1px);
  box-shadow:0 4px 16px rgba(108,92,231,.1);
}

.dropzone.active {
  border-color:var(--accent);
  background:var(--accent-light);
  border-style:solid;
  transform:scale(1.005);
  box-shadow:0 0 0 4px rgba(108,92,231,.12), 0 8px 24px rgba(108,92,231,.12);
}

.dropzone-icon {
  width:40px; height:40px;
  border-radius:10px;
  background:linear-gradient(135deg, var(--accent-light), rgba(108,92,231,.15));
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  color:var(--accent);
  transition:transform .3s ease;
}

.dropzone:hover .dropzone-icon { transform:translateY(-2px); }
.dropzone.active .dropzone-icon { transform:scale(1.1); animation:iconBounce .5s ease; }

@keyframes iconBounce {
  0%,100% { transform:scale(1.1); }
  50% { transform:scale(1.2); }
}

.dropzone-text { flex:1; }
.dropzone-title { font-size:14px; font-weight:700; color:var(--text); margin-bottom:2px; }
.dropzone-hint { font-size:13px; color:var(--text-muted); }
.dropzone:hover .dropzone-title { color:var(--accent); }

/* ─── Upload Queue (Compact card with header + scrollable list) ─── */
.upload-queue {
  margin-top:10px;
  background:var(--bg-white);
  border:1px solid var(--border-light);
  border-radius:var(--r);
  overflow:hidden;
}

.upload-queue-header {
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
  padding:10px 14px;
  background:var(--bg-subtle);
  border-bottom:1px solid var(--border-light);
}

.upload-queue.collapsed .upload-queue-header { border-bottom:none; }

.upload-queue-summary {
  font-size:12px; font-weight:600;
  color:var(--text);
  flex:1; min-width:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  line-height:1.3;
}

.upload-queue-toggle {
  background:transparent;
  border:1px solid var(--border);
  color:var(--text-muted);
  font-size:11px; font-weight:600;
  padding:5px 10px;
  border-radius:6px;
  cursor:pointer;
  transition:border-color .15s ease, color .15s ease, background .15s ease;
  flex-shrink:0;
  white-space:nowrap;
}

.upload-queue-toggle:hover {
  border-color:var(--accent);
  color:var(--accent);
  background:var(--accent-light);
}

.upload-queue-list {
  display:flex; flex-direction:column; gap:6px;
  padding:8px 10px;
  max-height:220px;
  overflow-y:auto;
  overscroll-behavior:contain;
}

.upload-queue.collapsed .upload-queue-list { display:none; }

.upload-item {
  display:flex; align-items:center; gap:12px;
  padding:10px 16px;
  background:var(--bg-white);
  border:1px solid var(--border-light);
  border-radius:var(--r-sm);
  animation:itemSlideIn .3s ease;
}

@keyframes itemSlideIn {
  from { opacity:0; transform:translateY(-8px); }
  to { opacity:1; transform:translateY(0); }
}

/* Salida de una tarjeta cuando su factura ya aparece en la tabla "Por revisar". */
.upload-item.removing {
  opacity:0;
  transform:translateX(8px);
  max-height:0;
  transition:opacity .35s ease, transform .35s ease, max-height .35s ease;
  overflow:hidden;
}

.upload-item-icon {
  width:36px; height:36px;
  border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  font-size:11px; font-weight:700;
}

.upload-item-icon.processing {
  background:var(--accent-light); color:var(--accent);
}
.upload-item-icon.done {
  background:var(--green-bg); color:var(--green);
}
.upload-item-icon.error {
  background:var(--red-bg); color:var(--red);
}
.upload-item-icon.waiting {
  background:var(--bg-subtle); color:var(--text-muted);
}

.upload-item-info { flex:1; min-width:0; }
.upload-item-name { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.upload-item-status { font-size:11px; color:var(--text-muted); margin-top:1px; }
.upload-item-status.processing { color:var(--accent); }
.upload-item-status.done { color:var(--green); }
.upload-item-status.error { color:var(--red); }

.upload-item-progress {
  width:100%; height:3px;
  background:var(--bg-subtle);
  border-radius:2px;
  overflow:hidden;
  margin-top:4px;
}

.upload-item-progress-fill {
  height:100%;
  background:var(--accent);
  border-radius:2px;
  transition:width .3s ease;
  animation:progressPulse 1.5s ease infinite;
}

@keyframes progressPulse {
  0%,100% { opacity:1; }
  50% { opacity:.6; }
}

.upload-item-progress-fill.done {
  background:var(--green);
  animation:none;
  width:100% !important;
}

.upload-item-check {
  width:24px; height:24px;
  flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}

/* Spinner */
.spinner {
  width:18px; height:18px;
  border:2px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin .7s linear infinite;
}

@keyframes spin { to { transform:rotate(360deg); } }

/* ─── Page Header ─── */
.page-header { margin-bottom:20px; }
.page-title { font-size:26px; font-weight:800; color:var(--text); letter-spacing:-.5px; line-height:1.2; }
.page-subtitle { font-size:14px; color:var(--text-muted); margin-top:2px; }

/* ─── Filters ─── */
.filters-bar { display:flex; gap:8px; margin-bottom:14px; align-items:center; }

.filter-search-wrap {
  position:relative; flex:1; max-width:300px;
}
.filter-search-icon {
  position:absolute; left:10px; top:50%; transform:translateY(-50%);
  color:var(--text-muted); pointer-events:none;
  transition:color .2s;
}
.filter-search-wrap:focus-within .filter-search-icon { color:var(--accent); }

.filter-input {
  width:100%; padding:8px 12px 8px 34px;
  border:1px solid var(--border); border-radius:8px;
  font-size:13px; font-family:inherit;
  background:var(--bg-white); outline:none;
  transition:all .2s ease;
}
.filter-input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(108,92,231,.08); }
.filter-input:not(:placeholder-shown) { border-color:var(--accent); background:var(--accent-light); }

.filter-select {
  padding:8px 28px 8px 12px;
  border:1px solid var(--border); border-radius:8px;
  font-size:13px; font-family:inherit;
  background:var(--bg-white); outline:none; cursor:pointer;
  transition:all .2s ease;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8da0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 10px center;
}
.filter-select:focus { border-color:var(--accent); }
.filter-select.active { border-color:var(--accent); background-color:var(--accent-light); }

.filter-count {
  font-size:12px; font-weight:600; color:var(--text-muted);
  white-space:nowrap; margin-left:4px;
  transition:color .2s;
}

/* ─── Invoice Table ─── */
/* Scroll interno: la tabla ocupa una altura fija (viewport - cabecera) y el
   scroll ocurre DENTRO de la tabla, no en la página. Patrón Gmail/Linear:
   thead sticky + wrapper con overflow-y auto. El cálculo de altura resta
   la altura estimada del header + filtros + pestañas. */
.invoice-table-wrap {
  background:var(--bg-white); border:1px solid var(--border);
  border-radius:var(--r); box-shadow:var(--shadow);
  /* ≈ header(60) + upload-zone densificada(~70) + filtros(40) + pestañas(50) +
     toolbar(30). Densificada la pila superior, se recupera altura de tabla. */
  max-height: calc(100vh - 250px); min-height: 300px;
  overflow-y: auto;
}
/* table-layout:auto — cada columna se dimensiona por su CONTENIDO (patrón tabla
   financiera Stripe/Mercury). El € NO se parte porque el importe lleva NBSP
   (espacio duro entre cifra y €, en app.js) + `white-space:nowrap` en Total, así
   que NO hace falta `fixed`. Con `fixed` los anchos los fijaba la fila de cabecera
   (los <th> no llevan las clases col-*, solo los <td>), así que TODAS las columnas
   sin clase caían a ~136px iguales y ahogaban Proveedor a 3 líneas. Con `auto`,
   Proveedor respira en 1 línea; las de icono van estrechas; Alertas se capa con
   max-width (más abajo). Verificado offline: prov 16px(1 línea)/euro 16px(1 línea). */
.invoice-table { width:100%; border-collapse:collapse; table-layout:auto; }
/* col-check (36px) y col-status (32px) ya tienen ancho propio mas abajo; aqui solo
   la celda de cuerpo del estado, alineada con su cabecera (32px). Evita duplicar. */
.invoice-table .col-status-cell  { width:32px; }
.invoice-table .row-actions-cell { width:40px; }
/* Columnas de dato corto en una sola línea (legibilidad) */
.invoice-table .col-invoice-num,
.invoice-table .col-date,
.invoice-table .col-time         { white-space:nowrap; }
/* Total: reserva mínima, nunca parte, cifras tabulares para alinear (Vercel/Mercury) */
.invoice-table td.col-total,
.invoice-table th.align-right { min-width:11ch; white-space:nowrap; font-variant-numeric:tabular-nums; }
.invoice-table th {
  text-align:left; font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:.5px; color:var(--text-muted); padding:8px 14px;
  border-bottom:2px solid var(--border); background:var(--bg-subtle);
  /* Sticky: el thead queda fijo mientras el tbody scrollea. */
  position: sticky; top: 0; z-index: 10;
}
.invoice-table td { padding:9px 14px; font-size:13px; border-bottom:1px solid var(--border-light); transition:background .15s; }
.invoice-table tr:last-child td { border-bottom:none; }

/* Fila "oracle-only": factura ya en Spyro que no volcamos nosotros (la
   metió Miren manualmente). No abre detail, checkbox deshabilitado. */
.inv-row.oracle-only { cursor: default; background: rgba(108,92,231,.02); }
.inv-row.oracle-only:hover td { background: rgba(108,92,231,.05); }
.inv-row.oracle-only:hover { box-shadow: none; }
.oracle-tag {
  display:inline-block; font-size:10px; font-weight:600;
  padding:2px 6px; margin-left:6px; border-radius:4px;
  background:rgba(108,92,231,.12); color:var(--accent);
  text-transform:uppercase; letter-spacing:.3px; vertical-align:middle;
}

/* Chip de origen — distingue facturas volcadas por TKV Intelligence
   (nuestras) de las introducidas a mano en el ERP por Miren u otros. */
.origen-tag {
  display:inline-block; font-size:10px; font-weight:600;
  padding:2px 7px; margin-left:6px; border-radius:10px;
  letter-spacing:.2px; vertical-align:middle; cursor:help;
}
.origen-tag.origen-si {
  background:rgba(108,92,231,.12); color:var(--accent);
  border:1px solid rgba(108,92,231,.25);
}
.origen-tag.origen-manual {
  background:rgba(120,120,128,.10); color:#666;
  border:1px solid rgba(120,120,128,.20);
}

.inv-row {
  cursor:pointer;
  transition:all .15s ease;
  position:relative;
}

.inv-row:hover td { background:rgba(108,92,231,.04); }
.inv-row:hover { box-shadow:inset 3px 0 0 var(--accent); }
.inv-row:active td { background:rgba(108,92,231,.08); }

/* Amount column emphasis */
.inv-row td:nth-child(5) { font-size:14px; }

/* Row actions */
.row-actions-cell { display:flex; gap:4px; opacity:.3; transition:opacity .2s ease; }
.inv-row:hover .row-actions-cell { opacity:1; }
.row-btn { width:30px; height:30px; border:none; background:none; border-radius:8px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text-muted); transition:all .15s; }
.row-btn:hover { transform:scale(1.1); }
.row-btn.archive:hover { background:var(--accent-light); color:var(--accent); }
.row-btn.delete:hover { background:var(--red-bg); color:var(--red); }

/* New row animation */
.inv-row { animation:rowFadeIn .4s ease; }
@keyframes rowFadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

/* Destello de fila recién llegada (refresco fluido en vivo). Fondo verde de
   marca que se desvanece — liga con el "verde = listo" de la cola de subida.
   Duración de notificación pasiva (NN/G); JS retira .row-new al acabar. */
@keyframes rowNewHighlight { 0% { background-color:var(--green-bg); } 100% { background-color:transparent; } }
.inv-row.row-new td { animation:rowNewHighlight 1.6s ease-out; }

/* Accesibilidad: con "reducir movimiento" desactivamos las animaciones de
   MOVIMIENTO (entrada con translateY). El destello es sólo cambio de color
   (permitido por WCAG 2.3.3), pero lo neutralizamos igualmente por prudencia. */
@media (prefers-reduced-motion: reduce) {
  .inv-row { animation:none; }
  .inv-row.row-new td { animation:none; }
  .upload-item.removing { transition:none; } /* retirada instantánea, sin movimiento */
}

/* Texto sólo para lectores de pantalla (región de anuncios aria-live). */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

.status-dot.archived { background:var(--text-muted); opacity:.4; }
.status-label.archived { background:var(--bg-subtle); color:var(--text-muted); }
.col-status { width:32px; }

/* Status dots & labels */
.status-dot { display:inline-block; width:8px; height:8px; border-radius:50%; }
.status-dot.extracted, .status-dot.processing { background:#3b82f6; }
.status-dot.review { background:var(--orange); }
.status-dot.approved, .status-dot.pushed { background:var(--green); }
.status-dot.rejected, .status-dot.error { background:var(--red); }
.status-dot.uploaded { background:var(--text-muted); }

.status-label { display:inline-block; font-size:11px; font-weight:600; padding:3px 8px; border-radius:4px; }
.status-label.extracted, .status-label.processing { background:#dbeafe; color:#2563eb; }
.status-label.review { background:var(--orange-bg); color:var(--orange); }
.status-label.approved { background:var(--green-bg); color:var(--green); }
.status-label.pushed { background:#dbeafe; color:#2563eb; }
.status-label.rejected, .status-label.error { background:var(--red-bg); color:var(--red); }
.status-label.lg { font-size:13px; padding:5px 12px; }

/* Confidence pill */
.conf-pill { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.conf-pill.conf-high { background:var(--green-bg); color:var(--green); }
.conf-pill.conf-medium { background:var(--orange-bg); color:var(--orange); }
.conf-pill.conf-low { background:var(--red-bg); color:var(--red); }
.conf-pill.lg { font-size:12px; padding:4px 10px; }

/* Badge "fpago sustituida" — P-08. Aparece junto al campo Forma pago cuando
   el sistema cambió la fpago del PDF por una del histórico/fallback. Estilo
   warning suave para que el contable la vea sin bloquear flujo. */
.fpago-subst-badge {
  display:inline-block; margin-left:8px;
  font-size:11px; font-weight:600;
  padding:2px 8px; border-radius:10px;
  background:var(--orange-bg); color:var(--orange);
  cursor:help;
}

.empresa-badge { display:inline-block; padding:3px 10px; border-radius:6px; font-size:11px; font-weight:700; background:var(--accent-light); color:var(--accent); letter-spacing:.3px; transition:transform .15s; }
.inv-row:hover .empresa-badge { transform:scale(1.05); }
.empresa-name { display:inline-block; max-width:260px; font-size:13px; font-weight:400; color:var(--text-secondary); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:middle; text-transform:none; cursor:help; }

/* Banner "¿Por qué aparece este aviso?" en el detalle de la factura.
   Aparece tras el veredicto principal y antes de las comprobaciones. Muestra
   en una frase humana el motivo REAL del chip que el contable vio en la lista,
   sin jerga técnica. */
.alert-reason-banner {
  margin:16px 0 12px;
  padding:12px 14px;
  border-radius:10px;
  background:#fffaf3;
  border-left:4px solid var(--orange);
}
.alert-reason-title {
  font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.4px; color:var(--orange);
  margin-bottom:8px;
}
.alert-reason-item {
  display:flex; align-items:flex-start; gap:10px;
  padding:6px 0;
  font-size:14px; line-height:1.4;
}
.alert-reason-item + .alert-reason-item {
  border-top:1px solid rgba(0,0,0,.05);
}
.alert-reason-item.critical { color:var(--red); }
.alert-reason-item.critical ~ * { color:var(--red); }
.alert-reason-banner:has(.alert-reason-item.critical) {
  background:#fdf2f2;
  border-left-color:var(--red);
}
.alert-reason-banner:has(.alert-reason-item.critical) .alert-reason-title {
  color:var(--red);
}
.alert-reason-badge {
  display:inline-block; flex-shrink:0;
  padding:2px 8px; border-radius:8px;
  font-size:11px; font-weight:700;
  background:rgba(0,0,0,.05);
  white-space:nowrap;
}
.alert-reason-item.critical .alert-reason-badge {
  background:var(--red-bg); color:var(--red);
}
.alert-reason-item.warning .alert-reason-badge {
  background:var(--orange-bg); color:var(--orange);
}
.alert-reason-text { flex:1; }

/* ───────────────────────────────────────────────────────────────
   Batch actions — footer flotante de selección masiva.
   Aparece cuando hay ≥1 factura seleccionada. Permite volcar en
   lote las facturas "Revisadas" (verdes) sin abrirlas.
   Patrón Gmail/Linear/Notion. */
.batch-bar {
  position:fixed;
  left:50%; bottom:24px;
  transform:translateX(-50%);
  background:#0f172a;
  color:#fff;
  padding:12px 20px;
  border-radius:12px;
  box-shadow:0 10px 40px rgba(0,0,0,.25);
  display:flex; align-items:center; gap:24px;
  z-index:200;
  font-size:14px;
  animation:batchBarIn .2s cubic-bezier(.2,.8,.2,1);
  max-width:calc(100vw - 32px);
}
@keyframes batchBarIn {
  from { transform:translate(-50%, 40px); opacity:0; }
  to { transform:translate(-50%, 0); opacity:1; }
}
.batch-bar-info strong { color:#fff; }
.batch-bar-info .batch-empresas { color:#94a3b8; margin-left:4px; font-size:13px; }
.batch-bar-actions { display:flex; gap:8px; }
.batch-bar-actions .btn-primary { background:#10b981; border:none; }
.batch-bar-actions .btn-primary:hover { background:#059669; }
.batch-bar-actions .btn-primary:disabled {
  background:#64748b; color:#cbd5e1; cursor:not-allowed;
}
@media(max-width:640px) {
  .batch-bar {
    bottom:70px;  /* no taparse con bottom-nav mobile */
    flex-direction:column; align-items:stretch; gap:10px;
    padding:12px 16px;
  }
  .batch-bar-actions { justify-content:space-between; }
}

/* Modal batch confirmación */
.batch-modal-backdrop {
  position:fixed; inset:0; background:rgba(0,0,0,.4);
  z-index:450; animation:fadeIn .15s ease-out;
}
.batch-modal {
  position:fixed;
  top:50%; left:50%;
  transform:translate(-50%, -50%);
  width:min(520px, 92vw);
  max-height:86vh;
  background:#fff;
  border-radius:14px;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  z-index:460;
  display:flex; flex-direction:column;
  animation:batchModalIn .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes batchModalIn {
  from { transform:translate(-50%, calc(-50% + 20px)); opacity:0; }
  to { transform:translate(-50%, -50%); opacity:1; }
}
.batch-modal-head {
  padding:18px 22px;
  border-bottom:1px solid #e5e7eb;
  display:flex; align-items:center; justify-content:space-between;
}
.batch-modal-head h3 { margin:0; font-size:17px; font-weight:700; }
.batch-modal-close {
  background:transparent; border:none; cursor:pointer;
  font-size:26px; line-height:1; color:#6b7280;
  width:32px; height:32px; border-radius:6px;
}
.batch-modal-close:hover { background:#f3f4f6; }
.batch-modal-body {
  padding:18px 22px; flex:1; overflow-y:auto;
  font-size:14px; color:#374151;
}
.batch-modal-body table {
  width:100%; border-collapse:collapse; margin-top:10px;
}
.batch-modal-body th {
  text-align:left; font-size:11px; text-transform:uppercase;
  color:#6b7280; font-weight:600; padding:6px 8px;
  border-bottom:1px solid #e5e7eb;
}
.batch-modal-body td {
  padding:8px; font-size:13px; border-bottom:1px solid #f3f4f6;
}
.batch-modal-body .batch-row-ok { color:#059669; }
.batch-modal-body .batch-row-fail { color:#dc2626; }
.batch-modal-total {
  margin-top:14px; padding-top:12px;
  border-top:2px solid #e5e7eb;
  display:flex; justify-content:space-between;
  font-size:15px; font-weight:700;
}
.batch-modal-progress { padding:0 22px 18px; }
.batch-progress-bar {
  width:100%; height:8px; background:#e5e7eb; border-radius:4px; overflow:hidden;
}
.batch-progress-fill {
  height:100%; background:#10b981; width:0%;
  transition:width .3s ease;
}
.batch-progress-text {
  margin-top:8px; font-size:13px; color:#6b7280; text-align:center;
}
.batch-modal-actions {
  padding:14px 22px;
  border-top:1px solid #e5e7eb;
  display:flex; justify-content:flex-end; gap:10px;
}

/* Checkbox deshabilitado: solo en filas Oracle-only (no hay registro
   local que tocar). Las filas locales con chips amarillos/rojos quedan
   seleccionables — la restricción se aplica al volcado masivo, no a la
   selección ni al borrado. Cursor "no permitido" + tooltip al hover. */
.inv-row .row-check:disabled {
  cursor:not-allowed;
  opacity:.35;
}
.inv-row.has-alerts .col-check {
  position:relative;
}
.inv-row.has-alerts .col-check::after {
  content:"";  /* el tooltip se aplica vía title= en el input */
}

/* Fila con foco por teclado (navegación ↓↑). Distinguir de hover y
   selected. Patrón Linear: border-left azul + background suave. */
.inv-row.kbd-focus {
  box-shadow:inset 3px 0 0 var(--accent);
  background:rgba(99,102,241,.04);
}
.inv-row.kbd-focus.selected {
  background:rgba(99,102,241,.10);
}

/* Banner "Proveedor sin IBAN fichado" en el detalle. Invita al contable a
   dar de alta el IBAN del proveedor (tras confirmarlo por canal oficial)
   para que futuras facturas se auto-completen. Gris neutro (no alerta),
   es una ayuda/oportunidad, no un problema. */
.noiban-banner {
  margin:12px 0;
  padding:12px 14px;
  border-radius:10px;
  background:#f5f5f7;
  border-left:4px solid #6b7280;
}
.noiban-title {
  font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.4px; color:#374151;
  margin-bottom:8px;
}
.noiban-body { font-size:13px; color:#374151; line-height:1.45; }
.noiban-body p { margin:0 0 10px; }

/* Slide-over panel (patrón Stripe/Ramp para dar de alta metadatos).
   400px desde la derecha. No modal: el usuario puede ver la factura al lado. */
.slideover-backdrop {
  position:fixed; inset:0;
  background:rgba(0,0,0,.25);
  z-index:550;
  animation:fadeIn .15s ease-out;
}
.slideover {
  position:fixed; top:0; right:0; bottom:0;
  width:min(420px, 100vw);
  background:#fff;
  z-index:560;
  box-shadow:-4px 0 20px rgba(0,0,0,.1);
  display:flex; flex-direction:column;
  animation:slideInRight .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes slideInRight { from { transform:translateX(100%); } to { transform:translateX(0); } }
.slideover-head {
  padding:16px 20px; border-bottom:1px solid #e5e7eb;
  display:flex; align-items:center; justify-content:space-between;
}
.slideover-head h3 { margin:0; font-size:16px; font-weight:700; }
.slideover-close {
  background:transparent; border:none; cursor:pointer;
  font-size:24px; line-height:1; color:#6b7280;
  width:32px; height:32px; border-radius:6px;
}
.slideover-close:hover { background:#f3f4f6; }
.slideover-body { padding:18px 20px; overflow-y:auto; flex:1; }
.slideover-intro { font-size:13px; color:#374151; margin:0 0 16px; line-height:1.5; }
.slideover-label {
  display:block; font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:.3px;
  color:#374151; margin-bottom:6px;
}
.slideover-input {
  width:100%; box-sizing:border-box;
  padding:10px 12px; border:1px solid #d1d5db; border-radius:8px;
  font-size:14px; font-family:'SF Mono', Menlo, Consolas, monospace;
  letter-spacing:.5px;
}
.slideover-input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(99,102,241,.15); }
.slideover-hint {
  font-size:12px; color:#6b7280; margin:6px 0 14px; min-height:16px;
}
.slideover-hint.err { color:var(--red); }
.slideover-hint.ok { color:#059669; }
.slideover-check {
  display:flex; align-items:flex-start; gap:8px;
  font-size:13px; color:#374151; line-height:1.45;
  padding:10px 12px; background:#fffbeb; border-radius:8px;
  cursor:pointer;
}
.slideover-check input { margin-top:3px; flex-shrink:0; cursor:pointer; }
.slideover-warning {
  font-size:12px; color:#92400e; line-height:1.5;
  margin:10px 0 18px; padding:10px 12px;
  background:#fef3c7; border-radius:8px;
}
.slideover-actions {
  display:flex; justify-content:flex-end; gap:10px;
  margin-top:10px;
  padding-top:16px; border-top:1px solid #e5e7eb;
}
@media (max-width:900px) {
  .slideover { width:100vw; }
}

/* Banner "IBAN auto-completado desde Spyro" en el detalle. Aparece cuando
   el PDF trae un IBAN parcial/censurado que coincide parcialmente con uno
   activo del maestro. Color informativo (azul/gris), no alerta — es una
   ayuda, no un warning. */
.iban-hint-banner {
  margin:12px 0;
  padding:12px 14px;
  border-radius:10px;
  background:#eff6ff;
  border-left:4px solid #3b82f6;
}
.iban-hint-title {
  font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.4px; color:#1e40af;
  margin-bottom:8px;
}
.iban-hint-body { font-size:13px; color:#1e3a8a; }
.iban-hint-row { margin:4px 0; line-height:1.4; }
.iban-hint-label {
  display:inline-block; min-width:70px;
  font-weight:600; color:#1e40af;
}
.iban-hint-row code {
  font-family:'SF Mono', Menlo, Consolas, monospace;
  font-size:12px;
  background:rgba(255,255,255,.6);
  padding:1px 6px; border-radius:4px;
}
.iban-hint-resolved { font-weight:700; }
.iban-hint-note {
  margin-top:6px;
  font-size:12px; color:#475569;
  font-style:italic;
}

/* Alertas chips (columna "Alertas"). Combina color + icono + texto para
   cumplir WCAG (no depender solo del color). Varios chips se apilan con wrap.
   Mobile: solo el más grave (primero) para mantener densidad informativa. */
.col-alerts { min-width:0; max-width:220px; }
.col-alerts-head { font-weight:600; }
.alert-chip {
  display:inline-flex; align-items:center; gap:4px;
  font-size:12px; font-weight:600;
  padding:3px 8px; border-radius:10px;
  white-space:nowrap; line-height:1.2;
  margin-right:4px; margin-bottom:2px;
  vertical-align:middle;
}
.alert-chip svg { flex-shrink:0; }
.alert-chip-critical { background:var(--red-bg); color:var(--red); }
.alert-chip-warning { background:var(--orange-bg); color:var(--orange); }
/* Verde desaturado: confirma "lista para volcar" sin competir visualmente
   con los rojos/naranjas. En una bandeja 100% OK no satura la vista. */
.alert-chip-ok {
  background:rgba(16,185,129,.10);
  color:#059669;
}
/* Motivo corto junto al chip "Mírame" (ej: "· IBAN tapado"). Gris para
   subordinarlo al estado principal, patrón GitHub/Asana. */
.alert-chip-reason {
  color:#6b7280;
  font-weight:400;
  margin-left:2px;
  max-width:140px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
/* Señal visual sutil "fila lista para volcar" (sin alertas): borde verde
   lateral en hover, sin inundar la tabla de color. */
.inv-row.no-alerts:hover td:first-child { box-shadow:inset 3px 0 0 var(--green); }

/* ─── Detail Overlay ─── */
.detail-overlay {
  position:fixed; inset:0;
  background:rgba(0,0,0,.35);
  backdrop-filter:blur(6px);
  z-index:300;
  display:flex; justify-content:flex-end;
  animation:overlayFadeIn .2s ease;
}
@keyframes overlayFadeIn { from{opacity:0} to{opacity:1} }

.detail-panel {
  width:700px; max-width:100%;
  background:var(--bg-white);
  height:100%; overflow-y:auto;
  box-shadow:-8px 0 30px rgba(0,0,0,.12);
  animation:slideIn .3s cubic-bezier(.16,1,.3,1);
  padding:28px 32px;
  position:relative;
}
@keyframes slideIn { from{transform:translateX(40px);opacity:0} to{transform:translateX(0);opacity:1} }

/* Close button */
.detail-close {
  position:absolute; top:16px; right:16px;
  width:36px; height:36px;
  border:none; background:var(--bg-subtle);
  border-radius:10px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  color:var(--text-muted);
  transition:all .15s ease;
  z-index:1;
}
.detail-close:hover { background:var(--red-bg); color:var(--red); transform:scale(1.05); }

.detail-header {
  display:flex; justify-content:space-between; align-items:flex-start;
  margin-bottom:20px; padding-bottom:16px; padding-right:40px;
  border-bottom:2px solid var(--border-light);
}
.detail-header-left { flex:1; min-width:0; }
.detail-header h2 { font-size:20px; font-weight:800; margin-bottom:4px; letter-spacing:-.2px; }
.detail-header-badges { display:flex; gap:8px; align-items:center; flex-shrink:0; }
.spyro-match-label { display:inline-block; font-size:13px; color:#1a7f37; font-weight:600; margin-bottom:2px; }

.detail-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:16px; }
.dcard { padding:10px 14px; background:var(--bg-subtle); border-radius:var(--r-sm); border:1px solid var(--border-light); }
.dcard-label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.3px; color:var(--text-muted); margin-bottom:2px; }
.dcard-value { font-size:14px; font-weight:600; color:var(--text); }

.detail-section { margin-bottom:20px; padding-bottom:16px; border-bottom:1px solid var(--border-light); }
.detail-section:last-of-type { border-bottom:none; }
.detail-section-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--text-muted); margin-bottom:10px; display:flex; align-items:center; gap:8px; }

.detail-table { width:100%; border-collapse:collapse; }
.detail-table th { text-align:left; font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.2px; color:var(--text-muted); padding:6px 10px; border-bottom:2px solid var(--border); }
.detail-table td { padding:8px 10px; font-size:13px; border-bottom:1px solid var(--border-light); }
.detail-table tr:last-child td { border-bottom:none; }
.detail-table.compact td { padding:5px 8px; font-size:12px; }
.detail-table.compact th { padding:5px 8px; font-size:9px; }

.detail-totals {
  background:var(--bg-subtle); border-radius:var(--r);
  padding:16px 20px; margin-bottom:20px;
  border:1px solid var(--border-light);
}
.dt-item { display:flex; justify-content:space-between; padding:4px 0; font-size:13px; color:var(--text-secondary); }
.dt-item span:last-child { font-weight:600; color:var(--text); font-family:'SF Mono','Fira Code',monospace; font-size:13px; }
.dt-total {
  font-size:20px; font-weight:800; color:var(--green);
  padding-top:10px; margin-top:8px;
  border-top:2px solid var(--border);
}
.dt-total span:last-child { font-size:20px; }

/* TOTAL siempre visible + desglose colapsable (Punto 1 rediseño UX 2026-06-01) */
.detail-total-summary {
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 16px; margin:10px 0; background:var(--bg-subtle);
  border-radius:var(--r); border:1px solid var(--border-light);
  font-size:15px; color:var(--text-secondary);
}
.detail-total-summary strong { font-size:22px; font-weight:800; color:var(--green); }
details.factura-desglose { margin:4px 0 18px; }
/* "Ver desglose" con aspecto de BOTÓN (ajuste 06-02: antes era texto suelto que
   pasaba desapercibido). Inline-block con borde, fondo y hover, para que se vea
   claramente clicable y con comportamiento consistente. */
details.factura-desglose > summary {
  cursor:pointer; display:inline-flex; align-items:center; gap:6px;
  padding:8px 14px; color:var(--accent); font-weight:600; font-size:13px;
  list-style:none; user-select:none;
  background:var(--accent-light); border:1px solid var(--accent);
  border-radius:8px; transition:background .15s ease;
}
details.factura-desglose > summary:hover { background:color-mix(in srgb, var(--accent-light) 82%, var(--accent)); }
details.factura-desglose > summary::-webkit-details-marker { display:none; }
details.factura-desglose > summary::before { content:'\25b6'; font-size:10px; }
details.factura-desglose[open] > summary::before { content:'\25bc'; }
/* Abierto: el botón se atenúa (parece "pulsado/activo") */
details.factura-desglose[open] > summary { background:var(--bg-subtle); border-color:var(--border-light); color:var(--text-muted); }

.detail-actions {
  display:flex; align-items:center; gap:10px;
  padding:20px 0 4px; border-top:2px solid var(--border-light);
  position:sticky; bottom:0; background:var(--bg-white);
}
.action-spacer { flex:1; }

/* Approved banner */
.approved-banner {
  display:flex; align-items:center; gap:8px;
  width:100%; justify-content:center;
  padding:14px; font-size:15px; font-weight:700;
  color:var(--green); background:var(--green-bg);
  border-radius:var(--r-sm); border:1px solid var(--green-border);
  animation:approvedPulse .6s ease;
}
@keyframes approvedPulse {
  0% { transform:scale(.95); opacity:0; }
  50% { transform:scale(1.02); }
  100% { transform:scale(1); opacity:1; }
}

.detail-empty { padding:48px; text-align:center; color:var(--text-muted); font-size:14px; }

/* Validations */
.val-verdict { padding:10px 14px; border-radius:var(--r-sm); font-size:13px; font-weight:600; margin-bottom:10px; }
.val-verdict.ok { background:var(--green-bg); color:var(--green); border:1px solid var(--green-border); }
.val-verdict.critical { background:var(--red-bg); color:var(--red); border:1px solid var(--red-border); }
.val-verdict.warning { background:var(--orange-bg); color:var(--orange); border:1px solid #fde68a; }

.val-line { font-size:12px; padding:3px 0; }
.val-line.ok { color:var(--green); }
.val-line.critical { color:var(--red); font-weight:600; }
.val-line.warning { color:var(--orange); }
.val-line.info { color:var(--text-muted); font-size:11px; padding:2px 0 2px 8px; }

/* Subtitulos de seccion en zona veredicto (jerarquia visual) */
.val-section-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; margin:10px 0 4px; padding-bottom:3px; border-bottom:1px solid transparent; }
.val-section-title:first-child { margin-top:6px; }
.val-section-critical { color:var(--red); border-bottom-color:#fecaca; }
.val-section-warning { color:#b45309; border-bottom-color:#fde68a; }

/* Diagnostico interno — seccion plegable (avisos para admin/agente, no para personal) */
.internal-diag { margin-top:12px; padding:8px 12px; background:var(--bg-subtle); border:1px dashed var(--border); border-radius:var(--r-sm); font-size:11px; color:var(--text-muted); }
.internal-diag summary { cursor:pointer; font-weight:600; color:var(--text-secondary); padding:2px 0; list-style:none; user-select:none; }
.internal-diag summary::-webkit-details-marker { display:none; }
.internal-diag summary::before { content:'\25B6'; margin-right:6px; font-size:9px; transition:transform .2s; display:inline-block; }
.internal-diag[open] summary::before { transform:rotate(90deg); }
.internal-diag-body { margin:8px 0 4px; padding-left:14px; }
.internal-diag-line { padding:3px 0; line-height:1.5; }
.internal-diag-copy { margin-top:6px; background:var(--bg-white); border:1px solid var(--border); color:var(--text-secondary); font-size:11px; padding:4px 10px; border-radius:6px; cursor:pointer; }
.internal-diag-copy:hover { background:var(--accent-light); color:var(--accent); border-color:var(--accent); }

.val-detail-toggle { margin-top:6px; }
.val-detail-toggle summary { font-size:11px; color:var(--text-muted); cursor:pointer; padding:4px 0; }
.val-detail-toggle summary:hover { color:var(--accent); }

/* ─── Buttons ─── */
.btn {
  padding:10px 20px; border-radius:var(--r-sm);
  font-size:13px; font-weight:600; font-family:inherit;
  cursor:pointer; transition:all .2s ease;
  display:inline-flex; align-items:center; gap:6px; border:none;
}
.btn:active { transform:scale(.97); }
.btn-success { background:var(--green); color:#fff; box-shadow:0 2px 8px rgba(5,150,105,.25); }
.btn-success:hover { background:#047857; transform:translateY(-1px); box-shadow:0 4px 12px rgba(5,150,105,.3); }
.btn-success:disabled { opacity:.5; cursor:not-allowed; transform:none; box-shadow:none; }
.btn-primary { background:#2563eb; color:#fff; box-shadow:0 2px 8px rgba(37,99,235,.25); }
.btn-primary:hover { background:#1d4ed8; transform:translateY(-1px); box-shadow:0 4px 12px rgba(37,99,235,.3); }
.btn-primary:disabled { opacity:.5; cursor:not-allowed; transform:none; box-shadow:none; }
.btn-danger { background:var(--bg-white); color:var(--red); border:1px solid var(--red-border); }
.btn-danger:hover { background:var(--red-bg); transform:translateY(-1px); }
.btn-secondary { background:var(--bg-white); color:var(--text-secondary); border:1px solid var(--border); }
.btn-secondary:hover { border-color:var(--text-muted); transform:translateY(-1px); }
.btn-sm { padding:7px 14px; font-size:12px; }

/* ─── Toast ─── */
.toast {
  position:fixed; bottom:24px; right:24px;
  padding:14px 20px;
  border-radius:12px;
  font-size:13px; font-weight:600;
  z-index:1000; max-width:400px;
  box-shadow:0 8px 30px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  animation:toastIn .4s cubic-bezier(.16,1,.3,1);
  display:flex; align-items:center; gap:10px;
  transition:opacity .3s, transform .3s;
}
.toast-out { opacity:0; transform:translateY(8px); }
.toast-success { background:var(--green-bg); border:1px solid var(--green-border); color:var(--green); }
.toast-error { background:var(--red-bg); border:1px solid var(--red-border); color:var(--red); }
.toast-info { background:#dbeafe; border:1px solid #bfdbfe; color:#2563eb; }
.toast svg { flex-shrink:0; }
@keyframes toastIn { from{opacity:0;transform:translateY(16px) scale(.95)} to{opacity:1;transform:translateY(0) scale(1)} }

/* ─── Checkbox column ─── */
.col-check { width:36px; text-align:center; }
.col-check input, .row-check { width:16px; height:16px; accent-color:var(--accent); cursor:pointer; }

/* ─── Batch actions ─── */
.batch-actions { display:flex; align-items:center; gap:8px; margin-left:auto; animation:itemSlideIn .2s ease; }
.batch-count { font-size:12px; font-weight:700; color:var(--accent); white-space:nowrap; }

/* ─── Sortable headers ─── */
.sortable { cursor:pointer; user-select:none; position:relative; white-space:nowrap; }
.sortable:hover { color:var(--accent); }
.sortable::after { content:''; display:inline-block; width:0; height:0; margin-left:4px; vertical-align:middle; opacity:0; transition:opacity .15s; }
.sortable:hover::after { opacity:.3; border-left:4px solid transparent; border-right:4px solid transparent; border-top:5px solid currentColor; }
.sortable.sort-asc::after { opacity:1; border-left:4px solid transparent; border-right:4px solid transparent; border-bottom:5px solid var(--accent); border-top:none; }
.sortable.sort-desc::after { opacity:1; border-left:4px solid transparent; border-right:4px solid transparent; border-top:5px solid var(--accent); border-bottom:none; }

/* ─── Pagination ─── */
.pagination-bar { display:flex; align-items:center; justify-content:center; gap:12px; margin-top:14px; padding:8px 0; }
.page-info { font-size:12px; font-weight:600; color:var(--text-muted); }

/* ─── Empresa badge full name tooltip ─── */
.empresa-badge { position:relative; }
.empresa-badge .empresa-tooltip { display:none; position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); background:var(--sidebar-bg); color:#fff; font-size:11px; font-weight:500; padding:5px 10px; border-radius:6px; white-space:nowrap; z-index:50; pointer-events:none; }
.empresa-badge .empresa-tooltip::after { content:''; position:absolute; top:100%; left:50%; transform:translateX(-50%); border:5px solid transparent; border-top-color:var(--sidebar-bg); }
.empresa-badge:hover .empresa-tooltip { display:block; }

/* ─── Row selected state ─── */
.inv-row.selected td { background:var(--accent-light); }

/* ─── Utilities ─── */
.align-right { text-align:right; }
.nowrap { white-space:nowrap; }
.text-mono { font-family:'SF Mono','Fira Code',monospace; font-size:12px; }
.text-sm { font-size:12px; }
.text-muted { color:var(--text-muted); }
.text-red { color:var(--red); }
.text-green { color:var(--green); }
.empty-state {
  padding:48px 32px; text-align:center; color:var(--text-muted); font-size:14px;
}
.empty-state-icon {
  width:64px; height:64px; margin:0 auto 16px;
  border-radius:16px; background:var(--bg-subtle);
  display:flex; align-items:center; justify-content:center; color:var(--text-muted); opacity:.5;
}
.empty-state p { margin-top:6px; font-size:13px; }
.empty-state strong { color:var(--text-secondary); }
.hidden { display:none !important; }

/* ─── Microanimaciones ─── */

/* Stats counter animation */
.stat-value { transition:color .3s ease; }

/* Conf pill subtle pulse on high confidence */
.conf-pill.conf-high { animation:confPulse 2s ease-in-out 1; }
@keyframes confPulse { 0%,100%{opacity:1} 50%{opacity:.7} }

/* Status label smooth transitions */
.status-label { transition:all .2s ease; }

/* Smooth page load */
.main-content { animation:pageIn .4s ease; }
@keyframes pageIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* Dcard hover in detail panel */
.dcard { transition:border-color .15s, box-shadow .15s; }
.dcard:hover { border-color:var(--accent); box-shadow:0 0 0 2px rgba(108,92,231,.06); }

/* Val verdict entrance */
.val-verdict { animation:verdictIn .4s ease; }
@keyframes verdictIn { from{opacity:0;transform:translateX(-8px)} to{opacity:1;transform:translateX(0)} }

/* Smooth scroll behavior */
html { scroll-behavior:smooth; }

/* Selection color */
::selection { background:rgba(108,92,231,.15); color:var(--text); }

/* Focus visible for keyboard nav */
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }

/* ─── Mobile-only stats (hidden on desktop) ─── */
.m-stats { display:none; }

/* ─── Bottom nav (hidden on desktop) ─── */
.bottom-nav { display:none; }

/* ─── Responsive ─── */

/* Tablet (769px–1024px): sidebar collapses to icons */
@media (min-width:769px) and (max-width:1024px) {
  .sidebar { width:60px; }
  .sidebar-brand,.sidebar-link span,.sidebar-section-label,.sidebar-user-info,.nav-badge { display:none; }
  .sidebar-header { justify-content:center; padding:12px 8px; }
  .sidebar-link { justify-content:center; padding:10px; }
  .sidebar-footer { padding:8px; }
  .sidebar-user { justify-content:center; }
  .sidebar-logout { display:none; }
  .main-content { margin-left:60px; padding:16px; }
  .stats-bar { grid-template-columns:repeat(2,1fr); }
}

/* Mobile (≤768px): full redesign 2026 */
@media (max-width:768px) {
  /* ── Reset layout ── */
  .app-layout { flex-direction:column; }
  body { background:#F4F4F5; } /* zinc-100 */
  .sidebar { display:none; }

  /* ── Main content ── */
  .main-content {
    margin-left:0; padding:16px 16px 80px;
    padding-bottom:max(80px, calc(env(safe-area-inset-bottom) + 64px));
    animation:none;
  }

  /* ── Hide desktop elements ── */
  .page-header { display:none; }
  .stats-bar { display:none; }

  /* ── Mobile stats: compact inline bar ── */
  .m-stats {
    display:flex; gap:0; margin-bottom:16px;
    background:#fff; border-radius:12px;
    overflow:hidden;
  }
  .m-stat {
    flex:1; display:flex; flex-direction:column; align-items:center;
    padding:12px 8px;
    border-right:1px solid rgba(0,0,0,.06);
  }
  .m-stat:last-child { border-right:none; }
  .m-stat-num {
    font-size:22px; font-weight:700; letter-spacing:-0.03em;
    color:var(--text); line-height:1;
  }
  .m-stat-num.orange { color:#D97706; }
  .m-stat-num.green { color:#059669; }
  .m-stat-label {
    font-size:10px; font-weight:500; text-transform:uppercase;
    letter-spacing:.5px; color:var(--text-muted); margin-top:4px;
  }

  /* ── Upload zone: minimal ── */
  .upload-section { margin-bottom:12px; }
  .dropzone {
    padding:14px 16px; gap:12px;
    border:1.5px dashed rgba(0,0,0,.15); border-radius:12px;
    background:#fff;
  }
  .dropzone-icon {
    width:40px; height:40px; border-radius:10px;
    background:rgba(139,92,246,.08); /* accent at 8% */
  }
  .dropzone-icon svg { width:20px; height:20px; }
  .dropzone-title { font-size:14px; font-weight:600; }
  .dropzone-hint { font-size:12px; }
  .dropzone-hint .desktop-hint { display:none; }

  /* ── Upload queue: compact on mobile ── */
  .upload-queue-header { padding:8px 12px; }
  .upload-queue-summary { font-size:11px; }
  .upload-queue-toggle { font-size:10px; padding:4px 8px; }
  .upload-queue-list { max-height:160px; padding:6px 8px; }

  /* ── Filters: clean single row ── */
  .filters-bar { gap:8px; flex-wrap:wrap; margin-bottom:12px; }
  .filter-search-wrap { flex:1 1 100%; max-width:100%; }
  .filter-input {
    min-height:40px; font-size:16px; padding:8px 12px 8px 36px;
    border-radius:12px; background:#fff; border-color:transparent;
  }
  .filter-input:focus { border-color:var(--accent); background:#fff; }
  .filter-select {
    flex:1; min-height:40px; font-size:13px;
    padding:8px 28px 8px 12px;
    border-radius:12px; border-color:transparent; background:#fff;
  }
  .filter-count { width:100%; text-align:center; font-size:11px; }
  .batch-actions {
    width:100%; margin-left:0; justify-content:center;
    padding:8px 0;
  }

  /* ── Invoice cards: clean, no borders ── */
  .invoice-table-wrap {
    border:none; box-shadow:none; background:transparent; border-radius:0;
    /* En móvil el scroll lo hace la página — no forzamos altura interna. */
    max-height: none; min-height: 0; overflow: visible;
  }
  .invoice-table thead { display:none; }
  .invoice-table { display:block; }
  .invoice-table tbody { display:flex; flex-direction:column; gap:8px; padding:0; }

  .inv-row {
    display:grid;
    grid-template-columns:1fr auto;
    grid-template-rows:auto auto;
    gap:4px 12px;
    padding:14px 16px;
    border:none;
    border-radius:12px;
    background:#fff;
    cursor:pointer;
    transition:transform 150ms ease, opacity 150ms ease;
  }
  .inv-row:active { transform:scale(0.98); opacity:.9; }
  .inv-row:hover { box-shadow:none; }
  .inv-row td { padding:0; border-bottom:none; display:block; }

  /* Hide non-essential columns */
  .inv-row .col-check,
  .inv-row .col-status-cell,
  .inv-row .col-invoice-num,
  .inv-row .col-confidence,
  .inv-row .col-time,
  .inv-row .row-actions-cell { display:none; }

  /* Row 1: Proveedor + Total (dominant) */
  .inv-row td[data-label="Proveedor"] {
    grid-row:1; grid-column:1;
    font-size:14px; font-weight:500;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
    align-self:center;
  }
  .inv-row td[data-label="Proveedor"] br { display:none; }
  .inv-row td[data-label="Proveedor"] .text-sm { display:none; }
  .inv-row .col-total {
    grid-row:1; grid-column:2;
    text-align:right; font-size:18px; font-weight:700;
    letter-spacing:-0.02em;
    align-self:center; white-space:nowrap;
    color:var(--text);
  }

  /* Row 2: Fecha + Estado + Empresa */
  .inv-row .col-date {
    grid-row:2; grid-column:1;
    color:var(--text-muted); font-size:12px;
  }
  .inv-row .col-empresa {
    grid-row:2; grid-column:2;
    text-align:right;
  }
  .inv-row .col-estado {
    grid-row:2; grid-column:1;
    display:inline;
  }
  /* Date and estado on same line */
  .inv-row .col-date { display:inline; margin-right:8px; }

  /* Alertas en mobile: mostrar SOLO el más grave al lado de la fecha.
     Ocultamos el label de texto y el motivo corto para ahorrar espacio;
     queda icono + color. El aria-label del chip mantiene la accesibilidad. */
  .inv-row .col-alerts {
    grid-row:2; grid-column:1;
    display:inline;
    margin-left:8px;
  }
  .inv-row .col-alerts::before { content:""; }
  .inv-row .col-alerts .alert-chip { padding:2px 6px; font-size:11px; margin:0; }
  .inv-row .col-alerts .alert-chip + .alert-chip { display:none; }
  .inv-row .col-alerts .alert-chip-label { display:none; }
  .inv-row .col-alerts .alert-chip-reason { display:none; }

  /* Status badges: pill with semi-transparent bg */
  .status-label { border-radius:9999px; padding:2px 10px; font-size:11px; }

  /* ── Detail panel full-screen ── */
  .detail-overlay { z-index:400; }
  .detail-panel {
    width:100%; padding:16px;
    padding-top:max(16px, env(safe-area-inset-top));
    padding-bottom:max(80px, calc(env(safe-area-inset-bottom) + 64px));
    background:#F4F4F5;
  }
  .detail-close { top:10px; right:10px; width:40px; height:40px; border-radius:12px; }
  .detail-header { flex-direction:column; gap:6px; padding-right:48px; }
  .detail-header h2 { font-size:17px; letter-spacing:-0.02em; }
  .detail-grid { grid-template-columns:1fr 1fr; gap:8px; }
  .dcard { padding:10px 12px; border-radius:12px; background:#fff; border-color:transparent; }
  .dcard-label { font-size:10px; }
  .dcard-value { font-size:13px; }
  .detail-table th { font-size:9px; padding:5px 8px; }
  .detail-table td { padding:6px 8px; font-size:12px; }
  .detail-totals { padding:12px 16px; border-radius:12px; }
  .dt-total { font-size:18px; }
  .dt-total span:last-child { font-size:18px; }

  /* Veredicto */
  .zone-veredicto { border-radius:12px; }
  .veredicto-row { flex-direction:column; gap:10px; }
  .veredicto-action { width:100%; }
  .veredicto-action .btn { width:100%; justify-content:center; border-radius:12px; }

  /* Tech details */
  .tech-details { border-radius:12px; }

  /* Sticky action bar */
  .detail-actions {
    position:fixed; bottom:0; left:0; right:0;
    padding:12px 16px;
    padding-bottom:max(12px, env(safe-area-inset-bottom));
    background:#fff;
    border-top:1px solid rgba(0,0,0,.06);
    box-shadow:0 -4px 16px rgba(0,0,0,.06);
    z-index:410; margin:0;
  }
  .detail-actions-secondary { flex-wrap:wrap; }

  /* ── Bottom navigation ── */
  .bottom-nav {
    display:flex; align-items:center; justify-content:space-around;
    position:fixed; bottom:0; left:0; right:0; z-index:500;
    background:#fff;
    border-top:1px solid rgba(0,0,0,.06);
    padding:6px 0;
    padding-bottom:max(6px, env(safe-area-inset-bottom));
  }
  .bnav-item {
    display:flex; flex-direction:column; align-items:center; gap:2px;
    background:none; border:none; cursor:pointer;
    padding:6px 16px;
    color:var(--text-muted);
    font-size:10px; font-weight:500;
    transition:color .15s;
    -webkit-tap-highlight-color:transparent;
  }
  .bnav-item.active { color:#8B5CF6; }
  .bnav-item svg { transition:transform .15s; }
  .bnav-item:active svg { transform:scale(0.9); }

  /* ── Toast mobile ── */
  .toast { bottom:70px; right:16px; left:16px; top:auto; max-width:100%; border-radius:12px; }

  /* ── Pagination ── */
  .pagination-bar { gap:8px; margin-top:8px; padding-bottom:8px; }

  /* ── Edit pencils visible ── */
  .hover-only { opacity:0.5; }
  .btn-inline-edit { min-width:32px; min-height:32px; display:inline-flex; align-items:center; justify-content:center; }

  /* ── Touch-friendly buttons ── */
  .btn { min-height:44px; border-radius:12px; }
  .btn-sm { min-height:38px; padding:8px 14px; border-radius:10px; }
  .btn-lg { min-height:52px; padding:14px 24px; border-radius:12px; }
}

/* Extra small screens (< 400px) */
@media (max-width:400px) {
  .main-content { padding:12px 12px 80px; }
  .m-stat-num { font-size:20px; }
  .detail-grid { grid-template-columns:1fr; }
}

/* Description mapping (biblioteca de descripciones) */
.desc-warn { color:#e53e3e; cursor:help; font-size:0.9em; }
.desc-icon { font-size:0.9em; }
.desc-mapped { color:#38a169; cursor:help; font-size:0.9em; }
.btn-desc-edit { background:#edf2f7; border:1px solid #cbd5e0; border-radius:4px; cursor:pointer; font-size:0.85em; color:#4a90d9; padding:2px 6px; vertical-align:middle; transition:all .2s; margin-left:6px; }
.btn-desc-edit:hover { background:#4a90d9; color:#fff; border-color:#4a90d9; transform:scale(1.05); }
tr:hover .btn-desc-edit { background:#e2e8f0; }
.desc-mapping-input { border:1px solid #cbd5e0; border-radius:4px; padding:3px 6px; font-family:inherit; }
.desc-mapping-input:focus { outline:none; border-color:#4a90d9; box-shadow:0 0 0 2px rgba(74,144,217,0.2); }
.desc-char-count { font-size:0.75em; color:#718096; margin-left:4px; vertical-align:middle; }
.btn-sm { padding:2px 8px; font-size:0.8rem; border-radius:3px; cursor:pointer; border:1px solid #cbd5e0; background:#f7fafc; }
.btn-sm:hover { background:#edf2f7; }
/* Fix contraste (UX 2026-06-16): .btn-sm (arriba) pisaba el fondo de .btn-primary,
   dejando "Confirmar cuenta" blanco sobre blanco (contraste 1.05:1 = botón invisible).
   Mayor especificidad (.btn-primary.btn-sm) restaura el azul -> contraste 5.17:1 (WCAG AA). */
.btn-primary.btn-sm { background:#2563eb; color:#fff; border-color:#2563eb; }
.btn-primary.btn-sm:hover { background:#1d4ed8; border-color:#1d4ed8; }
.btn-ok { background:#48bb78; color:#fff; border-color:#38a169; }
.btn-ok:hover { background:#38a169; }

/* ─── 3 Zonas del detalle ─── */
.zone { margin-bottom:0; }
.zone-factura { padding-bottom:16px; }
.zone-veredicto { border-radius:10px; padding:14px 18px; margin:12px 0; }
.zone-ok { background:#f0fff4; border:1px solid #c6f6d5; }
.zone-error { background:#fff5f5; border:1px solid #fed7d7; }
.zone-warn { background:#fffff0; border:1px solid #fefcbf; }
.zone-tech { padding-top:8px; }

/* Veredicto */
.veredicto-row { display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap; }
.veredicto-msg { font-size:0.95rem; font-weight:600; color:#2d3748; flex:1; }
.veredicto-icon { margin-right:6px; }
.veredicto-icon.ok { color:#38a169; }
.veredicto-icon.error { color:#e53e3e; }
.veredicto-icon.warn { color:#d69e2e; }
.veredicto-action { flex-shrink:0; }
.zone-veredicto .val-line { margin-top:8px; font-size:0.85rem; }
.zone-veredicto .val-detail-toggle { margin-top:10px; font-size:0.82rem; }

/* Punto 8: feedback aprendizaje */
.learn-feedback { font-size:0.82rem; color:#6b46c1; background:#faf5ff; border:1px solid #e9d8fd; border-radius:6px; padding:6px 12px; margin-top:10px; }

/* Header meta (NIF + Spyro match) */
.header-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:2px; }
.nif-display { font-family:'SF Mono',Consolas,monospace; color:#4a5568; font-size:0.85rem; letter-spacing:0.5px; }
.spyro-match-pill { background:#f0fff4; color:#276749; padding:2px 10px; border-radius:12px; font-size:0.78rem; font-weight:500; border:1px solid #c6f6d5; }

/* Punto 5: lapices solo en hover */
.hover-only { opacity:0; transition:opacity .2s; }
.editable-hover:hover .hover-only,
.header-meta:hover .hover-only,
.dcard:hover .hover-only { opacity:1; }

/* Mapped description */
.mapped-desc { font-weight:600; color:#276749; }
.desc-original-hint { font-size:0.7em; color:#cbd5e0; margin-top:1px; line-height:1.2; font-style:italic; }

/* Tech details (colapsable) */
.tech-details { border:1px solid #e2e8f0; border-radius:8px; overflow:hidden; }
.tech-summary { padding:10px 14px; cursor:pointer; font-size:0.88rem; font-weight:600; color:#4a5568; background:#f7fafc; user-select:none; display:flex; align-items:center; gap:8px; }
.tech-summary:hover { background:#edf2f7; }
.tech-summary::marker { color:#a0aec0; }
.tech-preview { font-weight:400; color:#a0aec0; font-size:0.82em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tech-content { padding:12px 14px; background:#fff; }

/* Punto 1: boton ghost (deshabilitado sin color) */
.btn-ghost { background:#e2e8f0; color:#a0aec0; border:1px solid #cbd5e0; cursor:not-allowed !important; }
.btn-ghost:hover { background:#e2e8f0; color:#a0aec0; }

/* Buttons */
.btn-disabled { opacity:0.45; cursor:not-allowed !important; }
.btn-lg { padding:12px 28px; font-size:1rem; font-weight:700; letter-spacing:0.02em; }
.btn-danger-outline { background:transparent; color:#e53e3e; border:1px solid #e53e3e; }
.btn-danger-outline:hover { background:#fff5f5; }

/* Acciones secundarias */
.detail-actions-secondary { display:flex; gap:8px; align-items:center; padding:12px 0 4px; margin-top:12px; border-top:1px solid #edf2f7; }

/* Punto 10: animacion apertura detalle */
@keyframes slideIn { from { opacity:0; transform:translateX(30px); } to { opacity:1; transform:translateX(0); } }
#detail-panel { animation:slideIn .25s ease-out; }

/* ─── Inline edit ─── */
.btn-inline-edit { background:#f0edfc; border:1px solid #d6cff5; border-radius:4px; cursor:pointer; font-size:12px; padding:2px 6px; transition:all .2s; vertical-align:middle; color:#6c5ce7; }
.btn-inline-edit:hover { background:#6c5ce7; color:#fff; border-color:#6c5ce7; transform:scale(1.05); }
.dcard:hover .btn-inline-edit, .detail-edit-row:hover .btn-inline-edit { background:#e8e4f8; }
.inline-edit-input { border:1px solid var(--accent); border-radius:4px; padding:2px 6px; font-family:inherit; font-size:0.85rem; width:auto; min-width:80px; max-width:160px; }
.inline-edit-input:focus { outline:none; box-shadow:0 0 0 2px rgba(108,92,231,0.2); }
.detail-edit-row { padding:4px 0 8px; font-size:0.85rem; }

/* ─── Volcado history timeline ─── */
/* Timeline vertical: línea conectora tenue entre entries para reforzar
   visualmente que el historial es una cronología archivada, no el estado
   actual. Patrón GitHub/Linear activity feed. */
.volcado-timeline {
  display:flex;
  flex-direction:column;
  gap:8px;
  position:relative;
  padding-left:14px;
}
.volcado-timeline::before {
  content:"";
  position:absolute;
  left:6px;
  top:6px;
  bottom:6px;
  width:2px;
  background:linear-gradient(to bottom, var(--border-light) 0%, var(--border-light) 90%, transparent 100%);
  border-radius:2px;
  pointer-events:none;
}
/* Fondo gris muy suave comunica "archivado" (vs blanco puro del estado
   actual). Borde-left colorido mantiene el código visual de severidad. */
.volcado-entry {
  display:flex;
  gap:10px;
  padding:10px 12px;
  border-radius:var(--r-sm);
  border:1px solid var(--border-light);
  background:#fafafa;
  font-size:0.85rem;
  position:relative;
}
/* Pill de timestamp en la esquina superior derecha — snapshot temporal.
   Ancho calculado para acomodar el caso más largo ("hace 12 meses" ≈ 110px
   con font-size:0.72rem + padding horizontal) y un margen de seguridad. */
.volcado-entry-body { position:relative; padding-right:130px; }
.volcado-pill {
  position:absolute;
  top:0;
  right:0;
  font-size:0.72rem;
  color:var(--text-secondary);          /* WCAG AA: ≥4.5:1 sobre blanco */
  background:rgba(255,255,255,0.95);
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--border-light);
  white-space:nowrap;
  line-height:1.3;
}
/* Responsive: en pantallas estrechas el pill molesta más de lo que aporta.
   Lo colapsamos a tamaño mínimo (el tooltip sigue accesible). */
@media (max-width: 540px) {
  .volcado-entry-body { padding-right:70px; }
  .volcado-pill { font-size:0.68rem; padding:1px 6px; }
}
.volcado-entry.real-ok { border-left:3px solid var(--green); }
.volcado-entry.dry-run { border-left:3px solid var(--accent); }
.volcado-entry.failed-active { border-left:3px solid var(--red); background:var(--red-bg); }
/* Causa corregida por el sistema: el fallo ocurrió antes del despliegue
   del fix que lo resuelve — afirmación determinista, no suposición.
   Verde suave, no naranja: es una no-cosa, no requiere atención. */
.volcado-entry.failed-resolved-system {
  border-left:3px solid #10b981;          /* emerald-500 */
  background:#f0fdf4;                     /* emerald-50 */
}
.volcado-entry.failed-resolved-system .volcado-note {
  color:#065f46;                          /* emerald-900 ≈ 11:1 sobre emerald-50 */
  font-style:normal;
}
/* Modo silencioso: toda la historia son fallos ya corregidos por el sistema.
   Panel compacto colapsado al pie del drawer, neutro. No contradice la
   bandeja verde. */
.volcado-history-quiet {
  margin-top:12px;
  border:1px solid var(--border-light);
  border-radius:var(--r-sm);
  background:#fafafa;
  font-size:0.82rem;
}
.volcado-history-quiet > summary {
  padding:8px 12px;
  cursor:pointer;
  color:#065f46;                          /* verde oscuro, afirmativo */
  user-select:none;
  list-style:none;
}
.volcado-history-quiet > summary::-webkit-details-marker { display:none; }
.volcado-history-quiet > summary:hover { background:#f3f4f6; }
.volcado-history-quiet[open] > summary {
  border-bottom:1px solid var(--border-light);
  font-weight:600;
}
.volcado-history-quiet .volcado-timeline {
  padding:10px 12px 12px;
}
/* Intento superado: fallo seguido de éxito posterior — atenuado en gris */
.volcado-entry.failed-resolved {
  border-left:3px solid var(--border-light);
  background:var(--bg-subtle, #f9fafb);
  opacity:0.75;
}
.volcado-entry.failed-resolved strong,
.volcado-entry.failed-resolved .volcado-error { text-decoration: line-through; }
.volcado-entry.failed-resolved .volcado-error { color: var(--text-muted); }
/* Intento reintentable: el último falló pero los controles actuales pasan */
.volcado-entry.failed-retryable {
  border-left:3px solid #f59e0b;          /* amber-500 */
  background:#fffbeb;                     /* amber-50 */
}
.volcado-entry.failed-retryable .volcado-error {
  color:#92400e;                          /* amber-900 sobre fondo amber-50 ≈ 7:1 */
  background:#fef3c7;
  padding:6px 8px;
  border-radius:4px;
  font-size:0.78rem;
  margin-top:4px;
}
.volcado-note {
  color:#78350f;                          /* amber-950 sobre fondo claro ≈ 9:1 */
  font-size:0.8rem;
  margin-top:3px;
  font-style:italic;
}
/* Mensaje humano del error (traducción accionable) — protagonista */
.volcado-error-human {
  color:#1f2937;                          /* slate-800 sobre fondo amber-50 ≈ 11:1 */
  font-size:0.88rem;
  margin-top:6px;
  line-height:1.35;
}
.volcado-error-tip {
  color:#4b5563;                          /* slate-600, aspecto de hint */
  font-size:0.8rem;
  margin-top:2px;
  line-height:1.35;
}
/* Detalle técnico colapsado — oculto por defecto, disponible bajo demanda */
.volcado-error-detail {
  margin-top:6px;
  font-size:0.75rem;
}
.volcado-error-detail > summary {
  cursor:pointer;
  color:var(--text-muted);
  user-select:none;
  padding:2px 0;
}
.volcado-error-detail > summary:hover { color: var(--text-secondary); }
.volcado-error-detail[open] > summary { margin-bottom:4px; }
.volcado-error-detail .volcado-error {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size:0.72rem;
  padding:6px 8px;
  background:#fff;
  border:1px solid var(--border-light);
  border-radius:4px;
  color:var(--text-secondary);
  word-break:break-word;
  margin-top:6px;
}
/* Mensaje humano del error cuando aparece DENTRO del details (casos no
   vigentes: el contexto histórico del intento). Sin peso visual de
   protagonista — es información de archivo. */
.volcado-error-detail .volcado-error-human-inline {
  color:var(--text-secondary);
  font-size:0.82rem;
  line-height:1.35;
  margin:0 0 4px;
}
.volcado-icon { font-size:1.1rem; flex-shrink:0; padding-top:1px; }
.volcado-entry-body { flex:1; min-width:0; }
.volcado-error { color:var(--red); font-size:0.8rem; margin-top:2px; }
.volcado-meta { color:var(--text-muted); font-size:0.75rem; margin-top:3px; }
.volcado-steps { margin-top:4px; font-size:0.78rem; }
.volcado-steps summary { cursor:pointer; color:var(--text-muted); }
.volcado-step { color:var(--text-secondary); padding:1px 0; }

/* ─── View Transitions (progressive enhancement) ─── */
.detail-panel { view-transition-name:detail-panel; }
::view-transition-old(detail-panel) { animation:fadeSlideOut .2s ease; }
::view-transition-new(detail-panel) { animation:fadeSlideIn .25s ease; }
@keyframes fadeSlideOut { to { opacity:0; transform:translateX(20px); } }
@keyframes fadeSlideIn { from { opacity:0; transform:translateX(20px); } }

/* ─── Knowledge Engine: confianza + alertas cerebro ─── */
.kb-prediction {
  display:inline-flex; align-items:center; gap:8px;
  font-size:12px; font-weight:600; padding:6px 12px;
  border-radius:8px; background:var(--bg-white); border:1px solid var(--border);
  margin-bottom:8px;
}
.kb-prediction.high { background:var(--green-bg); border-color:var(--green-border); color:var(--green); }
.kb-prediction.medium { background:var(--orange-bg); border-color:transparent; color:var(--orange); }
.kb-prediction.low { background:var(--red-bg); border-color:var(--red-border); color:var(--red); }
.kb-bar { display:flex; gap:2px; }
.kb-bar-b { width:6px; height:12px; border-radius:2px; background:currentColor; opacity:0.2; }
.kb-bar-b.on { opacity:1; }

.kb-alert {
  display:flex; align-items:flex-start; gap:10px;
  padding:10px 14px; margin:6px 0; border-radius:8px;
  font-size:12px; line-height:1.5;
  background:var(--purple-bg); border-left:3px solid var(--purple);
}
.kb-alert.warning { background:var(--orange-bg); border-left-color:var(--orange); }
.kb-alert-icon { font-size:15px; flex-shrink:0; }
.kb-alert-body { flex:1; }
.kb-alert-title { font-weight:600; color:var(--purple); }
.kb-alert.warning .kb-alert-title { color:var(--orange); }
.kb-alert-detail { color:var(--text-muted); font-size:11px; margin-top:2px; }
.kb-alert-meta { font-size:10px; color:var(--text-muted); font-style:italic; margin-top:3px; }

/* ─── @starting-style for sidebar (progressive enhancement) ─── */
@starting-style {
  .sidebar-overlay.visible { opacity:0; }
}

/* ─── Tarjeta de duplicado/similar (en panel de detalle) ─── */
.dup-alert {
  display: block;
  padding: 12px 14px;
  margin: 8px 0;
  border-radius: 8px;
  border-left: 4px solid var(--red, #dc2626);
  background: var(--red-bg, #fef2f2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.dup-alert--warning {
  border-left-color: var(--orange, #ea580c);
  background: var(--orange-bg, #fff7ed);
}
.dup-alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.dup-alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--red, #dc2626);
  flex-shrink: 0;
}
.dup-alert--warning .dup-alert-icon { color: var(--orange, #ea580c); }
.dup-alert-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.dup-alert-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 26px;
}
/* Sub-etiqueta cuando la tarjeta va sin titular (motivo ya mostrado arriba). */
.dup-alert-sublabel { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.dup-row { font-size: 13px; }
.dup-row-label {
  color: var(--text-muted);
  font-weight: 500;
}
.dup-row-muted {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}
.dup-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--text-secondary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ─── Resumen contextual bajo el tablist ─── */
.bandeja-summary {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 8px 2px 14px;
  min-height: 22px;
  /* W-0013: que el resumen ocupe el ancho disponible cuando tiene contenido,
     dejando al botón "Actualizar bandeja" pegado a la derecha. min-width:0
     evita que texto largo desborde el contenedor flex. */
  flex: 1;
  min-width: 0;
}
.bandeja-summary strong { color: var(--text-secondary); font-weight: 500; }
.bandeja-summary:empty { display: none; }

/* ─── Botón "Actualizar Spyro" + banner de error persistente ─── */
.bandeja-summary-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  /* W-0013: el alineado a la derecha del botón se hace con margin-left:auto
     en .spyro-sync-btn (más abajo). Eso funciona también cuando .bandeja-summary
     está vacío y se oculta por :empty — escenario que justify-content:
     space-between NO cubría (con un solo hijo, el botón se quedaba a la izquierda). */
}
.bandeja-summary-row .bandeja-summary { padding: 8px 2px; }

.spyro-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 200ms ease, color 200ms ease;
  white-space: nowrap;
  /* W-0013: anclado a la derecha del .bandeja-summary-row aunque
     .bandeja-summary esté oculto por :empty (escenario sin resumen). */
  margin-left: auto;
  flex-shrink: 0;
}
.spyro-sync-btn:hover:not(:disabled) { background: #f3f4f6; }
.spyro-sync-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.spyro-sync-btn:disabled { cursor: wait; opacity: 0.85; }
.spyro-sync-icon { display: inline-flex; }
.spyro-sync-icon svg { display: block; }

/* Estado "ejecutando": feedback fuerte visible siguiendo patrón Gmail/Linear/
   Stripe (Nielsen Norman heuristic #1). Background azul primario sólido,
   texto blanco, spinner blanco, cursor wait y pointer-events none para
   prevenir re-clic. Añade barra de progreso indeterminada en la base del
   botón como refuerzo visual (patrón Material Design 3 / Stripe checkout).
   Contraste WCAG AA: white sobre #2563eb = 8.6:1. */
.spyro-sync-btn[data-state="loading"] {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
  cursor: wait;
  pointer-events: none;
  position: relative;
  overflow: hidden;
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.spyro-sync-btn[data-state="loading"] .spyro-sync-icon svg {
  animation: spyroSyncSpin 900ms linear infinite;
  stroke: #ffffff;
}
.spyro-sync-btn[data-state="loading"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.85) 50%,
    transparent 100%);
  animation: spyroSyncProgress 1400ms ease-in-out infinite;
}
@keyframes spyroSyncSpin { to { transform: rotate(360deg); } }
@keyframes spyroSyncProgress {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
/* Respetar usuarios con prefers-reduced-motion: mantener color pero quitar
   animaciones (accesibilidad WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  .spyro-sync-btn[data-state="loading"] .spyro-sync-icon svg,
  .spyro-sync-btn[data-state="loading"]::after {
    animation: none;
  }
}

/* Estado ≥60 min: NEUTRO (slate), sin icono ⚠️. "Verificado hace un rato" NO es un error
   — el fallo real de Oracle tiene su propio banner rojo aparte. (system.css/bandeja.css
   refinan el color en el tema actual; aquí dejamos la base serena para el tema=off.) */
.spyro-sync-btn[data-state="stale"] {
  border-color: var(--border, #d1d5db);
  color: var(--text-secondary, #64748b);
  background: transparent;
}
.spyro-sync-btn[data-state="stale"]:hover:not(:disabled) { background: #f3f4f6; }

/* Estado <60 min: gris suave */
.spyro-sync-btn[data-state="fresh"] { color: var(--text-secondary); }

.spyro-sync-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #C41E3A;
  border-radius: 6px;
  color: #991B1B;
  font-size: 13px;
}
.spyro-sync-error-banner[hidden] { display: none; }
.spyro-sync-error-banner .banner-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #991B1B;
  padding: 0 4px;
  line-height: 1;
}

/* Banner del polling silencioso "Pendiente de contabilizar".
   Más discreto que el de error general (color ámbar, sin borde rojo) — la
   pestaña no es bloqueante, solo informativo. Se oculta solo al recuperar. */
.pendiente-conta-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  color: #78350f;
  font-size: 12px;
}
.pendiente-conta-error-banner[hidden] { display: none; }

/* Fade-out para filas que cambian a "Ya pagada" tras refresh (des-selección animada) */
.invoice-table tbody tr.spyro-sync-deselecting {
  animation: spyroSyncFadeOut 200ms ease-out;
}
@keyframes spyroSyncFadeOut {
  0% { background-color: transparent; }
  50% { background-color: #fee2e2; }
  100% { background-color: transparent; }
}

/* ═══════════════════════════════════════════════════════
   Campanita + modal de notificaciones email
═══════════════════════════════════════════════════════ */
.notif-bell {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #7c3aed;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
  z-index: 60;
  transition: transform 150ms ease, box-shadow 200ms ease;
}
.notif-bell:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(124,58,237,0.45); }
.notif-bell:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
@media (max-width: 640px) {
  .notif-bell { bottom: 86px; } /* no tapar bottom-nav móvil */
}
.notif-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #C41E3A;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  border: 2px solid #fff;
}

.notif-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-modal[hidden] { display: none; }
.notif-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
}
.notif-modal-body {
  position: relative;
  width: min(560px, 92vw);
  max-height: 88vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notifModalIn 200ms ease-out;
}
@keyframes notifModalIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notif-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.notif-modal-title-wrap { display: flex; align-items: center; gap: 10px; }
.notif-modal-icon { color: #7c3aed; display: inline-flex; }
.notif-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}
.notif-close {
  background: #f3f4f6;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}
.notif-close:hover { background: #e5e7eb; }
.notif-modal-content {
  overflow-y: auto;
  padding: 16px 20px 20px;
}
.notif-section { margin-bottom: 20px; }
.notif-section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #6b7280;
}

.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
}
.notif-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-row-email {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-row-events { font-size: 11px; color: #6b7280; }
.notif-row-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
}
.notif-row-status.active { color: #059669; }
.notif-row-status.paused { color: #6b7280; }
.notif-row-actions { display: flex; gap: 4px; align-items: center; }
.notif-row-actions button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  color: #374151;
}
.notif-row-actions button:hover { background: #f3f4f6; }
.notif-row-actions .notif-del { color: #C41E3A; border-color: #fecaca; }
.notif-row-actions .notif-del:hover { background: #fee2e2; }

.notif-form { display: flex; flex-direction: column; gap: 12px; }
.notif-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notif-form-field { display: flex; flex-direction: column; gap: 4px; }
.notif-form-field > span {
  font-size: 12px;
  font-weight: 500;
  color: #374151;
}
.notif-form-field input {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.notif-form-field input:focus-visible { outline: 2px solid #7c3aed; outline-offset: 0; border-color: #7c3aed; }

.notif-events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 12px;
  margin-top: 4px;
}
.notif-event-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
}
.notif-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
}
/* Indicador sutil del orden activo ("ordenado por urgencia", "más antiguas
   primero", etc.). Aparece solo si el sort es el default de la pestaña —
   si el usuario cambia el orden pinchando una columna, el indicador
   desaparece (researcher: evita confusión sobre ordenamiento implícito). */
.bandeja-sort-indicator {
  color:#9ca3af;
  font-size:12px;
  font-style:italic;
  margin-left:4px;
}
@media(max-width:640px) {
  /* En mobile la línea del resumen ya es estrecha; el indicador de sort es
     decorativo y se oculta para evitar wrap del italic a línea extra. */
  .bandeja-sort-indicator { display:none; }
}

/* ─── Bandejas (tablist) ─── */
.bandejas-wrap {
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.bandejas {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0;
}
.bandejas::-webkit-scrollbar { display: none; }
.bandeja {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
  margin-bottom: -1px;
  border-radius: 8px 8px 0 0;
}
.bandeja:hover { color: var(--text); background: var(--bg-subtle); }
.bandeja:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.bandeja.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.bandeja-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}
.bandeja-label { line-height: 1; }
.bandeja-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.bandeja.active .bandeja-badge {
  background: var(--accent);
  color: #fff;
}
.bandeja-badge[data-count="0"] { display: none; }

@media (max-width:768px) {
  .bandejas-wrap {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .bandeja {
    padding: 10px 12px;
    font-size: 13px;
  }
  .bandeja-label { font-size: 13px; }
}
