/* ============================================================
   SISTEMA DE COTIZACIÓN - CAMPOSANTO MUYA
   Estilos principales
   ============================================================ */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brown-dark:   #1e6b09;
  --brown-mid:    #134d05;
  --brown-light:  #3aaa10;
  --green-dduu:   #3aaa10;
  --green-light:  #eafce5;
  --gold-ssff:    #b7950b;
  --blue-inhum:   #1565c0;
  --gold-light:   #fffde7;
  --orange-res:   #e2520a;
  --orange-light: #fff3e0;
  --gray-bg:      #f0f5ee;
  --gray-border:  #d0dcc8;
  --white:        #ffffff;
  --text-dark:    #1a1a1a;
  --text-muted:   #888;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 20px rgba(0,0,0,0.12);
  --radius:       10px;
  --radius-sm:    6px;
}

html { font-size: var(--size-sistema, 14px); scroll-behavior: smooth; }

body {
  font-family: var(--font-sistema, 'Segoe UI', Arial, sans-serif);
  font-weight: var(--weight-sistema, 400);
  background: #e8f0e4;
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.main-header {
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 4px 12px rgba(30,107,9,0.08);
  position: sticky; top: 0; z-index: 100;
  border-bottom: none;
}
.main-header::after {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, #3aaa10 20%, #1e6b09 50%, #3aaa10 80%, transparent 100%);
  opacity: 0.75;
  pointer-events: none;
}
.header-inner {
  max-width: 100%;
  padding: 0 20px;
  display: flex; justify-content: space-between; align-items: center;
  min-height: 58px;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo {
  width: 36px; height: 36px;
  background: var(--orange-res);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; color: white;
  flex-shrink: 0;
  order: 0;
}
.brand-text { display: flex !important; flex-direction: column; gap: 1px; order: 1; }
.brand-text h1 { color: #1a4d05; font-size: 14px; font-weight: 700; line-height: 1.25; }
.brand-text span { color: rgba(26,77,5,0.65); font-size: 10.5px; line-height: 1.2; letter-spacing: 0.2px; }

.header-nav {
  display: flex; gap: 2px; align-items: center;
  flex: 1; justify-content: flex-end;
  overflow-x: auto; scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 6px;
  color: #2d6a14; font-size: 12.5px;
  text-decoration: none; transition: background 0.15s, color 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-btn:hover {
  background: rgba(58,170,16,0.1);
  color: #1a4d05;
}
.nav-btn.active {
  background: rgba(58,170,16,0.12);
  color: #1a4d05;
  font-weight: 700;
  border-color: rgba(58,170,16,0.3);
}
.nav-btn.active:hover {
  background: rgba(58,170,16,0.18);
}
.nav-separator {
  width: 1px; height: 22px;
  background: rgba(58,170,16,0.25);
  margin: 0 5px;
  flex-shrink: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page-container {
  max-width: 1300px; margin: 0 auto;
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header-section {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  background: var(--gray-bg);
  border-bottom: 2px solid var(--gray-border);
}
.card-header-section i { font-size: 18px; color: var(--brown-mid); }
.card-header-section h2 { font-size: 15px; font-weight: 700; color: var(--brown-dark); }
.badge-section {
  margin-left: auto;
  background: var(--brown-dark); color: white;
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
}
.badge-count {
  margin-left: auto;
  background: var(--orange-res); color: white;
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
}

/* Colores de sección */
.dduu-header { background: #eafce5; border-bottom-color: var(--green-dduu); }
.dduu-header i, .dduu-header h2 { color: var(--green-dduu); }
.ssff-header { background: #fffde7; border-bottom-color: var(--gold-ssff); }
.ssff-header i, .ssff-header h2 { color: var(--gold-ssff); }
.resultado-header { background: var(--orange-light); border-bottom-color: var(--orange-res); }
.resultado-header i, .resultado-header h2 { color: var(--orange-res); }

.card-body { padding: 20px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  display: flex; flex-direction: column; gap: 5px;
}
.form-group label {
  font-size: 12px; font-weight: 600; color: var(--brown-mid);
  display: flex; align-items: center; gap: 5px;
}
.form-group label i { color: var(--text-muted); font-size: 11px; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dark);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--orange-res);
  box-shadow: 0 0 0 3px rgba(226,82,10,0.12);
}
.form-group input:disabled, .form-group select:disabled {
  background: #f5f5f5; color: #aaa; cursor: not-allowed;
}
.readonly-field { background: #f8f8f8 !important; color: #555 !important; }

.form-hint { font-size: 11px; color: var(--text-muted); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }

/* Input con símbolo de moneda */
.input-currency {
  display: flex; align-items: center;
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}
.input-currency:focus-within { border-color: var(--orange-res); }
.currency-symbol {
  background: #eaf2e5; color: var(--brown-mid);
  padding: 9px 10px; font-size: 12px; font-weight: 700;
  border-right: 1px solid var(--gray-border); white-space: nowrap;
}
.input-currency input {
  border: none !important; border-radius: 0 !important;
  box-shadow: none !important; flex: 1;
}

/* Input porcentaje */
.input-pct {
  display: flex; align-items: center;
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: white;
  transition: border-color 0.2s;
}
.input-pct:focus-within { border-color: var(--orange-res); }
.input-pct input {
  border: none !important; border-radius: 0 !important;
  box-shadow: none !important; flex: 1;
  width: 80px;
  text-align: center;
}
.input-pct span {
  background: #eaf2e5; color: var(--brown-mid);
  padding: 9px 8px; font-size: 12px; font-weight: 700;
  border-left: 1px solid var(--gray-border);
}
.input-pct-big { display: flex; align-items: center; gap: 0; }
.input-pct-big input { flex: 1; }
.input-pct-big span {
  background: #eaf2e5; color: var(--brown-mid);
  padding: 9px 10px; border: 1.5px solid var(--gray-border);
  border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: 700;
}
.input-pct-big input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ============================================================
   TABLAS DE CÁLCULO (DDUU / SSFF)
   ============================================================ */
.calc-table {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.calc-row {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid #eaf2e5;
  font-size: 13px;
}
.calc-row:last-child { border-bottom: none; }
.calc-header {
  background: var(--brown-dark); color: white;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 14px;
}
.calc-row:nth-child(even):not(.calc-header) { background: #fafafa; }
.calc-value { text-align: right; font-weight: 600; }
.calc-input-row { background: #fff9f5 !important; }
.calc-total-row {
  background: #f5ede7 !important;
  font-weight: 700;
  border-top: 2px solid #ddd !important;
}
.calc-total { color: var(--orange-res); }
.text-discount { color: #c0392b; }
.text-info { color: #1a73e8; }
.text-warning { color: #b7950b; }

.dduu-dot { color: var(--green-dduu); font-size: 8px; margin-right: 4px; }
.ssff-dot  { color: var(--gold-ssff);  font-size: 8px; margin-right: 4px; }
.inhum-dot { color: var(--blue-inhum); font-size: 8px; margin-right: 4px; }

/* ============================================================
   RESULTADO
   ============================================================ */
.resultado-table {
  border: 1.5px solid #f0c8a0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.resultado-row {
  display: grid;
  grid-template-columns: 1fr 160px 180px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #fde8d4;
  font-size: 13px;
}
.resultado-row:last-child { border-bottom: none; }
.resultado-header-row {
  background: var(--orange-res); color: white;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 9px 16px;
}
.resultado-row:nth-child(even):not(.resultado-header-row) { background: #fff9f5; }
.resultado-input-row { background: #fff3e8 !important; }
.dsct-sf-row input:disabled { opacity: 0.4; cursor: not-allowed; }
.dsct-sf-rule { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; font-weight: 400; }
.resultado-financiar {
  background: #ffe5cc !important;
  border-top: 2px solid #f0c8a0 !important;
  border-bottom: 2px solid #f0c8a0 !important;
  color: #7a3b00 !important;
  font-weight: 700 !important;
}
.resultado-cuota { background: #fff0e0 !important; }
.resultado-cuota-val { color: var(--orange-res) !important; font-size: 16px !important; }
.resultado-grand-total {
  background: #fde5d4 !important;
  border-top: 2px solid #e0a070 !important;
}
.resultado-value { text-align: right; font-weight: 600; }

/* Cards de tipo de espacio (Personal, Doble, etc.) */
.tipo-cards-wrapper {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.tipo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 82px;
  height: 82px;
  border: 2px solid var(--gray-border);
  border-radius: 10px;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.18s;
  user-select: none;
}
.tipo-card:hover {
  border-color: var(--green-dduu);
  background: var(--green-light);
}
.tipo-card.selected {
  border-color: var(--green-dduu);
  background: var(--green-dduu);
  color: #fff;
  box-shadow: 0 2px 10px rgba(44,181,19,0.35);
}
.tipo-num {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: var(--brown-mid);
}
.tipo-lbl {
  font-size: 10px;
  font-weight: 700;
  margin-top: 5px;
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}
.tipo-card.selected .tipo-num,
.tipo-card.selected .tipo-lbl { color: #fff !important; }

/* Toggle NI / NF */
.ni-nf-toggle {
  display: flex; gap: 0;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--gray-border);
}
.ni-nf-toggle input[type="radio"] { display: none; }
.btn-modo {
  flex: 1; padding: 9px 12px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: #f5f5f5; color: #666;
  transition: all 0.2s; text-align: center;
}
.btn-modo:hover { background: #e9e9e9; }
.ni-nf-toggle input[type="radio"]:checked + .btn-modo.modo-ni {
  background: var(--green-dduu); color: #fff;
}
.ni-nf-toggle input[type="radio"]:checked + .btn-modo.modo-nf {
  background: var(--brown-mid); color: #fff !important;
}
.ni-nf-toggle input[type="radio"]:disabled + .btn-modo {
  opacity: 0.4; cursor: not-allowed;
}

/* Cantidad SSFF */
.ssff-cantidad-group {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap;
}
.ssff-cant-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.ssff-cant-btns { display: flex; gap: 6px; }
.ssff-cant-btn,
.inhum-cant-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 2px solid var(--gray-border); background: #fafafa;
  font-size: 14px; font-weight: 700; cursor: pointer;
  color: var(--brown-mid); transition: all 0.18s;
}
.ssff-cant-btn:hover,
.inhum-cant-btn:hover { border-color: var(--orange-res); background: #fff8f3; }
.ssff-cant-btn.selected,
.inhum-cant-btn.selected {
  border-color: var(--orange-res); background: var(--orange-res);
  color: #fff; box-shadow: 0 2px 8px rgba(230,126,34,0.35);
}

/* Toggle modo inicial */
.toggle-mode {
  display: inline-flex; gap: 4px; margin-left: 8px;
  background: #eee; border-radius: 14px; padding: 2px;
}
.btn-mode {
  padding: 3px 10px; border-radius: 12px; border: none;
  font-size: 11px; cursor: pointer; background: transparent;
  color: #666; transition: all 0.2s;
}
.btn-mode.active { background: var(--orange-res); color: white; font-weight: 700; }

/* Cuotas sugeridas */
.cuotas-sugeridas-wrapper { background: #fff9f5; border-radius: var(--radius-sm); padding: 14px; }
.cuotas-label { font-size: 12px; font-weight: 600; color: var(--brown-mid); margin-bottom: 10px; }
.cuotas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.cuota-card {
  border: 1.5px solid #f0c8a0;
  border-radius: var(--radius-sm);
  padding: 10px; text-align: center;
  background: white; cursor: pointer;
  transition: all 0.2s;
}
.cuota-card:hover, .cuota-card.selected {
  border-color: var(--orange-res);
  background: var(--orange-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.cuota-card .c-meses { font-size: 20px; font-weight: 800; color: var(--orange-res); }
.cuota-card .c-label { font-size: 10px; color: var(--text-muted); }
.cuota-card .c-cuota { font-size: 13px; font-weight: 700; color: var(--brown-dark); margin-top: 4px; }

/* ============================================================
   BOTONES DE ACCIÓN
   ============================================================ */
.acciones-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
}
.acciones-inner {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
}

.btn-action {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700;
  border: none; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
}
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-reset   { background: #eee; color: #555; }
.btn-reset:hover:not(:disabled) { background: #ddd; }
.btn-preview { background: #1a73e8; color: white; }
.btn-preview:hover:not(:disabled) { background: #1558b0; }
.btn-save    { background: var(--green-dduu); color: white; }
.btn-save:hover:not(:disabled) { background: #229e0f; }
.btn-pdf      { background: #c0392b; color: white; }
.btn-pdf:hover:not(:disabled) { background: #992d22; }
.pdf-dropdown-menu button:hover { background: #f5f5f5 !important; }
.btn-download { background: #e67e22; color: white; }
.btn-download:hover:not(:disabled) { background: #ca6f1e; }
.btn-wsp     { background: #25d366; color: white; }
.btn-wsp:hover:not(:disabled) { background: #128c7e; }
.btn-secondary { background: #888; color: white; }
.btn-secondary:hover { background: #666; }
.btn-filtrar { background: var(--orange-res); color: white; padding: 9px 18px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.btn-filtrar:hover { background: #c94008; }
.btn-limpiar { background: #888; color: white; padding: 9px 14px; border-radius: var(--radius-sm); text-decoration: none; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.btn-limpiar:hover { background: #666; }

/* ============================================================
   MODALES
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-box {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow-y: auto;
}
.modal-small  { width: 100%; max-width: 440px; }
.modal-large  { width: 100%; max-width: 860px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--gray-bg);
  border-bottom: 1px solid var(--gray-border);
  gap: 10px;
}
.modal-header h3 { font-size: 15px; color: var(--brown-dark); display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 4px; }
.modal-close:hover { color: #c0392b; }
.modal-header-success { background: #d1e7dd; }
.modal-body { padding: 20px; flex: 1; }
.modal-footer {
  padding: 14px 20px; background: #fafafa;
  border-top: 1px solid var(--gray-border);
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
}
.modal-footer-center { justify-content: center; }

/* WhatsApp modal */
.modal-header-wsp { background: #d1eed8; }
.wsp-tpl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 2px solid #ddd; border-radius: 20px;
  background: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
  color: #555; transition: all .15s;
}
.wsp-tpl-btn:hover { border-color: #25D366; color: #25D366; }
.wsp-tpl-btn.active { border-color: #25D366; background: #e8f8ec; color: #1a7a38; }
.wsp-phone-row { display: flex; gap: 8px; align-items: center; }
.wsp-phone-prefix {
  background: #f0f0f0; border: 1px solid #ddd; border-radius: 8px;
  padding: 9px 13px; font-weight: 700; color: #333; font-size: 14px; white-space: nowrap;
}
.wsp-phone-input {
  flex: 1; padding: 9px 13px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; outline: none;
}
.wsp-phone-input:focus { border-color: #25D366; box-shadow: 0 0 0 2px rgba(37,211,102,.15); }
.wsp-label { font-weight: 600; font-size: 13px; color: #444; display: block; margin-bottom: 6px; }
.wsp-textarea {
  width: 100%; padding: 10px 13px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 13px; font-family: inherit; resize: vertical; box-sizing: border-box;
  line-height: 1.5; outline: none;
}
.wsp-textarea:focus { border-color: #25D366; box-shadow: 0 0 0 2px rgba(37,211,102,.15); }
.wsp-chars { text-align: right; font-size: 11px; color: #999; margin-top: 4px; }
.wsp-edit-tpl-link {
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: #25a244; font-weight: 600; padding: 0; display: inline-flex; align-items: center; gap: 4px;
}
.wsp-edit-tpl-link:hover { text-decoration: underline; }
.wsp-var-chip {
  display: inline-block; background: #e8f8ec; color: #1a7a38; border: 1px solid #c8e6c9;
  border-radius: 4px; padding: 2px 7px; font-size: 11px; font-family: monospace;
  cursor: pointer; transition: background .1s;
}
.wsp-var-chip:hover { background: #c8e6c9; }

/* Success modal */
.text-center { text-align: center; }
.success-icon { font-size: 56px; color: var(--green-dduu); margin: 10px 0; }
.success-msg { font-size: 15px; margin: 8px 0; color: var(--text-dark); }
.success-sub { font-size: 13px; color: var(--text-muted); }

/* Preview content */
#preview_content table { width: 100%; border-collapse: collapse; font-size: 12px; }
#preview_content th { background: var(--brown-dark); color: white; padding: 8px; font-size: 11px; }
#preview_content td { padding: 7px 10px; border-bottom: 1px solid #eee; }
#preview_content .section-lbl { background: var(--gray-bg); font-weight: 700; color: var(--brown-mid); padding: 6px 10px; }
#preview_content .right { text-align: right; font-weight: 600; }
#preview_content .total-row td { background: #f5ede7; font-weight: 700; }
#preview_content .grand-total td { background: #fde5d4; font-weight: 700; font-size: 13px; }
#preview_content .cuota-row td { background: #fff3e0; color: var(--orange-res); font-weight: 700; font-size: 15px; }

/* Responsive styles for proforma preview on screen */
@media (max-width: 768px) {
  #proforma_imprimible {
    margin: 0 auto !important;
  }
  .modal-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .modal-footer .btn-action {
    width: 100% !important;
    justify-content: center !important;
  }
  /* Ocultar botón de imprimir en celulares reales */
  button[onclick="imprimirPreview()"] {
    display: none !important;
  }
}

/* Simulated Mobile View support in preview */
body.view-mobile #proforma_imprimible {
  margin: 0 auto !important;
}
body.view-mobile .modal-footer {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 8px !important;
}
body.view-mobile .modal-footer .btn-action {
  width: 100% !important;
  justify-content: center !important;
}
/* Ocultar botón de imprimir en simulación de celular */
body.view-mobile button[onclick="imprimirPreview()"] {
  display: none !important;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: white;
  opacity: 0; transform: translateY(16px);
  transition: all 0.3s; z-index: 2000;
  box-shadow: var(--shadow-md);
  background: var(--brown-dark);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--green-dduu); }
.toast-error   { background: #c0392b; }
.toast-info    { background: #1a73e8; }
.toast-warn    { background: var(--gold-ssff); }

/* ============================================================
   HISTORIAL TABLE
   ============================================================ */
.filtros-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.filtro-search {
  flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 8px;
  background: white; border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm); padding: 0 12px;
}
.filtro-search i { color: var(--text-muted); }
.filtro-search input {
  border: none; outline: none; padding: 9px 0; font-size: 13px;
  width: 100%; background: transparent;
}
.filtros-bar select {
  padding: 9px 12px; border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm); font-size: 13px; background: white;
}

.table-responsive { overflow-x: auto; }
.historial-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.historial-table thead th {
  background: var(--brown-dark); color: white;
  padding: 10px 12px; font-size: 11px;
  text-align: left; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
.historial-table tbody tr { border-bottom: 1px solid #eaf2e5; transition: background 0.15s; }
.historial-table tbody tr:hover { background: #faf7f4; }
.historial-table td { padding: 15px 12px; vertical-align: middle; }
.empty-row { text-align: center; padding: 40px !important; color: var(--text-muted); font-size: 16px; }

/* Column sizes for better breathing room and preventing wrap-compression */
.col-numero { min-width: 140px; white-space: nowrap; }
.col-fecha { min-width: 95px; white-space: nowrap; }
.col-cliente { min-width: 220px; }
.col-producto { min-width: 160px; }
.col-total { min-width: 100px; white-space: nowrap; }
.col-cuota { min-width: 110px; white-space: nowrap; }
.col-asesor { min-width: 130px; }
.col-estado { min-width: 110px; }
.col-acciones { min-width: 140px; }

/* For clientes.php columns */
.col-idx { width: 40px; text-align: center; }
.col-dni { min-width: 100px; white-space: nowrap; }
.col-telefono { min-width: 120px; white-space: nowrap; }
.col-correo { min-width: 160px; }
.col-direccion { min-width: 180px; }
.col-total-cot { min-width: 110px; text-align: center; }
.col-fecha-visita { min-width: 110px; white-space: nowrap; }

/* Custom scrollbar for table-responsive */
.table-responsive {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--brown-light) #eaf2e5;
}
.table-responsive::-webkit-scrollbar {
  height: 10px;
  width: 8px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #eaf2e5;
  border-radius: 6px;
  margin: 0 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: var(--brown-light);
  border-radius: 6px;
  border: 2px solid #eaf2e5;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--brown-dark);
}

.cot-num { color: var(--orange-res); font-size: 13px; white-space: nowrap; display: inline-block; }
.cliente-cell {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cliente-cell strong {
  display: block;
  line-height: 1.4;
  color: #2c3e50;
  font-weight: 600;
}
.cliente-cell small {
  color: var(--text-muted);
  font-size: 11px;
}
.cliente-dir-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.prod-cell { display: flex; flex-direction: column; gap: 2px; }
.zona-tag { display: inline-block; background: var(--green-light); color: var(--green-dduu); padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.prod-cell small { color: var(--text-muted); font-size: 11px; }
.monto-cell { white-space: nowrap; }
.cuota-cell { white-space: nowrap; }
.cuota-cell small { display: block; color: var(--text-muted); font-size: 11px; }

/* Badges de estado */
.badge-estado {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; white-space: nowrap;
}
.badge-PENDIENTE { background: #fff3cd; color: #856404; }
.badge-ACEPTADA  { background: #d1e7dd; color: #0f5132; }
.badge-RECHAZADA { background: #f8d7da; color: #842029; }
.badge-VENCIDA   { background: #e2e3e5; color: #41464b; }

/* Action buttons in table */
.action-btns { display: flex; gap: 5px; }
.btn-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; text-decoration: none;
  transition: all 0.2s;
}
.btn-pdf     { background: #f8d7da; color: #842029; }
.btn-pdf:hover { background: #c0392b; color: white; }
.btn-wsp-sm  { background: #d4edda; color: #0f5132; }
.btn-wsp-sm:hover { background: #25d366; color: white; }
.btn-estado  { background: #fff3cd; color: #856404; }
.btn-estado:hover { background: #f0c800; color: #333; }
.btn-eliminar-red { background: #fde8e8; color: #c0392b; }
.btn-eliminar-red:hover { background: #c0392b; color: white; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.page-link {
  padding: 6px 13px; border-radius: var(--radius-sm);
  background: white; border: 1.5px solid var(--gray-border);
  color: var(--brown-mid); font-size: 13px; text-decoration: none;
  transition: all 0.2s;
}
.page-link:hover { border-color: var(--orange-res); color: var(--orange-res); }
.page-link.active { background: var(--orange-res); border-color: var(--orange-res); color: white; font-weight: 700; }

.form-select-big { width: 100%; padding: 10px 14px; font-size: 14px; border: 1.5px solid var(--gray-border); border-radius: var(--radius-sm); }

/* ============================================================
   CLIENTE CARD
   ============================================================ */
.card-cliente .card-header-section i { color: var(--orange-res); }
.card-cliente .card-header-section h2 { color: var(--brown-dark); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .calc-row { grid-template-columns: 1fr auto; }
  .calc-row > span:nth-child(2) { display: none; }
  .calc-input-row { grid-template-columns: 1fr auto; }
  .calc-input-row > span:nth-child(2) { display: block; }
  .calc-input-row > span:nth-child(3) { display: none; }
  .resultado-row { grid-template-columns: 1fr auto; }
  .resultado-row > span:nth-child(2) { display: none; }
  .resultado-input-row { grid-template-columns: 1fr auto; }
  .resultado-input-row > span:nth-child(2) { display: block; }
  .resultado-input-row > span:nth-child(3) { display: none; }
  .header-inner { flex-direction: column; padding: 12px; gap: 10px; }
  .header-nav { flex-wrap: wrap; justify-content: center; }
  .acciones-inner { justify-content: center; }
  .historial-table { font-size: 12px; }
  .historial-table th, .historial-table td { padding: 12px 10px; }
}
@media (max-width: 480px) {
  .form-grid-4 { grid-template-columns: 1fr; }
  .page-container { padding: 12px; }
  .card-body { padding: 14px; }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CARD CLIENTE
   ============================================================ */
.card-cliente  { border-top: 3px solid var(--orange-res); }
.card-dduu     { border-top: 3px solid var(--green-dduu); }
.card-ssff     { border-top: 3px solid var(--gold-ssff); }
.card-resultado{ border-top: 3px solid var(--orange-res); }
.card-plazos   { border-top: 3px solid var(--blue-inhum); }

.plazos-header { color: var(--blue-inhum) !important; }
.plazos-header i { color: var(--blue-inhum) !important; }

.plazos-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 768px) {
  .plazos-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .plazo-card {
    padding: 12px 8px !important;
  }
  .plazo-num {
    font-size: 28px !important;
  }
}

.plazo-card {
  border: 2px solid #b0c4de;
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}
.plazo-card:hover {
  border-color: var(--blue-inhum);
  background: #e3f0ff;
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}
.plazo-card.selected {
  border-color: var(--blue-inhum);
  background: var(--blue-inhum);
  color: #fff;
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.plazo-num {
  font-size: 36px;
  font-weight: 800;
  color: var(--blue-inhum);
  line-height: 1;
}
.plazo-card.selected .plazo-num { color: #fff; }
.plazo-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.plazo-card.selected .plazo-lbl { color: rgba(255,255,255,0.8); }
.plazo-cuota {
  font-size: 13px;
  font-weight: 700;
  color: var(--brown-dark);
  background: #f0f4ff;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
}
.plazo-card.selected .plazo-cuota {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* Corrección de color para iconos dentro de botones */
.btn-green i,
.btn-gray i,
.btn-red i,
.btn-blue i,
.btn-save i,
.btn-pdf i,
.btn-wsp i,
.btn-download i,
.btn-filtrar i,
.btn-limpiar i,
.btn-preview i,
.btn-save-premium i,
.btn-secondary-premium i,
.v-sidebar-action-btn i,
.btn-gps-premium i {
  color: #ffffff !important;
}
button i,
.btn-edit i {
  color: inherit !important;
}

/* Información de usuario en cabecera */
.user-header-info,
.user-header-info span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 12.5px;
  color: #1a4d05 !important;
  transition: color 0.2s ease;
}
.user-header-info {
  order: 2;
  border-left: 1px solid rgba(30,107,9,0.25);
  padding-left: 12px;
  margin-left: 4px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-header-info i {
  font-size: 14px;
  opacity: 0.85;
  color: #1a4d05 !important;
}

/* Espacio en la cabecera para el adaptador de vistas (simulador) en escritorio */
@media (min-width: 1025px) {
  .header-inner {
    padding-left: 80px !important;
  }
}

/* Botón de captura rápida express — ligeramente destacado del resto */
.nav-btn[title="Captura Rápida"],
#top-nav-express {
  font-size: 13px !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
  color: rgba(255,255,255,0.92) !important;
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.12) !important;
}
.nav-btn[title="Captura Rápida"]:hover,
#top-nav-express:hover {
  background: rgba(255,255,255,0.14) !important;
}
.nav-btn[title="Captura Rápida"].active,
#top-nav-express.active {
  background: rgba(44, 181, 19, 0.28) !important;
  border-color: rgba(44, 181, 19, 0.4) !important;
  color: white !important;
}



