/* ═══════════════════════════════════════════════════════════════════════
   Desarrollos — unidades, cotizador, avance de obra (desarrollos.html)
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --color-primary:       #0e7c66;
  --color-primary-dark:  #095843;
  --color-primary-light: #e4f5f0;
  --color-accent:        #b3630c;
  --color-text:          #1a1a1a;
  --color-text-muted:    #666;
  --color-bg:            #ffffff;
  --color-bg-alt:        #f4f7f6;
  --color-border:        #e5e7eb;
  --color-success:       #10b981;
  --color-warning:       #f59e0b;
  --color-danger:        #ef4444;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg-alt);
  color: var(--color-text);
  line-height: 1.55;
  min-height: 100vh;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

.solo-print { display: none; }

/* Header de módulo */
.modulo-header {
  background: linear-gradient(135deg, #0b2822, var(--color-primary-dark) 60%, var(--color-primary));
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.btn-volver-modulo {
  padding: 8px 14px;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 9px;
  font-size: .85rem;
  font-weight: 600;
  transition: all .15s ease;
}
.btn-volver-modulo:hover { background: rgba(255,255,255,.14); }
.modulo-titulo { flex: 1; }
.modulo-titulo h1 { font-size: 1.3rem; font-weight: 800; }
.modulo-titulo p { font-size: .8rem; opacity: .75; }
.modulo-tabs { display: flex; gap: 6px; }
.mtab {
  padding: 9px 18px;
  border-radius: 9px;
  font-size: .87rem;
  font-weight: 700;
  color: rgba(255,255,255,.8);
  transition: all .15s ease;
}
.mtab:hover { background: rgba(255,255,255,.12); }
.mtab.activo { background: #fff; color: var(--color-primary-dark); }

.modulo-main { max-width: 1250px; margin: 0 auto; padding: 26px 28px 60px; }
.mvista { display: none; }
.mvista.activo { display: block; animation: aparecer .25s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─── Selector de desarrollos ──────────────────────────────────────────── */
.selector-desarrollos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.des-selector-card {
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all .2s ease;
}
.des-selector-card:hover { border-color: var(--color-primary); }
.des-selector-card.activo { border-color: var(--color-primary); background: var(--color-primary-light); }
.des-sel-nombre { font-weight: 800; font-size: 1rem; }
.des-sel-meta { font-size: .78rem; color: var(--color-text-muted); margin: 2px 0 8px; }
.des-sel-avance { display: flex; align-items: center; gap: 10px; font-size: .76rem; font-weight: 700; }
.des-sel-barra { flex: 1; height: 6px; background: var(--color-border); border-radius: 50px; overflow: hidden; }
.des-sel-fill { height: 100%; background: var(--color-primary); border-radius: 50px; }

/* ─── Unidades ─────────────────────────────────────────────────────────── */
.unidades-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.ukpi {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
}
.ukpi strong { display: block; font-size: 1.5rem; font-weight: 800; color: var(--color-primary); }
.ukpi span { font-size: .74rem; color: var(--color-text-muted); font-weight: 600; }

.unidades-leyenda {
  display: flex;
  gap: 18px;
  font-size: .78rem;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}
.unidades-leyenda > span { display: inline-flex; align-items: center; gap: 6px; }
.cubo { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.cubo.disponible { background: #a7e8d4; border: 1.5px solid #0e7c66; }
.cubo.apartada   { background: #fde5b4; border: 1.5px solid #b3630c; }
.cubo.vendida    { background: #fecaca; border: 1.5px solid #b91c1c; }

.torre-bloque {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.torre-nombre { font-weight: 800; font-size: .95rem; margin-bottom: 12px; }
.nivel-fila { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nivel-num {
  width: 42px;
  font-size: .7rem;
  font-weight: 800;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.unidad-celda {
  min-width: 74px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  border: 1.5px solid transparent;
  line-height: 1.3;
}
.unidad-celda small { display: block; font-weight: 600; opacity: .8; }
.unidad-celda:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.unidad-celda.disponible { background: #d7f5ea; color: #065f46; border-color: #7fd8c4; }
.unidad-celda.apartada   { background: #fdeedc; color: #92400e; border-color: #f4c27a; }
.unidad-celda.vendida    { background: #fee2e2; color: #991b1b; border-color: #fda4a4; }

.etapa-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ─── Panel de unidad ──────────────────────────────────────────────────── */
.perfil-fondo {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 899;
  opacity: 0;
  visibility: hidden;
  transition: all .25s ease;
}
.perfil-fondo.abierto { opacity: 1; visibility: visible; }
.panel-unidad {
  position: fixed;
  top: 0; right: -440px;
  width: min(420px, 95vw);
  height: 100vh;
  background: var(--color-bg);
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  z-index: 900;
  transition: right .3s ease;
  display: flex;
  flex-direction: column;
}
.panel-unidad.abierto { right: 0; }
.panel-unidad-head {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  color: #fff;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pu-id { font-size: 1.1rem; font-weight: 800; font-family: 'Consolas', monospace; }
.pu-modelo { font-size: .8rem; opacity: .8; }
.btn-x {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.btn-x:hover { background: rgba(255,255,255,.35); }
.panel-unidad-cuerpo { flex: 1; overflow-y: auto; padding: 22px 24px; }
.dato-fila {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .87rem;
}
.dato-fila dt { color: var(--color-text-muted); font-weight: 600; }
.dato-fila dd { font-weight: 700; text-align: right; }
.pu-acciones { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* ─── Cotizador ────────────────────────────────────────────────────────── */
.cotizador-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  align-items: start;
}
.cot-form { display: flex; flex-direction: column; gap: 14px; }
.bloque {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.bloque h3 { font-size: .92rem; font-weight: 800; margin-bottom: 12px; }
.campo-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 9px;
  font-size: .88rem;
  background: var(--color-bg);
  font-family: inherit;
}
.campo-control:focus { outline: none; border-color: var(--color-primary); }
.campo-hint {
  font-size: .76rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-top: 8px;
  background: var(--color-primary-light);
  border-radius: 8px;
  padding: 8px 10px;
}
.campo-label-sm { font-size: .76rem; font-weight: 700; display: block; margin: 10px 0 5px; }
.esquema-fila { display: flex; gap: 8px; margin-bottom: 8px; }
.esquema-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1.5px solid var(--color-border);
  border-radius: 9px;
  font-size: .78rem;
  font-weight: 700;
  transition: all .15s ease;
}
.esquema-btn:hover { border-color: var(--color-primary); }
.esquema-btn.activo { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.btn-prim {
  padding: 12px 20px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 800;
  transition: all .15s ease;
  text-align: center;
}
.btn-prim:hover { background: var(--color-primary-dark); }
.btn-grande { padding: 15px; font-size: 1rem; }
.btn-sec {
  padding: 11px 18px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: .87rem;
  font-weight: 700;
  background: var(--color-bg);
  transition: all .15s ease;
}
.btn-sec:hover { border-color: var(--color-primary); color: var(--color-primary); }

.cot-resultado {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 420px;
}
.resultado-vacio {
  height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-text-muted);
  text-align: center;
}
.resultado-vacio .icono { font-size: 3rem; }

.cot-res-head { margin-bottom: 18px; }
.cot-res-head h3 { font-size: 1.2rem; font-weight: 800; }
.cot-res-head p { font-size: .84rem; color: var(--color-text-muted); }
.cot-tabla { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.cot-tabla td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--color-border);
  font-size: .9rem;
}
.cot-tabla td:last-child { text-align: right; font-weight: 700; }
.cot-tabla tr.destacado td {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-primary);
  border-bottom: none;
  padding-top: 14px;
}
.cot-nota {
  font-size: .74rem;
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.cot-acciones { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── Avance de obra ───────────────────────────────────────────────────── */
.avance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.avance-global-wrap { flex: 1; min-width: 260px; }
.avance-global-label { font-size: .9rem; font-weight: 700; margin-bottom: 8px; }
.avance-global-label strong { color: var(--color-primary); font-size: 1.15rem; }
.avance-barra-grande {
  height: 14px;
  background: var(--color-border);
  border-radius: 50px;
  overflow: hidden;
}
.avance-fill-grande {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #21c063);
  border-radius: 50px;
  transition: width .6s ease;
}
.avance-entrega { font-size: .78rem; color: var(--color-text-muted); margin-top: 8px; }
.avance-acciones { display: flex; gap: 10px; }

.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 9px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--color-border);
  border-radius: 3px;
}
.hito {
  position: relative;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.hito::before {
  content: "";
  position: absolute;
  left: -26px; top: 22px;
  width: 15px; height: 15px;
  background: var(--color-primary);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--color-primary);
}
.hito-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.hito-titulo { font-weight: 800; font-size: .98rem; }
.hito-fecha { font-size: .74rem; color: var(--color-text-muted); font-weight: 700; }
.hito-pct {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: .74rem;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 50px;
}
.hito-desc { font-size: .87rem; color: var(--color-text-muted); margin-bottom: 12px; }
.hito-foto { border-radius: 10px; max-height: 240px; width: 100%; object-fit: cover; }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-fondo {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-fondo.abierto { display: flex; }
.modal-panel {
  background: var(--color-bg);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalSube .28s ease;
}
@keyframes modalSube { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-top {
  padding: 18px 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-top h3 { font-size: 1.05rem; font-weight: 800; }
.modal-cuerpo { padding: 24px; max-height: 70vh; overflow-y: auto; }
.mc-form { display: flex; flex-direction: column; gap: 12px; }
.mc-form label { font-size: .78rem; font-weight: 700; }

/* Toasts */
.toast-contenedor {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #1a2b27;
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: .87rem;
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  animation: toastEntra .3s ease;
  max-width: 380px;
}
.toast.exito { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }
.toast.info  { border-left: 4px solid #3b82f6; }
@keyframes toastEntra { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.saliendo { animation: toastSale .3s ease forwards; }
@keyframes toastSale { to { transform: translateX(60px); opacity: 0; } }

/* ─── Impresión de cotización ──────────────────────────────────────────── */
@media print {
  @page { margin: 1.4cm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .solo-print { display: block !important; }
  .modulo-main { padding: 0; max-width: none; }
  .mvista { display: none !important; }
  #vista-cotizador { display: block !important; }
  .cotizador-grid { display: none !important; }

  .print-membrete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0e7c66;
    padding-bottom: 14px;
    margin-bottom: 24px;
  }
  .print-membrete h2 { font-size: 1.35rem; color: #0e7c66; }
  .print-membrete p { font-size: .78rem; color: #555; }
  .print-titulo { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
  .print-sub { font-size: .82rem; color: #555; margin-bottom: 18px; }
  .print-tabla { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
  .print-tabla td { padding: 9px 6px; border-bottom: 1px solid #ddd; font-size: .88rem; }
  .print-tabla td:last-child { text-align: right; font-weight: 700; }
  .print-tabla tr.destacado td { font-weight: 800; color: #0e7c66; font-size: 1rem; }
  .print-legal { font-size: .68rem; color: #777; line-height: 1.5; margin-top: 26px; border-top: 1px solid #ddd; padding-top: 12px; }
}

@media (max-width: 1023px) {
  .cotizador-grid { grid-template-columns: 1fr; }
  .unidades-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .modulo-main { padding: 18px 14px 50px; }
}
