/* ========================================================
   ACCANDBI.TECH - FEL TO PRINT PRO DESIGN SYSTEM
   Diseño inspirado en accandbi.tech con soporte para DTE SAT Guatemala
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  /* IDENTIDAD VISUAL ACCANDBI.TECH */
  --cyan: #0cb7f2;
  --cyan-600: #029fd4;
  --cyan-soft: #eaf8fe;
  --cyan-glow: rgba(12, 183, 242, 0.32);
  --cyan-glow-intense: rgba(12, 183, 242, 0.55);
  
  --navy: #151936;
  --navy-900: #0a0e1a;
  --navy-800: #0f1527;
  --navy-700: #1a2238;
  --ink: #111827;
  --muted: #8c97ad;
  --line-dark: rgba(255, 255, 255, 0.12);
  --soft-dark: rgba(255, 255, 255, 0.04);
  
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-full: 999px;

  /* VARIABLES CONFIGURABLES DE LA FACTURA IMPRESA */
  --doc-primary: #0F4C68;       /* Encabezado de tabla, badge DTE, barra TOTAL */
  --doc-primary-text: #FFFFFF;  /* Texto sobre primario */
  --doc-accent: #B47D28;        /* Línea divisoria dorada y borde de total en letras */
  --doc-bg-info: #F1F5F9;       /* Fondo de recuadro receptor */
  --doc-bg-table-alt: #F8FAFC;  /* Fondo de filas alternas */
  --doc-border: #E2E8F0;        /* Bordes sutiles */
  --doc-text: #1E293B;          /* Texto principal del papel */
  --doc-text-muted: #64748B;    /* Texto secundario del papel */
  --doc-paper-width: 8.5in;     /* Carta por defecto */
  --doc-paper-min-height: 11in;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--navy-900);
  color: #FFFFFF;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Barra decorativa superior de progreso estilo accandbi */
.top-glow-bar {
  height: 3.5px;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), #73d9ff 50%, #ffffff);
  box-shadow: 0 0 12px var(--cyan-glow-intense);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
}

/* ========================================================
   BARRA SUPERIOR (HEADER ESTILO ACCANDBI.TECH)
   ======================================================== */
.app-header {
  height: 70px;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-logo-img {
  height: 42px;
  width: auto;
  border-radius: 8px;
  object-fit: contain;
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 2px;
}

.brand-domain {
  color: var(--cyan);
  font-weight: 800;
}

.brand-badge {
  font-family: var(--font-display);
  background: rgba(12, 183, 242, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(12, 183, 242, 0.4);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-left: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========================================================
   BOTONES ESTILO ACCANDBI
   ======================================================== */
.btn {
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  text-decoration: none;
  line-height: 1;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--cyan);
  color: #041019;
  box-shadow: 0 8px 24px var(--cyan-glow);
}
.btn-primary:hover {
  background: #30c5f7;
  color: #020b12;
  box-shadow: 0 12px 28px var(--cyan-glow-intense);
}

.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  background: transparent;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.6);
  color: #FFFFFF;
}

.btn-erp {
  background: rgba(12, 183, 242, 0.1);
  color: #FFFFFF;
  border: 1px solid rgba(12, 183, 242, 0.4);
}
.btn-erp:hover {
  background: var(--cyan);
  color: #041019;
  border-color: var(--cyan);
  box-shadow: 0 6px 20px var(--cyan-glow);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #F87171;
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #EF4444;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 13px 26px;
  font-size: 0.98rem;
}

/* ========================================================
   CONTENEDOR PRINCIPAL: SIDEBAR + PREVIEW CANVAS
   ======================================================== */
.app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 70px);
  overflow: hidden;
}

/* SIDEBAR DE CONFIGURACIÓN */
.app-sidebar {
  width: 400px;
  background: var(--navy-800);
  border-right: 1px solid var(--line-dark);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
}

.sidebar-section {
  background: var(--navy-700);
  border: 1px solid var(--line-dark);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.sidebar-section.highlight {
  border-color: rgba(12, 183, 242, 0.4);
  background: linear-gradient(180deg, rgba(12, 183, 242, 0.08) 0%, rgba(21, 25, 54, 0.6) 100%);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title svg {
  color: var(--cyan);
}

.sidebar-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.45;
}

/* Zona Drag & Drop para XML */
.dropzone {
  border: 2px dashed rgba(12, 183, 242, 0.5);
  background: rgba(12, 183, 242, 0.04);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 12px;
}
.dropzone:hover, .dropzone.dragover {
  background: rgba(12, 183, 242, 0.12);
  border-color: var(--cyan);
  box-shadow: 0 0 20px var(--cyan-glow);
}
.dropzone-icon {
  font-size: 28px;
  margin-bottom: 6px;
  display: block;
}
.dropzone-text {
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 700;
  color: #F1F5F9;
}
.dropzone-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Campos de Formulario */
.form-group {
  margin-bottom: 12px;
}
.form-group:last-child {
  margin-bottom: 0;
}
.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: #CBD5E1;
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  background: var(--navy-900);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  padding: 9px 12px;
  color: #FFFFFF;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s ease;
}
.form-control:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(12, 183, 242, 0.2);
}

/* Control deslizante de tamaño de logo con badge numérico */
.logo-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.slider-val-badge {
  font-family: var(--font-display);
  background: rgba(12, 183, 242, 0.15);
  color: var(--cyan);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--navy-900);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--cyan-glow);
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ========================================================
   SECCIÓN DE COLORES DE RECOMENDACIÓN Y SELECTOR MANUAL
   ======================================================== */
.recommended-colors-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
}

.rec-color-card {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  background: var(--navy-900);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
}
.rec-color-card:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}
.rec-color-card.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan);
  background: rgba(12, 183, 242, 0.08);
}

.rec-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.rec-color-info {
  line-height: 1.15;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}
.rec-color-name {
  font-family: var(--font-display);
  font-size: 0.70rem;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  display: block;
}
.rec-color-hex {
  font-size: 0.63rem;
  color: var(--muted);
  font-family: monospace;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  display: block;
}

/* Botones para abrir el selector manual de color */
.manual-color-pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.manual-color-btn {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  background: var(--navy-900);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  box-sizing: border-box;
}
.manual-color-btn:hover {
  border-color: var(--cyan);
  background: rgba(12, 183, 242, 0.05);
}
.manual-color-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}
.manual-color-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.manual-color-sub {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ========================================================
   COMPONENTE SELECTOR MANUAL (IDÉNTICO A LA IMAGEN ADJUNTA)
   ======================================================== */
.custom-color-picker-card {
  display: none;
  position: fixed;
  width: 290px;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  color: #111827;
  font-family: var(--font-body);
  user-select: none;
}
.custom-color-picker-card.open {
  display: block;
}

.cp-header {
  padding: 10px 14px;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F9FAFB;
}
.cp-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
}
.cp-close {
  cursor: pointer;
  font-size: 1.3rem;
  color: #9CA3AF;
  line-height: 1;
}
.cp-close:hover {
  color: #111827;
}

.cp-canvas-wrap {
  position: relative;
  width: 100%;
  height: 150px;
  cursor: crosshair;
}
.cp-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.cp-pointer {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cp-middle-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cp-eyedropper-btn {
  background: none;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: #4B5563;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.cp-eyedropper-btn:hover {
  background: #F3F4F6;
  color: #111827;
}

.cp-color-preview {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #E5E7EB;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.cp-hue-slider-wrap {
  flex: 1;
}
.cp-hue-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  outline: none;
  cursor: pointer;
}
.cp-hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid #111827;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: pointer;
}

.cp-values-row {
  padding: 0 14px 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-rgb-inputs {
  display: flex;
  gap: 8px;
  flex: 1;
}
.cp-hex-inputs {
  flex: 1;
}
.cp-input-group {
  flex: 1;
  text-align: center;
}
.cp-input {
  width: 100%;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 0.85rem;
  font-family: monospace;
  text-align: center;
  outline: none;
  color: #111827;
}
.cp-input:focus {
  border-color: #2563EB;
}
.cp-input-group label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #6B7280;
  margin-top: 3px;
}

.cp-mode-toggle {
  background: none;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  color: #4B5563;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-mode-toggle:hover {
  background: #F3F4F6;
  color: #111827;
}

/* ========================================================
   ÁREA DE VISTA PREVIA (CANVAS)
   ======================================================== */
.preview-container {
  flex: 1;
  background: var(--navy-900);
  overflow-y: auto;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-toolbar {
  width: 100%;
  max-width: var(--doc-paper-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

/* ========================================================
   DOCUMENTO FEL (HOJA OFICIAL DE IMPRESIÓN)
   ======================================================== */
.fel-document {
  width: var(--doc-paper-width);
  min-height: var(--doc-paper-min-height);
  background-color: #FFFFFF;
  color: var(--doc-text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 24mm 20mm 20mm 20mm;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ENCABEZADO SUPERIOR: EMISOR + BADGE DTE */
.fel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

/* Bloque Izquierdo: Logo e Información del Emisor */
.emisor-block {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex: 1;
}

.emisor-logo-wrap {
  width: 130px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
  transition: width 0.15s ease;
}

.emisor-logo-img {
  width: 100%;
  max-width: 100%;
  object-fit: contain;
}

.emisor-logo-placeholder {
  width: 100%;
  height: 65px;
  border: 1px dashed #94A3B8;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #64748B;
  text-align: center;
  padding: 6px;
  background: #F8FAFC;
}

.emisor-details {
  flex: 1;
}

.emisor-nombre {
  font-size: 19px;
  font-weight: 700;
  color: var(--doc-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.emisor-nit {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--doc-text);
  margin-bottom: 2px;
}

.emisor-line {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.35;
}

/* Bloque Derecho: Recuadro DTE Oficial */
.dte-box {
  width: 290px;
  border: 1.5px solid var(--doc-primary);
  border-radius: 8px;
  overflow: hidden;
  background-color: #FFFFFF;
  flex-shrink: 0;
}

.dte-box-header {
  background-color: var(--doc-primary);
  color: var(--doc-primary-text);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  padding: 6px 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.25;
}

.dte-box-body {
  padding: 8px 14px;
  font-size: 11px;
}

.dte-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.dte-row-label {
  color: #475569;
  font-weight: 500;
}

.dte-row-value {
  font-weight: 700;
  color: var(--doc-primary);
  font-size: 12px;
}

.dte-auth-section {
  margin-top: 2px;
}
.dte-auth-label {
  color: #475569;
  font-weight: 500;
  font-size: 10.5px;
  margin-bottom: 1px;
}
.dte-auth-code {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--doc-primary);
  word-break: break-all;
  line-height: 1.25;
  font-family: 'Courier New', Courier, monospace;
}

/* LÍNEA DIVISORIA DORADA / ACENTO */
.accent-separator {
  height: 2.5px;
  background-color: var(--doc-accent);
  margin: 14px 0 16px 0;
  border-radius: 2px;
}

/* RECUADRO RECEPTOR & FECHA DE EMISIÓN */
.receptor-card {
  background-color: var(--doc-bg-info);
  border-radius: 8px;
  border-left: 5px solid var(--doc-primary);
  padding: 12px 18px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-bottom: 18px;
}

.info-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11.5px;
}
.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-weight: 700;
  color: var(--doc-primary);
  min-width: 85px;
  flex-shrink: 0;
}

.info-value {
  color: var(--doc-text);
  font-weight: 500;
  word-break: break-word;
}

/* TABLA DE PRODUCTOS Y SERVICIOS */
.items-table-wrapper {
  margin-bottom: 18px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.items-table th {
  background-color: var(--doc-primary);
  color: var(--doc-primary-text);
  font-weight: 700;
  padding: 8px 10px;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.items-table th.col-cant { width: 8%; text-align: center; }
.items-table th.col-desc { width: 52%; text-align: left; }
.items-table th.col-unit { width: 14%; text-align: right; }
.items-table th.col-desc-num { width: 12%; text-align: right; }
.items-table th.col-total { width: 14%; text-align: right; }

.items-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--doc-border);
  color: var(--doc-text);
  vertical-align: middle;
}

.items-table tbody tr.row-alt {
  background-color: var(--doc-bg-table-alt);
}

.items-table td.col-cant { text-align: center; }
.items-table td.col-desc { text-align: left; line-height: 1.35; }
.items-table td.col-unit { text-align: right; font-variant-numeric: tabular-nums; }
.items-table td.col-desc-num { text-align: right; font-variant-numeric: tabular-nums; }
.items-table td.col-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* SECCIÓN TOTALES: LETRAS + RESUMEN */
.totals-section {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}

/* Total en letras (Sin 'SON:') */
.total-letras-box {
  flex: 1;
  background-color: #F8FAFC;
  border-left: 4px solid var(--doc-accent);
  border-radius: 4px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.total-letras-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--doc-primary);
  margin-bottom: 3px;
}

.total-letras-text {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--doc-text);
  line-height: 1.35;
  letter-spacing: 0.1px;
}

/* Resumen numérico */
.totals-summary-box {
  width: 280px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--doc-border);
  background-color: #FFFFFF;
}

.totals-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 11.5px;
  border-bottom: 1px solid var(--doc-border);
}
.totals-summary-row:last-child {
  border-bottom: none;
}
.totals-summary-label {
  color: #475569;
}
.totals-summary-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.totals-summary-row.grand-total-row {
  background-color: var(--doc-primary);
  color: var(--doc-primary-text);
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 800;
  align-items: center;
}
.totals-summary-row.grand-total-row .totals-summary-label {
  color: var(--doc-primary-text);
}
.totals-summary-row.grand-total-row .totals-summary-val {
  font-size: 14px;
}

/* ========================================================
   FRASE / LEYENDA DEL XML (OBLIGATORIA SEGÚN XML)
   ======================================================== */
.frase-legend-container {
  margin: 12px 0 16px 0;
  text-align: center;
}

.frase-legend-text {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  font-style: italic;
  padding: 4px 14px;
  border-radius: 4px;
  background-color: rgba(22, 101, 52, 0.05);
}

.frase-legend-container.style-border .frase-legend-text {
  border: 1px dashed #86EFAC;
  background-color: #F0FDF4;
  padding: 6px 18px;
  border-radius: 6px;
}

.frase-legend-container.style-text .frase-legend-text {
  background: transparent;
  color: #475569;
}

/* ========================================================
   CERTIFICACIÓN / SELLO GRÁFICO OFICIAL FEL
   ======================================================== */
.certification-card {
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background-color: #FFFFFF;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
}

.cert-qr-wrap {
  width: 82px;
  height: 82px;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cert-qr-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.cert-info-wrap {
  flex: 1;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--doc-text);
}

.cert-data-row {
  margin-bottom: 2px;
}
.cert-data-label {
  font-weight: 700;
  color: var(--doc-text);
}

.cert-sat-statement {
  font-size: 9.5px;
  color: #64748B;
  margin-top: 4px;
  line-height: 1.3;
}

/* Sello Gráfico Oficial FEL por defecto */
.cert-fel-graphic-seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  flex-shrink: 0;
}

.fel-seal-img {
  max-height: 48px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Pie final de documento con Emisor y Sitio Web dinámico */
.document-footer-line {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: #94A3B8;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #F1F5F9;
}

/* ========================================================
   REGLAS DE IMPRESIÓN OFICIAL (@MEDIA PRINT)
   ======================================================== */
@media print {
  @page {
    size: letter portrait;
    margin: 10mm;
  }

  html, body {
    background-color: #FFFFFF !important;
    color: #000000 !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print,
  .top-glow-bar,
  .app-header,
  .app-sidebar,
  .preview-toolbar,
  .custom-color-picker-card {
    display: none !important;
  }

  .app-layout {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .preview-container {
    background-color: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .fel-document {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .items-table, .totals-section, .certification-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}
