/* ==========================================================================
   KTRINA SATÉLITE - SISTEMA GENERADOR DE COTIZACIONES Y RECIBOS
   Formato Carta Oficial (Letter 8.5" x 11"), Múltiples Conceptos y Optimizado para Móvil
   ========================================================================== */

:root {
  /* Paleta General de la Interfaz (Tema Ktrina Horror / Dark Studio) */
  --app-bg: #0c0a0a;
  --app-panel: #161212;
  --app-panel-header: #1f1919;
  --app-border: #2e2424;
  --app-text: #f0ebeb;
  --app-text-muted: #9e9393;
  --app-accent: #e64a19;
  --app-accent-glow: rgba(230, 74, 25, 0.35);
  --app-whatsapp: #25d366;
  --app-whatsapp-hover: #20ba59;
  --app-success: #2e7d32;
  --app-warning: #f57c00;

  /* Variables del Recibo Oficial (Réplica exacta de Ktrina) */
  --receipt-header-bg: #050404;
  --receipt-ktrina-orange: #d74700;
  --receipt-satelite-gray: #b0b0b0;
  --receipt-divider-orange: #d74700;
  --receipt-body-bg: #f4f6f6;
  --receipt-text-dark: #121212;
  --receipt-company-teal: #143d34;
  --receipt-heading-rust: #b8380d;
  --receipt-pill-orange: #cc4d00;
  --receipt-cancel-bg: #ffe4dc;
  --receipt-cancel-border: #cb2800;
  --receipt-cancel-title: #b71c1c;
  --receipt-cancel-text: #333333;
}

/* Reset básico */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--app-bg);
  color: var(--app-text);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  background: linear-gradient(180deg, #181212 0%, #0d0a0a 100%);
  border-bottom: 2px solid var(--receipt-divider-orange);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.app-header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-img {
  height: 44px;
  width: auto;
  filter: drop-shadow(0 0 8px rgba(215, 71, 0, 0.4));
}

.brand-titles h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}

.brand-titles h1 span {
  color: var(--receipt-ktrina-orange);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--app-text-muted);
}

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

.btn-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #221a1a;
  color: #f0ebeb;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-nav-back:hover {
  background: #2e2222;
  border-color: var(--receipt-divider-orange);
  color: #ffffff;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(46, 125, 50, 0.2);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.4);
  white-space: nowrap;
}

.header-badge .badge-dot {
  width: 8px;
  height: 8px;
  background-color: #4caf50;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ==========================================================================
   BARRA DE PESTAÑAS PARA MÓVIL
   ========================================================================== */
.mobile-tabs-bar {
  display: none; /* Solo visible en tablets y móviles <= 1024px */
  background: #140f0f;
  border-bottom: 1px solid var(--app-border);
  padding: 6px 12px;
  position: sticky;
  top: 66px;
  z-index: 95;
  gap: 8px;
}

.mobile-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: #201818;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  color: var(--app-text-muted);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-tab-btn.active {
  background: linear-gradient(135deg, #2b1c1c 0%, #1c1414 100%);
  color: #ffffff;
  border-color: var(--receipt-divider-orange);
  box-shadow: 0 2px 10px rgba(215, 71, 0, 0.3);
}

.mobile-tab-btn svg {
  color: var(--receipt-ktrina-orange);
}

.mobile-tab-pill {
  background: var(--receipt-ktrina-orange);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
}

/* ==========================================================================
   MAIN WORKSPACE LAYOUT (2 COLUMNAS EN DESKTOP)
   ========================================================================== */
.app-main {
  flex: 1;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.generator-layout {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 26px;
  align-items: start;
}

/* ==========================================================================
   PANEL IZQUIERDO: FORMULARIO Y CONTROLES
   ========================================================================== */
.generator-panel {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-header {
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h2 svg {
  color: var(--receipt-ktrina-orange);
}

.btn-reset-form {
  background: none;
  border: 1px solid var(--app-border);
  color: var(--app-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-form:hover {
  background: #221a1a;
  color: #ff6b6b;
  border-color: #ff6b6b;
}

/* Fieldsets / Secciones del Formulario */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--receipt-ktrina-orange);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-add-concept {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #261919;
  color: #ff8a65;
  border: 1px solid #4a2d2d;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-add-concept:hover {
  background: var(--receipt-ktrina-orange);
  color: #ffffff;
  border-color: var(--receipt-ktrina-orange);
  box-shadow: 0 2px 10px var(--app-accent-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: #dedede;
}

.form-group label span.required {
  color: var(--receipt-ktrina-orange);
  margin-left: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: #0d0a0a;
  border: 1px solid #332626;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.92rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--receipt-ktrina-orange);
  box-shadow: 0 0 0 3px var(--app-accent-glow);
}

.form-textarea {
  min-height: 75px;
  resize: vertical;
  line-height: 1.4;
  font-family: inherit;
  font-size: 0.85rem;
}

.input-with-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 12px;
  color: var(--receipt-ktrina-orange);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
}

.input-with-prefix .form-input {
  padding-left: 30px;
  font-weight: 700;
}

/* Lista dinámica de conceptos */
.concepts-list-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.concept-item-card {
  background: #110d0d;
  border: 1px solid #332424;
  border-left: 4px solid var(--receipt-ktrina-orange);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease;
}

.concept-item-card:hover {
  border-color: #4a3333;
  border-left-color: #ff5722;
}

.concept-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.concept-badge-number {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--receipt-ktrina-orange);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-remove-concept {
  background: none;
  border: none;
  color: #ff5252;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.btn-remove-concept:hover {
  background: rgba(255, 82, 82, 0.15);
  color: #ff8a80;
}

.btn-remove-concept:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Barra de Total en Formulario */
.form-total-summary-card {
  background: linear-gradient(135deg, #1f1414 0%, #150d0d 100%);
  border: 1px solid #3d2626;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.total-summary-left {
  display: flex;
  flex-direction: column;
}

.total-label-text {
  font-size: 0.8rem;
  color: #bbb;
  font-weight: 600;
}

.total-items-count {
  font-size: 0.72rem;
  color: var(--app-text-muted);
}

.total-summary-right {
  font-size: 1.25rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.5px;
}

/* Toggle Checkbox */
.toggle-control {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #110e0e;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--app-border);
  cursor: pointer;
}

.toggle-control input[type="checkbox"] {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--receipt-divider-orange);
  cursor: pointer;
}

.toggle-info {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
}

.toggle-desc {
  font-size: 0.72rem;
  color: var(--app-text-muted);
}

/* Botón solo visible en móvil para alternar a la vista previa */
.mobile-only-preview-trigger {
  display: none;
}

.btn-mobile-preview-switch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: #241a1a;
  border: 1px solid var(--receipt-divider-orange);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}

/* Botones de Acción del Panel */
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--app-border);
}

.btn-action-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #e64a19 0%, #d84315 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--app-accent-glow);
  transition: all 0.25s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-action-primary:hover {
  background: linear-gradient(135deg, #ff5722 0%, #e64a19 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(230, 74, 25, 0.55);
}

.btn-action-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 18px;
  background: linear-gradient(135deg, #25d366 0%, #1ebe57 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.35);
  transition: all 0.2s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-action-whatsapp:hover {
  background: linear-gradient(135deg, #2ae26f 0%, #25d366 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(37, 211, 102, 0.5);
}

.btn-grid-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-action-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  background: #1f1818;
  color: #dedede;
  border: 1px solid #3d2c2c;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action-secondary:hover {
  background: #2a2020;
  border-color: var(--receipt-divider-orange);
  color: #ffffff;
}

.btn-action-secondary.save:hover {
  background: #1b263b;
  border-color: #4a90e2;
  color: #64b5f6;
}

/* ==========================================================================
   PANEL DERECHO: VISTA PREVIA HOJA TAMAÑO CARTA
   ========================================================================== */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-toolbar {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--app-text-muted);
}

.preview-info strong {
  color: #ffffff;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-btn {
  background: #221a1a;
  border: 1px solid var(--app-border);
  color: #ccc;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: #2e2222;
  border-color: var(--receipt-divider-orange);
  color: #fff;
}

.zoom-level-text {
  font-size: 0.82rem;
  min-width: 48px;
  text-align: center;
  color: #bbb;
  font-weight: 600;
}

/* Viewport con scroll y escalado para móvil */
.receipt-viewport {
  background: #110e0e;
  border: 2px dashed #2f2222;
  border-radius: 12px;
  padding: 24px 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  min-height: 850px;
}

.receipt-outer-frame {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  transition: width 0.2s ease, height 0.2s ease;
}

.receipt-scale-wrapper {
  transform-origin: top left;
  width: 816px;
  min-height: 1056px;
}

@media (max-width: 1024px) {
  .receipt-outer-frame {
    position: relative;
    overflow: hidden;
  }
  .receipt-scale-wrapper {
    position: absolute;
    top: 0;
    left: 0;
  }
}

@media (min-width: 1025px) {
  .receipt-outer-frame {
    width: auto !important;
    height: auto !important;
    overflow: visible;
  }
  .receipt-scale-wrapper {
    position: relative;
    width: auto;
    height: auto;
    transform: none !important;
  }
}

.preview-mobile-actions {
  display: none;
}

/* ==========================================================================
   EL DOCUMENTO: HOJA TAMAÑO CARTA (LETTER 8.5" x 11")
   Proporción 816px × 1056px (Exact Letter Aspect Ratio 1 : 1.294)
   ========================================================================== */
.receipt-card.letter-size {
  width: 816px;
  min-height: 1056px;
  max-width: 100%;
  box-sizing: border-box;
  background-color: var(--receipt-body-bg);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--receipt-text-dark);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: transform 0.2s ease;
  user-select: text;
  margin: 0 auto;
}

/* 1. Franja Superior Negra */
.receipt-header-top {
  background-color: var(--receipt-header-bg);
  padding: 24px 36px 18px 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.receipt-header-branding {
  display: flex;
  flex-direction: column;
}

.receipt-ktrina-title {
  font-family: 'Impact', 'Arial Black', -apple-system, sans-serif;
  font-size: 48px;
  line-height: 1;
  font-weight: 900;
  color: var(--receipt-ktrina-orange);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.receipt-satelite-subtitle {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 19px;
  font-weight: 500;
  color: var(--receipt-satelite-gray);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 6px;
}

.receipt-header-logo {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.receipt-logo-img {
  width: 115px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

/* 2. Barra Divisoria Naranja */
.receipt-divider-bar {
  background-color: var(--receipt-divider-orange);
  height: 8px;
  width: 100%;
  flex-shrink: 0;
}

/* 3. Cuerpo del Documento Carta */
.receipt-body-content {
  flex: 1;
  padding: 28px 42px 34px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  box-sizing: border-box;
}

.receipt-top-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Fila de Datos de Empresa & Tipo de Comprobante */
.receipt-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.company-contact-block {
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--receipt-company-teal);
  font-weight: 500;
}

.company-contact-block .contact-city {
  font-weight: 600;
}

.company-contact-block .contact-state {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.company-contact-block .contact-tel {
  font-weight: 700;
}

.company-contact-block .contact-email {
  font-weight: 500;
}

.voucher-type-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.voucher-title-text {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--receipt-company-teal);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.voucher-date-text {
  font-size: 19px;
  font-weight: 600;
  color: var(--receipt-company-teal);
  margin-top: 8px;
}

.voucher-folio-text {
  font-size: 13px;
  font-weight: 700;
  color: #78909c;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Título Central del Recibo */
.receipt-heading-container {
  text-align: center;
  margin-top: 2px;
}

.receipt-main-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--receipt-heading-rust);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.receipt-dashed-line {
  border-bottom: 2px dashed #b8380d;
  margin-top: 12px;
  width: 100%;
}

/* Bloque Cliente & Fecha del Servicio */
.client-info-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 2px;
}

.client-field-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.client-field-label {
  width: 140px;
  text-align: right;
  font-size: 19px;
  font-weight: 800;
  color: #1a1a1a;
  flex-shrink: 0;
}

.client-field-value {
  flex: 1;
  font-size: 19px;
  font-weight: 800;
  color: #111111;
  border-bottom: 1.5px solid #a4b0b7;
  padding-bottom: 3px;
  padding-left: 6px;
  min-height: 28px;
}

/* Tabla de Conceptos (Pill Naranja) */
.receipt-table-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.receipt-table-header {
  background-color: var(--receipt-pill-orange);
  border-radius: 18px;
  padding: 10px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.receipt-items-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 10px;
}

.receipt-item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 1px dotted #cfd8dc;
  page-break-inside: avoid;
  break-inside: avoid;
}

.receipt-item-row:last-child {
  border-bottom: none;
}

.item-desc-col {
  flex: 1;
}

.item-concept-name {
  font-size: 19px;
  font-weight: 800;
  color: #111111;
}

.item-concept-note {
  font-size: 14px;
  color: #555555;
  margin-top: 5px;
  line-height: 1.4;
  font-weight: 500;
}

.item-amount-col {
  text-align: right;
  flex-shrink: 0;
}

.item-amount-value {
  font-size: 21px;
  font-weight: 800;
  color: #111111;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Fila de Total General */
.receipt-totals-section {
  border-top: 2px solid #b0bec5;
  padding-top: 10px;
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.receipt-total-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.total-label-lead {
  font-size: 18px;
  font-weight: 800;
  color: var(--receipt-company-teal);
  letter-spacing: 0.5px;
}

.total-amount-lead {
  font-size: 26px;
  font-weight: 900;
  color: var(--receipt-pill-orange);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.receipt-extra-summary {
  display: flex;
  justify-content: flex-end;
  padding: 6px 10px 0 10px;
  font-size: 13.5px;
  color: #455a64;
  font-weight: 600;
}

/* Caja de Términos de Cancelación (Warning Box Oficial) */
.cancellation-terms-card {
  margin-top: 14px;
  background-color: var(--receipt-cancel-bg);
  border-left: 8px solid var(--receipt-cancel-border);
  border-radius: 0 8px 8px 0;
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cancellation-title {
  color: var(--receipt-cancel-title);
  font-size: 15.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.2px;
}

.cancellation-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--receipt-cancel-text);
  font-weight: 400;
}

.cancellation-text strong {
  font-weight: 800;
}

.cancellation-text .highlight-red {
  color: #b71c1c;
  font-weight: 800;
}

/* ==========================================================================
   HISTORIAL DE RECIBOS GUARDADOS
   ========================================================================== */
.history-section {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.history-header h3 {
  font-size: 1.05rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.history-card {
  background: #110e0e;
  border: 1px solid #2d2222;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.history-card:hover {
  border-color: var(--receipt-divider-orange);
  transform: translateY(-2px);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-card-folio {
  font-weight: 700;
  color: var(--receipt-ktrina-orange);
  font-size: 0.85rem;
}

.history-card-date {
  font-size: 0.75rem;
  color: var(--app-text-muted);
}

.history-card-client {
  font-weight: 600;
  color: #ffffff;
  font-size: 0.95rem;
}

.history-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--app-text-muted);
}

.history-card-amount {
  font-weight: 800;
  color: #ffffff;
  font-size: 1.05rem;
}

.history-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #241a1a;
}

.btn-history-action {
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #3d2b2b;
  background: #1c1515;
  color: #d0c8c8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-history-action:hover {
  background: #2a1f1f;
  color: #fff;
  border-color: var(--receipt-divider-orange);
}

.btn-history-action.delete:hover {
  background: #331515;
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.empty-history-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: var(--app-text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   TOAST NOTIFICATION MODAL
   ========================================================================== */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e1717;
  border: 1px solid var(--receipt-divider-orange);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   RESPONSIVE DESIGN Y OPTIMIZACIÓN MÓVIL (< 1024px, < 768px, < 480px)
   ========================================================================== */

/* Tablets y Pantallas Medianas / Móviles (< 1024px) */
@media (max-width: 1024px) {
  .generator-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .mobile-tabs-bar {
    display: flex;
  }

  .desktop-only {
    display: none !important;
  }

  /* Modo pestañas: solo se muestra el panel activo en móvil */
  body.mobile-tab-preview-active #generatorPanel {
    display: none !important;
  }

  body.mobile-tab-preview-active #previewPanel {
    display: flex !important;
  }

  body.mobile-tab-form-active #previewPanel {
    display: none !important;
  }

  body.mobile-tab-form-active #generatorPanel {
    display: flex !important;
  }

  .mobile-only-preview-trigger {
    display: block;
    margin-top: 10px;
  }

  .receipt-viewport {
    padding: 12px 6px;
    min-height: auto;
    overflow: hidden;
  }

  .preview-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
    width: 100%;
  }
}

/* Móviles Estándar (< 768px) */
@media (max-width: 768px) {
  .app-header {
    padding: 8px 12px;
  }

  .brand-logo-img {
    height: 38px;
  }

  .brand-titles h1 {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    font-size: 0.72rem;
  }

  .btn-back-text {
    display: none;
  }

  .btn-nav-back {
    padding: 8px;
  }

  .app-main {
    padding: 12px 10px;
  }

  .generator-panel {
    padding: 16px 14px;
    border-radius: 10px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Tamaño de fuente amigable para touch en móvil (evita auto-zoom iOS) */
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    padding: 11px 12px;
  }

  .btn-grid-secondary {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    padding: 8px 12px;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .receipt-viewport {
    padding: 12px 6px;
    min-height: unset;
  }

  .preview-info {
    font-size: 0.78rem;
    text-align: center;
  }

  .preview-controls {
    justify-content: center;
  }

  .history-grid {
    grid-template-columns: 1fr;
  }

  .toast-notice {
    bottom: 16px;
    left: 16px;
    right: 16px;
    font-size: 0.85rem;
    padding: 12px 16px;
    justify-content: center;
    text-align: center;
  }
}

/* Pantallas Pequeñas (< 480px) */
@media (max-width: 480px) {
  .mobile-tabs-bar {
    padding: 6px 8px;
    top: 58px;
  }

  .mobile-tab-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .btn-action-primary,
  .btn-action-whatsapp {
    font-size: 0.92rem;
    padding: 13px 14px;
  }

  .form-total-summary-card {
    padding: 10px 12px;
  }

  .total-summary-right {
    font-size: 1.1rem;
  }
}

/* ==========================================================================
   ESTILOS DE IMPRESIÓN DIRECTA (@media print) - TAMAÑO CARTA
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-header,
  .mobile-tabs-bar,
  .generator-panel,
  .preview-toolbar,
  .history-section,
  .toast-notice,
  .mobile-only-preview-trigger {
    display: none !important;
  }

  .app-main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .generator-layout {
    display: block !important;
  }

  .preview-panel {
    display: block !important;
  }

  .receipt-viewport {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
    overflow: visible !important;
    min-height: auto !important;
  }

  .receipt-scale-wrapper {
    transform: none !important;
    height: auto !important;
  }

  .receipt-card.letter-size {
    box-shadow: none !important;
    width: 100% !important;
    max-width: 816px !important;
    min-height: 1056px !important;
    margin: 0 auto !important;
    page-break-inside: avoid !important;
    transform: none !important;
  }

  @page {
    size: letter portrait;
    margin: 6mm;
  }
}
