/* ============================================================================
   ESPERALOYA — modulos.css  v3.0
   Usuarios, Proveedores, CxP, Auditoría, Búsqueda, Modales, Tablas
   ============================================================================ */

/* ── Tabla general (tbl-card + data-table) ──────────────────────────────── */
.tbl-card {
  background: var(--white);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226,232,240,.6);
  margin-bottom: 18px; overflow: hidden;
}
.tbl-card h3 {
  font-size: 14px; margin: 0 0 16px; color: var(--navy);
  font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
table.data-table th {
  text-align: left; color: var(--g400); font-weight: 700;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 12px; border-bottom: 1.5px solid var(--g100);
  white-space: nowrap; background: var(--g50);
}
table.data-table td {
  padding: 12px 12px; border-bottom: 1px solid var(--g100);
  color: var(--g700); vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background var(--t-fast); }
table.data-table tbody tr:hover { background: var(--g50); }

/* ── Badges de estado ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap; letter-spacing: .02em;
}
.badge-green  { background: var(--green-light); color: #065F46; }
.badge-red    { background: var(--red-light);   color: #991B1B; }
.badge-yellow { background: #FEF9C3;            color: #713F12; }
.badge-blue   { background: var(--blue-light);  color: #1D4ED8; }
.badge-gray   { background: var(--g100);         color: var(--g500); }
.badge-orange { background: var(--orange-light); color: #92400E; }
.badge-purple { background: var(--purple-light); color: #5B21B6; }

/* ── Botones de acción en tabla ──────────────────────────────────────────── */
.action-btns { display: flex; gap: 6px; flex-wrap: nowrap; }
.btn-action {
  height: 30px; padding: 0 11px;
  border: none; border-radius: 7px;
  font-size: 11.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.btn-action:hover   { opacity: .82; transform: translateY(-1px); }
.btn-action:active  { transform: translateY(0); }
.btn-action.edit    { background: var(--blue-light);   color: var(--blue); }
.btn-action.delete  { background: var(--red-light);    color: var(--red); }
.btn-action.pay     { background: var(--green-light);  color: #065F46; }
.btn-action.view    { background: var(--g100);          color: var(--g600); }
.btn-action .icon-svg { width: 13px; height: 13px; }

/* ── Modal / Dialog ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,27,42,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: overlayIn var(--t-fast) ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white); border-radius: var(--r-lg);
  padding: 28px 24px;
  width: 100%; max-width: 480px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 {
  font-size: 17px; margin: 0 0 20px;
  color: var(--navy); font-weight: 800; letter-spacing: -.3px;
}

.modal .field { margin-bottom: 14px; }
.modal .field label {
  display: block; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--g400); margin-bottom: 6px;
}

.modal-actions {
  display: flex; gap: 10px;
  margin-top: 22px; justify-content: flex-end;
}
.btn-modal-cancel {
  height: 42px; padding: 0 20px; border-radius: 10px;
  border: 1.5px solid var(--g200);
  background: white; color: var(--g600);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.btn-modal-cancel:hover { border-color: var(--g300); color: var(--g700); }
.btn-modal-ok {
  height: 42px; padding: 0 20px; border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--blue) 0%, #1D4ED8 100%);
  color: white; font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
  transition: opacity var(--t), transform var(--t);
}
.btn-modal-ok:hover    { opacity: .9; transform: translateY(-1px); }
.btn-modal-ok:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-modal-danger { background: linear-gradient(135deg, var(--red) 0%, #DC2626 100%); box-shadow: 0 3px 10px rgba(239,68,68,.3); }

/* ── Stats row ───────────────────────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 16px;
}
@media (min-width: 600px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat-box {
  background: var(--white); border-radius: var(--r-md);
  padding: 16px; box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226,232,240,.6);
  transition: box-shadow var(--t);
}
.stat-box:hover { box-shadow: var(--shadow); }
.stat-box .stat-label {
  font-size: 10.5px; color: var(--g400);
  text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; margin: 0 0 6px;
}
.stat-box .stat-value { font-size: 20px; font-weight: 800; color: var(--navy); margin: 0; letter-spacing: -.4px; }

/* ── CxP: barra de progreso de pago ─────────────────────────────────────── */
.pay-progress {
  height: 5px; background: var(--g100);
  border-radius: 99px; margin-top: 5px; overflow: hidden;
}
.pay-progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--green) 0%, #34D399 100%);
  transition: width .3s ease;
}

/* ── Buscador ────────────────────────────────────────────────────────────── */
.search-bar { position: relative; margin-bottom: 16px; }
.search-bar input { padding-left: 42px; height: 46px; border-radius: var(--r-md); }
.search-bar .search-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%); color: var(--g400);
}
.search-bar .search-icon .icon-svg { width: 18px; height: 18px; }
.search-results {
  background: var(--white); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); margin-top: 6px;
  overflow: hidden; max-height: 400px; overflow-y: auto;
  border: 1px solid var(--g200);
}
.search-result-item {
  padding: 13px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--g100); cursor: pointer;
  transition: background var(--t-fast);
}
.search-result-item:hover { background: var(--g50); }
.search-result-item:last-child { border-bottom: none; }
.search-badge {
  flex-shrink: 0; padding: 2px 9px;
  border-radius: 6px; font-size: 10.5px; font-weight: 700;
}
.search-result-title { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 2px; }
.search-result-detail { font-size: 12px; color: var(--g400); }

/* ── Upload area ─────────────────────────────────────────────────────────── */
.upload-area, .upload-zone {
  border: 2px dashed var(--g200); border-radius: var(--r-md);
  padding: 26px 16px; text-align: center; cursor: pointer;
  transition: border-color var(--t), background var(--t);
  background: var(--g50);
}
.upload-area:hover, .upload-zone:hover,
.upload-area.drag-over, .upload-zone.drag-over {
  border-color: var(--blue); background: var(--blue-light);
}
.upload-zone .uz-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--white); margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.upload-zone .uz-icon .icon-svg { width: 22px; height: 22px; color: var(--blue); }
.upload-zone h4 { font-size: 14px; margin: 0 0 4px; color: var(--navy); font-weight: 600; }
.upload-zone p  { font-size: 12px; color: var(--g400); margin: 0; }
.uploaded-file {
  display: flex; align-items: center; gap: 10px;
  background: var(--g100); border-radius: 9px;
  padding: 10px 14px; font-size: 13px; margin-top: 8px;
}
.uploaded-file .icon-svg { color: var(--blue); width: 16px; height: 16px; }

/* ── Timeline de pagos ───────────────────────────────────────────────────── */
.payment-timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 12px;
  padding-bottom: 18px; position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.timeline-dot .icon-svg { width: 15px; height: 15px; }
.timeline-line {
  position: absolute; left: 15px; top: 32px; bottom: 0;
  width: 2px; background: var(--g100);
}
.timeline-item:last-child .timeline-line { display: none; }
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-amount  { font-size: 16px; font-weight: 700; color: var(--navy); }
.timeline-meta    { font-size: 12px; color: var(--g400); margin-top: 2px; }

/* ── Toast / Notificación ────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--navy); color: white;
  padding: 12px 22px; border-radius: 99px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  max-width: calc(100vw - 40px); text-align: center;
  box-shadow: var(--shadow-md);
}
#toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error   { background: var(--red); }
#toast.success { background: var(--green); }
@media (min-width: 901px) { #toast { bottom: 28px; } }

/* ── Pestañas de reportes ────────────────────────────────────────────────── */
.rpt-tab {
  height: 36px; padding: 0 18px; border-radius: 99px;
  border: 1.5px solid var(--g200);
  background: var(--white); color: var(--g500);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--t);
}
.rpt-tab:hover  { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.rpt-tab.active { background: var(--blue); color: white; border-color: var(--blue); box-shadow: 0 3px 10px rgba(37,99,235,.3); }
.rpt-panel { display: none; }
.rpt-panel.active { display: block; animation: fadeIn .2s ease; }

/* ── Analizador de facturas ──────────────────────────────────────────────── */
.processing-state  { text-align: center; padding: 28px 16px; }
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--g200); border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-state h4 { font-size: 14px; margin: 0 0 4px; color: var(--navy); font-weight: 600; }
.processing-state p  { font-size: 12px; color: var(--g400); margin: 0; }

.extracted-card {
  background: var(--green-pale);
  border: 1px solid #A7F3D0;
  border-radius: var(--r-sm); padding: 14px; margin-bottom: 14px;
}
.extracted-card .ec-header {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px; font-size: 13px; font-weight: 700; color: #065F46;
}
.extracted-card .ec-header .icon-svg { width: 15px; height: 15px; color: var(--green); }
.ec-badge { margin-left: auto; font-size: 10px; padding: 2px 9px; border-radius: 8px; font-weight: 600; background: #D1FAE5; color: #065F46; }
.ec-badge.ia { background: var(--purple-light); color: #5B21B6; }
.ep-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid #A7F3D0; font-size: 13px;
}
.ep-row:last-child { border-bottom: none; }
.ep-lbl { color: #059669; font-weight: 500; }
.ep-val { font-weight: 700; color: var(--navy); }
.ep-val.warn { color: var(--orange); }

.dup-alert {
  background: var(--orange-light); border: 1px solid #FCD34D;
  border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 14px;
}
.dup-alert strong { font-size: 13px; color: #92400E; display: block; margin-bottom: 3px; }
.dup-alert span   { font-size: 12px; color: #92400E; }

/* ── Formulario dentro del modal ─────────────────────────────────────────── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .form-grid-2 { grid-template-columns: 1fr; } }

.mf { margin-bottom: 10px; }
.mf label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--g400); text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 5px;
}
.mf input, .mf select {
  width: 100%; height: 40px;
  border: 1.5px solid var(--g200); border-radius: 9px;
  padding: 0 11px; font-size: 13px; color: var(--navy);
  font-family: var(--font); background: var(--white);
  transition: border-color var(--t), box-shadow var(--t);
}
.mf input:focus, .mf select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Botón "Ver factura" ─────────────────────────────────────────────────── */
.btn-ver-fac {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--blue); font-weight: 600;
  background: var(--blue-light); border: none;
  border-radius: 7px; padding: 4px 10px; cursor: pointer;
  transition: background var(--t), opacity var(--t);
  text-decoration: none;
}
.btn-ver-fac:hover { background: var(--blue-pale); opacity: .9; }
.btn-ver-fac .icon-svg { width: 12px; height: 12px; }

/* ============================================================================
   HERO CARDS — mod-hero (Dashboard, Ventas, Gastos)
   ============================================================================ */

.mod-hero {
  border-radius: var(--r-lg);
  padding: 22px 20px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  overflow: hidden;
  position: relative;
}
.mod-hero__left {
  display: flex; align-items: center; gap: 14px; flex: 1;
}
.mod-hero__icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.mod-hero__icon .icon-svg { width: 22px; height: 22px; color: white; }
.mod-hero__text h1 {
  font-size: 20px; font-weight: 800; color: white;
  margin: 0 0 2px; letter-spacing: -.4px;
}
.mod-hero__text p { font-size: 12px; color: rgba(255,255,255,.75); margin: 0; }
.mod-hero__kpi { text-align: right; flex-shrink: 0; }
.mod-hero__kpi-label {
  display: block; font-size: 10.5px; color: rgba(255,255,255,.7);
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 4px;
}
.mod-hero__kpi-value {
  font-size: 22px; font-weight: 800; color: white; letter-spacing: -.5px;
}

/* Variante dashboard (sin kpi lateral) */
.mod-hero--dash {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a5c 100%);
  box-shadow: 0 8px 28px rgba(13,27,42,.25);
}
.mod-hero--dash .mod-hero__icon { background: rgba(255,255,255,.15); }

/* Variante ventas (azul) */
.mod-hero--ventas {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 50%, #1e40af 100%);
  box-shadow: 0 8px 28px rgba(37,99,235,.35);
}

/* Variante gastos (rojo) */
.mod-hero--gastos {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 50%, #b91c1c 100%);
  box-shadow: 0 8px 28px rgba(239,68,68,.35);
}

/* ============================================================================
   FIELD STANDALONE — campos como tarjetas individuales
   ============================================================================ */

.fields-section-label {
  font-size: 11px; font-weight: 700; color: var(--g400);
  text-transform: uppercase; letter-spacing: .07em;
  margin: 6px 0 10px; padding: 0;
}

.field-standalone {
  background: var(--white);
  border-radius: var(--r-md);
  border: 1.5px solid rgba(226,232,240,.8);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t), box-shadow var(--t);
}
.field-standalone:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1), var(--shadow-sm);
}
.field-standalone__icon {
  flex-shrink: 0;
  /* inherits .field-icon sizing */
}
.field-standalone__body {
  flex: 1; min-width: 0;
}
.field-standalone__body label {
  display: block;
  font-size: 11px; font-weight: 700; color: var(--g400);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 5px;
}
.field-standalone__body label .opt {
  font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--g300);
}
.field-standalone__body input,
.field-standalone__body select {
  border: none; background: none; padding: 0;
  height: auto; font-size: 16px;
  font-weight: 600; color: var(--navy);
  width: 100%; box-shadow: none;
}
.field-standalone__body input::placeholder { font-weight: 400; color: var(--g300); font-size: 15px; }
.field-standalone__body input:focus,
.field-standalone__body select:focus { outline: none; box-shadow: none; border: none; }

/* Para campos con monto (símbolo + input alineados) */
.field-standalone__right {
  display: flex; align-items: baseline; gap: 6px;
}
.field-standalone__right input {
  text-align: right; flex: 1;
}
.currency-prefix {
  font-size: 13px; font-weight: 700; color: var(--g400);
  flex-shrink: 0;
}

/* ============================================================================
   SCREEN HEADERS — header estándar para Usuarios, Auditoría, Proveedores, CxP
   ============================================================================ */

.mod-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.mod-screen-header__text h1 {
  font-size: 26px; font-weight: 800;
  color: var(--navy); margin: 0 0 3px;
  letter-spacing: -.6px;
}
.mod-screen-header__text p {
  font-size: 13px; color: var(--g400); margin: 0;
}

/* ── Botón de acción principal (+ Nuevo usuario, + Nuevo proveedor, etc.) ── */
.btn-action-primary {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 20px;
  background: linear-gradient(135deg, var(--blue) 0%, #1D4ED8 100%);
  color: white; border: none; border-radius: 10px;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
  transition: opacity var(--t), transform var(--t);
}
.btn-action-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-action-primary .icon-svg { width: 16px; height: 16px; }

/* ── Auditoría: filtro en 4 columnas en todos los tamaños ─────────────────── */
.aud-filter-grid {
  grid-template-columns: 1fr 1fr;
}

/* ════════════════════════════════════════════════════════════════════════════
   ESCRITORIO (≥901px) — Usuarios y Auditoría
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 901px) {

  /* Header de pantalla más grande */
  .mod-screen-header { margin-bottom: 28px; }
  .mod-screen-header__text h1 { font-size: 30px; letter-spacing: -.8px; }
  .mod-screen-header__text p  { font-size: 14px; }
  .btn-action-primary { height: 44px; padding: 0 24px; font-size: 14px; }

  /* Auditoría: filtros en 4 columnas en escritorio */
  .aud-filter-grid { grid-template-columns: repeat(4, 1fr); }

  /* Tablas más espaciosas en desktop */
  .tbl-card { padding: 24px; }
  .tbl-card h3 { font-size: 16px; margin-bottom: 20px; }

  table.data-table th {
    font-size: 11px; padding: 10px 14px 14px;
    letter-spacing: .06em;
  }
  table.data-table td {
    padding: 14px 14px; font-size: 13.5px;
  }

  /* Botón Consultar de auditoría más compacto */
  .filter-card .btn-outline {
    height: 44px; padding: 0 24px; font-size: 14px;
  }
}
