:root {
  --bg-gradient: linear-gradient(135deg, rgba(10, 25, 47, 0.85) 0%, rgba(15, 43, 70, 0.85) 50%, rgba(30, 58, 138, 0.88) 100%);
  --surface-glass: rgba(255, 255, 255, 0.94);
  --border-cyan: rgba(56, 189, 248, 0.35);
  --primary: #0284C7;
  --primary-glow: #38BDF8;
  --text-main: #0F172A;
  --text-muted: #475569;
  --good: #16A34A;
  --bad: #EF4444;

  --font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --shadow-card: 0 10px 30px -5px rgba(2, 132, 199, 0.2);
}

* { 
  box-sizing: border-box; 
}

/* Fondo global unificado desde Servidor Gimca */
body {
  margin: 0; 
  min-height: 100vh;
  background-color: #0a192f;
  background-image: var(--bg-gradient), url('https://gimcadigital.com/Sist.Productos.PVC/img/fondo-pwa.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text-main); 
  font-family: var(--font-display);
  display: flex; 
  flex-direction: column;
}

.main-container, .app-body, .view {
  background-color: transparent !important;
}

/* Header */
.topbar {
  position: sticky; 
  top: 0; 
  z-index: 20;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 12px 18px; 
  background: rgba(10, 25, 47, 0.98);
  border-bottom: 1px solid var(--border-cyan);
}
.brand { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}
.brand-logo { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
  border: 2px solid var(--primary-glow); 
  object-fit: cover;
}
.brand-text strong { 
  font-size: 15px; 
  color: #FFF; 
  display: block; 
}
.brand-text span { 
  font-size: 10px; 
  color: var(--primary-glow); 
  letter-spacing: .05em; 
}

.sync-btn {
  width: 38px; 
  height: 38px; 
  border-radius: 10px;
  border: 1px solid var(--border-cyan); 
  background: rgba(255,255,255,0.1);
  color: var(--primary-glow); 
  display: grid; 
  place-items: center; 
  cursor: pointer;
}
.sync-btn.spinning svg { 
  animation: spin 1s linear infinite; 
}
@keyframes spin { 
  to { transform: rotate(360deg); } 
}

.main-content { 
  flex: 1; 
  padding: 16px 14px 90px; 
}

/* Buscador & Compartir */
.search-wrap { 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
  margin-bottom: 14px; 
}
.price-selector-bar {
  background: rgba(10, 25, 47, 0.9); 
  padding: 8px 12px; 
  border-radius: 12px;
  border: 1px solid var(--border-cyan); 
  display: flex; 
  align-items: center; 
  gap: 8px;
}
.price-selector-bar label { 
  color: var(--primary-glow); 
  font-size: 11px; 
  font-weight: 700; 
}
.price-dropdown { 
  flex: 1; 
  padding: 8px; 
  border-radius: 8px; 
  font-weight: 700; 
  font-size: 13.5px; 
  border: 1px solid var(--border-cyan);
  background: #ffffff;
  color: #0f172a;
}

.input-container { 
  position: relative; 
}
.search-icon { 
  position: absolute; 
  left: 14px; 
  top: 50%; 
  transform: translateY(-50%); 
  color: var(--primary); 
}
#searchInput {
  width: 100%; 
  padding: 12px 14px 12px 42px; 
  border-radius: 12px;
  border: 2px solid var(--border-cyan); 
  font-size: 15px; 
  font-weight: 600;
  background: #ffffff;
  color: #0f172a;
}

.share-actions { 
  display: flex; 
  gap: 8px; 
}
.action-btn {
  flex: 1; 
  padding: 8px; 
  border-radius: 8px; 
  border: none; 
  font-weight: 700;
  font-size: 12px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 6px; 
  cursor: pointer;
}
.action-btn.pdf { 
  background: #E11D48; 
  color: #FFF; 
}
.action-btn.wa { 
  background: #16A34A; 
  color: #FFF; 
}

.result-count { 
  color: #BAE6FD; 
  font-size: 12px; 
  margin-bottom: 10px; 
  font-weight: 700; 
}

/* Tarjetas y Galería de Productos */
.results-list { 
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 15px;
}
.card {
  background: var(--surface-glass); 
  border-radius: 14px; 
  padding: 14px;
  border: 1px solid #FFF; 
  box-shadow: var(--shadow-card);
}
.card-top { 
  display: flex; 
  justify-content: space-between; 
  margin-bottom: 8px; 
}
.card-code { 
  font-family: var(--font-mono); 
  font-size: 12px; 
  font-weight: 700; 
  color: #0369A1; 
  background: #E0F2FE; 
  padding: 2px 8px; 
  border-radius: 6px; 
}
.card-stock { 
  font-size: 11px; 
  font-weight: 700; 
}

.card-desc { 
  font-size: 15px; 
  font-weight: 700; 
  margin-bottom: 4px; 
}
.card-meta { 
  font-size: 11.5px; 
  color: var(--text-muted); 
  margin-bottom: 12px; 
}
.card-price-single { 
  background: #0369A1; 
  color: #FFF; 
  padding: 10px 14px; 
  border-radius: 10px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}
.price-value-active { 
  font-family: var(--font-mono); 
  font-size: 16px; 
  font-weight: 800; 
}

/* Estilos Grid del Catálogo de Productos */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.catalog-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-cyan);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Cotizador */
.cotizador-card { 
  background: #FFF; 
  border-radius: 14px; 
  padding: 16px; 
  color: #0F172A; 
}
.quote-header { 
  border-bottom: 2px solid #0284C7; 
  padding-bottom: 10px; 
  margin-bottom: 12px; 
  display: flex; 
  justify-content: space-between; 
}
.seller-name { 
  margin: 0; 
  font-size: 16px; 
  font-weight: 800; 
  color: #0369A1; 
}
.seller-sub, .seller-contact { 
  margin: 2px 0; 
  font-size: 11px; 
  color: #475569; 
}
.quote-badge { 
  background: #0284C7; 
  color: #FFF; 
  padding: 6px 12px; 
  font-weight: 800; 
  border-radius: 6px; 
  font-size: 12px; 
  height: fit-content; 
}

.quote-meta-grid { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 8px; 
  margin-bottom: 14px; 
  background: #F8FAFC; 
  padding: 10px; 
  border-radius: 8px; 
}
.quote-meta-grid .field label { 
  display: block; 
  font-size: 10px; 
  font-weight: 700; 
  color: #64748B; 
}
.quote-meta-grid .field input, .quote-meta-grid .field select { 
  width: 100%; 
  padding: 6px; 
  font-size: 12px; 
  border: 1px solid #CBD5E1; 
  border-radius: 6px; 
}

.quote-add-box { 
  margin-bottom: 12px; 
}
.quote-add-box label { 
  font-size: 11px; 
  font-weight: 700; 
  display: block; 
  margin-bottom: 4px; 
}
.quote-add-box input { 
  width: 100%; 
  padding: 10px; 
  border: 2px solid #0284C7; 
  border-radius: 8px; 
  font-size: 13px; 
}

.table-responsive { 
  overflow-x: auto; 
  margin-bottom: 12px; 
}
.quote-table { 
  width: 100%; 
  border-collapse: collapse; 
  font-size: 11px; 
}
.quote-table th { 
  background: #0284C7; 
  color: #FFF; 
  padding: 6px; 
  text-align: left; 
}
.quote-table td { 
  padding: 6px; 
  border-bottom: 1px solid #E2E8F0; 
}
.quote-table input { 
  width: 45px; 
  padding: 4px; 
  font-weight: 700; 
}
.btn-del { 
  background: #EF4444; 
  color: #FFF; 
  border: none; 
  border-radius: 4px; 
  padding: 2px 6px; 
  cursor: pointer; 
}

.quote-total-box { 
  display: flex; 
  justify-content: space-between; 
  background: #0F172A; 
  color: #FFF; 
  padding: 12px; 
  border-radius: 8px; 
  font-weight: 800; 
  font-size: 16px; 
}

.cotizador-actions { 
  display: flex; 
  gap: 10px; 
  margin-top: 14px; 
}

/* Panel Márgenes & Configuración */
.panel-card { 
  background: rgba(10, 25, 47, 0.95); 
  border: 1px solid var(--border-cyan); 
  border-radius: 16px; 
  padding: 16px; 
  color: #FFF; 
}
.panel-tabs { 
  display: flex; 
  gap: 8px; 
  margin-bottom: 16px; 
  border-bottom: 1px solid var(--border-cyan); 
  padding-bottom: 8px; 
}
.panel-tab-btn { 
  background: none; 
  border: none; 
  color: #94A3B8; 
  font-weight: 700; 
  font-size: 12px; 
  padding: 6px 12px; 
  cursor: pointer; 
}
.panel-tab-btn.active { 
  color: var(--primary-glow); 
  border-bottom: 2px solid var(--primary-glow); 
}

.section-title { 
  font-size: 11px; 
  text-transform: uppercase; 
  margin: 14px 0 8px; 
  padding: 4px 8px; 
  border-radius: 4px; 
}
.section-title.tuberia { background: #0369A1; }
.section-title.accesorios { background: #15803D; }
.section-title.global { background: #B45309; }

.margin-grid { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 8px; 
}
.m-field label { 
  font-size: 10.5px; 
  color: #BAE6FD; 
  display: block; 
  margin-bottom: 2px; 
}
.m-field input { 
  width: 100%; 
  padding: 8px; 
  border-radius: 6px; 
  border: 1px solid var(--border-cyan); 
  background: #FFF; 
  color: #000; 
  font-weight: 700; 
}

.primary-btn, .secondary-btn { 
  width: 100%; 
  padding: 12px; 
  border-radius: 10px; 
  border: none; 
  font-weight: 800; 
  font-size: 14px; 
  margin-top: 12px; 
  cursor: pointer; 
}
.primary-btn { background: #0284C7; color: #FFF; }
.secondary-btn { background: rgba(255,255,255,0.1); color: #FFF; border: 1px solid var(--border-cyan); }

/* Tabbar Navegación */
.tabbar { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  display: flex; 
  background: rgba(10, 25, 47, 0.98); 
  border-top: 1px solid var(--border-cyan); 
  z-index: 20; 
}
.tab-btn { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 2px; 
  padding: 10px 0; 
  background: none; 
  border: none; 
  color: #94A3B8; 
  font-size: 11px; 
  font-weight: 700; 
}
.tab-btn.active { color: var(--primary-glow); }

/* =========================================================
   AJUSTES RESPONSIVOS PARA MÓVIL (SISTEMA PVC GIMCA)
   ========================================================= */

/* 1. Visibilidad de los textos en el Panel de Márgenes */
.panel-card label,
.ptab-content label,
.m-field label {
  color: #FFFFFF !important; /* Fuerza color blanco para que resalte sobre el fondo */
  font-weight: 700 !important;
  display: block !important;
  margin-bottom: 4px !important;
}

.m-field input {
  background-color: #FFFFFF !important;
  color: #0F172A !important;
  font-weight: 700 !important;
}

/* 2. Cuadrícula adaptable para Celulares (Buscador y Catálogo) */
.results-list,
.catalog-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  gap: 12px !important;
  width: 100% !important;
}

@media (max-width: 480px) {
  .results-list,
  .catalog-grid {
    grid-template-columns: 1fr !important; /* 1 sola columna ordenada en el celular */
  }
}

/* 3. Tabla del Cotizador adaptable en Celular */
.table-responsive {
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px !important;
}

.quote-table {
  min-width: 520px !important; /* Mantiene la tabla legible permitiendo deslizamiento */
  width: 100% !important;
}
/* Corrección para que la cotización ocupe todo el ancho en PDF / Impresión */
#cotizadorPrintArea {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Ocultar botones de eliminar al exportar/imprimir */
@media print {
  .btn-del, .no-print {
    display: none !important;
  }
}