* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #050b18;
  --bg-window: #071126;
  --panel-bg: rgba(8, 18, 40, 0.92);
  --panel-border: rgba(255, 255, 255, 0.06);
  --input-bg: #020814;
  --input-border: rgba(255, 255, 255, 0.05);
  --text-main: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.68);
  --text-faint: rgba(255, 255, 255, 0.5);
  --accent: #5583f3;
  --accent-hover: #6a93f5;
  --shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  --whatsapp: #1faa59;
  --whatsapp-hover: #16924a;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top center, rgba(29, 67, 163, 0.22), transparent 35%),
    linear-gradient(180deg, #030815 0%, #050b18 100%);
  color: var(--text-main);
  padding: 24px;
}

.window {
  width: 100%;
  max-width: 1620px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  background: linear-gradient(90deg, #071126 0%, #020a18 100%);
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.logo-img {
  width: 160px;
  height: auto;
  object-fit: contain;
  display: block;
}

.top-actions {
  display: flex;
  gap: 12px;
}

.ghost {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 15px;
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 1fr 1.16fr;
  gap: 28px;
  align-items: stretch;
}

.panel {
  background: rgba(6, 15, 34, 0.58);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 30px 28px;
  min-height: auto;
}

.form-panel {
  max-width: 100%;
}

.preview {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 36px;
  padding-bottom: 140px;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
h1 {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 28px;
  line-height: 1.1;
}

.section-title {
  margin: 18px 0 14px;
  color: var(--text-soft);
  font-size: 15px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 15px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: white;
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 16px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(85, 131, 243, 0.5);
  box-shadow: 0 0 0 3px rgba(85, 131, 243, 0.12);
}

textarea {
  min-height: 102px;
  resize: vertical;
}

.servicio-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 14px;
}

#agregar_servicio,
#descargar,
#enviar_whatsapp,
#enviar_presupuesto {
  color: white;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 700;
}
#agregar_servicio,
#descargar,
#enviar_presupuesto {
  background: var(--accent);
}
#agregar_servicio:hover,
#descargar:hover,
#enviar_presupuesto:hover {
  background: var(--accent-hover);
}
#agregar_servicio {
  padding: 0 20px;
  min-width: 108px;
}

.acciones-finales {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}
.acciones-finales button {
  padding: 14px 18px;
  font-size: 16px;
  border-radius: 12px;
  transition: transform 0.15s ease;
}

.acciones-finales button:active {
  transform: scale(0.97);
}

#descargar,
#enviar_whatsapp,
#enviar_presupuesto {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  margin-top: 0;
}
#enviar_whatsapp {
  background: var(--whatsapp);
}

#enviar_whatsapp:hover {
  background: var(--whatsapp-hover);
}

#lista_servicios {
  margin: 6px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.servicio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 12px 14px;
}

.servicio-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.servicio-item-nombre {
  color: white;
  font-size: 15px;
}

.servicio-item-precio {
  color: var(--text-soft);
  font-size: 14px;
}

.btn-eliminar {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
}

.form-panel h1::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin-top: 18px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.06) 65%,
    rgba(255, 255, 255, 0) 100%
  );
}

.form-panel .section-title:first-of-type {
  position: relative;
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.form-panel .section-title:first-of-type::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.05) 65%,
    rgba(255, 255, 255, 0) 100%
  );
}

.acciones-finales::before {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin-bottom: 12px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.10) 0%,
    rgba(255, 255, 255, 0.04) 65%,
    rgba(255, 255, 255, 0) 100%
  );
}

.historial-presupuestos {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.historial-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.historial-header .section-title {
  margin: 0 0 4px;
}

.historial-ayuda {
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.4;
}

.historial-toggle {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}

.historial-toggle:hover {
  border-color: rgba(85, 131, 243, 0.5);
  background: rgba(85, 131, 243, 0.08);
}

#lista_presupuestos {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.historial-item {
  list-style: none;
}

.historial-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 14px 15px;
  color: white;
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.historial-card:hover {
  border-color: rgba(85, 131, 243, 0.42);
  background: rgba(85, 131, 243, 0.08);
  transform: translateY(-1px);
}

.historial-card.is-active {
  border-color: rgba(85, 131, 243, 0.72);
  background: rgba(85, 131, 243, 0.12);
  box-shadow: 0 0 0 1px rgba(85, 131, 243, 0.2);
}

.historial-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 6px;
}

.historial-numero {
  font-size: 14px;
  font-weight: 800;
  color: white;
}

.historial-total {
  font-size: 14px;
  font-weight: 800;
  color: #cfe0ff;
}

.historial-cliente {
  font-size: 14px;
  color: white;
  margin-bottom: 4px;
  word-break: break-word;
}

.historial-meta {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.4;
  word-break: break-word;
}

.presupuesto {
  width: 100%;
  max-width: 760px;
  background: #020710;
  border-radius: 24px;
  padding: 28px 30px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
  align-self: flex-start;
}
.preview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: flex-start;
}

.preview-brand-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.mini-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  min-width: 0;
}

.mini-logo-img {
  width: 140px;
  height: auto;
  flex-shrink: 0;
}

.preview-emisor {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.emisor-nombre {
  font-size: 15px;
  font-weight: 700;
  color: white;
  line-height: 1.35;
  word-break: break-word;
}

.emisor-meta {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  line-height: 1.45;
  word-break: break-word;
}

.sep {
  color: rgba(255,255,255,0.35);
}

.preview-doc {
  text-align: right;
  min-width: 190px;
  flex-shrink: 0;
}

.doc-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.doc-meta {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
}

.linea-separador {
  width: 100%;
  height: 1px;
  background: rgba(85, 131, 243, 0.55);
  margin: 18px 0 18px;
}

.cliente-linea {
  font-size: 18px;
  margin-bottom: 16px;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255,255,255,0.05);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 12px;
}

#preview_servicios {
  min-height: 92px;
}

.empty-state {
  color: var(--text-soft);
  font-style: italic;
  font-size: 16px;
}

.preview-servicio-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 16px;
}

.preview-servicio-item:last-child {
  border-bottom: none;
}

.total-bar {
  margin-top: 16px;
  background: var(--accent);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 800;
}

.bloque-notas {
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.bloque-notas strong {
  color: white;
}

@media (max-width: 1200px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .preview {
    justify-content: stretch;
  }

  .presupuesto {
    max-width: 100%;
  }
}

@media (max-width: 780px) {
  body {
    padding: 0;
  }

  .window {
    min-height: 100vh;
    padding: 16px 14px;
    border-radius: 0;
  }

  .topbar {
    margin-bottom: 18px;
    gap: 12px;
    align-items: center;
  }

  .logo {
    gap: 10px;
    font-size: 16px;
  }

  .logo-img {
    width: 110px;
    height: auto;
  }

  .top-actions {
    gap: 8px;
  }

  .ghost {
    padding: 9px 12px;
    font-size: 13px;
    border-radius: 10px;
  }

  .app {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  .panel {
    width: 100%;
    min-height: auto;
    padding: 20px 16px;
    border-radius: 20px;
  }

  h1 {
    font-size: 26px;
    margin-bottom: 20px;
    line-height: 1.05;
  }

  .form-panel h1::after {
    margin-top: 14px;
  }

  .section-title {
    margin: 16px 0 12px;
    font-size: 14px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
  }

  label {
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 7px;
  }

  input,
  select,
  textarea {
    padding: 14px 14px;
    font-size: 16px;
    border-radius: 14px;
  }

  textarea {
    min-height: 100px;
  }

  .servicio-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #agregar_servicio {
    min-height: 52px;
    padding: 0 16px;
  }

  .acciones-finales {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #descargar,
  #enviar_whatsapp {
    padding: 15px 16px;
    font-size: 16px;
  }

  .servicio-item {
    padding: 11px 12px;
  }

  .historial-header {
    flex-direction: column;
    align-items: stretch;
  }

  .historial-toggle {
    width: 100%;
  }

  .historial-card {
    padding: 12px;
  }

  .historial-numero,
  .historial-total,
  .historial-cliente {
    font-size: 13px;
  }

  .historial-meta {
    font-size: 12px;
  }

  .preview {
    transform: scale(0.94);
    transform-origin: top center;
    justify-content: center;
  }

  .presupuesto {
    max-width: 100%;
    padding: 22px 18px;
    border-radius: 20px;
  }

  .preview-head {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .preview-doc {
    text-align: left;
    min-width: 0;
  }

  .mini-logo {
    font-size: 18px;
    gap: 8px;
  }

  .mini-logo-img {
    width: 110px;
    height: auto;
  }

  .doc-title {
    font-size: 18px;
    margin-bottom: 6px;
  }

  .doc-meta,
  .emisor-meta {
    font-size: 13px;
  }

  .cliente-linea {
    font-size: 16px;
    margin-bottom: 14px;
  }

  .table-head {
    font-size: 13px;
    padding: 11px 12px;
    border-radius: 12px;
  }

  .preview-servicio-item {
    font-size: 14px;
    padding: 9px 2px;
  }

  .empty-state {
    font-size: 14px;
  }

  .bloque-notas {
    font-size: 14px;
    margin-top: 16px;
  }

  .total-bar {
    font-size: 16px;
    padding: 14px 16px;
    border-radius: 16px;
  }
  .acciones-finales {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #071126;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 25px rgba(0,0,0,0.5);
}

.form-panel {
  padding-bottom: 220px;
}

.presupuesto {
  margin-bottom: 180px;
}
}

.save-status{
  font-size:12px;
  opacity:0.7;
  margin-bottom:10px;
}

.historial-card{
  width:100%;
  text-align:left;
  padding:12px;
  border-radius:10px;
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
  cursor:pointer;
}

.historial-top{
  display:flex;
  justify-content:space-between;
  font-weight:600;
}

.historial-cliente{
  font-size:13px;
  opacity:0.8;
  margin-top:4px;
}

.historial-meta{
  font-size:12px;
  color: rgba(255,255,255,0.68);
  margin-top:6px;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.historial-action-btn:hover{
  opacity: 0.9;
}
#enviar_recordatorio {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  margin-top: 10px;
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s ease;
  font-weight: 700;
  background: rgba(255,255,255,0.06);
}

#enviar_recordatorio:hover {
  background: rgba(255,255,255,0.10);
}
/* ESTADOS PRESUPUESTO */
.estado-ganado,
.estado-perdido,
.estado-pendiente,
.estado-enviado,
.estado-recordado,
.estado-vencido,
.estado-hoy,
.estado-manana {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  border: 1px solid transparent;
  opacity: 1 !important;
  white-space: nowrap;
}

.estado-ganado {
  background: rgba(46, 204, 113, 0.28);
  color: #8cffbf;
  border-color: rgba(46, 204, 113, 0.55);
}

.estado-perdido {
  background: rgba(255, 82, 82, 0.26);
  color: #ffb0b0;
  border-color: rgba(255, 82, 82, 0.55);
}

.estado-pendiente {
  background: rgba(255, 193, 7, 0.24);
  color: #ffe082;
  border-color: rgba(255, 193, 7, 0.5);
}

.estado-enviado {
  background: rgba(120, 160, 255, 0.22);
  color: #c9d9ff;
  border-color: rgba(120, 160, 255, 0.42);
}

.estado-recordado {
  background: rgba(0, 200, 255, 0.22);
  color: #9cebff;
  border-color: rgba(0, 200, 255, 0.42);
}

.estado-vencido {
  background: rgba(255, 82, 82, 0.26);
  color: #ff9d9d;
  border-color: rgba(255, 82, 82, 0.55);
}

.estado-hoy,
.estado-manana {
  background: rgba(255, 145, 0, 0.26);
  color: #ffc680;
  border-color: rgba(255, 145, 0, 0.55);
}
.btn-activo-ganado{
  background: rgba(46,204,113,0.25) !important;
  border-color: rgba(46,204,113,0.7) !important;
  box-shadow: 0 0 10px rgba(46,204,113,0.35);
}

.btn-activo-perdido{
  background: rgba(255,82,82,0.25) !important;
  border-color: rgba(255,82,82,0.7) !important;
  box-shadow: 0 0 10px rgba(255,82,82,0.35);
}

.btn-activo-pendiente{
  background: rgba(255,193,7,0.25) !important;
  border-color: rgba(255,193,7,0.7) !important;
  box-shadow: 0 0 10px rgba(255,193,7,0.35);
}

@media (max-width:780px){

.acciones-finales{
position:fixed;
bottom:0;
left:0;
width:100%;
background:#071126;
padding:12px;
box-shadow:0 -10px 25px rgba(0,0,0,0.5);
z-index:1000;
}

.panel{
padding-bottom:120px;
}

#descargar,
#enviar_presupuesto{
font-size:18px;
padding:16px;
}

}

.historial-sugerencia {
  font-size: 12px;
  color: #ffb347;
  margin-top: 6px;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: white;
}

@media (max-width: 520px) {
  .stats-panel {
    grid-template-columns: 1fr 1fr;
  }
}

#instalar_app{
background: linear-gradient(135deg,#4c82ff,#5c90ff);
color:white;
border:none;
border-radius:12px;
padding:14px;
font-size:16px;
font-weight:600;
cursor:pointer;
transition:all 0.2s ease;
}

#instalar_app:hover{
transform:translateY(-1px);
box-shadow:0 6px 14px rgba(0,0,0,0.25);
}