/* ==========================================================================
   REPAMAX - COTIZADOR DE MANTENIMIENTO
   Estilos CSS Premium para Aplicación SPA
   ========================================================================== */

/* 1. VARIABLES DE DISEÑO (DESIGN TOKENS) */
:root {
  /* Paleta de Colores Principal */
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1f2937;
  --border-color: #1f2937;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent: #40A2E3; /* Celeste Repamax */
  --accent-hover: #62b6ec;
  --accent-glow: rgba(64, 162, 227, 0.15);
  
  --success: #10b981;
  --danger: #ef4444;
  --info: #3b82f6;
  
  /* Sombras y Efectos */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px -5px rgba(64, 162, 227, 0.25);
  
  /* Fuentes y Bordes */
  --font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Claro Opcional (Activado por clase .light-theme) */
.light-theme {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --accent: #003B6F; /* Azul Marino Repamax */
  --accent-hover: #002D56;
  --accent-glow: rgba(0, 59, 111, 0.1);
  
  --shadow-glow: 0 8px 30px rgba(0, 59, 111, 0.08);
}

/* 2. REGLAS GENERALES Y RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Contenedor Principal */
.app-container {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

@media (min-width: 1024px) {
  .app-container {
    grid-template-columns: 320px 1fr;
  }
}

/* 3. BARRA LATERAL (HISTORIAL Y DASHBOARD) */
.sidebar {
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  max-height: 100vh;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-b: 1px solid var(--border-color);
}

.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--accent);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: var(--shadow-glow);
}

.brand-info h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-info span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* Dashboard Estadístico */
.stats-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background-color: var(--bg-main);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

/* Historial List */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-grow: 1;
}

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

.history-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-box {
  width: 100%;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.2rem;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.6;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 0.25rem;
}

.history-card {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-card:hover {
  border-color: var(--accent);
  background-color: var(--bg-card-hover);
}

.history-card.active {
  border-color: var(--accent);
  background-color: var(--accent-glow);
}

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

.hist-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

.hist-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.hist-client {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border-color);
}

.hist-total {
  font-size: 0.85rem;
  font-weight: 700;
}

.hist-machine {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.no-history {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem 1rem;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
}

/* 4. CONTENIDO PRINCIPAL (CREAR / EDITAR COTIZACIÓN) */
.main-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .main-content {
    padding: 2rem;
  }
}

/* Barra superior de acciones */
.action-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1rem;
  border-b: 1px solid var(--border-color);
}

@media (min-width: 768px) {
  .action-header {
    flex-direction: row;
    align-items: center;
  }
}

.page-title h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.global-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Botones Base */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background-color: var(--accent);
  color: #0f172a;
}

.light-theme .btn-primary {
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: white;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 5. TARJETAS DE FORMULARIO */
.grid-forms {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Panel de Plantillas y Servicios Rápidos */
.templates-selector-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .templates-selector-wrapper {
    flex-direction: row;
    align-items: flex-end;
    gap: 1.5rem;
  }
}

.template-info-box {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.6;
}

.template-info-box strong {
  color: var(--accent);
}

.template-info-box ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 0.4rem;
}

.template-info-box li {
  position: relative;
  padding-left: 0.85rem;
  margin-bottom: 0.2rem;
}

.template-info-box li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Administrador de Plantillas */
.card-collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.collapsible-trigger-btn {
  font-size: 0.8rem;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 700;
  transition: var(--transition);
}

.card:hover .collapsible-trigger-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.collapsible-body {
  display: none; /* Por defecto oculto, controlado por JS */
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  flex-direction: column;
  gap: 1.25rem;
}

.collapsible-body.show {
  display: flex;
}

.mini-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  margin-top: 0.5rem;
}

.mini-items-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8rem;
}

.mini-items-table th {
  background-color: var(--bg-card);
  padding: 0.5rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

.mini-items-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.mini-items-table tr:last-child td {
  border-bottom: none;
}

.mini-items-table select,
.mini-items-table input {
  padding: 0.35rem 0.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  width: 100%;
}

.mini-items-table select:focus,
.mini-items-table input:focus {
  border-color: var(--accent);
}

.col-mini-type { width: 20%; min-width: 140px; }
.col-mini-desc { width: 50%; min-width: 180px; }
.col-mini-qty { width: 10%; min-width: 60px; }
.col-mini-price { width: 15%; min-width: 80px; }
.col-mini-action { width: 5%; text-align: center; }

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  color: var(--accent);
}

.form-group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-group-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  .form-group-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .grid-span-2 {
    grid-column: span 2;
  }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1500;
  box-shadow: var(--shadow-lg);
  margin-top: 0.25rem;
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

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

.autocomplete-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--accent);
}

.light-theme .autocomplete-item:hover {
  background-color: #f1f5f9;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.form-field input::placeholder {
  color: var(--text-muted);
}

/* 6. TABLA DINÁMICA DE CONCEPTOS */
.items-card {
  width: 100%;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.items-table th {
  background-color: var(--bg-card);
  padding: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.items-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.items-table tr:last-child td {
  border-bottom: none;
}

/* Inputs dentro de la tabla */
.items-table select,
.items-table input {
  padding: 0.45rem 0.6rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

.items-table select:focus,
.items-table input:focus {
  border-color: var(--accent);
}

.col-type { width: 15%; min-width: 120px; }
.col-desc { width: 45%; min-width: 250px; }
.col-qty { width: 10%; min-width: 70px; }
.col-price { width: 15%; min-width: 100px; }
.col-subtotal { width: 10%; min-width: 90px; text-align: right; font-weight: 700; }
.col-action { width: 5%; text-align: center; }

.subtotal-val {
  padding-right: 0.5rem;
  color: var(--text-primary);
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

/* 7. RESUMEN FINANCIERO Y NOTAS */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.notes-card {
  height: 100%;
}

.calculator-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.calc-row.tax-config {
  gap: 1rem;
}

.calc-row.tax-config label {
  color: var(--text-secondary);
}

.calc-row.tax-config .tax-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 90px;
}

.calc-row.tax-config input {
  padding: 0.3rem 0.5rem;
  text-align: right;
  font-weight: 600;
}

.calc-row .calc-label {
  color: var(--text-secondary);
}

.calc-row .calc-val {
  font-weight: 600;
  text-align: right;
}

.calc-row.total {
  font-size: 1.25rem;
  font-weight: 800;
  border-top: 1px solid var(--border-color);
  padding-top: 0.85rem;
  margin-top: 0.4rem;
}

.calc-row.total .calc-label {
  color: var(--accent);
}

.calc-row.total .calc-val {
  color: var(--accent);
}

.action-buttons-footer {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
}

.action-buttons-footer .btn {
  flex: 1;
  justify-content: center;
}

/* 8. VISTA PREVIA IMPRESIÓN / MEMBRETE (OCULTO EN PANTALLA) */
#preview-print-modal {
  display: none;
}

/* 9. MEDIA QUERIES PARA IMPRESIÓN (PDF MEMBRETADO) */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  /* Forzar colores de fondo de impresión y deshabilitar fondos oscuros */
  html, body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Ocultar la aplicación SPA entera en pantalla */
  .app-container {
    display: none !important;
  }
  
  /* Mostrar contenedor de impresión */
  #preview-print-modal {
    display: block !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: 'Inter', sans-serif !important;
    width: 100% !important;
  }

  .print-page {
    width: 100% !important;
    max-width: 100% !important;
    padding: 18mm 15mm 15mm 15mm !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0 !important;
  }

  /* Cabecera del PDF (Estilo Corporativo) */
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #003B6F;
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .print-logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .print-logo-box {
    width: 3rem;
    height: 3rem;
    background-color: #f59e0b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color: #0f172a !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    border-radius: 4px;
  }

  .print-brand-title {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.1;
  }
  
  .print-brand-subtitle {
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #4b5563 !important;
  }

  .print-meta-box {
    text-align: right;
  }

  .print-doc-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a !important;
    margin-bottom: 0.25rem;
  }

  .print-doc-code {
    font-size: 1rem;
    font-weight: 700;
    color: #003B6F !important;
  }

  .print-doc-dates {
    font-size: 8.5pt;
    color: #4b5563 !important;
    margin-top: 0.25rem;
  }

  /* Ficha de datos doble columna */
  .print-details-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .print-col-section {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.85rem;
  }

  .print-col-section h3 {
    font-size: 9pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.35rem;
    margin-bottom: 0.6rem;
    color: #1f2937 !important;
  }

  .print-info-row {
    display: flex;
    font-size: 8.5pt;
    margin-bottom: 0.35rem;
  }

  .print-info-label {
    width: 90px;
    font-weight: 700;
    color: #4b5563 !important;
    flex-shrink: 0;
  }

  .print-info-value {
    color: #111827 !important;
  }

  /* Tabla de ítems para imprimir */
  .print-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
  }

  .print-items-table th {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 8.5pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #374151 !important;
    border: 1px solid #d1d5db;
    padding: 0.6rem;
    text-align: left;
  }

  .print-items-table td {
    font-size: 8.5pt;
    border: 1px solid #e5e7eb;
    padding: 0.55rem 0.6rem;
    color: #1f2937 !important;
  }

  .print-items-table th.right-align,
  .print-items-table td.right-align {
    text-align: right;
  }

  /* Seccion de totales y firmas */
  .print-footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .print-conditions {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.85rem;
    font-size: 8pt;
    color: #4b5563 !important;
  }

  .print-conditions h4 {
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: #1f2937 !important;
    text-transform: uppercase;
    font-size: 8pt;
  }

  .print-conditions ul {
    list-style-type: none;
    padding-left: 0;
  }

  .print-conditions li {
    margin-bottom: 0.25rem;
    position: relative;
    padding-left: 0.75rem;
  }

  .print-conditions li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #40A2E3;
  }

  .print-totals-box {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background-color: #f9fafb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  .print-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 8.5pt;
  }

  .print-total-row .label {
    font-weight: 600;
    color: #4b5563 !important;
  }

  .print-total-row .value {
    font-weight: 700;
  }

  .print-total-row.grand-total {
    border-top: 1px solid #d1d5db;
    padding-top: 0.5rem;
    font-size: 11pt;
    font-weight: 800;
    color: #0f172a !important;
  }

  /* Firmas y pie */
  .print-signatures-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-top: 2rem;
    text-align: center;
  }

  .signature-box {
    border-top: 1px solid #9ca3af;
    padding-top: 0.5rem;
    font-size: 8pt;
    color: #4b5563 !important;
  }

  .signature-box .signer-title {
    font-weight: 700;
    color: #1f2937 !important;
  }

  .print-disclaimer {
    font-size: 7.5pt;
    text-align: center;
    color: #9ca3af !important;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.85rem;
    margin-top: auto;
  }
}

/* 10. ESTILOS DE ICONOS LUCIDE (VECTORIALES SVG) */
.lucide {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2.25;
  vertical-align: middle;
  display: inline-block;
}

/* Iconos en botones */
.btn .lucide {
  margin-right: 0.25rem;
}

/* Iconos de botones sin texto (solo icono) */
.btn-icon .lucide {
  margin-right: 0;
}

/* Iconos en cabeceras de tarjeta */
.card-title .lucide {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--accent);
  stroke-width: 2.5;
  margin-right: 0.5rem;
}

/* Icono del logo principal */
.brand-logo .lucide {
  width: 1.35rem;
  height: 1.35rem;
  color: #0f172a;
  stroke-width: 3;
}

/* 11. BANNER DE RESTAURACIÓN DE BORRADOR */
.draft-banner {
  background-color: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
}

@media (min-width: 640px) {
  .draft-banner {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
  }
}

.draft-banner-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
}

.draft-banner-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.draft-banner-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

/* 12. TABLAS RESPONSIVAS EN MÓVILES (CONVERSIÓN A TARJETAS) */
@media (max-width: 767px) {
  .items-table, 
  .items-table thead, 
  .items-table tbody, 
  .items-table tr, 
  .items-table td {
    display: block;
    width: 100% !important;
  }
  
  .items-table thead {
    display: none; /* Ocultar cabeceras en móviles */
  }
  
  .items-table tr {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    padding: 1rem;
    position: relative;
    box-shadow: var(--shadow-sm);
  }
  
  .items-table td {
    border: none;
    padding: 0.6rem 0;
    text-align: right !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .light-theme .items-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  .items-table td:last-child {
    border-bottom: none;
    padding-top: 0.85rem;
    justify-content: flex-end;
  }
  
  /* Inyección de etiquetas descriptivas */
  .items-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 800;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    text-align: left;
    margin-right: 1rem;
    letter-spacing: 0.05em;
  }
}

/* ==========================================================================
   TOOLTIPS PREMIUM CSS PERSONALIZADOS
   ========================================================================== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background-color: #0f172a;
  color: #ffffff;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 1;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Evitar que los SVG capturen el ratón y rompan el hover en botones pequeños */
.btn-icon svg,
.btn-icon .lucide,
.btn-icon i {
  pointer-events: none;
}
