/* ============================================================
   Facturación Module — Premium Styles
   A world-class billing UI inspired by Stripe, Chargebee, Holded
   Extends iEnTop.css erp-* component library
   ============================================================ */

/* â”€â”€ Left Nav (testing only — will be replaced by iEnTop menu) â”€â”€ */
.fac-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.fac-nav {
  width: 210px;
  flex-shrink: 0;
  background: var(--color-bg-secondary, #1e293b);
  border-right: 1.5px solid var(--color-border, #334155);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
}

.fac-nav-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-border, #334155);
}

.fac-nav-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-accent, #818cf8);
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fac-nav-version {
  font-size: 10px;
  color: var(--color-text-muted, #64748b);
  margin-top: 3px;
}

.fac-nav-section {
  padding: 10px 12px 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--color-text-muted, #64748b);
}

.fac-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  border-left: 3px solid transparent;
  font-family: inherit;
  position: relative;
}

.fac-nav-btn:hover {
  background: var(--color-bg-hover, #334155);
  color: var(--color-text-primary, #f1f5f9);
}

.fac-nav-btn.fac-active {
  background: var(--color-accent-subtle, rgba(99, 102, 241, .15));
  color: var(--color-text-accent, #818cf8);
  border-left-color: var(--color-accent, #6366f1);
  font-weight: 600;
}

.fac-nav-btn .nav-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.fac-nav-btn .nav-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--color-accent, #6366f1);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.fac-nav-btn .nav-count.warn {
  background: var(--color-warning, #f59e0b);
}

.fac-nav-btn .nav-count.danger {
  background: var(--color-danger, #ef4444);
}

/* ── New V3 Navigation Items ── */
.fac-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 4px 16px;
  border-radius: 8px;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
}

.fac-nav-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.fac-nav-item.fac-active {
  background: var(--color-accent-subtle);
  color: var(--color-text-accent);
}

.fac-nav-item .fac-nav-icon {
  font-size: 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 24px;
}

/* â”€â”€ Main Content â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--color-bg-primary, #0f172a);
}

.fac-view {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* â”€â”€ Enforcing alignment to preventing central gaps â”€â”€ */
.fac-view.fac-active {
  display: flex !important;
  opacity: 1;
  justify-content: flex-start !important;
  /* Force content to top */
  align-items: stretch !important;
  animation: fac-slide-in .4s ease-out forwards;
}

.fac-header {
  margin-top: 0 !important;
}

@keyframes fac-slide-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* â”€â”€ Page Header (top bar inside each view) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px;
  background: var(--color-bg-secondary, #1e293b);
  border-bottom: 1.5px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.fac-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.fac-header-icon.icon-dash {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

.fac-header-icon.icon-docs {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.fac-header-icon.icon-venc {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.fac-header-icon.icon-conf {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.fac-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 290px;
  flex-shrink: 0;
}

.fac-header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact Nuevo button */
.fac-btn-nuevo {
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.fac-btn-nuevo:hover:not(:disabled) {
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.fac-btn-nuevo:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.fac-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* ── Document Type Filter Bar (Ventas / Compras in header row) ── */
.fac-tipo-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 8px;
}

/* ── Sub-type bar (second row, responsive wrap) ───────────────── */
.fac-subtipo-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 6px 16px;
  justify-content: center;
  align-items: center;
  min-height: 0;
}

.fac-subtipo-bar:empty {
  display: none;
}

.fac-tipo-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-secondary, #cbd5e1);
  background: color-mix(in srgb, var(--color-border) 40%, transparent);
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.fac-tipo-btn:hover {
  color: var(--color-text-primary, #e2e8f0);
  background: color-mix(in srgb, var(--color-border) 40%, transparent);
  border-color: color-mix(in srgb, var(--color-border) 80%, transparent);
}

.fac-tipo-btn.active {
  color: #fff;
  border-color: color-mix(in srgb, var(--color-border) 80%, transparent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.fac-tipo-btn.tipo-all.active {
  background: linear-gradient(135deg, #475569, #64748b);
}

.fac-tipo-btn.tipo-PRE_VTA.active,
.fac-tipo-btn.tipo-PRE_COM.active {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

.fac-tipo-btn.tipo-PED_VTA.active,
.fac-tipo-btn.tipo-PED_COM.active,
.fac-tipo-btn.tipo-PED_OBR.active {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.fac-tipo-btn.tipo-ALB_VTA.active,
.fac-tipo-btn.tipo-ALB_COM.active,
.fac-tipo-btn.tipo-ALB.active {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.fac-tipo-btn.tipo-F_VTA.active,
.fac-tipo-btn.tipo-F_COM.active,
.fac-tipo-btn.tipo-FAC.active,
.fac-tipo-btn.tipo-FRC.active {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.fac-tipo-btn.tipo-AB_FVTA.active,
.fac-tipo-btn.tipo-AB_FCOM.active {
  background: linear-gradient(135deg, #ef4444, #f87171);
}

.fac-tipo-btn.tipo-REC.active {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.fac-tipo-btn.tipo-PROY_OBR.active {
  background: linear-gradient(135deg, #14b8a6, #2dd4bf);
}

/* Ventas / Compras — soft colored backgrounds by default */
.fac-tipo-btn.tipo-ventas {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.fac-tipo-btn.tipo-compras {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.fac-tipo-btn.tipo-ventas.active {
  background: linear-gradient(135deg, #10b981, #34d399);
  color: #fff;
}

.fac-tipo-btn.tipo-compras.active {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #fff;
}

.fac-tipo-sep {
  color: var(--color-text-muted, #64748b);
  font-size: 18px;
  padding: 0 2px;
  user-select: none;
}

.fac-tipo-btn .tipo-icon {
  font-size: 13px;
}

.fac-tipo-btn .tipo-count {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 2px;
}

/* Nuevo button disabled state */
.fac-btn-primary:disabled,
.fac-btn-primary[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* â”€â”€ Action Buttons â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.fac-btn:active {
  transform: scale(.97);
}

.fac-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.fac-btn-primary {
  background: linear-gradient(135deg, var(--color-accent, #6366f1), #818cf8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .3);
}

.fac-btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, .4);
  transform: translateY(-1px);
}

.fac-btn-success {
  background: linear-gradient(135deg, #22c55e, #4ade80);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, .3);
}

.fac-btn-success:hover {
  box-shadow: 0 4px 16px rgba(34, 197, 94, .4);
  transform: translateY(-1px);
}

.fac-btn-ghost {
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  border: 1.5px solid var(--color-border, #334155);
}

.fac-btn-ghost:hover {
  background: var(--color-bg-hover, #334155);
  color: var(--color-text-primary);
}

.fac-btn-danger {
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, .3);
}

.fac-btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
}

.fac-btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   DASHBOARD
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.fac-dash-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* â”€â”€ KPI Row â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  flex-shrink: 0;
}

.fac-kpi {
  background: var(--color-bg-card, #1e293b);
  border: 1.5px solid var(--color-border, #334155);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}

.fac-kpi:hover {
  border-color: var(--color-accent, #6366f1);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

.fac-kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.fac-kpi.k-blue::before {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

.fac-kpi.k-amber::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.fac-kpi.k-red::before {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.fac-kpi.k-green::before {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.fac-kpi.k-purple::before {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.fac-kpi.k-cyan::before {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
}

.fac-kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.fac-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--color-text-secondary, #94a3b8);
}

.fac-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.fac-kpi.k-blue .fac-kpi-icon {
  background: rgba(99, 102, 241, .15);
}

.fac-kpi.k-amber .fac-kpi-icon {
  background: rgba(245, 158, 11, .15);
}

.fac-kpi.k-red .fac-kpi-icon {
  background: rgba(239, 68, 68, .15);
}

.fac-kpi.k-green .fac-kpi-icon {
  background: rgba(34, 197, 94, .15);
}

.fac-kpi.k-purple .fac-kpi-icon {
  background: rgba(139, 92, 246, .15);
}

.fac-kpi.k-cyan .fac-kpi-icon {
  background: rgba(6, 182, 212, .15);
}

.fac-kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-text-primary, #f1f5f9);
  letter-spacing: -.8px;
  line-height: 1.1;
}

.fac-kpi-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
}

.fac-trend {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.fac-trend.up {
  color: var(--color-success, #22c55e);
}

.fac-trend.down {
  color: var(--color-danger, #ef4444);
}

.fac-trend.flat {
  color: var(--color-text-muted, #64748b);
}

/* â”€â”€ Mini Sparkline (CSS-only) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  margin-top: 6px;
}

.fac-spark-bar {
  flex: 1;
  border-radius: 2px;
  transition: height .5s cubic-bezier(.16, 1, .3, 1);
  min-height: 2px;
}

.fac-kpi.k-blue .fac-spark-bar {
  background: rgba(99, 102, 241, .5);
}

.fac-kpi.k-amber .fac-spark-bar {
  background: rgba(245, 158, 11, .5);
}

.fac-kpi.k-red .fac-spark-bar {
  background: rgba(239, 68, 68, .5);
}

.fac-kpi.k-green .fac-spark-bar {
  background: rgba(34, 197, 94, .5);
}

/* â”€â”€ Dashboard Grid (2-col + activity feed) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

/* â”€â”€ Card (generic dashboard card) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-card {
  background: var(--color-bg-card, #1e293b);
  border: 1.5px solid var(--color-border, #334155);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .2s;
}

.fac-card:hover {
  border-color: color-mix(in srgb, var(--color-border) 100%, white 20%);
}

.fac-card-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.fac-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fac-card-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* â”€â”€ Bar Chart (improved) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  height: 100%;
  padding: 20px 18px 8px;
}

.fac-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  max-width: 56px;
}

.fac-chart-bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--color-accent, #6366f1) 0%, rgba(99, 102, 241, .3) 100%);
  transition: height .7s cubic-bezier(.16, 1, .3, 1);
  min-height: 3px;
  position: relative;
}

.fac-chart-bar:hover {
  filter: brightness(1.2);
}

.fac-chart-bar::after {
  content: attr(data-val);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary, #94a3b8);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s;
}

.fac-chart-bar:hover::after {
  opacity: 1;
}

.fac-chart-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted, #64748b);
}

/* â”€â”€ Donut Chart (CSS-only) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  height: 100%;
}

.fac-donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.fac-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.fac-donut-total {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-text-primary, #f1f5f9);
  line-height: 1;
}

.fac-donut-label {
  font-size: 10px;
  color: var(--color-text-muted, #64748b);
}

.fac-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fac-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-secondary, #94a3b8);
}

.fac-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.fac-legend-val {
  margin-left: auto;
  font-weight: 600;
  color: var(--color-text-primary, #f1f5f9);
}

/* â”€â”€ Activity Feed â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-feed {
  padding: 0;
}

.fac-feed-item {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-border, #334155);
  transition: background .12s;
  cursor: pointer;
}

.fac-feed-item:hover {
  background: var(--color-bg-hover, #334155);
}

.fac-feed-item:last-child {
  border-bottom: none;
}

.fac-feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.fac-feed-dot.dot-blue {
  background: #6366f1;
}

.fac-feed-dot.dot-green {
  background: #22c55e;
}

.fac-feed-dot.dot-amber {
  background: #f59e0b;
}

.fac-feed-dot.dot-red {
  background: #ef4444;
}

.fac-feed-dot.dot-purple {
  background: #8b5cf6;
}

.fac-feed-content {
  flex: 1;
  min-width: 0;
}

.fac-feed-text {
  font-size: 12px;
  color: var(--color-text-primary, #f1f5f9);
  line-height: 1.4;
}

.fac-feed-text strong {
  color: var(--color-text-accent, #818cf8);
  font-weight: 600;
}

.fac-feed-time {
  font-size: 10px;
  color: var(--color-text-muted, #64748b);
  margin-top: 2px;
}

.fac-feed-badge {
  flex-shrink: 0;
  align-self: center;
}

/* â”€â”€ Alerts Row (dashboard) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-alerts {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.fac-alert {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  transition: transform .15s;
  cursor: pointer;
}

.fac-alert:hover {
  transform: translateY(-1px);
}

.fac-alert-warn {
  background: rgba(245, 158, 11, .08);
  border: 1px solid rgba(245, 158, 11, .25);
  color: #fbbf24;
}

.fac-alert-danger {
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  color: #f87171;
}

.fac-alert-info {
  background: rgba(6, 182, 212, .08);
  border: 1px solid rgba(6, 182, 212, .25);
  color: #22d3ee;
}

.fac-alert-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.fac-alert-text {
  flex: 1;
}

.fac-alert-count {
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   DOCUMENT LIST (LISTADO)
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

/* â”€â”€ Stats Bar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-stats-bar {
  display: flex;
  gap: 4px;
  padding: 8px 20px;
  background: var(--color-bg-secondary, #1e293b);
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.fac-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  border: 1.5px solid transparent;
}

.fac-stat-pill:hover {
  transform: translateY(-1px);
}

.fac-stat-pill.pill-active {
  border-color: var(--color-accent, #6366f1);
  background: var(--color-accent-subtle);
}

.fac-stat-pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.fac-stat-pill .pill-count {
  font-weight: 800;
}

/* pill colors */
.pill-all {
  background: rgba(148, 163, 184, .1);
  color: #94a3b8;
}

.pill-all .pill-dot {
  background: #94a3b8;
}

.pill-brr {
  background: rgba(148, 163, 184, .1);
  color: #cbd5e1;
}

.pill-brr .pill-dot {
  background: #cbd5e1;
}

.pill-val {
  background: rgba(59, 130, 246, .08);
  color: #60a5fa;
}

.pill-val .pill-dot {
  background: #3b82f6;
}

/* APR = pendiente de aprobación (aún no emitido): ámbar de aviso, no el verde
   de «aprobado» (10-09-2026). */
.pill-apr {
  background: rgba(245, 158, 11, .08);
  color: #fbbf24;
}

.pill-apr .pill-dot {
  background: var(--color-warning, #f59e0b);
}

.pill-ctb {
  background: rgba(168, 85, 247, .08);
  color: #c084fc;
}

.pill-ctb .pill-dot {
  background: #8b5cf6;
}

/* SLD = saldado: pagado entero, lo pone el cobro o el pago (11-09-2026). */
.pill-sld {
  background: rgba(34, 197, 94, .08);
  color: #4ade80;
}

.pill-sld .pill-dot {
  background: var(--color-success, #22c55e);
}

.pill-anu {
  background: rgba(239, 68, 68, .08);
  color: #f87171;
}

.pill-anu .pill-dot {
  background: #ef4444;
}

/* Los demás estados (Abierto, Cerrado, Traspasado, En obra…): los chips salen
   de los estados presentes en los datos, no de una lista fija (12-09-2026). */
.pill-otro {
  background: rgba(148, 163, 184, .08);
  color: var(--color-text-secondary, #94a3b8);
}

.pill-otro .pill-dot {
  background: var(--color-text-muted, #64748b);
}

/* â”€â”€ Search + Filters Bar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--color-bg-secondary, #1e293b);
  border-bottom: 1.5px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.fac-search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.fac-search-wrap::before {
  content: '\1F50D';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

.fac-search {
  width: 100%;
  background: var(--color-bg-input, #334155);
  color: var(--color-text-primary, #f1f5f9);
  border: 1.5px solid var(--color-border, #334155);
  border-radius: 8px;
  padding: 7px 10px 7px 32px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.fac-search:focus {
  border-color: var(--color-accent, #6366f1);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.fac-search::placeholder {
  color: var(--color-text-muted, #64748b);
}

.fac-filters-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Fila del buscador de Documentos, con los filtros de fecha (14-09-2026).
   El buscador nunca baja de 200px: con el flex:1 de .fac-search-wrap (base 0)
   las fechas lo aplastaban hasta dejarlo en nada. Cuando buscador y fechas ya no
   caben juntos, las fechas bajan a su propia línea y Servicio y orden se quedan
   arriba, al lado del buscador.
   1020px = buscador 200 + hueco 10 + fechas 765-773 y algo de holgura, medido con
   las hojas del shell en Pruebas/FacturacionFilaFiltros/banco.html (el ancho de
   las fechas varía unos px con la escala de pantalla). Si cambian los botones de
   fecha, se vuelve a medir. */
.fac-filters-docs {
  flex-wrap: wrap;
  container: facfiltrosdocs / inline-size;
}

.fac-filters-docs > .fac-search-wrap {
  flex: 1 1 200px;
  min-width: 200px;
}

@container facfiltrosdocs (max-width: 1020px) {
  .fac-filters-docs > #docFiltrosFecha {
    order: 1;
    flex-basis: 100%;
  }

  .fac-filters-docs > #docFechaAviso {
    order: 2;
  }
}

.fac-sortbtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-bg-input, #334155);
  color: var(--color-text-secondary, #94a3b8);
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}

.fac-sortbtn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.fac-sortbtn.active {
  background: rgba(99, 102, 241, .15);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, .4);
}

/* â”€â”€ Document List (card-based) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-doc-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fac-doc-row {
  display: grid;
  /* La 1ª columna (26px) es la casilla de agrupación. Al añadirla hay que
     sumarla aquí o el grid mete todo lo demás una posición a la izquierda y
     la última columna se sale de la fila. */
  grid-template-columns: 26px 44px minmax(140px, 1fr) minmax(160px, 1.4fr) minmax(180px, 2fr) 90px 100px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--color-bg-card, #1e293b);
  border: 1.5px solid var(--color-border, #334155);
  cursor: pointer;
  transition: all .15s;
  position: relative;
}

/* ── Agrupación: casilla y estados de la fila ─────────────────────────────
   La casilla sólo se ve al pasar por encima, al estar marcada o cuando hay
   una agrupación en curso: si estuviera siempre visible, el listado pasaría
   de ser una lista de documentos a un formulario de selección. */
.fac-doc-agr {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}
.fac-doc-row:hover .fac-doc-agr,
.fac-doc-row.fac-agr-on .fac-doc-agr,
#docList.fac-agr-activa .fac-doc-agr { opacity: 1; }
.fac-doc-agr input { cursor: pointer; width: 15px; height: 15px; }
.fac-doc-agr input:disabled { cursor: not-allowed; }

/* Marcada para agrupar */
.fac-doc-row.fac-agr-on {
  border-color: var(--color-accent, #6366f1);
  background: color-mix(in srgb, var(--color-bg-card) 85%, var(--color-accent) 15%);
}

/* No compatible con la agrupación en curso (otro tercero, otro tipo, otra
   moneda, anulado). Se atenúa en vez de ocultarse: el documento sigue ahí y
   se puede abrir; lo único que no se puede es meterlo en ESTA agrupación. */
.fac-doc-row.fac-agr-off { opacity: .42; }
.fac-doc-row.fac-agr-off:hover { opacity: .62; }

/* La barra de agrupación es position:fixed sobre el listado, así que sin este
   hueco la última fila se queda debajo de ella justo cuando se hace scroll
   hasta abajo — que es cuando se está buscando el último documento a marcar. */
#docList.fac-agr-activa { padding-bottom: 96px; }

.fac-doc-row:hover {
  border-color: var(--color-accent, #6366f1);
  background: color-mix(in srgb, var(--color-bg-card) 90%, var(--color-accent) 10%);
  transform: translateX(2px);
}

.fac-doc-row.selected {
  border-color: var(--color-accent, #6366f1);
  background: var(--color-accent-subtle, rgba(99, 102, 241, .12));
  box-shadow: 0 0 0 1px var(--color-accent);
}

.fac-doc-row.doc-anulado {
  opacity: .5;
}

.fac-doc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -.3px;
}

.fac-doc-avatar.av-pre {
  background: rgba(148, 163, 184, .15);
  color: #cbd5e1;
}

.fac-doc-avatar.av-ped {
  background: rgba(59, 130, 246, .15);
  color: #60a5fa;
}

.fac-doc-avatar.av-alb {
  background: rgba(245, 158, 11, .15);
  color: #fbbf24;
}

.fac-doc-avatar.av-fac {
  background: rgba(34, 197, 94, .15);
  color: #4ade80;
}

.fac-doc-avatar.av-abn {
  background: rgba(239, 68, 68, .15);
  color: #f87171;
}

.fac-doc-avatar.av-rec {
  background: rgba(168, 85, 247, .15);
  color: #c084fc;
}

.fac-doc-info {
  min-width: 0;
}

.fac-doc-id {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
  letter-spacing: -.2px;
}

.fac-doc-tercero {
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fac-doc-asunto {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--color-text-primary, #f1f5f9);
}
.fac-doc-asunto .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fac-doc-asunto-ico {
  color: var(--color-text-secondary, #94a3b8);
  font-size: 11px;
  flex-shrink: 0;
}
.fac-doc-asunto-empty {
  color: var(--color-text-muted, #64748b);
  font-style: italic;
}

.fac-doc-client-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Hover Actions */
.fac-doc-actions {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) scale(0.95);
  display: flex;
  gap: 4px;
  background: var(--color-bg-card, #1e293b);
  padding: 4px 6px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border, #334155);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

.fac-doc-row:hover .fac-doc-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.fac-doc-actions .fac-btn-icon {
  background: transparent;
  color: var(--color-text-secondary, #94a3b8) !important;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.fac-doc-actions .fac-btn-icon i,
.fac-doc-actions .fac-btn-icon .fas,
.fac-doc-actions .fac-btn-icon .fa-solid {
  color: inherit !important;
  font-size: 13px !important;
  display: inline-block !important;
}

.fac-doc-actions .fac-btn-icon:hover {
  background: var(--color-bg-hover, #334155);
  color: var(--color-text-primary, #f1f5f9) !important;
}

.fac-doc-actions .fac-btn-icon.del-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444 !important;
}

.fac-doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  min-width: 0;
}

.fac-doc-meta-obs {
  font-size: 11px;
  color: var(--color-text-secondary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex-basis: 100%;
}

.fac-doc-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.fac-doc-tag.tag-pay {
  background: rgba(59, 130, 246, .1);
  color: #60a5fa;
}

.fac-doc-tag.tag-method {
  background: rgba(34, 197, 94, .1);
  color: #4ade80;
}

.fac-doc-tag.tag-vf {
  background: rgba(245, 158, 11, .1);
  color: #fbbf24;
}

/* FacturaE: azul, para no confundirlo con el ámbar de VeriFactu. El check
   indica firmada; el punto, generada pero aún sin firmar. */
.fac-doc-tag.tag-fae {
  background: rgba(59, 130, 246, .12);
  color: #60a5fa;
}

.fac-doc-tag.tag-lines {
  background: rgba(148, 163, 184, .08);
  color: #94a3b8;
}

.fac-doc-date {
  font-size: 12px;
  color: var(--color-text-secondary, #94a3b8);
  text-align: center;
}

.fac-doc-date small {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted, #64748b);
}

/* Fecha de recepción de una recibida distinta de la de la factura (10-10-2026):
   decide el trimestre del IVA, por eso destaca. También en el listado de Compras. */
.fac-doc-date small.fac-doc-recep,
small.fac-doc-recep {
  display: block;
  font-size: 10px;
  white-space: nowrap;
  color: var(--color-warning, #f59e0b);
}

.fac-doc-status {
  text-align: center;
}

.fac-doc-total {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
  letter-spacing: -.3px;
  width: 100%;
  padding-right: 4px;
}

.fac-doc-total small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-muted, #64748b);
  text-align: right;
}

/* â”€â”€ Status Badges â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-brr {
  background: rgba(148, 163, 184, .15);
  color: #cbd5e1;
}

.badge-val {
  background: rgba(59, 130, 246, .15);
  color: #60a5fa;
}

.badge-apr {
  background: rgba(245, 158, 11, .15);
  color: #fbbf24;
}

.badge-ctb {
  background: rgba(168, 85, 247, .15);
  color: #c084fc;
}

.badge-sld {
  background: rgba(34, 197, 94, .15);
  color: #4ade80;
}

.badge-anu {
  background: rgba(239, 68, 68, .15);
  color: #f87171;
}

.badge-pre {
  background: rgba(148, 163, 184, .15);
  color: #cbd5e1;
}

.badge-ped {
  background: rgba(59, 130, 246, .15);
  color: #60a5fa;
}

.badge-alb {
  background: rgba(245, 158, 11, .15);
  color: #fbbf24;
}

.badge-fac {
  background: rgba(34, 197, 94, .15);
  color: #4ade80;
}

.badge-abn {
  background: rgba(239, 68, 68, .15);
  color: #f87171;
}

.badge-rec {
  background: rgba(168, 85, 247, .15);
  color: #c084fc;
}

/* â”€â”€ Grid Footer / Pagination â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-list-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 20px;
  border-top: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
  background: var(--color-bg-secondary, #1e293b);
}

.fac-footer-count {
  font-weight: 600;
  color: var(--color-text-secondary, #94a3b8);
}

.fac-footer-totals {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.fac-footer-item {
  font-size: 11px;
  color: #94a3b8;
}

.fac-footer-item b {
  color: #cbd5e1;
  font-weight: 700;
}

.fac-footer-sep {
  width: 1px;
  height: 14px;
  background: var(--color-border, #334155);
}

.fac-footer-grand {
  font-size: 12px;
  color: #e2e8f0;
}

.fac-footer-grand b {
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 800;
}

.fac-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: .8rem;
}

/* Paginación canónica modelo Diario: chips Anterior / Pág X de Y / Siguiente / N por página.
   Las clases antiguas .fac-page-btn (.active, .fac-page-sep) quedan deprecated. */
.fac-pg-btn {
  background: transparent;
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-secondary, #94a3b8);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .12s;
  white-space: nowrap;
  font-family: inherit;
}
.fac-pg-btn:hover:not([disabled]) {
  border-color: var(--color-accent, #6366f1);
  color: var(--color-text-primary, #f8fafc);
  background: rgba(99, 102, 241, 0.08);
}
.fac-pg-btn[disabled] {
  opacity: .35;
  cursor: not-allowed;
}
.fac-pg-info {
  color: var(--color-text-primary, #f8fafc);
  font-size: .8rem;
  padding: 0 4px;
}
.fac-pg-info b {
  color: var(--color-accent, #6366f1);
}
.fac-pg-size {
  padding: 4px 8px;
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  background: var(--color-bg-secondary, #1e293b);
  color: var(--color-text-primary, #f8fafc);
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   DETAIL PANEL (slide-in from right)
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.fac-detail-overlay {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  background: var(--color-bg-card, #1e293b);
  border-left: 2px solid var(--color-accent, #6366f1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, .3);
  z-index: 20;
  flex-direction: column;
  overflow: hidden;
  animation: fac-slide-right .25s ease-out;
}

.fac-detail-overlay.open {
  display: flex;
}

@keyframes fac-slide-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.fac-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1.5px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.fac-detail-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--color-border, #334155);
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
}

.fac-detail-close:hover {
  background: var(--color-danger, #ef4444);
  color: #fff;
  border-color: transparent;
}

.fac-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fac-detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fac-detail-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--color-text-muted, #64748b);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border, #334155);
}

.fac-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.fac-detail-row .label {
  color: var(--color-text-secondary, #94a3b8);
}

.fac-detail-row .value {
  color: var(--color-text-primary, #f1f5f9);
  font-weight: 600;
}

.fac-detail-row .value.big {
  font-size: 18px;
  color: var(--color-text-accent, #818cf8);
  font-weight: 800;
}

/* â”€â”€ Detail Line Items â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-detail-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.fac-detail-lines th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted, #64748b);
  border-bottom: 1.5px solid var(--color-border, #334155);
}

.fac-detail-lines td {
  padding: 6px 8px;
  color: var(--color-text-primary, #f1f5f9);
  border-bottom: 1px solid rgba(255, 255, 255, .04);
}

.fac-detail-lines td.r {
  text-align: right;
}

.fac-detail-lines tr:hover td {
  background: rgba(255, 255, 255, .03);
}

/* â”€â”€ Workflow Progress â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.fac-workflow {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 0;
}

.fac-wf-step {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.fac-wf-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid var(--color-border, #334155);
  background: var(--color-bg-primary, #0f172a);
  color: var(--color-text-muted, #64748b);
  transition: all .2s;
}

.fac-wf-dot.done {
  background: var(--color-success, #22c55e);
  border-color: var(--color-success);
  color: #fff;
}

.fac-wf-dot.current {
  background: var(--color-accent, #6366f1);
  border-color: var(--color-accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.fac-wf-line {
  flex: 1;
  height: 2px;
  background: var(--color-border, #334155);
}

.fac-wf-line.done {
  background: var(--color-success, #22c55e);
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   RESPONSIVE
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
@media (max-width: 1200px) {
  .fac-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .fac-dash-grid {
    grid-template-columns: 1fr;
  }

  .fac-doc-row {
    grid-template-columns: 44px 1fr 1.2fr 100px 120px;
  }

  .fac-doc-date,
  .fac-doc-meta {
    display: none;
  }
}

@media (max-width: 900px) {
  .fac-nav {
    width: 56px;
  }

  .fac-nav-btn span:not(.nav-icon) {
    display: none;
  }

  .fac-nav-header,
  .fac-nav-section {
    display: none;
  }

  .fac-nav-btn .nav-count {
    display: none;
  }

  .fac-kpi-row {
    grid-template-columns: 1fr 1fr;
  }

  .fac-doc-row {
    grid-template-columns: 36px 1fr 100px;
  }
  .fac-doc-asunto {
    display: none;
  }

  .fac-doc-status,
  .fac-doc-date,
  .fac-doc-meta {
    display: none;
  }

  .fac-detail-overlay {
    width: 100%;
  }
  }


  /* â•â•â• DEBUG LAYOUT â•â•â• */
  /* Remove these comments to enable borders */
  /*
  .fac-main { border: 4px solid red !important; box-shadow: inset 0 0 50px rgba(255,0,0,0.2); }
  .fac-view { border: 4px solid yellow !important; box-shadow: inset 0 0 50px rgba(255,255,0,0.2); }
  .fac-header { border: 4px solid lime !important; }
  .fac-nav { border: 4px solid cyan !important; }
  */

  /* â•â•â• FORCED LAYOUT RESET â•â•â• */
  .fac-layout {
    display: flex !important;
    flex-direction: row !important;
    /* Forces side-by-side */
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .fac-nav {
    flex-shrink: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
  }

  .fac-main {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    /* Ensures top alignment */
    align-items: stretch !important;
    height: 100% !important;
    width: auto !important;
    /* Let flex handle width */
    overflow: hidden !important;
    background: var(--color-bg-primary, #0f172a) !important;
    position: relative !important;
    /* Ensure content flows inside */
  }

  .fac-view {
    flex: 1 !important;
    display: none;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    height: 100% !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .fac-view.fac-active {
    display: flex !important;
  }

  .fac-header {
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    width: 100% !important;
  }
 


/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   EDITOR / FORM STYLES (DARK PREMIUM THEME)
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.fac-form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fac-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-secondary, #94a3b8);
  letter-spacing: .5px;
}

.fac-input {
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: #f1f5f9;
  /* Light Text */
  transition: all .15s;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
}

.fac-input:focus {
  outline: none;
  border-color: var(--color-accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .2);
  background: var(--color-bg-card, #1e293b);
}

.fac-input[readonly] {
  background: var(--color-bg-secondary, #1e293b);
  color: #64748b;
  cursor: default;
  border-color: transparent;
}

.fac-subtext {
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
  margin-top: 4px;
}

/* Editor Table */
.fac-table-editor {
  width: 100%;
  border-collapse: collapse;
}

.fac-table-editor th {
  background: var(--color-bg-secondary, #1e293b);
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #94a3b8;
  border-bottom: 1px solid var(--color-border, #334155);
  text-align: left;
}

.fac-table-editor td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border, #334155);
  color: #e2e8f0;
}

.fac-table-editor input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  transition: all .15s;
  font-family: inherit;
  box-sizing: border-box;
  color: #f1f5f9;
}

.fac-table-editor input:hover {
  background: var(--color-bg-primary, #0f172a);
  border-color: var(--color-border, #334155);
}

.fac-table-editor input:focus {
  background: var(--color-bg-primary, #0f172a);
  border-color: var(--color-accent, #6366f1);
  outline: none;
}

.fac-table-editor .del-btn {
  color: #ef4444;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity .15s;
  background: none;
  border: none;
  font-size: 16px;
  padding: 4px;
}

.fac-table-editor tr:hover .del-btn {
  opacity: 1;
}

/* Editor Footer & Totals */
.fac-editor-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border, #334155);
  display: flex;
  justify-content: flex-end;
  gap: 32px;
  background: var(--color-bg-secondary, #1e293b);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.fac-total-box {
  text-align: right;
}

.fac-total-box .lbl {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.fac-total-box .val {
  font-size: 15px;
  font-weight: 600;
  color: #e2e8f0;
}

.fac-total-box.big .val {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-accent, #6366f1);
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   MODAL & RICH EDITOR
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.fac-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeIn .2s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.fac-modal {
  background: var(--color-bg-card, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-radius: 12px;
  width: 900px;
  max-width: 92%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fac-modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #334155);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fac-modal-title {
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
}

.fac-editor-toolbar {
  padding: 8px 16px;
  background: var(--color-bg-primary, #0f172a);
  border-bottom: 1px solid var(--color-border, #334155);
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.fac-tool-select {
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-secondary, #94a3b8);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  cursor: pointer;
  height: 28px;
}

.fac-tool-select:focus {
  outline: none;
  border-color: var(--color-accent, #6366f1);
}

.fac-tool-color {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--color-border, #334155);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.fac-tool-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.fac-tool-color::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.fac-tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-secondary, #94a3b8);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.fac-tool-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.fac-tool-sep {
  width: 1px;
  background: var(--color-border, #334155);
  margin: 0 4px;
}

.fac-rich-edit {
  min-height: 420px;
  max-height: 60vh;
  padding: 20px;
  color: var(--color-text-primary, #f1f5f9);
  outline: none;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 14px;
}

.fac-rich-edit:focus {
  background: rgba(99, 102, 241, 0.05);
}

.fac-modal-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border, #334155);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--color-bg-primary, #0f172a);
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   EDITOR v3 — Premium Single-Row Layout
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

/* â”€â”€ Global Editor Inputs â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
#view-editor input,
#view-editor select,
#view-editor textarea {
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: #f1f5f9;
  font-family: inherit;
  box-sizing: border-box;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

#view-editor textarea {
  field-sizing: content;
  min-height: 80px;
  resize: vertical;
}

/* Checkboxes: override width:100% from above (ID specificity required) */
#view-editor input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 3px;
  accent-color: var(--color-accent, #6366f1);
}

#view-editor input:focus,
#view-editor select:focus,
#view-editor textarea:focus {
  outline: none;
  border-color: var(--color-accent, #6366f1);
  box-shadow: 0 0 0 2px var(--color-accent-subtle, rgba(99, 102, 241, .2));
}

#view-editor input[readonly] {
  background: var(--color-bg-secondary, #1e293b);
  color: #64748b;
  cursor: default;
  border-color: transparent;
}

#view-editor label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #94a3b8;
  margin-bottom: 3px;
}

/* â”€â”€ Single-Row Header â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px 10px 16px;
  background: var(--color-bg-secondary, #1e293b);
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.ed-header-row {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.ed-header-row-data {
  align-items: flex-end;
  flex-wrap: wrap;
}

.ed-header-row-actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 18px; /* mayor que la fila de datos para distinguir bloques */
  border-top: 1px dashed var(--color-border, #334155);
  padding-top: 10px;
}

/* Separador vertical entre bloques de la fila de acciones (totales | estado | …) */
.ed-vsep {
  width: 1px;
  height: 28px;
  background: var(--color-border, #334155);
  flex-shrink: 0;
  align-self: center;
}

.ed-actions-spacer {
  flex: 1;
  min-width: 0;
}

/* Bloque acciones izquierdo (Validar/Anular + Rectificativa/Anticipo/Clonar).
   - flex-shrink:0 + flex-wrap:nowrap → los botones internos NO se separan;
     todo el bloque salta a la siguiente línea como unidad cuando no cabe.
   - Hijo de .ed-header-row-actions que sí permite wrap (de los grupos). */
.ed-actions-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* (.ed-row1-right eliminado: Guardar va siempre a la derecha vía
   .ed-actions-spacer, NO pegado a los totales). */

/* «Volver» con fondo neutro del tema para que se vea (10-09-2026: era un
   borde fino con texto gris). Colores por tokens de iEnTop.css: la cabecera
   se adapta sola a los temas [data-theme]. */
.ed-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-hover, #334155);
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-primary, #f1f5f9);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .15s;
  align-self: flex-end;   /* a ras de los inputs de la fila de datos */
}

.ed-btn-back:hover {
  border-color: var(--color-accent, #6366f1);
  color: var(--color-text-accent, #818cf8);
}

.ed-sep {
  width: 1px;
  height: 28px;
  background: var(--color-border, #334155);
  flex-shrink: 0;
  align-self: center;
}

.ed-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ed-field input,
.ed-field select {
  width: 100%;
}

/* Anchos (10-09-2026): Proveedor, Serie y Número se quedaban cortos y la
   Fecha tenía espacio de sobra. El tercero crece con la fila hasta un tope. */
.ed-field-client {
  flex: 1 1 320px;
  min-width: 220px;
  max-width: 480px;
}

.ed-field-serie  { width: 210px; flex-shrink: 0; }
.ed-field-numero { width: 160px; flex-shrink: 0; }
.ed-field-fecha  { width: 140px; flex-shrink: 0; }

/* ── Acciones de la cabecera (fila 2, 10-09-2026) ──────────────────────
   Todas a la vista, con icono y título, sin desplegables (el menú lo
   escondía todo). Sustituyen a .ed-state-actions, .ed-convert-actions y
   .ed-doc-actions, de un diseño anterior que ya no se usaba. Cada grupo va
   de una pieza: si no cabe, baja entero de línea. Separadores sin rótulos:
   lo pone el grupo que tiene otro grupo visible delante
   (_syncGruposAcciones, en el engine). Colores por tokens del tema. */
.ed-act-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  padding-left: 12px;
  border-left: 1px solid var(--color-border, #334155);
}

.ed-act-group.ed-act-group-first {
  padding-left: 0;
  border-left: none;
}

.ed-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-card, #1e293b);
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-primary, #f1f5f9);
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.ed-act i {
  font-size: 13px;
  color: var(--color-text-accent, #818cf8);
}

.ed-act:hover {
  border-color: var(--color-accent, #6366f1);
  background: var(--color-accent-subtle, rgba(99, 102, 241, .15));
}

/* Destructivas (Anular, Eliminar): el color de peligro del tema. */
.ed-act-danger,
.ed-act-danger i {
  color: var(--color-danger, #ef4444);
}

.ed-act-danger:hover {
  border-color: var(--color-danger, #ef4444);
  background: rgba(239, 68, 68, .12);
}

/* Estado del documento FacturaE en sus botones: correcto o con error. */
.ed-act-ok i  { color: var(--color-success, #22c55e); }
.ed-act-err i { color: var(--color-danger, #ef4444); }

/* A la vista pero no aplicable ahora (el asistente en un documento cerrado):
   se deja pulsar para explicar por qué. */
.ed-act-off {
  opacity: .5;
}

/* Switch del Anticipo — variante FAC del patrón switch (track + thumb).
   El input nativo se oculta y el toggle visual lo construyen los dos spans.
   IMPORTANTE: el wrapper NO usa la clase .ed-field para evitar heredar el
   estilo uppercase/block del label de campo. Colores por tokens del tema. */
.ed-anticipo-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row;
  width: auto;
  align-self: flex-end;  /* alinea con la base de los inputs adyacentes */
  padding-bottom: 6px;
}

.ed-switch-label {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-primary, #f1f5f9);
  user-select: none;
  white-space: nowrap;
  font-weight: 600;
  text-transform: none !important;  /* anula uppercase de .ed-field label si fuera el caso */
  letter-spacing: normal !important;
  margin: 0 !important;
}

/* Texto "Anticipo" del switch — para no heredar estilos de span genéricos */
.ed-switch-text {
  font-size: 13px;
  color: var(--color-text-primary, #f1f5f9);
}

.ed-switch-label input[type="checkbox"] {
  display: none;
}

.ed-switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--color-bg-hover, #334155);
  border-radius: 10px;
  transition: background .2s;
  flex-shrink: 0;
}

.ed-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-text-secondary, #94a3b8);
  border-radius: 50%;
  transition: all .2s;
}

.ed-switch-label input:checked + .ed-switch-track {
  background: var(--color-accent, #6366f1);
}

.ed-switch-label input:checked + .ed-switch-track .ed-switch-thumb {
  left: 18px;
  background: #fff;
}

/* â”€â”€ Smart Search Dropdown â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-smart-search {
  position: relative;
}

.ed-smart-search input {
  padding-right: 28px;
}

.ed-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-bg-card, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.ed-dropdown.open {
  display: block;
}

.ed-dropdown .dd-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text-primary, #e2e8f0);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
  transition: background .1s;
}

.ed-dropdown .dd-item:hover {
  background: rgba(99, 102, 241, .1);
}

.ed-dropdown .dd-item.dd-selected {
  background: rgba(99, 102, 241, .15);
}

.ed-dropdown .dd-action {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent, #818cf8);
  cursor: pointer;
  border-top: 1px solid var(--color-border, #334155);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .1s;
}

.ed-dropdown .dd-action:hover {
  background: rgba(99, 102, 241, .15);
}

.ed-dropdown .dd-action+.dd-action {
  border-top: none;
}

/* â”€â”€ Badges (Header & Footer) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;     /* badges (Base/IVA/Total) viajan SIEMPRE juntos */
  flex-shrink: 0;
}

/* En la fila de datos (10-09-2026): bloque a la derecha, a ras de los inputs. */
.ed-header-row-data .ed-badges {
  margin-left: auto;
  align-self: flex-end;
  padding-bottom: 5px;
}

/* Colores por tokens del tema (10-09-2026): eran lilas fijos pensados para
   fondo oscuro y en los temas claros apenas se leían. */
.ed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-accent-subtle, rgba(99, 102, 241, .1));
  color: var(--color-text-secondary, #94a3b8);
  white-space: nowrap;
}

.ed-badge b {
  color: var(--color-text-primary, #f1f5f9);
  font-weight: 800;
}

.ed-badge-accent {
  background: var(--color-accent-subtle, rgba(99, 102, 241, .25));
  border: 1px solid var(--color-accent, #6366f1);
  color: var(--color-text-accent, #818cf8);
}

.ed-badge-accent b {
  color: var(--color-text-accent, #818cf8);
}

.ed-badge-warn {
  background: rgba(245, 158, 11, .15);
  color: var(--color-warning, #f59e0b);
}

.ed-badge-warn b {
  color: var(--color-warning, #f59e0b);
}

.ed-badge-danger {
  background: rgba(239, 68, 68, .15);
  color: var(--color-danger, #ef4444);
}

.ed-badge-danger b {
  color: var(--color-danger, #ef4444);
}

.ed-badge-muted {
  background: var(--color-bg-hover, #334155);
  color: var(--color-text-secondary, #94a3b8);
}

.ed-badge-total {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  font-size: 12px;
  padding: 6px 14px;
}

.ed-badge-total b {
  color: #fff;
  font-weight: 800;
}

/* â”€â”€ Action Buttons â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-btn-icon {
  background: none;
  border: 1px solid var(--color-border, #334155);
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
  align-self: center;
}

.ed-btn-icon:hover {
  color: #fff;
  border-color: #6366f1;
}

/* Guardar: el acento del tema (10-09-2026: era un degradado índigo fijo). */
.ed-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-accent, #6366f1);
  color: #fff;
  border: 1px solid var(--color-accent, #6366f1);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
  align-self: center;
}

.ed-btn-save:hover {
  background: var(--color-accent-hover, #818cf8);
  border-color: var(--color-accent-hover, #818cf8);
}

/* Variante secundaria del boton de guardar (20-09-2026): la cabecera del
   editor tiene dos acciones de guardado -- «Guardar» (sigue editando) y
   «Guardar y salir» (cierra y vuelve al listado). La terminal se queda con el
   acento y esta va en outline, para que se lean como una sola pareja y no
   compitan. Solo cambia color: hereda de .ed-btn-save todo el layout. */
.ed-btn-save.ed-btn-save-alt {
  background: var(--color-bg-card, #1e293b);
  color: var(--color-text-primary, #f1f5f9);
  border-color: var(--color-accent, #6366f1);
  margin-right: 8px;
}

.ed-btn-save.ed-btn-save-alt:hover {
  background: var(--color-accent, #6366f1);
  border-color: var(--color-accent, #6366f1);
  color: #fff;
}

/* â”€â”€ Tabs Navigation â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-tabs {
  display: flex;
  gap: 0;
  align-items: center;
  background: var(--color-bg-primary, #0f172a);
  border-bottom: 2px solid var(--color-border, #334155);
  flex-shrink: 0;
  padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.ed-tabs::-webkit-scrollbar {
  height: 3px;
}

.ed-tabs::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, .4);
  border-radius: 3px;
}

.ed-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  white-space: nowrap;
}

.ed-tab:hover {
  color: #e2e8f0;
}

.ed-tab.active {
  color: var(--color-accent, #818cf8);
  border-bottom-color: var(--color-accent, #6366f1);
}

/* â”€â”€ Tab Content Area â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.ed-pane {
  display: none;
  padding: 16px;
  animation: edFadeIn .2s ease;
}

.ed-pane.active {
  display: block;
}

#tab-lines.active {
  display: flex;
  flex-direction: column;
}

@keyframes edFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* â”€â”€ Toolbar (Lines tab) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-toolbar {
  display: flex;
  gap: 8px;
  padding: 0 0 10px 0;
  flex-shrink: 0;
}

/* â”€â”€ Lines Grid â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-grid-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--color-border, #334155);
  border-radius: 8px;
}

.ed-grid {
  min-width: 900px;
  border-collapse: collapse;
}

.ed-grid th {
  background: var(--color-bg-secondary, #1e293b);
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: #64748b;
  border-bottom: 1px solid var(--color-border, #334155);
  text-align: left;
}

/* Column widths for Lines grid */
.col-ref {
  width: 8%;
}

.col-desc {
  width: 30%;
}

.col-num {
  width: 8%;
  text-align: right !important;
}

.col-iva {
  width: 10%;
  text-align: center !important;
}

.col-total {
  width: 10%;
  text-align: right !important;
}

.col-act {
  width: 36px;
  text-align: center !important;
}

/* ── Drag Grip Handle ── */
.ed-grip {
  cursor: grab;
  color: var(--color-text-muted, #475569);
  font-size: 14px;
  text-align: center;
  padding: 4px 2px !important;
  user-select: none;
  width: 28px;
  letter-spacing: -3px;
  transition: color .15s;
}

.ed-grip:hover {
  color: #818cf8;
}

.ed-grip:active {
  cursor: grabbing;
}

.ed-drag-over {
  outline: 2px dashed #6366f1;
  outline-offset: -2px;
  background: rgba(99, 102, 241, .06) !important;
}

.ed-grid td {
  padding: 4px 4px;
  border-bottom: 1px solid rgba(51, 65, 85, .4);
  vertical-align: middle;
}

.ed-grid input,
.ed-grid select {
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #f1f5f9;
  transition: all .12s;
}

.ed-grid input:hover,
.ed-grid select:hover {
  background: var(--color-bg-primary, #0f172a);
  border-color: var(--color-border, #334155);
}

.ed-grid input:focus,
.ed-grid select:focus {
  background: var(--color-bg-primary, #0f172a);
  border-color: var(--color-accent, #6366f1);
  outline: none;
}

.ed-grid .cell-right input {
  text-align: right;
}

.ed-grid .del-btn {
  color: #ef4444;
  cursor: pointer;
  opacity: .3;
  transition: opacity .15s;
  background: none;
  border: none;
  font-size: 15px;
  padding: 3px;
}

.ed-grid tr:hover .del-btn {
  opacity: 1;
}

/* IVA combo in grid */
.ed-grid .iva-select {
  width: 100%;
  padding: 4px 4px;
  font-size: 12px;
  text-align: center;
  background: transparent;
  border: 1px solid transparent;
  color: #f1f5f9;
  cursor: pointer;
}

.ed-grid .iva-select:hover {
  background: var(--color-bg-primary, #0f172a);
  border-color: var(--color-border, #334155);
}

/* â”€â”€ 2-Column Layout â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* â”€â”€ Panel â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-panel {
  background: var(--color-bg-secondary, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-radius: 10px;
  padding: 16px;
}

.ed-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border, #334155);
}

.ed-panel-full {
  margin-top: 16px;
}

/* â”€â”€ Form Layout â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ed-form>label {
  margin-top: 8px;
}

.ed-form>label:first-child {
  margin-top: 0;
}

.ed-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ed-input,
input.ed-input,
textarea.ed-input {
  background: var(--color-bg-input, #0f172a);
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-primary, #f8fafc);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.ed-input:focus,
input.ed-input:focus,
textarea.ed-input:focus {
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 3px var(--color-accent-subtle, rgba(99, 102, 241, 0.15));
}

.ed-input::placeholder,
input.ed-input::placeholder,
textarea.ed-input::placeholder {
  color: var(--color-text-muted, #475569);
}

.ed-input[readonly] {
  background: var(--color-bg-secondary, #1e293b);
  color: var(--color-text-secondary, #94a3b8);
  cursor: default;
}

/* Cascada VeriFactu (field-rules): control deshabilitado por regla del BL.
   08-09-2026: sustituye a los estilos inline "de diagnostico" (borde rojo). */
.ed-form .vf-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ed-select,
select.ed-select {
  background: var(--color-bg-input, #0f172a);
  border: 1px solid var(--color-border, #334155);
  color: var(--color-text-primary, #f8fafc);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  appearance: auto;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.ed-select:focus,
select.ed-select:focus {
  border-color: var(--color-border-focus, #6366f1);
  box-shadow: 0 0 0 3px var(--color-accent-subtle, rgba(99, 102, 241, 0.15));
}

.ed-select option {
  background: var(--color-bg-card, #1e293b);
  color: var(--color-text-primary, #f8fafc);
}

/* ── Field Labels ────────────────────────────────── */
.ed-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ed-field>label {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.025em;
}

/* ── Custom Checkboxes within dark theme ─────────── */
.ed-form input[type="checkbox"],
.fac-modal input[type="checkbox"] {
  accent-color: #6366f1;
  width: 16px;
  height: 16px;
}

/* ── Date inputs dark theme ──────────────────────── */
input[type="date"].ed-input {
  color-scheme: dark;
}

/* ── Modal body scrollbar dark theme ─────────────── */
.fac-modal-body::-webkit-scrollbar {
  width: 6px;
}

.fac-modal-body::-webkit-scrollbar-track {
  background: var(--color-bg-primary, #0f172a);
}

.fac-modal-body::-webkit-scrollbar-thumb {
  background: var(--color-border, #334155);
  border-radius: 3px;
}

.fac-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--color-bg-hover, #475569);
}

/* â”€â”€ Divider â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-divider {
  height: 1px;
  background: var(--color-border, #334155);
  margin: 12px 0;
}

/* â”€â”€ Checkboxes â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.ed-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: #e2e8f0 !important;
  cursor: pointer;
}

.ed-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--color-accent, #6366f1);
}

/* Marcador bloqueado o automatico (08-09-2026): o el ERP no trata esa
   funcionalidad, o el valor lo deriva el sistema. Mismo criterio visual que la
   casilla de SII en Configuracion de Empresa: atenuado y sin cursor de mano.
   El motivo va en el title del label. */
.ed-check-off {
  opacity: 0.55;
  cursor: not-allowed !important;
}

.ed-check-off input[type="checkbox"] {
  cursor: not-allowed;
}

/* â”€â”€ Vencimientos Grid â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-vtos-wrap {
  overflow-y: auto;
  max-height: 200px;
}

.ed-vtos-grid {
  width: 100%;
  border-collapse: collapse;
}

.ed-vtos-grid th {
  background: var(--color-bg-primary, #0f172a);
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  text-align: left;
  border-bottom: 1px solid var(--color-border, #334155);
}

.ed-vtos-grid td {
  padding: 8px 10px;
  font-size: 13px;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
}

/* â”€â”€ Address Preview â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-address-preview {
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 8px;
}

.ed-addr-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
}

.ed-addr-row label {
  width: 70px;
  flex-shrink: 0;
  font-size: 10px;
  margin-bottom: 0;
}

.ed-addr-row span {
  font-size: 13px;
  color: #e2e8f0;
}

/* â”€â”€ Tax Breakdown Grid â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-tax-grid {
  width: 100%;
  border-collapse: collapse;
}

.ed-tax-grid th {
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  text-align: right;
  border-bottom: 1px solid var(--color-border, #334155);
}

.ed-tax-grid th:first-child {
  text-align: left;
}

.ed-tax-grid td {
  padding: 8px 10px;
  font-size: 13px;
  color: #e2e8f0;
  text-align: right;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
}

.ed-tax-grid td:first-child {
  text-align: left;
}

/* â”€â”€ VeriFactu Status â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-vf-status {
  margin-bottom: 8px;
}

/* â”€â”€ Mono Input (CSV Hash) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-input-mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
  font-size: 12px !important;
  letter-spacing: .5px;
}

/* â”€â”€ Audit Section â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-audit {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ed-audit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ed-audit-lbl {
  font-size: 11px;
  color: #64748b;
  width: 120px;
  flex-shrink: 0;
}

.ed-audit-val {
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 500;
}

/* â”€â”€ Footer (Badges bar) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.ed-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  background: var(--color-bg-secondary, #1e293b);
  border-top: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

/* â”€â”€ Responsive: Stack on narrow screens â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

/* ── Inline Rich Text Editor ─────────────────────────── */
.ed-rich-wrap {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, .2);
}

.ed-rich-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.ed-tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, .65);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.ed-tool-btn:hover {
  background: rgba(255, 255, 255, .08);
  color: var(--fac-accent);
  border-color: rgba(99, 179, 237, .25);
}

.ed-tool-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, .1);
  margin: 0 4px;
}

.ed-rich-edit {
  min-height: 90px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 12px;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}

.ed-rich-edit:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, .25);
  pointer-events: none;
}

.ed-rich-edit:focus {
  box-shadow: inset 0 0 0 1px rgba(99, 179, 237, .3);
}

/* ── Label Hints ─────────────────────────────────────── */
.ed-label-hint {
  font-weight: 400;
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
  font-style: italic;
}

/* ── Product Traceability Grid ───────────────────────── */
.ed-trace-wrap {
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 6px;
  overflow: hidden;
}

.ed-trace-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ed-trace-grid th {
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .5);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: 10px;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.ed-trace-grid td {
  padding: 6px 10px;
  color: #cbd5e0;
  border-bottom: 1px solid rgba(255, 255, 255, .03);
}

.ed-trace-grid tr:last-child td {
  border-bottom: none;
}

.ed-trace-grid tr:hover td {
  background: rgba(255, 255, 255, .02);
}

.ed-trace-empty {
  color: rgba(255, 255, 255, .25);
  font-style: italic;
  text-align: center;
  padding: 16px !important;
}

.ed-trace-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, .3);
  margin: 8px 0 0 0;
  padding: 0;
}

.ed-trace-lot,
.ed-trace-serial {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  letter-spacing: .4px;
  color: var(--fac-accent);
}

/* ── Checkbox Overflow Fix (Fiscal Tab) ──────────────── */
.ed-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.ed-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e0;
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
}

.ed-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--fac-accent);
}

/* ── Field Layout (inside ed-form-row / ed-fe-input-row) ── */
.ed-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ── Tax Breakdown Grid ───────────────────────────────── */
.ed-tax-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin: -6px 0 10px 0;
  padding: 6px 10px;
  background: rgba(99, 102, 241, .06);
  border-radius: 6px;
  border-left: 3px solid #6366f1;
}

.ed-tax-subtitle strong {
  color: #c7d2fe;
  font-weight: 700;
}

/* ── FacturaE Centers Grid ─────────────────────────────── */
.ed-fe-input-row {
  display: flex !important;
  grid-template-columns: unset !important;
  align-items: flex-end;
  gap: 6px;
}

.ed-fe-grid {
  margin-top: 6px;
}

.ed-fe-grid tbody tr:hover {
  background: rgba(99, 179, 237, .08);
}

.ed-fe-grid .ed-fe-del {
  background: none;
  border: none;
  color: #e53e3e;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

.ed-fe-grid .ed-fe-del:hover {
  background: rgba(229, 62, 62, .15);
}

.ed-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--fac-accent);
  background: transparent;
  color: var(--fac-accent);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}

.ed-btn-icon:hover {
  background: var(--fac-accent);
  color: #fff;
}

.ed-btn-add {
  border-color: #48bb78;
  color: #48bb78;
}

.ed-btn-add:hover {
  background: #48bb78;
  color: #fff;
}

.ed-select-sm {
  padding: 4px 6px;
  font-size: 12px;
}

.ed-label-hint {
  font-size: 11px;
  color: #718096;
  font-weight: 400;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}


/* ── Responsive: 2-row header on medium screens ──────── */
@media (max-width: 1500px) {
  .ed-header {
    flex-wrap: wrap;
  }

  .ed-field-client {
    flex: 1 1 auto;
    min-width: 250px;
  }

  .ed-badges {
    margin-left: auto;
  }
}

/* ── Responsive: Stack on narrow screens ──────────────── */
@media (max-width: 860px) {
  .ed-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .ed-field-client {
    /* Antes flex:1 1 100% forzaba al campo Cliente a saltar de línea aún
       habiendo espacio tras el botón Volver. Ahora ocupa el espacio
       restante de la fila junto a Volver y solo baja si realmente no cabe. */
    max-width: none;
    flex: 1 1 220px;
    min-width: 180px;
  }

  .ed-badges {
    margin-left: 0;
    /* mantenemos flex-wrap:nowrap del estilo base — los badges siempre
       viajan unidos; lo que envuelve es el .ed-row1-right padre. */
  }

  .ed-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   CATALOG SLIDE-OVER PANEL
   ═══════════════════════════════════════════════════════════ */

/* Patron #content-host (igual que cps-address-widget en Terceros).
   El JS reparenta cat-overlay y cat-panel a #content-host (no a body)
   para esquivar la regla TMS body>div{w:100%;h:100%} y el stacking
   context del frame, sin necesidad de luchar con z-index extremos. */

.cat-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .3);
  z-index: 100;
  backdrop-filter: blur(1px);
  display: none;
}

.cat-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100%;
  background: var(--color-bg-primary, #0f172a);
  border-left: 1px solid var(--color-border, #334155);
  z-index: 101;
  display: none;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, .4);
  animation: catSlideIn .25s ease;
  box-sizing: border-box;
}

@keyframes catSlideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.cat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
}

.cat-close {
  background: none;
  border: 1px solid var(--color-border, #334155);
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.cat-close:hover {
  color: #fff;
  border-color: #ef4444;
  background: rgba(239, 68, 68, .1);
}

.cat-close-btn {
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #f87171;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}

.cat-close-btn:hover {
  background: rgba(239, 68, 68, .18);
  border-color: #ef4444;
  color: #fca5a5;
}

.cat-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.cat-search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg-secondary, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}

.cat-search input:focus {
  border-color: var(--color-accent, #6366f1);
}

.cat-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
  overflow-x: auto;
  flex-wrap: wrap;
}

.cat-tab {
  background: rgba(51, 65, 85, .25);
  border: 1px solid rgba(51, 65, 85, .5);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  border-radius: 20px;
  transition: all .15s;
  white-space: nowrap;
}

.cat-tab:hover {
  color: #e2e8f0;
  background: rgba(99, 102, 241, .1);
  border-color: rgba(99, 102, 241, .3);
}

.cat-tab.active {
  color: #fff;
  background: var(--color-accent, #6366f1);
  border-color: var(--color-accent, #6366f1);
}

.cat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
}

.cat-item:hover {
  background: rgba(99, 102, 241, .06);
}

.cat-item-info {
  flex: 1;
  min-width: 0;
}

.cat-item-ref {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-accent, #818cf8);
  margin-bottom: 2px;
}

.cat-item-desc {
  font-size: 13px;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item-price {
  font-size: 13px;
  font-weight: 700;
  color: #c7d2fe;
  white-space: nowrap;
}

.cat-item-add {
  background: none;
  border: 1px solid rgba(72, 187, 120, .3);
  color: #48bb78;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}

.cat-item-add:hover {
  background: #48bb78;
  color: #fff;
  border-color: #48bb78;
}

.cat-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.cat-btn-new {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, rgba(79, 70, 229, .12), rgba(99, 102, 241, .08));
  border: 1px dashed var(--color-accent, #6366f1);
  color: var(--color-accent, #818cf8);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.cat-btn-new:hover {
  background: linear-gradient(135deg, rgba(79, 70, 229, .2), rgba(99, 102, 241, .15));
  color: #c7d2fe;
}

.cat-empty {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  font-size: 13px;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   DETAIL MODAL (Generic Entity Form)
   ═══════════════════════════════════════════════════════════ */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 950;
  backdrop-filter: blur(3px);
}

.detail-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 520px;
  max-width: 92vw;
  max-height: 85vh;
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 12px;
  z-index: 960;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: detailFadeIn .2s ease;
}

@keyframes detailFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

.detail-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #e2e8f0;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #64748b;
}

.detail-field input,
.detail-field select,
.detail-field textarea {
  padding: 8px 12px;
  background: var(--color-bg-secondary, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.detail-field input:focus,
.detail-field select:focus,
.detail-field textarea:focus {
  border-color: var(--color-accent, #6366f1);
}

.detail-field textarea {
  resize: vertical;
  min-height: 60px;
}

.detail-field-full {
  grid-column: 1 / -1;
}

.detail-divider {
  height: 1px;
  background: var(--color-border, #334155);
  margin: 4px 0;
}

.detail-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
  cursor: pointer;
}

.detail-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent, #6366f1);
}

.detail-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border, #334155);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   SMART-SEARCH DROPDOWN
   ═══════════════════════════════════════════════════════════ */

.ed-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg-secondary, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

/* Colores por token del tema (26-10-2026): el texto iba fijo en #e2e8f0 y el
   fondo seguia el tema; en un tema claro las cuentas salian blanco sobre
   blanco y la lista parecia vacia (popup de gastos, Cuenta de Pago). */
.ed-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text-primary, #e2e8f0);
  cursor: pointer;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
  transition: background .12s;
}

.ed-dropdown-item:hover {
  background: rgba(99, 102, 241, .08);
}

.ed-dropdown-item:last-of-type {
  border-bottom: none;
}

.ed-dropdown-empty {
  padding: 12px;
  text-align: center;
  color: var(--color-text-muted, #64748b);
  font-size: 12px;
  font-style: italic;
}

/* SMART-SEARCH DROPDOWN ACTION ROW */

.ed-dropdown-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--color-border, #334155);
  background: rgba(99, 102, 241, .04);
}

.ed-dropdown-action {
  background: none;
  border: 1px dashed var(--color-border, #334155);
  color: var(--color-accent, #818cf8);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.ed-dropdown-action:hover {
  background: rgba(99, 102, 241, .1);
  border-color: var(--color-accent, #6366f1);
  color: var(--color-accent-hover, #c7d2fe);
}

/* ═══════════════════════════════════════════════════════════
   SERIE SELECTOR (Select + Add button)
   ═══════════════════════════════════════════════════════════ */

.ed-serie-wrap {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ed-serie-wrap select {
  flex: 1;
  min-width: 0;
}

.ed-serie-add {
  background: rgba(99, 102, 241, .1);
  border: 1px solid rgba(99, 102, 241, .3);
  color: var(--color-accent, #818cf8);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}

.ed-serie-add:hover {
  background: var(--color-accent, #6366f1);
  color: #fff;
  border-color: var(--color-accent, #6366f1);
}

/* ═══════════════════════════════════════════════════════════
   DATE INPUTS — Calendar icon visibility in dark theme
   ═══════════════════════════════════════════════════════════ */

input[type="date"] {
  position: relative;
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
  opacity: .7;
  transition: opacity .15s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   EDITOR TYPE BADGE — Shows document type in header
   ═══════════════════════════════════════════════════════════ */

.ed-tipo-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  white-space: nowrap;
  background: rgba(99, 102, 241, .15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, .25);
  text-transform: uppercase;
}

.ed-tipo-badge.badge-fac {
  background: rgba(59, 130, 246, .15);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, .3);
}

.ed-tipo-badge.badge-pre {
  background: rgba(168, 85, 247, .15);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, .3);
}

.ed-tipo-badge.badge-ped {
  background: rgba(245, 158, 11, .15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, .3);
}

.ed-tipo-badge.badge-alb {
  background: rgba(16, 185, 129, .15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, .3);
}

.ed-tipo-badge.badge-abn {
  background: rgba(239, 68, 68, .15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, .3);
}

.ed-tipo-badge.badge-rec {
  background: rgba(14, 165, 233, .15);
  color: #7dd3fc;
  border-color: rgba(14, 165, 233, .3);
}

/* ═══════════════════════════════════════════════════════════
   LINE TRACEABILITY — Sub-row & Smart-Search
   ═══════════════════════════════════════════════════════════ */

.ed-trace-row {
  background: rgba(30, 41, 59, .6);
}

.ed-trace-detail {
  padding: 10px 16px !important;
  border-top: 1px dashed rgba(100, 116, 139, .3);
}

.ed-trace-fields {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ed-trace-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}

.ed-trace-field label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: .5px;
}

.ed-trace-field input,
.ed-trace-field select {
  background: var(--color-bg-primary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--color-text-primary, #f1f5f9);
}

.ed-trace-field input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, .15);
  outline: none;
}

.ed-trace-field-lote {
  min-width: 220px;
  flex: 1;
  max-width: 320px;
}

/* ── Smart-search wrapper (Lote) ────────────── */

.ed-trace-search-wrap {
  position: relative;
}

.ed-trace-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--color-bg-secondary, #1e293b);
  border: 1px solid var(--color-border, #334155);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
  min-width: 300px;
}

.ed-trace-dd-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(51, 65, 85, .3);
  transition: background .15s;
}

.ed-trace-dd-item:last-child {
  border-bottom: none;
}

.ed-trace-dd-item:hover {
  background: rgba(99, 102, 241, .12);
}

.ed-trace-dd-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ed-trace-dd-main strong {
  color: #e2e8f0;
  font-size: 13px;
}

.ed-trace-dd-prov {
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

.ed-trace-dd-meta {
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
  display: flex;
  gap: 8px;
}

.ed-trace-dd-stock {
  color: #4ade80;
  font-weight: 600;
}

.ed-trace-dd-stock.ed-trace-stock-low {
  color: #fb923c;
}

.ed-trace-dd-empty {
  padding: 12px;
  text-align: center;
  color: #64748b;
  font-size: 12px;
  font-style: italic;
}

/* ── Stock info / validation ────────────── */

.ed-trace-stock-info {
  flex-basis: 100%;
  margin-top: 6px;
  transition: opacity .3s;
}

.ed-trace-warn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(251, 146, 60, .12);
  border: 1px solid rgba(251, 146, 60, .3);
  border-radius: 6px;
  color: #fb923c;
  font-size: 12px;
  font-weight: 500;
}

.ed-trace-ok {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(74, 222, 128, .1);
  border: 1px solid rgba(74, 222, 128, .2);
  border-radius: 6px;
  color: #4ade80;
  font-size: 12px;
  font-weight: 500;
}

.ed-trace-adjust-btn {
  background: rgba(251, 146, 60, .2);
  border: 1px solid rgba(251, 146, 60, .4);
  color: #fb923c;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.ed-trace-adjust-btn:hover {
  background: rgba(251, 146, 60, .35);
}

/* ── Trace toggle button ────────────── */

.ed-trace-toggle {
  background: none;
  border: 1px solid var(--color-border, #334155);
  color: #64748b;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.ed-trace-toggle:hover {
  border-color: #818cf8;
  color: #818cf8;
  background: rgba(129, 140, 248, .08);
}

.ed-trace-toggle.ed-trace-has {
  border-color: rgba(251, 191, 36, .4);
  color: #fbbf24;
  background: rgba(251, 191, 36, .08);
}

.ed-trace-toggle.ed-trace-open {
  background: rgba(129, 140, 248, .15);
  border-color: #818cf8;
  color: #a5b4fc;
}

/* ═══════════════════════════════════════════════════════════
   EDITOR TABLE — Cell alignment
   ═══════════════════════════════════════════════════════════ */

.cell-right {
  text-align: right !important;
}

.cell-right input {
  text-align: right;
}

.col-num {
  text-align: right;
}

.col-total {
  text-align: right;
}

.col-trace {
  width: 32px;
  text-align: center;
}

.ed-trace-icon {
  font-size: 14px;
  cursor: help;
}

.ed-trace-empty-icon {
  color: var(--color-text-muted, #475569);
  font-size: 12px;
}

/* -- Trace Toggle Button -- */
.ed-trace-toggle {
  background: none;
  border: 1px solid rgba(100, 116, 139, .3);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ed-trace-toggle:hover {
  background: rgba(99, 102, 241, .12);
  border-color: rgba(99, 102, 241, .4);
  color: #a5b4fc;
}

.ed-trace-toggle.ed-trace-has {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, .3);
}

.ed-trace-toggle.ed-trace-open {
  background: rgba(99, 102, 241, .15);
  border-color: rgba(99, 102, 241, .5);
  color: #818cf8;
}

/* -- Trace Expandable Sub-Row -- */
.ed-trace-row {
  background: rgba(30, 41, 59, .6);
}

.ed-trace-detail {
  padding: 8px 16px 12px !important;
  border-bottom: 1px solid rgba(99, 102, 241, .15);
}

.ed-trace-fields {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.ed-trace-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.ed-trace-field label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #94a3b8;
}

.ed-trace-field input {
  height: 30px;
  font-size: 12px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--color-border, #334155);
  background: var(--color-bg-primary, #0f172a);
  color: var(--color-text-primary, #f1f5f9);
}

/* ── Loading Spinner Overlay ────────────────────────────────── */
.fac-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  animation: fac-fade-in 0.2s ease forwards;
}

.fac-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(99, 102, 241, 0.15);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: fac-spin 0.7s linear infinite;
}

.fac-loading-text {
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.3px;
}

@keyframes fac-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fac-fade-in {
  to {
    opacity: 1;
  }
}

/* ── CPS Address Widget Dark Theme Overrides for Facturación ── */
.fac-layout [id$="-addresses-container"] .text-gray-900,
.fac-layout [id$="-addresses-container"] .text-gray-800,
.fac-modal .text-gray-900,
.fac-modal .text-gray-800 {
  color: var(--color-text-primary, #f1f5f9) !important;
}

.fac-layout [id$="-addresses-container"] .text-gray-600,
.fac-modal .text-gray-600 {
  color: var(--color-text-secondary, #94a3b8) !important;
}

.fac-layout [id$="-addresses-container"] .text-gray-500,
.fac-modal .text-gray-500 {
  color: var(--color-text-muted, #64748b) !important;
}

.fac-layout [id$="-addresses-container"] .bg-white,
.fac-modal .bg-white {
  background-color: var(--color-bg-card, #1e293b) !important;
}

.fac-layout [id$="-addresses-container"] input.bg-white,
.fac-layout [id$="-addresses-container"] select.bg-white,
.fac-modal input.bg-white,
.fac-modal select.bg-white {
  background-color: var(--color-bg-input, #334155) !important;
  color: var(--color-text-primary, #f1f5f9) !important;
}

.fac-layout [id$="-addresses-container"] .border-gray-200,
.fac-layout [id$="-addresses-container"] .border-gray-300,
.fac-modal .border-gray-200,
.fac-modal .border-gray-300 {
  border-color: var(--color-border, #334155) !important;
}

.fac-layout [id$="-addresses-container"] .hover\:bg-gray-100:hover,
.fac-modal .hover\:bg-gray-100:hover {
  background-color: var(--color-bg-hover, #475569) !important;
}

/* ── Sticky Totals Footer ────────────────────────────────────────── */
.fac-sticky-totals {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: color-mix(in srgb, var(--color-bg-card, #1e293b) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border, #334155);
  margin: 0 -20px -20px -20px;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 20;
}

.fac-st-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.fac-st-lbl {
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.fac-st-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary, #f1f5f9);
  font-variant-numeric: tabular-nums;
}

.fac-st-grand .fac-st-val {
  font-size: 20px;
  color: var(--color-accent, #6366f1);
}

/* ── PDF Preview Drawer ──────────────────────────────────────────── */
.fac-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.fac-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.fac-drawer {
  position: fixed;
  top: 0;
  right: -600px;
  width: 600px;
  max-width: 100vw;
  height: 100vh;
  background: var(--color-bg-primary, #0f172a);
  border-left: 1px solid var(--color-border, #334155);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
  z-index: 3001;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.fac-drawer.open {
  transform: translateX(-100%);
}

.fac-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-card, #1e293b);
}

.fac-drawer-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fac-drawer-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted, #64748b);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.fac-drawer-close:hover {
  background: var(--color-bg-hover, #334155);
  color: var(--color-text-primary, #f1f5f9);
}

.fac-drawer-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative;
  background: var(--color-bg-primary, #0f172a);
}

.fac-pdf-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-primary, #0f172a);
  z-index: 2;
}

/* ══════════════════════════════════════════════════════════════════
   FIX: Confirm dialog dark theme + anti-TMS body>div stretch
   ══════════════════════════════════════════════════════════════════ */
.cp-confirm-overlay {
  width: auto !important;
  height: auto !important;
}

.cp-confirm-box {
  background: var(--color-bg-card, #1e293b) !important;
  border: 1.5px solid var(--color-border, #334155) !important;
  max-width: 420px !important;
  width: 90% !important;
  padding: 28px !important;
}

.cp-confirm-box h3 {
  color: var(--color-text-primary, #f1f5f9) !important;
  font-size: 16px !important;
}

.cp-confirm-box p {
  color: var(--color-text-secondary, #94a3b8) !important;
  font-size: 13px !important;
  margin-bottom: 20px !important;
}

.cp-confirm-cancel {
  background: transparent !important;
  border: 1.5px solid var(--color-border, #475569) !important;
  color: var(--color-text-secondary, #94a3b8) !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
}

.cp-confirm-cancel:hover {
  background: var(--color-bg-hover, #334155) !important;
  color: var(--color-text-primary, #f1f5f9) !important;
}

.cp-confirm-ok {
  border-radius: 8px !important;
  padding: 8px 20px !important;
  font-size: 13px !important;
}

.cp-confirm-icon {
  width: 40px !important;
  height: 40px !important;
  border-radius: 10px !important;
  margin-bottom: 12px !important;
}

/* Campos de showForm y showPrompt (14-10-2026): cp-notifications.js los pinta
   con estilos en linea de tema CLARO (etiqueta #374151, campo blanco y texto
   #111). Sobre la caja oscura de arriba las etiquetas casi no se leian y los
   campos salian blancos. !important porque vencen a estilos en linea. */
.cp-confirm-box label {
  color: var(--color-text-secondary, #94a3b8) !important;
}

.cp-confirm-box input,
.cp-confirm-box select,
.cp-confirm-box textarea {
  background: var(--color-bg-input, #334155) !important;
  color: var(--color-text-primary, #f1f5f9) !important;
  border: 1px solid var(--color-border, #475569) !important;
}

.cp-confirm-box input:focus,
.cp-confirm-box select:focus,
.cp-confirm-box textarea:focus {
  border-color: var(--color-border-focus, #6366f1) !important;
}

.cp-confirm-box input::placeholder,
.cp-confirm-box textarea::placeholder {
  color: var(--color-text-muted, #64748b) !important;
}

.cp-confirm-box select option {
  background: var(--color-bg-card, #1e293b);
  color: var(--color-text-primary, #f1f5f9);
}

/* ══════════════════════════════════════════════════════════════════
   FIX: List row action buttons — icon visibility on dark theme
   ══════════════════════════════════════════════════════════════════ */
.fac-btn-icon {
  color: var(--color-text-secondary, #94a3b8);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.fac-btn-icon:hover {
  color: var(--color-text-primary, #f1f5f9);
  background: var(--color-bg-hover, rgba(255,255,255,0.08));
  border-color: var(--color-border, #475569);
}

.fac-btn-icon.del-btn {
  color: var(--color-text-muted, #64748b);
}

.fac-btn-icon.del-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ══════════════════════════════════════════════════════════════════
   FIX: Modal Liquidar — Anti-stretch from TMS WEB Core shell
   Strategy: Overlay uses display:block (no flex), card self-centers
   with position:absolute + transform:translate(-50%,-50%).
   This is immune to global align-items:stretch inheritance.
   z-index must exceed shell header popovers (999999).
   ══════════════════════════════════════════════════════════════════ */
#modalLiquidar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  z-index: 9999999 !important;
  flex: none !important;
  align-self: auto !important;
}

#modalLiquidar > div:first-child {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 460px !important;
  max-width: 90% !important;
  height: auto !important;
  max-height: 90vh !important;
  flex: none !important;
}

/* Same shield for Rectificativa and Anticipo modals */
#rectModal,
#antModal {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999999 !important;
  flex: none !important;
  align-self: auto !important;
}

#rectModal > div:first-child {
  width: 480px !important;
  max-width: 90vw !important;
  flex: none !important;
}

#antModal > div:first-child {
  width: 660px !important;
  max-width: 95vw !important;
  flex: none !important;
}

/* ============================================================================
   Vencimientos (Cobros y Pagos) — layout con header y footer sticky.
   - .fac-vencimientos-wrap ocupa el alto disponible del view.
   - .fac-vencimientos-scroll es la zona scrollable de filas.
   - <thead> sticky (top:0), <tfoot> sticky via .fac-vencimientos-footer fuera del table.
   ============================================================================ */
.fac-vencimientos-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px); /* deja sitio para el header del view */
  min-height: 400px;
  padding: 16px 20px;
  box-sizing: border-box;
}

.fac-vencimientos-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  flex: 0 0 auto;
}

.fac-vencimientos-toolbar-actions {
  margin-bottom: 12px;
  padding: 4px 0;
  border-top: 1px dashed var(--color-border, #334155);
}

.fac-vencimientos-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  /* En pantallas pequeñas la tabla NO se comprime hasta romper los botones:
     min-width en la tabla + scroll horizontal aquí. */
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-card, #1e293b);
}

.fac-vencimientos-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--color-text-primary, #cbd5e1);
  font-size: 13px;
  text-align: left;
}

/* Los botones de acción (Liquidar/Ver/Eliminar) van SIEMPRE en una línea. */
.fac-vencimientos-table td:last-child {
  white-space: nowrap;
}

.fac-vencimientos-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-bg-secondary, #0f172a);
  color: var(--color-text-secondary, #94a3b8);
  font-weight: 600;
  padding: 10px;
  border-bottom: 1px solid var(--color-border, #334155);
  white-space: nowrap;
}

.fac-vencimientos-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--color-border, #1e293b);
  vertical-align: middle;
}

.fac-vencimientos-table tbody tr:hover {
  background: rgba(99,102,241,0.04);
}

.fac-vencimientos-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-top: 8px;
  background: var(--color-bg-secondary, #0f172a);
  border: 1px solid var(--color-border, #334155);
  border-radius: 8px;
  flex: 0 0 auto;
}

.fac-kpis {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
}

.fac-kpi-item {
  color: var(--color-text-primary, #cbd5e1);
}

.fac-kpi-label {
  color: var(--color-text-muted, #94a3b8);
  margin-right: 4px;
}

.fac-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.fac-page-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border, #334155);
  background: transparent;
  color: var(--color-text-secondary, #94a3b8);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.fac-page-btn:hover:not(:disabled) {
  border-color: var(--color-accent, #6366f1);
  color: var(--color-accent, #6366f1);
  background: rgba(99,102,241,0.08);
}

.fac-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fac-page-btn.fac-active {
  background: var(--color-accent, #6366f1);
  border-color: var(--color-accent, #6366f1);
  color: #fff;
  font-weight: 600;
}

.fac-page-info {
  user-select: none;
}

/* Compacto en viewports estrechos */
@media (max-width: 900px) {
  .fac-vencimientos-wrap { height: calc(100vh - 180px); padding: 8px 10px; }
  .fac-vencimientos-table { font-size: 12px; }
  .fac-kpis { gap: 10px; font-size: 12px; }
}

/* =================================================================
   TELÉFONO (≤ 760 px) — Facturación, 10-11-2026
   Cada vista se desplaza entera (cabecera, KPIs, filtros y lista en un solo
   scroll), listas en tarjetas, filas de chips deslizables y editor en una columna.
   ================================================================= */
@media (max-width: 760px) {

  /* ── 1. Un solo desplazamiento por vista ──────────────────────────────
     La vista activa es la que se desplaza; lo que dentro tenía su propio
     scroll (listas, cuadros) se estira a su altura. !important: varias
     vistas traen overflow:hidden y height en línea (facturacion_views.js). */
  .fac-layout .fac-view.fac-active {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100% !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .fac-layout .fac-view.fac-active > * { flex-shrink: 0; }
  .fac-layout .fac-doc-scroll,
  .fac-layout .fac-dash-scroll {
    flex: none;
    overflow: visible;
  }

  /* ── 2. Cabecera de pantalla compacta ─────────────────────────────── */
  .fac-layout .fac-header {
    padding: 10px 14px;
    gap: 8px 10px;
  }
  .fac-layout .fac-header-icon {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
  .fac-layout .fac-header-text {
    flex: 1 1 0;
    min-width: 0;
  }
  .fac-layout .fac-header-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fac-layout .fac-header-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Acciones de cabecera: su propia fila, deslizable si no caben */
  .fac-layout .fac-header-actions {
    flex: 1 0 100%;
    min-width: 0;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .fac-layout .fac-header-actions::-webkit-scrollbar { display: none; }
  .fac-layout .fac-header-actions > * { flex: 0 0 auto; }
  .fac-layout .fac-header-actions .fac-btn { min-height: 36px; }

  /* Filas de chips (estados, subtipos): una línea deslizable */
  .fac-layout .fac-stats-bar,
  .fac-layout .fac-subtipo-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
    padding: 8px 14px;
    gap: 6px;
  }
  .fac-layout .fac-stats-bar::-webkit-scrollbar,
  .fac-layout .fac-subtipo-bar::-webkit-scrollbar { display: none; }
  .fac-layout .fac-stats-bar > *,
  .fac-layout .fac-subtipo-bar > * { flex: 0 0 auto; }
  .fac-layout .fac-stat-pill { min-height: 32px; }

  /* ── 3. Documentos Comerciales ────────────────────────────────────── */
  /* Cabecera: título; Ventas / Compras con «Nuevo»; acciones deslizables */
  #view-listado .fac-header-title-wrap {
    width: auto;
    flex: 1 1 100%;
    min-width: 0;
    gap: 10px;
  }
  #view-listado .fac-tipo-bar {
    margin-left: 0;
    flex: 1 1 0;
    min-width: 0;
  }
  #view-listado .fac-tipo-btn {
    flex: 1 1 0;
    justify-content: center;
    min-height: 38px;
  }
  #view-listado #btnNuevoDoc { min-height: 38px; }

  /* Filtros: buscador a lo ancho; servicio y orden; periodos deslizables;
     fechas desde/hasta de dos en dos */
  #view-listado .fac-filters-docs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px 14px;
  }
  #view-listado .fac-filters-docs > .fac-search-wrap {
    max-width: none;
    min-width: 0;
  }
  #view-listado .fac-filters-docs .fac-search { min-height: 40px; }
  #view-listado .fac-filters-right {
    margin-left: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }
  #view-listado .fac-filters-right select { min-height: 38px; width: 100%; }
  #view-listado .fac-filters-right .fac-sortbtn { min-height: 38px; white-space: nowrap; }
  #view-listado #docFiltrosFecha {
    display: grid !important;   /* en línea: display:flex */
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px !important;
  }
  /* «Fecha» sobra: lo dicen los propios botones */
  #view-listado #docFiltrosFecha > span:first-child { display: none; }
  #view-listado #docFiltrosFecha .fac-fecha-presets {
    display: flex !important;   /* en línea: display:contents (escritorio) */
    grid-column: 1 / -1;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #view-listado #docFiltrosFecha .fac-fecha-presets::-webkit-scrollbar { display: none; }
  #view-listado #docFiltrosFecha .fac-fecha-preset {
    flex: 0 0 auto;
    min-height: 34px;
    white-space: nowrap;
  }
  #view-listado #docFiltrosFecha input[type="date"] {
    width: 100%;
    min-width: 0;
    min-height: 38px;
  }

  /* Lista en tarjetas: número y tercero arriba, total a la derecha; asunto;
     fecha y estado abajo */
  #view-listado .fac-doc-scroll {
    padding: 10px 12px 14px;
    gap: 8px;
  }
  #view-listado .fac-doc-row {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    grid-template-areas:
      "av info  total"
      "av asu   asu"
      "av fecha estado";
    gap: 4px 10px;
    padding: 10px 12px;
    align-items: center;
  }
  #view-listado .fac-doc-row:hover { transform: none; }
  #view-listado .fac-doc-agr { display: none; }
  /* Modo «Seleccionar»: la casilla entra como primera columna */
  #docList.fac-agr-activa .fac-doc-row {
    grid-template-columns: 26px 46px minmax(0, 1fr) auto;
    grid-template-areas:
      "agr av info  total"
      "agr av asu   asu"
      "agr av fecha estado";
  }
  #docList.fac-agr-activa .fac-doc-agr {
    display: flex;
    grid-area: agr;
  }
  #docList.fac-agr-activa .fac-doc-agr input { width: 20px; height: 20px; }
  #view-listado .fac-doc-avatar {
    grid-area: av;
    align-self: start;
    width: 46px;
    height: 44px;
    font-size: 9px;
    letter-spacing: -.3px;
    white-space: nowrap;
  }
  #view-listado .fac-doc-info { grid-area: info; }
  #view-listado .fac-doc-id {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #view-listado .fac-doc-asunto {
    grid-area: asu;
    display: flex;
    font-size: 12px;
  }
  #view-listado .fac-doc-asunto:has(.fac-doc-asunto-empty) { display: none; }
  #view-listado .fac-doc-meta { display: none; }
  #view-listado .fac-doc-date {
    grid-area: fecha;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
    text-align: left;
  }
  #view-listado .fac-doc-date small { display: inline; }
  #view-listado .fac-doc-status {
    grid-area: estado;
    display: block;
    justify-self: end;
    text-align: right;
    white-space: nowrap;
  }
  #view-listado .fac-doc-total {
    grid-area: total;
    align-self: start;
    margin-right: 0 !important;   /* en línea: margin-right:140px (hueco de las acciones flotantes) */
    font-size: 15px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  /* Las acciones flotantes son de ratón: en el teléfono la tarjeta abre el
     documento y ahí están Editar, Imprimir y Eliminar */
  #view-listado .fac-doc-actions { display: none; }

  /* Pie con totales y paginación: pegado abajo mientras se desplaza. Tres
     filas: nº de documentos y total; base e impuestos; paginación. Los
     totales se reparten como hijos del pie (display:contents). */
  #view-listado .fac-list-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 8px 14px;
    gap: 4px 12px;
  }
  #view-listado .fac-footer-totals { display: contents; }
  #view-listado .fac-footer-sep { display: none; }
  #view-listado .fac-footer-count { order: 0; flex: 1 1 auto; }
  #view-listado .fac-footer-grand { order: 1; margin-left: auto; white-space: nowrap; }
  #view-listado .fac-list-footer::after { content: ''; order: 2; flex-basis: 100%; height: 0; }   /* salto de fila */
  #view-listado .fac-footer-item:not(.fac-footer-grand) { order: 3; white-space: nowrap; }
  #view-listado .fac-footer-item:not(.fac-footer-grand) + .fac-footer-sep + .fac-footer-item:not(.fac-footer-grand) { margin-left: auto; }
  #view-listado .fac-pagination {
    order: 4;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 2px;
  }
  #view-listado .fac-pg-btn { padding: 6px; min-height: 36px; }
  #view-listado .fac-pg-info { white-space: nowrap; }
  #view-listado .fac-pg-size { padding: 4px 6px; min-width: 0; }

  /* ── 4. Editor de documento ───────────────────────────────────────────
     Una columna: datos de dos en dos, acciones en filas deslizables,
     pestañas fijas arriba al desplazar, líneas en tarjetas y el resumen
     (líneas, VeriFactu, total) pegado abajo. */
  #view-editor .ed-body,
  #view-editor .ed-grid-wrap {
    flex: none;
    overflow: visible;
  }
  #view-editor #edViewHeaderWrapper { padding: 10px 14px 0 !important; }   /* en línea: 12px 18px 0 */
  #view-editor .ed-header {
    margin-top: 8px !important;   /* en línea: 12px */
    padding: 10px 14px;
    /* Columna de una sola línea: con el wrap de los @media de 1500/860 px cada
       fila tomaba su ancho máximo de contenido y se salía de la pantalla */
    flex-wrap: nowrap;
    min-width: 0;
  }
  #view-editor .ed-header-row-data {
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
  }
  #view-editor .ed-sep { display: none; }
  #view-editor .ed-btn-back {
    min-height: 40px;
    padding: 8px 12px;
  }
  #view-editor .ed-field-client {
    flex: 1 1 60%;   /* comparte fila solo con «Volver» */
    min-width: 0;
    max-width: none;
  }
  #view-editor .ed-field-serie,
  #view-editor .ed-field-numero,
  #view-editor .ed-field-fecha {
    width: auto;
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }
  #view-editor .ed-field input,
  #view-editor .ed-field select {
    min-height: 40px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  #view-editor .ed-anticipo-wrapper {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    min-height: 40px;
    flex-wrap: wrap;
    gap: 8px;
  }
  #view-editor .ed-header-row-data .ed-badges {
    flex: 1 1 100%;
    margin-left: 0;
    flex-wrap: wrap;
    padding-bottom: 0;
  }
  /* Acciones: cada grupo en su fila deslizable; Eliminar y Guardar al final */
  #view-editor .ed-header-row-actions {
    gap: 8px;
    padding-top: 10px;
  }
  #view-editor .ed-act-group {
    flex: 1 1 100%;
    min-width: 0;
    padding-left: 0;
    border-left: none;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #view-editor .ed-act-group::-webkit-scrollbar { display: none; }
  #view-editor .ed-act-group:empty { display: none; }
  #view-editor .ed-act-group > * { flex: 0 0 auto; }
  #view-editor .ed-act { min-height: 38px; }
  #view-editor .ed-actions-spacer { display: none; }
  /* Orden en el teléfono: Estado (Validar, Anular…) con Eliminar al lado;
     Documento; Salida; y Guardar / Guardar y salir a medias */
  #view-editor #fac-estado-acciones { order: 0; flex: 1 1 0; }
  #view-editor .ed-header-row-actions > .ed-act-danger { order: 1; flex: 0 0 auto; }
  #view-editor #fac-doc-acciones { order: 2; }
  #view-editor #fac-salida-acciones { order: 3; }
  #view-editor .ed-header-row-actions > .ed-btn-save {
    order: 4;
    flex: 1 1 0;
    min-height: 42px;
    justify-content: center;
    white-space: nowrap;
  }
  /* Pestañas: siguen a la vista mientras se baja por el documento */
  #view-editor .ed-tabs {
    position: sticky;
    top: 0;
    z-index: 6;
    padding: 0 8px;
    scrollbar-width: none;
  }
  #view-editor .ed-tabs::-webkit-scrollbar { display: none; }
  #view-editor .ed-tab { padding: 12px; flex: 0 0 auto; }
  #view-editor .ed-pane { padding: 12px; }
  #view-editor .ed-cols-2 { grid-template-columns: minmax(0, 1fr); }

  /* Líneas en tarjetas: concepto arriba; cantidad, precio y total;
     descuentos e IVA; referencia y calificación. Cada dato con su rótulo. Columnas de
     la fila (facturacion_engine.js, addLine y renderEditor): 1 asa, 2 ref,
     3 concepto, 4 cant., 5 precio, 6 dto %, 7 dto €, 8 IVA, 9 calif.,
     10 total, 11 trazabilidad, 12 quitar. */
  #view-editor .ed-grid-wrap {
    padding-bottom: 0 !important;   /* en línea: 70px (hueco del pie flotante del escritorio) */
    border: none;
  }
  #view-editor .ed-grid,
  #view-editor .ed-grid tbody { display: block; min-width: 0; width: 100%; }
  #view-editor .ed-grid thead { display: none; }
  #editorLines > tr:not(.ed-trace-row) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "desc desc desc acc"
      "cant prec prec tot"
      "dpct deur iva  iva"
      "ref  ref  cal  cal";
    gap: 8px;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--color-border, #334155);
    border-radius: 10px;
    background: var(--color-bg-card, #1e293b);
  }
  #editorLines > tr:not(.ed-trace-row) > td {
    display: block;
    padding: 0;
    border: none;
    min-width: 0;
    text-align: left;
  }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(1) { display: none; }   /* asa de arrastre: no hay arrastre táctil */
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(2)  { grid-area: ref; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(3)  { grid-area: desc; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(4)  { grid-area: cant; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(5)  { grid-area: prec; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(6)  { grid-area: dpct; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(7)  { grid-area: deur; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(8)  { grid-area: iva; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(9)  { grid-area: cal; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(10) { grid-area: tot; text-align: right; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(11) { grid-area: acc; justify-self: start; align-self: center; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(12) { grid-area: acc; justify-self: end; align-self: center; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(2)::before,
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(n+4):nth-child(-n+10)::before {
    display: block;
    margin-bottom: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--color-text-muted, #64748b);
  }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(2)::before  { content: 'Ref'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(4)::before  { content: 'Cant.'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(5)::before  { content: 'Precio'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(6)::before  { content: 'Dto %'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(7)::before  { content: 'Dto €'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(8)::before  { content: 'IVA'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(9)::before  { content: 'Calif.'; }
  #editorLines > tr:not(.ed-trace-row) > td:nth-child(10)::before { content: 'Total'; }
  #editorLines > tr:not(.ed-trace-row) input,
  #editorLines > tr:not(.ed-trace-row) select {
    width: 100% !important;   /* la calificación lo trae en línea */
    min-width: 0;
    min-height: 40px;
  }
  #editorLines > tr:not(.ed-trace-row) .ed-total {
    display: block;
    font-size: 15px;
    line-height: 40px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  #editorLines .del-btn,
  #editorLines .ed-trace-toggle {
    width: 36px;
    height: 36px;
    opacity: 1;
  }
  /* Trazabilidad (lote, serie, caducidad) debajo de su tarjeta */
  #editorLines > tr.ed-trace-row { display: block; margin: -4px 0 8px; }
  #editorLines > tr.ed-trace-row > td { display: block; }

  /* Totales del documento: rejilla compacta al final de las líneas; el
     total sigue a la vista en el resumen de abajo */
  #view-editor .fac-sticky-totals {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin: 4px 0 0;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--color-border, #334155);
    box-shadow: none;
  }
  #view-editor .fac-st-col { align-items: flex-start; }
  #view-editor .fac-st-grand {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    border-top: 1px solid var(--color-border, #334155);
    padding-top: 8px;
  }
  #view-editor .ed-footer-summary {
    position: sticky;
    bottom: 0;
    margin-top: auto;   /* con pocas líneas, abajo del todo igualmente */
    z-index: 6;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 2px 10px;
    padding: 8px 14px;
    white-space: nowrap;
  }
  #view-editor .ed-footer-summary .ed-foot-total { margin-left: auto; }
  #view-editor .ed-footer-summary .ed-foot-sep { display: none; }
  #view-editor .ed-footer-summary .ed-foot-section { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  /* ── 5. Piezas comunes de las demás vistas ────────────────────────────
     Las vistas de Gastos, Presupuestos, Remesas, Objetivos, Costes,
     Suscripciones y Configuración se maquetan con estilos en línea
     (facturacion_views.js y el engine): de ahí los selectores por atributo
     y los !important, cada uno para vencer un valor concreto en línea. */

  /* Zonas que en el escritorio tienen su propio scroll (flex:1 + overflow
     en línea): a su altura, para que se desplace la vista entera */
  .fac-layout .fac-view.fac-active > [style*="flex:1"],
  .fac-layout .fac-view.fac-active > [style*="overflow-y:auto"],
  .fac-layout .fac-view.fac-active > [style*="overflow:auto"],
  #view-remesas > div > [style*="overflow-y:auto"],
  #view-compras [style*="max-height:calc(100vh"] {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  /* Tiras de KPI en línea (Gastos, Presupuestos, Remesas): de dos en dos;
     la tercera, si queda sola, a lo ancho */
  .fac-layout .fac-view.fac-active > [style^="padding:20px 20px 0;display:flex;gap:15px"],
  #view-remesas > div > [style^="padding:20px 20px 0;display:flex;gap:15px"] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
    padding: 12px 14px 0 !important;
  }
  .fac-layout .fac-view.fac-active > [style^="padding:20px 20px 0;display:flex;gap:15px"] > div,
  #view-remesas > div > [style^="padding:20px 20px 0;display:flex;gap:15px"] > div {
    min-width: 0 !important;
    padding: 12px 14px !important;
  }
  .fac-layout .fac-view.fac-active > [style^="padding:20px 20px 0;display:flex;gap:15px"] > div:last-child:nth-child(odd),
  #view-remesas > div > [style^="padding:20px 20px 0;display:flex;gap:15px"] > div:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  /* Rejillas de KPI de los informes pintados por el engine (Objetivos, Costes) */
  #objetivos-content > [style*="grid-template-columns:repeat(4,1fr)"],
  #costes-content > [style*="grid-template-columns:repeat(4,1fr)"] {
    padding: 12px 14px 0 !important;
    gap: 10px !important;
  }
  #objetivos-content > [style*="grid-template-columns:repeat(4,1fr)"] > div,
  #costes-content > [style*="grid-template-columns:repeat(4,1fr)"] > div {
    min-width: 0;
    padding: 12px 14px !important;
  }
  /* Importes de esas tarjetas: caben en la tarjeta, sin partir el «€» */
  .fac-layout .fac-view.fac-active [style*="font-size:24px;font-weight:700"],
  .fac-layout .fac-view.fac-active [style*="font-size:26px;font-weight:700"],
  .fac-layout .fac-view.fac-active [style*="font-size:28px;font-weight:700"] {
    font-size: clamp(16px, 4.6vw, 21px) !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Pastillas de pestañas (Costes, Configuración) y pestañas de
     Suscripciones: una fila deslizable */
  #costes-dim-pills,
  #view-config > div:has(> .config-pill),
  #recTabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px 14px 0 !important;
    gap: 8px !important;
  }
  #recTabs { padding: 0 14px !important; gap: 4px !important; }
  #costes-dim-pills::-webkit-scrollbar,
  #view-config > div:has(> .config-pill)::-webkit-scrollbar,
  #recTabs::-webkit-scrollbar { display: none; }
  #costes-dim-pills > *,
  #view-config > div:has(> .config-pill) > *,
  #recTabs > * { flex: 0 0 auto; white-space: nowrap; min-height: 36px; }
  /* Márgenes de 20 px del escritorio → 14 px */
  .fac-layout .fac-view.fac-active > [style^="padding:20px"],
  #objetivos-content > [style^="padding:20px"],
  #costes-content > [style^="padding:20px"],
  #config-content > [style^="padding:20px"] {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Tablas que pasan a tarjetas (Gastos, Presupuestos, Cobros y Pagos,
     Suscripciones): sin cabecera; cada fila es una tarjeta con su rejilla.
     La fila de «Cargando…» / «No hay…» (una celda con colspan) se queda
     como texto a lo ancho. */
  .fac-layout table:has(> #tbody-compras-list),
  .fac-layout table:has(> #tblPresupuestosBody),
  .fac-layout table:has(> #tblVencimientosBody),
  .fac-layout table:has(> #tblRecurrentesBody) {
    display: block;
    min-width: 0 !important;
    width: 100%;
  }
  .fac-layout table:has(> #tbody-compras-list) > thead,
  .fac-layout table:has(> #tblPresupuestosBody) > thead,
  .fac-layout table:has(> #tblVencimientosBody) > thead,
  .fac-layout table:has(> #tblRecurrentesBody) > thead { display: none; }
  #tbody-compras-list,
  #tblPresupuestosBody,
  #tblVencimientosBody,
  #tblRecurrentesBody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  #tbody-compras-list > tr:not(:has(> td[colspan])),
  #tblPresupuestosBody > tr:not(:has(> td[colspan])),
  #tblVencimientosBody > tr:not(:has(> td[colspan])),
  #tblRecurrentesBody > tr:not(:has(> td[colspan])) {
    display: grid;
    gap: 4px 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--color-border, #334155) !important;   /* en línea: solo border-bottom */
    border-radius: 10px;
    background: var(--color-bg-card, #1e293b);
  }
  #tbody-compras-list > tr > td,
  #tblPresupuestosBody > tr > td,
  #tblVencimientosBody > tr > td,
  #tblRecurrentesBody > tr > td {
    display: block;
    min-width: 0;
    max-width: none !important;
    padding: 0 !important;   /* en línea: 10-12px de celda de tabla */
    border: none !important;
    text-align: left !important;
  }
  #tbody-compras-list > tr > td[colspan],
  #tblPresupuestosBody > tr > td[colspan],
  #tblVencimientosBody > tr > td[colspan],
  #tblRecurrentesBody > tr > td[colspan] {
    padding: 24px 12px !important;
    text-align: center !important;
  }
  /* Rótulos de los importes secundarios */
  #tbody-compras-list > tr > td:nth-child(6)::before { content: 'Base '; }
  #tbody-compras-list > tr > td:nth-child(7)::before { content: 'Ded. '; }
  #tbody-compras-list > tr > td:nth-child(8)::before { content: 'IVA '; }
  #tblVencimientosBody > tr > td:nth-child(3)::before { content: 'Total '; }
  #tblVencimientosBody > tr > td:nth-child(4)::before { content: 'Pendiente '; }
  #tbody-compras-list > tr > td:nth-child(n+6):nth-child(-n+8)::before,
  #tblVencimientosBody > tr > td:nth-child(n+3):nth-child(-n+4)::before {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--color-text-muted, #64748b);
  }

  /* Gastos: miniatura | proveedor y ref. | total; asunto | estado;
     categoría | fecha; base · IVA · deducible. Celdas (engine,
     renderCompras): 1 miniatura, 2 proveedor, 3 asunto, 4 categoría,
     5 fecha, 6 base, 7 % ded., 8 IVA, 9 total, 10 estado, 11 acciones. */
  #tbody-compras-list > tr:not(:has(> td[colspan])) {
    grid-template-columns: 48px repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "img prov prov tot"
      "img asu  asu  est"
      "acc cat  cat  fec"
      "acc base iva  ded";
  }
  #tbody-compras-list > tr > td:nth-child(1)  { grid-area: img; width: auto !important; align-self: start; }
  #tbody-compras-list > tr > td:nth-child(2)  { grid-area: prov; overflow: hidden; text-overflow: ellipsis; }
  #tbody-compras-list > tr > td:nth-child(3)  { grid-area: asu; font-size: 12px; }
  #tbody-compras-list > tr > td:nth-child(4)  { grid-area: cat; font-size: 11px; color: var(--color-text-muted, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #tbody-compras-list > tr > td:nth-child(5)  { grid-area: fec; font-size: 12px; text-align: right !important; white-space: nowrap; }
  #tbody-compras-list > tr > td:nth-child(6)  { grid-area: base; font-size: 11px; white-space: nowrap; }
  #tbody-compras-list > tr > td:nth-child(7)  { grid-area: ded; font-size: 11px; white-space: nowrap; text-align: right !important; }
  #tbody-compras-list > tr > td:nth-child(8)  { grid-area: iva; font-size: 11px; white-space: nowrap; }
  #tbody-compras-list > tr > td:nth-child(9)  { grid-area: tot; font-size: 15px; white-space: nowrap; text-align: right !important; }
  #tbody-compras-list > tr > td:nth-child(10) {
    grid-area: est;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    white-space: normal !important;   /* en línea: nowrap (estado + pago) */
  }
  #tbody-compras-list > tr > td:nth-child(11) { grid-area: acc; align-self: start; display: flex; flex-direction: column; gap: 4px; }
  /* El botón ⚙ abre lo mismo que tocar la tarjeta; se queda «Ver doc.»
     cuando lo añade el engine (hay adjunto) */
  #tbody-compras-list > tr > td:nth-child(11) > button[title="Editar"] { display: none; }
  #tbody-compras-list > tr > td:nth-child(11) > button { min-height: 32px; padding: 4px 6px; }

  /* Buscador y paginación de Gastos; filtros de dos en dos, periodos en
     su fila deslizable, fechas con «Limpiar» */
  .fac-layout div:has(> .fac-pag-premium) { flex-wrap: wrap; gap: 8px !important; }   /* Gastos e Incidencias */
  .fac-layout div:has(> .fac-pag-premium) > div:first-child { flex: 1 1 100% !important; min-width: 0 !important; }
  .fac-layout .fac-pag-premium { flex: 1 1 100%; justify-content: space-between; }
  #view-compras div:has(> #compras-estado-filter) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px !important;
  }
  #compras-estado-filter { min-width: 0 !important; width: 100%; }
  #compras-cat-filter { min-width: 0 !important; width: 100%; grid-column: 2 / -1; }
  #compras-fechas-presets {
    grid-column: 1 / -1;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 6px !important;
  }
  #compras-fechas-presets::-webkit-scrollbar { display: none; }
  #compras-fechas-presets > button { flex: 0 0 auto; min-height: 34px; white-space: nowrap; }
  #compras-fecha-desde, #compras-fecha-hasta { min-width: 0; width: 100%; }
  #view-compras div:has(> #compras-estado-filter) select,
  #view-compras div:has(> #compras-estado-filter) input,
  #view-compras div:has(> #compras-estado-filter) > button { min-height: 40px; }
  #view-compras div:has(> div > #tbody-compras-list),
  #view-compras div:has(> div > table > #tbody-compras-list) {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
  }

  /* Presupuestos: nº | total; cliente | estado; fecha y validez;
     acciones. Celdas: 1 nº, 2 cliente, 3 fecha, 4 total, 5 estado, 6 acciones. */
  #tblPresupuestosBody > tr:not(:has(> td[colspan])) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num tot"
      "cli est"
      "fec fec"
      "acc acc";
  }
  #tblPresupuestosBody > tr > td:nth-child(1) { grid-area: num; font-size: 14px; }
  #tblPresupuestosBody > tr > td:nth-child(2) { grid-area: cli; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #tblPresupuestosBody > tr > td:nth-child(3) { grid-area: fec; font-size: 12px; color: var(--color-text-secondary, #94a3b8); }
  #tblPresupuestosBody > tr > td:nth-child(4) { grid-area: tot; font-size: 15px; white-space: nowrap; text-align: right !important; }
  #tblPresupuestosBody > tr > td:nth-child(5) { grid-area: est; text-align: right !important; }
  #tblPresupuestosBody > tr > td:nth-child(6) {
    grid-area: acc;
    display: flex !important;   /* en línea: display:flex, justify-content:flex-end */
    justify-content: flex-start !important;
    padding-top: 6px !important;
    border-top: 1px solid var(--color-border, #334155) !important;
  }
  #tblPresupuestosBody > tr > td:nth-child(6) > button { min-height: 34px; }
  #view-presupuestos div:has(> .btn-pres-filtro) {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 6px !important;
  }
  #view-presupuestos div:has(> .btn-pres-filtro)::-webkit-scrollbar { display: none; }
  #view-presupuestos .btn-pres-filtro { flex: 0 0 auto; min-height: 36px; white-space: nowrap; }

  /* Cobros y Pagos: documento y vencimiento | total; tercero | pendiente;
     estado; acciones. Celdas: 1 documento, 2 tercero, 3 total,
     4 pendiente, 5 estado, 6 acciones. */
  #view-vencimientos .fac-vencimientos-wrap {
    height: auto;
    min-height: 0;
    padding: 10px 14px 0;
  }
  #view-vencimientos .fac-vencimientos-scroll {
    flex: none;
    overflow: visible;
    border: none;
    background: transparent;
  }
  #view-vencimientos .fac-vencimientos-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #view-vencimientos .fac-vencimientos-toolbar > div {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #view-vencimientos .fac-vencimientos-toolbar > div::-webkit-scrollbar { display: none; }
  #view-vencimientos .fac-vencimientos-toolbar > div > button { flex: 0 0 auto; min-height: 36px; white-space: nowrap; }
  #view-vencimientos .fac-vencimientos-toolbar > .fac-pagination { justify-content: center; flex-wrap: wrap !important; }
  #tblVencimientosBody > tr:not(:has(> td[colspan])) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "doc tot"
      "ter pen"
      "est est"
      "acc acc";
  }
  #tblVencimientosBody > tr > td:nth-child(1) { grid-area: doc; }
  #tblVencimientosBody > tr > td:nth-child(2) { grid-area: ter; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #tblVencimientosBody > tr > td:nth-child(3) { grid-area: tot; white-space: nowrap; text-align: right !important; }
  #tblVencimientosBody > tr > td:nth-child(4) { grid-area: pen; white-space: nowrap; text-align: right !important; }
  #tblVencimientosBody > tr > td:nth-child(5) { grid-area: est; }
  #tblVencimientosBody > tr > td:nth-child(6) {
    grid-area: acc;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px !important;
    border-top: 1px solid var(--color-border, #334155) !important;
    white-space: normal;
  }
  #tblVencimientosBody > tr > td:nth-child(6) > button { min-height: 34px; }
  #view-vencimientos .fac-vencimientos-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 8px -14px 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  #view-vencimientos .fac-kpis { flex-wrap: wrap; gap: 4px 14px; }

  /* Suscripciones: contrato | estado; tercero; tipo y periodicidad;
     próxima y última emisión; acciones. Celdas: 1 contrato, 2 tercero,
     3 tipo, 4 periodicidad, 5 próxima, 6 última, 7 estado, 8 acciones. */
  #rec-plantillas > [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  #rec-plantillas > [style*="grid-template-columns:repeat(3,1fr)"] > div { padding: 10px !important; min-width: 0; }
  #view-recurrentes div:has(> table > #tblRecurrentesBody) {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;   /* en línea: overflow:hidden */
  }
  #tblRecurrentesBody > tr:not(:has(> td[colspan])) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "con est"
      "ter ter"
      "tip per"
      "pro ult"
      "acc acc";
  }
  #tblRecurrentesBody > tr > td:nth-child(1) { grid-area: con; }
  #tblRecurrentesBody > tr > td:nth-child(2) { grid-area: ter; }
  #tblRecurrentesBody > tr > td:nth-child(3) { grid-area: tip; }
  #tblRecurrentesBody > tr > td:nth-child(4) { grid-area: per; justify-self: end; }
  #tblRecurrentesBody > tr > td:nth-child(5) { grid-area: pro; }
  #tblRecurrentesBody > tr > td:nth-child(6) { grid-area: ult; justify-self: end; }
  #tblRecurrentesBody > tr > td:nth-child(7) { grid-area: est; justify-self: end; }
  #tblRecurrentesBody > tr > td:nth-child(8) {
    grid-area: acc;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px !important;
    border-top: 1px solid var(--color-border, #334155) !important;
    white-space: normal !important;
  }
  #tblRecurrentesBody > tr > td:nth-child(5)::before { content: 'Próxima: '; color: var(--color-text-muted, #64748b); font-weight: 400; }
  #tblRecurrentesBody > tr > td:nth-child(6)::before { content: 'Última: '; color: var(--color-text-muted, #64748b); }

  /* ── 6. Dashboard ──────────────────────────────────────────────────── */
  #view-dashboard .fac-dash-scroll { padding: 12px 14px; gap: 12px; }
  #view-dashboard .fac-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #view-dashboard .fac-kpi { padding: 12px 14px; min-width: 0; }
  #view-dashboard .fac-kpi:hover { transform: none; }
  #view-dashboard .fac-kpi-value {
    font-size: clamp(16px, 4.6vw, 21px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
  }
  #view-dashboard .fac-alerts { flex-direction: column; gap: 8px; }
  #view-dashboard .fac-alert { padding: 10px 14px; }
  #view-dashboard .fac-alert-text { flex: 1; }
  #view-dashboard #statusSummary {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #view-dashboard .fac-dash-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    flex: none;
  }
  #view-dashboard .fac-dash-grid > .fac-card { grid-column: auto !important; }   /* en línea: 1 / -1 */
  /* Barras en %: sin la altura que daba la rejilla del escritorio se quedaban a 3 px */
  #view-dashboard #chartBars { height: 190px; padding: 24px 8px 8px; }
  #view-dashboard .fac-card-body {
    flex: none;
    max-height: 420px;   /* listas largas (actividad): tope con su scroll, sin empujar el resto fuera */
  }

  /* ── 7. Objetivos, Costes, Remesas, Conciliación, Configuración ────── */
  #objetivos-content > [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  #objetivos-content > [style*="grid-template-columns:1fr 1fr"] > div { min-width: 0; }
  #obj-projection > div { flex-wrap: wrap; }
  #view-conciliacion .fac-header-actions select { min-width: 0 !important; flex: 0 0 220px; }
  #view-conciliacion > [style^="padding:20px"] > div:first-child { flex-direction: column; }
  #n43Kpis {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }
  #n43Kpis > .n43-kpi { min-width: 0; }
  #view-conciliacion .n43-drop { min-height: 90px; width: 100%; box-sizing: border-box; }
  #n43Scroll { max-height: none !important; }   /* en línea: 240px */
  #view-conciliacion #n43MovWrap input#n43Buscar { min-width: 0 !important; max-width: none !important; flex: 1 1 100% !important; }
  #view-conciliacion #n43MovWrap > div {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #view-conciliacion #n43MovWrap > div:first-child { flex-wrap: wrap !important; }
  #view-conciliacion #n43MovWrap > div::-webkit-scrollbar { display: none; }
  #view-conciliacion #n43MovWrap > div > * { flex: 0 0 auto; }
  #view-conciliacion #n43MovWrap > div:first-child > div[style*="margin-left:auto"] { margin-left: 0 !important; }
  /* Tablas de informe (Objetivos, Costes): importes en una línea; la
     tabla se desplaza de lado dentro de su caja (capa común) */
  #objetivos-content table td + td,
  #costes-content table td + td { white-space: nowrap; }
  /* Tablas de edición de Configuración (series, textos, impuestos): con
     su ancho natural y desplazamiento lateral, sin aplastar los campos */
  #config-content table { min-width: 620px; }
  /* Editores de Suscripción y de Plantilla: una columna, sin scroll propio */
  #susEditorForm,
  #tplEditorForm {
    grid-template-columns: minmax(0, 1fr) !important;   /* en línea: 3fr + 2fr */
    overflow: visible !important;
    padding: 12px 14px !important;
    gap: 12px !important;
  }
  #susEditorForm > div,
  #tplEditorForm > div {
    overflow: visible !important;
    padding-right: 0 !important;
    min-width: 0;
  }
  #susEditorForm > div > div,
  #tplEditorForm > div > div { padding: 14px !important; }
  #susTercerosList { overflow: visible !important; }
  #view-recurrentes-editor .fac-header > .fac-btn:first-child,
  #view-plantilla-editor .fac-header > .fac-btn:first-child { margin-right: 0 !important; min-height: 36px; }

  /* Ventana de informes (openInformeDetail): la zona de trabajo entera y el título
     en su propia línea, sin cortar («Pérdid…»); los botones debajo. La caja lleva
     medidas en línea, por eso el !important. */
  .fac-informe-box {
    width: 100% !important;
    max-width: none !important;
    max-height: 100% !important;
    height: 100%;
    border-radius: 0 !important;
    align-self: stretch !important;
  }
  .fac-informe-hdr { flex-wrap: wrap; padding: 12px 14px !important; row-gap: 8px !important; }
  .fac-informe-hdr > h3 { flex: 1 1 100% !important; white-space: normal !important; }
  .fac-informe-hdr > div { width: 100%; justify-content: flex-start; }
  .fac-informe-hdr > div > button:last-child { margin-left: auto; }
  #fac-informe-body { padding: 12px 14px !important; overflow: auto !important; }
}
